syntax-attoparsec (empty) → 0.1.0.0
raw patch · 5 files changed
+145/−0 lines, 5 filesdep +attoparsecdep +basedep +bytestringsetup-changed
Dependencies added: attoparsec, base, bytestring, semi-iso, syntax, text
Files
- Data/Syntax/Attoparsec/ByteString.hs +51/−0
- Data/Syntax/Attoparsec/Text.hs +51/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- syntax-attoparsec.cabal +21/−0
+ Data/Syntax/Attoparsec/ByteString.hs view
@@ -0,0 +1,51 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{- |+Module : Data.Syntax.Attoparsec.ByteString+Description : Syntax instance for Attoparsec.ByteString.Parser.+Copyright : (c) Paweł Nowak+License : MIT++Maintainer : Paweł Nowak <pawel834@gmail.com>+Stability : experimental++Provides a Syntax instance for Attoparsec.ByteString.Parser.+-}+module Data.Syntax.Attoparsec.ByteString (+ Parser(..)+ ) where++import Control.Applicative+import Control.Lens.SemiIso+import Control.Monad+import qualified Data.Attoparsec.ByteString as AP+import Data.SemiIsoFunctor+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++instance Syntax Parser ByteString where+ anyChar = Parser AP.anyWord8+ char = Parser . void . AP.word8+ notChar = Parser . AP.notWord8+ 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
+ Data/Syntax/Attoparsec/Text.hs view
@@ -0,0 +1,51 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{- |+Module : Data.Syntax.Attoparsec.Text+Description : Syntax instance for Attoparsec.Text.Parser.+Copyright : (c) Paweł Nowak+License : MIT++Maintainer : Paweł Nowak <pawel834@gmail.com>+Stability : experimental++Provides a Syntax instance for Attoparsec.Text.Parser.+-}+module Data.Syntax.Attoparsec.Text (+ Parser(..)+ ) where++import Control.Applicative+import Control.Lens.SemiIso+import Control.Monad+import qualified Data.Attoparsec.Text as AP+import Data.SemiIsoFunctor+import Data.Syntax+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++instance Syntax Parser 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
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 Paweł Nowak++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ syntax-attoparsec.cabal view
@@ -0,0 +1,21 @@+name: syntax-attoparsec+version: 0.1.0.0+synopsis: Syntax instances for Attoparsec.+license: MIT+license-file: LICENSE+author: Paweł Nowak+maintainer: Paweł Nowak <pawel834@gmail.com>+copyright: Paweł Nowak 2014+category: Data+build-type: Simple+cabal-version: >=1.10++source-repository head+ type: git+ location: git@github.com:Pawel834/syntax-attoparsec.git++library+ exposed-modules: Data.Syntax.Attoparsec.Text+ Data.Syntax.Attoparsec.ByteString+ build-depends: base >= 4 && < 5, syntax, semi-iso, attoparsec, text, bytestring+ default-language: Haskell2010