Skip to content

Commit 888b7d7

Browse files
committed
Add IsString instance for (Parser Text)
1 parent dec333a commit 888b7d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Data/Attoparsec/Text.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{-# LANGUAGE BangPatterns #-}
1+
{-# LANGUAGE BangPatterns, FlexibleInstances, TypeSynonymInstances #-}
2+
{-# OPTIONS_GHC -fno-warn-orphans #-}
3+
24
-- |
35
-- Module : Data.Attoparsec.Text
46
-- Copyright : Bryan O'Sullivan 2011
@@ -102,12 +104,16 @@ import Data.Bits (Bits, (.|.), shiftL)
102104
import Data.Char (isAlpha, isDigit, isSpace, ord)
103105
import Data.Int (Int8, Int16, Int32, Int64)
104106
import Data.Ratio ((%))
107+
import Data.String (IsString(..))
105108
import Data.Text (Text)
106109
import Data.Word (Word8, Word16, Word32, Word64, Word)
107110
import qualified Data.Attoparsec.Internal.Types as T
108111
import qualified Data.Attoparsec.Text.Internal as I
109112
import qualified Data.Text as T
110113

114+
instance IsString (Parser Text) where
115+
fromString = I.string . T.pack
116+
111117
-- $parsec
112118
--
113119
-- Compared to Parsec 3, Attoparsec makes several tradeoffs. It is

0 commit comments

Comments
 (0)