parsers-megaparsec (empty) → 0.1.0.0
raw patch · 5 files changed
+197/−0 lines, 5 filesdep +basedep +faildep +megaparsecsetup-changed
Dependencies added: base, fail, megaparsec, mtl, parsers, semigroups, text, transformers
Files
- ChangeLog.md +2/−0
- LICENCE +31/−0
- Setup.hs +2/−0
- parsers-megaparsec.cabal +39/−0
- src/Text/Megaparsec/Parsers.hs +123/−0
+ ChangeLog.md view
@@ -0,0 +1,2 @@+0.1.0.0+* Initial release
+ LICENCE view
@@ -0,0 +1,31 @@+Copyright (c) 2017, Commonwealth Scientific and Industrial Research Organisation+(CSIRO) ABN 41 687 119 230.++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Data61 nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ parsers-megaparsec.cabal view
@@ -0,0 +1,39 @@+-- Initial parsers-megaparsec.cabal generated by cabal init. For further documentation,+-- see http://haskell.org/cabal/users-guide/++name: parsers-megaparsec+version: 0.1.0.0+synopsis: `parsers` instances for Megaparsec+description: A newtype around ParsecT with instances for Parsing,+ CharParsing, LookAheadParsing, and TokenParsing+extra-source-files: ChangeLog.md+category: Text, Parsing+license: BSD3+-- Must be spelled with a 'C' for nix+license-file: LICENCE+author: Queensland Functional Programming Lab <oᴉ˙ldɟb@llǝʞsɐɥ>++maintainer: Queensland Functional Programming Lab <oᴉ˙ldɟb@llǝʞsɐɥ>+homepage: https://github.com/qfpl/parsers-megaparsec+bug-reports: https://github.com/qfpl/parsers-megaparsec/issues+build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3, GHC == 8.6.1++source-repository head+ type: git+ location: git@github.com:qfpl/parsers-megaparsec.git++library+ exposed-modules: Text.Megaparsec.Parsers+ build-depends: base >=4.7 && <5+ , fail >=4.7 && <5+ , megaparsec ==6.*+ , parsers ==0.12.*+ , mtl >=2.2 && <2.3+ , semigroups >=0.9 && <0.19+ , text >=1.2 && <1.3+ , transformers >=0.4.2 && <0.6+ hs-source-dirs: src+ default-language: Haskell2010
+ src/Text/Megaparsec/Parsers.hs view
@@ -0,0 +1,123 @@+-- |+-- A newtype wrapper for 'Parsec.ParsecT' that has instances of 'Parsing', 'CharParsing',+-- 'LookAheadParsing', and 'TokenParsing'.+--+-- 'Parsing' and 'LookAheadParsing' have instances for any 'Stream' instance.+--+-- 'CharParsing' and 'TokenParsing' only have instances for 'String', strict 'Text.Text',+-- and lazy 'Lazy.Text', because those type classes expect the 'Token' type to be 'Char'++{-# language GeneralizedNewtypeDeriving #-}+{-# language FlexibleInstances #-}+module Text.Megaparsec.Parsers+ ( module Text.Parser.Combinators+ , module Text.Parser.Char+ , module Text.Parser.LookAhead+ , module Text.Parser.Token+ , ParsecT(..)+ )+where++import Control.Applicative (Applicative, Alternative)+import Control.Monad (MonadPlus)+import Control.Monad.Cont.Class (MonadCont)+import Control.Monad.Error.Class (MonadError)+import Control.Monad.Fail (MonadFail)+import Control.Monad.IO.Class (MonadIO)+import Control.Monad.Reader.Class (MonadReader)+import Control.Monad.State.Class (MonadState)+import Control.Monad.Trans (MonadTrans)+import Data.Monoid (Monoid)+import Data.Functor ((<$))+import Data.Semigroup (Semigroup)+import Data.String (fromString)+import Text.Megaparsec (MonadParsec, Stream, Token)+import Text.Parser.Combinators+import Text.Parser.Char+import Text.Parser.LookAhead+import Text.Parser.Token++import qualified Data.List.NonEmpty as NonEmpty+import qualified Data.Text as Text+import qualified Data.Text.Lazy as Lazy+import qualified Text.Megaparsec as Parsec+import qualified Text.Megaparsec.Char as Parsec++newtype ParsecT e s m a+ = ParsecT { unParsecT :: Parsec.ParsecT e s m a }+ deriving+ ( Functor, Applicative, Alternative, Monad, MonadPlus+ , MonadParsec e s, MonadError e', MonadReader r, MonadState st+ , MonadTrans, MonadFail, MonadIO, MonadCont, Semigroup, Monoid+ )++-- | Note: 'unexpected' requires a non-empty string+instance (Ord e, Stream s) => Parsing (ParsecT e s m) where+ {-# inline try#-}+ try = Parsec.try++ {-# inline (<?>) #-}+ (<?>) = (Parsec.<?>)++ {-# inline notFollowedBy #-}+ notFollowedBy = Parsec.notFollowedBy++ {-# inline eof #-}+ eof = Parsec.eof++ {-# inline unexpected #-}+ unexpected = Parsec.unexpected . Parsec.Label . NonEmpty.fromList++instance Ord e => CharParsing (ParsecT e String m) where+ {-# inline satisfy #-}+ satisfy = Parsec.satisfy+ {-# inline char #-}+ char = Parsec.char+ {-# inline notChar #-}+ notChar = Parsec.notChar+ {-# inline anyChar #-}+ anyChar = Parsec.anyChar+ {-# inline string #-}+ string = Parsec.string+ {-# inline text #-}+ text t = t <$ string (Text.unpack t)++-- | Lazy 'Lazy.Text'+instance Ord e => CharParsing (ParsecT e Lazy.Text m) where+ {-# inline satisfy #-}+ satisfy = Parsec.satisfy+ {-# inline char #-}+ char = Parsec.char+ {-# inline notChar #-}+ notChar = Parsec.notChar+ {-# inline anyChar #-}+ anyChar = Parsec.anyChar+ {-# inline string #-}+ string t = t <$ Parsec.string (Lazy.pack t)+ {-# inline text #-}+ text t = t <$ Parsec.string (Lazy.fromStrict t)++-- | Strict 'Text.Text'+instance Ord e => CharParsing (ParsecT e Text.Text m) where+ {-# inline satisfy #-}+ satisfy = Parsec.satisfy+ {-# inline char #-}+ char = Parsec.char+ {-# inline notChar #-}+ notChar = Parsec.notChar+ {-# inline anyChar #-}+ anyChar = Parsec.anyChar+ {-# inline string #-}+ string t = t <$ Parsec.string (Text.pack t)+ {-# inline text #-}+ text = Parsec.string++instance (Ord e, Stream s) => LookAheadParsing (ParsecT e s m) where+ {-# inline lookAhead #-}+ lookAhead = Parsec.lookAhead++instance Ord e => TokenParsing (ParsecT e String m)+-- | Lazy 'Lazy.Text'+instance Ord e => TokenParsing (ParsecT e Text.Text m)+-- | Strict 'Text.Text'+instance Ord e => TokenParsing (ParsecT e Lazy.Text m)