Skip to content

Change equational constraints on IsString (Parser a) to a ~ () #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Data/Attoparsec/ByteString/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ import qualified Data.Attoparsec.Internal as I
import qualified Data.ByteString as B8
import qualified Data.ByteString.Char8 as B

instance (a ~ B.ByteString) => IsString (Parser a) where
fromString = I.string . B.pack
instance a ~ () => IsString (Parser a) where
fromString = void . I.string . B.pack

-- $encodings
--
Expand Down
6 changes: 3 additions & 3 deletions Data/Attoparsec/Text/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module Data.Attoparsec.Text.Internal
) where

import Control.Applicative ((<|>), (<$>), pure, (*>))
import Control.Monad (when)
import Control.Monad (void, when)
import Data.Attoparsec.Combinator ((<?>))
import Data.Attoparsec.Internal
import Data.Attoparsec.Internal.Types hiding (Parser, Failure, Success)
Expand All @@ -88,8 +88,8 @@ type Result = IResult Text
type Failure r = T.Failure Text Buffer r
type Success a r = T.Success Text Buffer a r

instance (a ~ Text) => IsString (Parser a) where
fromString = string . T.pack
instance a ~ () => IsString (Parser a) where
fromString = void . string . T.pack

-- | The parser @satisfy p@ succeeds for any character for which the
-- predicate @p@ returns 'True'. Returns the character that is
Expand Down
2 changes: 1 addition & 1 deletion attoparsec.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.0
-- 2.0 needed for internal libraries
name: attoparsec
version: 0.14.4
version: 0.15.0
license: BSD3
license-file: LICENSE
category: Text, Parsing
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/Genome.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ genome = bgroup "genome" [
geneTL = rechunkT 4 geneT

searchBS :: B.Parser ByteString
searchBS = "caac" *> ("aaca" <|> "aact")
searchBS = "caac" *> (B.string "aaca" <|> B.string "aact")

searchBSCI :: B.Parser ByteString
searchBSCI = B.stringCI "CAAC" *> (B.stringCI "AACA" <|> B.stringCI "AACT")

searchT :: T.Parser Text
searchT = "caac" *> ("aaca" <|> "aact")
searchT = "caac" *> (T.string "aaca" <|> T.string "aact")

searchTCI :: T.Parser Text
searchTCI = T.asciiCI "CAAC" *> (T.asciiCI "AACA" <|> T.asciiCI "AACT")
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.15.0

* Change equational constraints:
- `a ~ Text => IsString (Parser a)` to `a ~ () => IsString (Parser a)`
- `a ~ ByteString => IsString (Parser a)` to `a ~ () => IsString (Parser a)`

# 0.14.4

* Fix a segmentation fault when built against `text-2.0`
Expand Down
2 changes: 1 addition & 1 deletion tests/QC/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as A
t_issue75 = expect issue75 "ab" (A.Done "" "b")

issue75 :: A.Parser ByteString
issue75 = "a" >> ("b" <|> "")
issue75 = "a" >> (A.string "b" <|> A.string "")

expect :: (Show r, Eq r) => A.Parser r -> ByteString -> A.Result r -> Property
expect p input wanted =
Expand Down
Loading