attoparsec-data (empty) → 0.1.1.1
raw patch · 6 files changed
+226/−0 lines, 6 filesdep +attoparsecdep +attoparsec-timedep +basesetup-changed
Dependencies added: attoparsec, attoparsec-time, base, base-prelude, bytestring, scientific, text, time
Files
- LICENSE +22/−0
- Setup.hs +2/−0
- attoparsec-data.cabal +57/−0
- library/Attoparsec/Data/Explicit.hs +78/−0
- library/Attoparsec/Data/Implicit.hs +41/−0
- library/Attoparsec/Data/Prelude.hs +26/−0
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2017, 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
+ attoparsec-data.cabal view
@@ -0,0 +1,57 @@+name:+ attoparsec-data+version:+ 0.1.1.1+category:+ Parsing+synopsis:+ Parsers for the standard Haskell data types+homepage:+ https://github.com/nikita-volkov/attoparsec-data+bug-reports:+ https://github.com/nikita-volkov/attoparsec-data/issues +author:+ Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:+ Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:+ (c) 2017, 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/attoparsec-data.git++library+ hs-source-dirs:+ library+ exposed-modules:+ Attoparsec.Data.Explicit+ Attoparsec.Data.Implicit+ other-modules:+ Attoparsec.Data.Prelude+ default-extensions:+ Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+ default-language:+ Haskell2010+ build-depends:+ -- data:+ time >= 1.4 && < 2,+ scientific >= 0.2 && < 0.4,+ text >= 1 && < 2,+ bytestring >= 0.10 && < 0.11,+ -- + attoparsec == 0.13.*,+ attoparsec-time == 0.1.*,+ -- + base-prelude < 2,+ base < 5
+ library/Attoparsec/Data/Explicit.hs view
@@ -0,0 +1,78 @@+module Attoparsec.Data.Explicit+(+ char,+ text,+ utf8Bytes,+ bool,+ signedIntegral,+ unsignedIntegral,+ A.double,+ A.scientific,+ -- * Time+ B.timeOfDayInISO8601,+ B.dayInISO8601,+ B.timeZoneInISO8601,+ B.utcTimeInISO8601,+)+where++import Attoparsec.Data.Prelude hiding (bool)+import qualified Data.Attoparsec.Text as A+import qualified Attoparsec.Time as B+import qualified Data.Text.Encoding as C+++{-|+Any character.+-}+char :: A.Parser Char+char =+ A.anyChar++{-|+Consumes all the remaining input.+-}+text :: A.Parser Text+text =+ A.takeText++{-|+Consumes all the remaining input, encoding it using UTF8.+-}+utf8Bytes :: A.Parser ByteString+utf8Bytes =+ C.encodeUtf8 <$> A.takeText++{-|+Accepts any string interpretable as a boolean:+"1" or "0", "true" or "false", "yes" or "no", "y" or "n", "t" or "f".+Case-insensitive.+-}+bool :: A.Parser Bool+bool =+ A.anyChar >>= \case+ '0' -> return False+ '1' -> return True+ 'f' -> A.asciiCI "alse" $> False <|> pure False+ 'F' -> A.asciiCI "alse" $> False <|> pure False+ 't' -> A.asciiCI "rue" $> True <|> pure True+ 'T' -> A.asciiCI "rue" $> True <|> pure True+ 'n' -> A.satisfy (A.inClass "oO") $> False <|> pure False+ 'N' -> A.satisfy (A.inClass "oO") $> False <|> pure False+ 'y' -> A.asciiCI "es" $> True <|> pure True+ 'Y' -> A.asciiCI "es" $> True <|> pure True+ _ -> empty++{-|+Signed decimal.+-}+signedIntegral :: Integral a => A.Parser a+signedIntegral =+ A.signed A.decimal++{-|+Unsigned decimal.+-}+unsignedIntegral :: Integral a => A.Parser a+unsignedIntegral =+ A.decimal
+ library/Attoparsec/Data/Implicit.hs view
@@ -0,0 +1,41 @@+{-# LANGUAGE CPP #-}+module Attoparsec.Data.Implicit where++import Attoparsec.Data.Prelude+import qualified Attoparsec.Data.Explicit as A+import qualified Data.Attoparsec.Text as B+++{-|+Provides the default lenient parser for a type.+-}+class LenientParser a where+ lenientParser :: B.Parser a++#define INSTANCE(TYPE, FUNCTION) instance LenientParser TYPE where {{-# INLINE lenientParser #-}; lenientParser = FUNCTION;}++-- | Consumes all the remaining input.+INSTANCE(Text, A.text)+-- | Consumes all the remaining input, encoding it using UTF8.+INSTANCE(ByteString, A.utf8Bytes)+INSTANCE(Char, A.char)+INSTANCE(Bool, A.bool)+INSTANCE(Integer, A.signedIntegral)+INSTANCE(Int, A.signedIntegral)+INSTANCE(Int8, A.signedIntegral)+INSTANCE(Int16, A.signedIntegral)+INSTANCE(Int32, A.signedIntegral)+INSTANCE(Int64, A.signedIntegral)+INSTANCE(Word, A.unsignedIntegral)+INSTANCE(Word8, A.unsignedIntegral)+INSTANCE(Word16, A.unsignedIntegral)+INSTANCE(Word32, A.unsignedIntegral)+INSTANCE(Word64, A.unsignedIntegral)+INSTANCE(Double, A.double)+INSTANCE(Scientific, A.scientific)+INSTANCE(TimeOfDay, A.timeOfDayInISO8601)+INSTANCE(Day, A.dayInISO8601)+INSTANCE(TimeZone, A.timeZoneInISO8601)+INSTANCE(UTCTime, A.utcTimeInISO8601)++#undef INSTANCE
+ library/Attoparsec/Data/Prelude.hs view
@@ -0,0 +1,26 @@+module Attoparsec.Data.Prelude+(+ module Exports,+)+where+++-- base-prelude+-------------------------+import BasePrelude as Exports++-- text+-------------------------+import Data.Text as Exports (Text)++-- bytestring+-------------------------+import Data.ByteString as Exports (ByteString)++-- scientific+-------------------------+import Data.Scientific as Exports (Scientific)++-- time+-------------------------+import Data.Time as Exports