syntax-attoparsec 0.2.0.0 → 0.3.0.0
raw patch · 4 files changed
+89/−49 lines, 4 filesdep +scientificdep ~semi-isodep ~syntaxPVP ok
version bump matches the API change (PVP)
Dependencies added: scientific
Dependency ranges changed: semi-iso, syntax
API changes (from Hackage documentation)
- Data.Syntax.Attoparsec.ByteString: Parser :: Parser a -> Parser a
- Data.Syntax.Attoparsec.ByteString: instance SemiIsoAlternative Parser
- Data.Syntax.Attoparsec.ByteString: instance SemiIsoApply Parser
- Data.Syntax.Attoparsec.ByteString: instance SemiIsoFunctor Parser
- Data.Syntax.Attoparsec.ByteString: instance SemiIsoMonad Parser
- Data.Syntax.Attoparsec.ByteString: instance Syntax Parser ByteString
- Data.Syntax.Attoparsec.ByteString: newtype Parser a
- Data.Syntax.Attoparsec.Text: Parser :: Parser a -> Parser a
- Data.Syntax.Attoparsec.Text: instance SemiIsoAlternative Parser
- Data.Syntax.Attoparsec.Text: instance SemiIsoApply Parser
- Data.Syntax.Attoparsec.Text: instance SemiIsoFunctor Parser
- Data.Syntax.Attoparsec.Text: instance SemiIsoMonad Parser
- Data.Syntax.Attoparsec.Text: instance Syntax Parser Text
- Data.Syntax.Attoparsec.Text: instance SyntaxChar Parser Text
- Data.Syntax.Attoparsec.Text: newtype Parser a
+ Data.Syntax.Attoparsec.ByteString: data WrappedParser a
+ Data.Syntax.Attoparsec.ByteString: instance SemiIsoAlternative WrappedParser
+ Data.Syntax.Attoparsec.ByteString: instance SemiIsoApply WrappedParser
+ Data.Syntax.Attoparsec.ByteString: instance SemiIsoFunctor WrappedParser
+ Data.Syntax.Attoparsec.ByteString: instance SemiIsoMonad WrappedParser
+ Data.Syntax.Attoparsec.ByteString: instance Syntax WrappedParser ByteString
+ Data.Syntax.Attoparsec.Text: data WrappedParser a
+ Data.Syntax.Attoparsec.Text: instance SemiIsoAlternative WrappedParser
+ Data.Syntax.Attoparsec.Text: instance SemiIsoApply WrappedParser
+ Data.Syntax.Attoparsec.Text: instance SemiIsoFunctor WrappedParser
+ Data.Syntax.Attoparsec.Text: instance SemiIsoMonad WrappedParser
+ Data.Syntax.Attoparsec.Text: instance Syntax WrappedParser Text
+ Data.Syntax.Attoparsec.Text: instance SyntaxChar WrappedParser Text
+ Data.Syntax.Attoparsec.Text.Lazy: data WrappedParser a
+ Data.Syntax.Attoparsec.Text.Lazy: getParser :: WrappedParser a -> Parser a
+ Data.Syntax.Attoparsec.Text.Lazy: instance SemiIsoAlternative WrappedParser
+ Data.Syntax.Attoparsec.Text.Lazy: instance SemiIsoApply WrappedParser
+ Data.Syntax.Attoparsec.Text.Lazy: instance SemiIsoFunctor WrappedParser
+ Data.Syntax.Attoparsec.Text.Lazy: instance SemiIsoMonad WrappedParser
+ Data.Syntax.Attoparsec.Text.Lazy: instance Syntax WrappedParser Text
+ Data.Syntax.Attoparsec.Text.Lazy: instance SyntaxChar WrappedParser Text
- Data.Syntax.Attoparsec.ByteString: getParser :: Parser a -> Parser a
+ Data.Syntax.Attoparsec.ByteString: getParser :: WrappedParser a -> Parser a
- Data.Syntax.Attoparsec.Text: getParser :: Parser a -> Parser a
+ Data.Syntax.Attoparsec.Text: getParser :: WrappedParser a -> Parser a
Files
- Data/Syntax/Attoparsec/ByteString.hs +15/−24
- Data/Syntax/Attoparsec/Text.hs +17/−23
- Data/Syntax/Attoparsec/Text/Lazy.hs +54/−0
- syntax-attoparsec.cabal +3/−2
Data/Syntax/Attoparsec/ByteString.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {- | Module : Data.Syntax.Attoparsec.ByteString Description : Syntax instance for Attoparsec.ByteString.Parser.@@ -12,38 +13,24 @@ Provides a Syntax instance for Attoparsec.ByteString.Parser. -} module Data.Syntax.Attoparsec.ByteString (- Parser(..)+ WrappedParser,+ getParser ) where -import Control.Applicative-import Control.Lens.SemiIso import Control.Monad import qualified Data.Attoparsec.ByteString as AP+import Data.ByteString (ByteString) import Data.SemiIsoFunctor+import Data.SemiIsoFunctor.Wrapped import Data.Syntax-import Data.ByteString (ByteString) --- | A wrapped 'Data.Attoparsec.Text.Parser'.-newtype Parser a = Parser {- -- | Extracts the parser.- getParser :: AP.Parser a-}--instance SemiIsoFunctor Parser where- simapCo ai (Parser p) = Parser $ p >>= either fail return . apply ai--instance SemiIsoApply Parser where- sipure ai = Parser $ either fail pure (unapply ai ())- (Parser x) /*/ (Parser y) = Parser $ (,) <$> x <*> y--instance SemiIsoAlternative Parser where- siempty = Parser empty- (Parser x) /|/ (Parser y) = Parser $ x <|> y+-- | A wrapped 'Data.Attoparsec.ByteString.Parser'.+newtype WrappedParser a = Wrapped (WrappedCovariant AP.Parser a)+ deriving (SemiIsoFunctor, SemiIsoApply, SemiIsoAlternative, SemiIsoMonad) -instance SemiIsoMonad Parser where- (Parser m) //= f = Parser $ m >>= (\x -> (x,) <$> getParser (f x))+pattern Parser a = Wrapped (WrappedCovariant a) -instance Syntax Parser ByteString where+instance Syntax WrappedParser ByteString where anyChar = Parser AP.anyWord8 char = Parser . void . AP.word8 notChar = Parser . AP.notWord8@@ -53,3 +40,7 @@ takeWhile = Parser . AP.takeWhile takeWhile1 = Parser . AP.takeWhile1 takeTill = Parser . AP.takeTill++-- | Extracts the parser.+getParser :: WrappedParser a -> AP.Parser a+getParser (Parser a) = a
Data/Syntax/Attoparsec/Text.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {- | Module : Data.Syntax.Attoparsec.Text Description : Syntax instance for Attoparsec.Text.Parser.@@ -12,39 +13,26 @@ Provides a Syntax instance for Attoparsec.Text.Parser. -} module Data.Syntax.Attoparsec.Text (- Parser(..)+ WrappedParser,+ getParser ) where -import Control.Applicative-import Control.Lens.SemiIso import Control.Monad import qualified Data.Attoparsec.Text as AP+import Data.Scientific import Data.SemiIsoFunctor+import Data.SemiIsoFunctor.Wrapped import Data.Syntax import Data.Syntax.Char import Data.Text (Text) -- | A wrapped 'Data.Attoparsec.Text.Parser'.-newtype Parser a = Parser {- -- | Extracts the parser.- getParser :: AP.Parser a-}--instance SemiIsoFunctor Parser where- simapCo ai (Parser p) = Parser $ p >>= either fail return . apply ai--instance SemiIsoApply Parser where- sipure ai = Parser $ either fail pure (unapply ai ())- (Parser x) /*/ (Parser y) = Parser $ (,) <$> x <*> y--instance SemiIsoAlternative Parser where- siempty = Parser empty- (Parser x) /|/ (Parser y) = Parser $ x <|> y+newtype WrappedParser a = Wrapped (WrappedCovariant AP.Parser a)+ deriving (SemiIsoFunctor, SemiIsoApply, SemiIsoAlternative, SemiIsoMonad) -instance SemiIsoMonad Parser where- (Parser m) //= f = Parser $ m >>= (\x -> (x,) <$> getParser (f x))+pattern Parser a = Wrapped (WrappedCovariant a) -instance Syntax Parser Text where+instance Syntax WrappedParser Text where anyChar = Parser AP.anyChar char = Parser . void . AP.char notChar = Parser . AP.notChar@@ -55,6 +43,12 @@ takeWhile1 = Parser . AP.takeWhile1 takeTill = Parser . AP.takeTill -instance SyntaxChar Parser Text where+instance SyntaxChar WrappedParser Text where decimal = Parser AP.decimal+ hexadecimal = Parser AP.hexadecimal+ realFloat = Parser $ fmap toRealFloat AP.scientific scientific = Parser AP.scientific++-- | Extracts the parser.+getParser :: WrappedParser a -> AP.Parser a+getParser (Parser m) = m
+ Data/Syntax/Attoparsec/Text/Lazy.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{- |+Module : Data.Syntax.Attoparsec.Text.Laxy+Description : Syntax instance for Attoparsec.Text.Lazy.Parser.+Copyright : (c) Paweł Nowak+License : MIT++Maintainer : Paweł Nowak <pawel834@gmail.com>+Stability : experimental++Provides a Syntax instance for Attoparsec.Text.Lazy.Parser.+-}+module Data.Syntax.Attoparsec.Text.Lazy (+ WrappedParser,+ getParser+ ) where++import Control.Monad+import qualified Data.Attoparsec.Text.Lazy as AP+import Data.Scientific+import Data.SemiIsoFunctor+import Data.SemiIsoFunctor.Wrapped+import Data.Syntax+import Data.Syntax.Char+import Data.Text (Text)++-- | A wrapped 'Data.Attoparsec.Text.Parser'.+newtype WrappedParser a = Wrapped (WrappedCovariant AP.Parser a)+ deriving (SemiIsoFunctor, SemiIsoApply, SemiIsoAlternative, SemiIsoMonad)++pattern Parser a = Wrapped (WrappedCovariant a)++instance Syntax WrappedParser Text where+ anyChar = Parser AP.anyChar+ char = Parser . void . AP.char+ notChar = Parser . AP.notChar+ satisfy = Parser . AP.satisfy+ string = Parser . void . AP.string+ take = Parser . AP.take+ takeWhile = Parser . AP.takeWhile+ takeWhile1 = Parser . AP.takeWhile1+ takeTill = Parser . AP.takeTill++instance SyntaxChar WrappedParser Text where+ decimal = Parser AP.decimal+ hexadecimal = Parser AP.hexadecimal+ realFloat = Parser $ fmap toRealFloat AP.scientific+ scientific = Parser AP.scientific++-- | Extracts the parser.+getParser :: WrappedParser a -> AP.Parser a+getParser (Parser m) = m
syntax-attoparsec.cabal view
@@ -1,5 +1,5 @@ name: syntax-attoparsec-version: 0.2.0.0+version: 0.3.0.0 synopsis: Syntax instances for Attoparsec. license: MIT license-file: LICENSE@@ -16,6 +16,7 @@ library exposed-modules: Data.Syntax.Attoparsec.Text+ Data.Syntax.Attoparsec.Text.Lazy Data.Syntax.Attoparsec.ByteString- build-depends: base >= 4 && < 5, syntax >= 0.2, semi-iso >= 0.3, attoparsec, text, bytestring+ build-depends: base >= 4 && < 5, syntax >= 0.3, semi-iso >= 0.5, attoparsec, text, bytestring, scientific default-language: Haskell2010