list-t-attoparsec (empty) → 0.2.0.0
raw patch · 4 files changed
+117/−0 lines, 4 filesdep +attoparsecdep +base-preludedep +exceptionssetup-changed
Dependencies added: attoparsec, base-prelude, exceptions, list-t, mtl-prelude, text
Files
- LICENSE +22/−0
- Setup.hs +2/−0
- library/ListT/Attoparsec.hs +39/−0
- list-t-attoparsec.cabal +54/−0
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2015, Nikita Volkov++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
+ library/ListT/Attoparsec.hs view
@@ -0,0 +1,39 @@+module ListT.Attoparsec where++import BasePrelude hiding (cons, uncons)+import MTLPrelude+import Control.Monad.Catch+import Data.Text (Text)+import ListT+import qualified Data.Attoparsec.Text as P+++-- |+-- A text message and a list of contexts,+-- as per the failure in \"attoparsec\".+data ParsingFailure =+ ParsingFailure !String ![String]+ deriving (Show, Eq, Ord, Data, Typeable, Generic)++instance Exception ParsingFailure++-- |+-- Given a text parser, produces +-- a transformation of a stream of text chunks into a stream of parsed results.+-- In case of a parsing failure it raises a 'ParsingFailure' error in the base monad.+textParser :: MonadThrow m => P.Parser a -> Transformation m Text a+textParser p =+ loop (P.parse p)+ where+ loop parse input =+ lift (uncons input) >>= maybe mzero (onUncons parse)+ onUncons parse (chunk, otherChunks) =+ case parse chunk of+ P.Done chunk' result -> + cons result (onUncons (P.parse p) (chunk', otherChunks))+ P.Partial parse' -> + loop parse' otherChunks+ P.Fail _ contexts message -> + lift $ throwM $ ParsingFailure message contexts++
+ list-t-attoparsec.cabal view
@@ -0,0 +1,54 @@+name:+ list-t-attoparsec+version:+ 0.2.0.0+synopsis:+ An "attoparsec" adapter for "list-t"+category:+ Streaming, Parsing+homepage:+ https://github.com/nikita-volkov/list-t-attoparsec+bug-reports:+ https://github.com/nikita-volkov/list-t-attoparsec/issues +author:+ Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:+ Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:+ (c) 2015, Nikita Volkov+license:+ MIT+license-file:+ LICENSE+build-type:+ Simple+cabal-version:+ >=1.10+++source-repository head+ type:+ git+ location:+ git://github.com/nikita-volkov/list-t-attoparsec.git+++library+ hs-source-dirs:+ library+ other-modules:+ exposed-modules:+ ListT.Attoparsec+ ghc-options:+ -funbox-strict-fields+ default-extensions:+ Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators+ default-language:+ Haskell2010+ build-depends:+ attoparsec >= 0.10 && < 0.13,+ text >= 1 && < 1.3,+ list-t == 0.4.*,+ exceptions == 0.8.*,+ mtl-prelude >= 1 && < 3,+ base-prelude >= 0.1.19 && < 0.2