Commits

solirc committed e1fbd21

Add IsString instance for (Parser Text)

Comments (0)

Files changed (1)

Data/Attoparsec/Text.hs

-{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE BangPatterns, FlexibleInstances, TypeSynonymInstances #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
 -- |
 -- Module      :  Data.Attoparsec.Text
 -- Copyright   :  Bryan O'Sullivan 2011
 import Data.Char (isAlpha, isDigit, isSpace, ord)
 import Data.Int (Int8, Int16, Int32, Int64)
 import Data.Ratio ((%))
+import Data.String (IsString(..))
 import Data.Text (Text)
 import Data.Word (Word8, Word16, Word32, Word64, Word)
 import qualified Data.Attoparsec.Internal.Types as T
 import qualified Data.Attoparsec.Text.Internal as I
 import qualified Data.Text as T
 
+instance IsString (Parser Text) where
+    fromString = I.string . T.pack
+
 -- $parsec
 --
 -- Compared to Parsec 3, Attoparsec makes several tradeoffs.  It is