Bryan O'Sullivan avatar Bryan O'Sullivan committed 4c2fa06 Merge

Merge pull request #30 from sol/use-equational-constraints

Use equational constraints for IsString instances

Comments (0)

Files changed (3)


-{-# LANGUAGE BangPatterns, FlexibleInstances, TypeSynonymInstances #-}
+{-# LANGUAGE BangPatterns, FlexibleInstances, TypeSynonymInstances, GADTs #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
 -- |
 import qualified Data.ByteString as B8
 import qualified Data.ByteString.Char8 as B
-instance IsString (Parser B.ByteString) where
+instance (a ~ B.ByteString) => IsString (Parser a) where
     fromString = I.string . B.pack
 -- $encodings


 {-# LANGUAGE BangPatterns, CPP, FlexibleInstances, OverloadedStrings,
-    Rank2Types, RecordWildCards, TypeSynonymInstances #-}
+    Rank2Types, RecordWildCards, TypeSynonymInstances, GADTs #-}
 {-# OPTIONS_GHC -fno-warn-orphans #-}
 -- |
 -- Module      :  Data.Attoparsec.Text.Internal
 type Failure r = T.Failure Text r
 type Success a r = T.Success Text a r
-instance IsString (Parser Text) where
+instance (a ~ Text) => IsString (Parser a) where
     fromString = string . T.pack
 lengthAtLeast :: T.Text -> Int -> Bool


     } deriving (Eq, Ord, Show)
 httpVersion :: Parser B.ByteString
-httpVersion = string "HTTP/" *> P.takeWhile (\c -> isDigit_w8 c || c == 46)
+httpVersion = "HTTP/" *> P.takeWhile (\c -> isDigit_w8 c || c == 46)
 requestLine :: Parser Request
 requestLine = do
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.