packages feed

data-textual 0.2.0.1 → 0.3.0.1

raw patch · 3 files changed

+18/−204 lines, 3 filesdep +type-hintdep −taggedPVP ok

version bump matches the API change (PVP)

Dependencies added: type-hint

Dependencies removed: tagged

API changes (from Hackage documentation)

- Data.Textual: aCenti :: Proxy Centi
- Data.Textual: aChar :: Proxy Char
- Data.Textual: aDeci :: Proxy Deci
- Data.Textual: aDouble :: Proxy Double
- Data.Textual: aFixed :: Proxy Fixed
- Data.Textual: aFixedOf :: Proxy α -> Proxy (Fixed α)
- Data.Textual: aFloat :: Proxy Float
- Data.Textual: aList :: Proxy []
- Data.Textual: aListOf :: Proxy α -> Proxy ([α])
- Data.Textual: aMaybe :: Proxy Maybe
- Data.Textual: aMaybeOf :: Proxy α -> Proxy (Maybe α)
- Data.Textual: aMicro :: Proxy Micro
- Data.Textual: aMilli :: Proxy Milli
- Data.Textual: aNano :: Proxy Nano
- Data.Textual: aPico :: Proxy Pico
- Data.Textual: aRatio :: Proxy Ratio
- Data.Textual: aRatioOf :: Proxy α -> Proxy (Ratio α)
- Data.Textual: aRational :: Proxy Rational
- Data.Textual: aUni :: Proxy Uni
- Data.Textual: aUnit :: Proxy ()
- Data.Textual: aWord :: Proxy Word
- Data.Textual: aWord16 :: Proxy Word16
- Data.Textual: aWord32 :: Proxy Word32
- Data.Textual: aWord64 :: Proxy Word64
- Data.Textual: aWord8 :: Proxy Word8
- Data.Textual: anInt :: Proxy Int
- Data.Textual: anInt16 :: Proxy Int16
- Data.Textual: anInt32 :: Proxy Int32
- Data.Textual: anInt64 :: Proxy Int64
- Data.Textual: anInt8 :: Proxy Int8
- Data.Textual: anInteger :: Proxy Integer
- Data.Textual: hintType :: α -> Proxy α -> α
- Data.Textual: hintType1 :: f α -> Proxy f -> f α
- Data.Textual: hintTypeArg :: f α -> Proxy α -> f α
- Data.Textual: fromAsciiAs :: Textual α => Proxy α -> ByteString -> Maybe α
+ Data.Textual: fromAsciiAs :: Textual α => p α -> ByteString -> Maybe α
- Data.Textual: fromLazyAsciiAs :: Textual α => Proxy α -> ByteString -> Maybe α
+ Data.Textual: fromLazyAsciiAs :: Textual α => p α -> ByteString -> Maybe α
- Data.Textual: fromLazyTextAs :: Textual α => Proxy α -> Text -> Maybe α
+ Data.Textual: fromLazyTextAs :: Textual α => p α -> Text -> Maybe α
- Data.Textual: fromLazyUtf8As :: Textual α => Proxy α -> ByteString -> Maybe α
+ Data.Textual: fromLazyUtf8As :: Textual α => p α -> ByteString -> Maybe α
- Data.Textual: fromStringAs :: Textual α => Proxy α -> String -> Maybe α
+ Data.Textual: fromStringAs :: Textual α => p α -> String -> Maybe α
- Data.Textual: fromTextAs :: Textual α => Proxy α -> Text -> Maybe α
+ Data.Textual: fromTextAs :: Textual α => p α -> Text -> Maybe α
- Data.Textual: fromUtf8As :: Textual α => Proxy α -> ByteString -> Maybe α
+ Data.Textual: fromUtf8As :: Textual α => p α -> ByteString -> Maybe α
- Data.Textual: parseAsciiAs :: Textual α => Proxy α -> ByteString -> Parsed α
+ Data.Textual: parseAsciiAs :: Textual α => p α -> ByteString -> Parsed α
- Data.Textual: parseLazyTextAs :: Textual α => Proxy α -> Text -> Parsed α
+ Data.Textual: parseLazyTextAs :: Textual α => p α -> Text -> Parsed α
- Data.Textual: parseLazyUtf8As :: Textual α => Proxy α -> ByteString -> Parsed α
+ Data.Textual: parseLazyUtf8As :: Textual α => p α -> ByteString -> Parsed α
- Data.Textual: parseStringAs :: Textual α => Proxy α -> String -> Parsed α
+ Data.Textual: parseStringAs :: Textual α => p α -> String -> Parsed α
- Data.Textual: parseTextAs :: Textual α => Proxy α -> Text -> Parsed α
+ Data.Textual: parseTextAs :: Textual α => p α -> Text -> Parsed α
- Data.Textual: parseUtf8As :: Textual α => Proxy α -> ByteString -> Parsed α
+ Data.Textual: parseUtf8As :: Textual α => p α -> ByteString -> Parsed α

Files

data-textual.cabal view
@@ -1,5 +1,5 @@ Name: data-textual-Version: 0.2.0.1+Version: 0.3.0.1 Category: Data, Text Stability: experimental Synopsis: Human-friendly textual representations.@@ -29,7 +29,6 @@     base >= 4 && < 5,     bytestring >= 0.10,     text,-    tagged >= 0.2,     text-latin1 >= 0.3,     text-printer >= 0.4,     parsers >= 0.5@@ -49,7 +48,7 @@     test-framework-quickcheck2 >= 0.2,     QuickCheck                 >= 2.4,     text-printer,-    tagged,+    type-hint >= 0.1,     parsers,     data-textual   Hs-Source-Dirs: tests
src/Data/Textual.hs view
@@ -24,41 +24,6 @@   , toLazyUtf8   -- * Parsing   , Textual(..)-  -- ** Standard types proxies-  , hintType-  , hintType1-  , hintTypeArg-  , aUnit-  , aChar-  , anInteger-  , anInt-  , anInt8-  , anInt16-  , anInt32-  , anInt64-  , aWord-  , aWord8-  , aWord16-  , aWord32-  , aWord64-  , aRatio-  , aRatioOf-  , aRational-  , aFixed-  , aFixedOf-  , aUni-  , aDeci-  , aCenti-  , aMilli-  , aMicro-  , aNano-  , aPico-  , aFloat-  , aDouble-  , aMaybe-  , aMaybeOf-  , aList-  , aListOf   -- ** Built-in parser   , Parsed(..)   , isParsed@@ -97,15 +62,13 @@  import Prelude hiding (print) import Data.Typeable (Typeable)-import Data.Proxy (Proxy(..)) import Data.Foldable (Foldable) import Data.Traversable (Traversable) import Data.Monoid (mempty) import Data.Int import Data.Word import Data.Ratio (Ratio)-import Data.Fixed (Fixed, HasResolution,-                   Uni, Centi, Deci, Milli, Micro, Nano, Pico)+import Data.Fixed (Fixed, HasResolution) import Data.List (stripPrefix) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS8@@ -213,37 +176,30 @@ -- | A shorthand for @'TP.buildString' . 'print'@. toString ∷ Printable α ⇒ α → String toString = TP.buildString . print-{-# INLINE toString #-}  -- | A shorthand for @'TP.buildText' . 'print'@. toText ∷ Printable α ⇒ α → TS.Text toText = TP.buildText . print-{-# INLINE toText #-}  -- | A shorthand for @'TP.buildLazyText' . 'print'@. toLazyText ∷ Printable α ⇒ α → TL.Text toLazyText = TP.buildLazyText . print-{-# INLINE toLazyText #-}  -- | A shorthand for @'TP.buildAscii' . 'print'@. toAscii ∷ Printable α ⇒ α → BS.ByteString toAscii = TP.buildAscii . print-{-# INLINE toAscii #-}  -- | A shorthand for @'TP.buildLazyAscii' . 'print'@. toLazyAscii ∷ Printable α ⇒ α → BL.ByteString toLazyAscii = TP.buildLazyAscii . print-{-# INLINE toLazyAscii #-}  -- | A shorthand for @'TP.buildUtf8' . 'print'@. toUtf8 ∷ Printable α ⇒ α → BS.ByteString toUtf8 = TP.buildUtf8 . print-{-# INLINE toUtf8 #-}  -- | A shorthand for @'TP.buildLazyUtf8' . 'print'@. toLazyUtf8 ∷ Printable α ⇒ α → BL.ByteString toLazyUtf8 = TP.buildLazyUtf8 . print-{-# INLINE toLazyUtf8 #-}  -- | The default parser for values of a type, must satisfy --   @@@ -308,147 +264,6 @@   textual = fractional   {-# INLINE textual #-} --- | Hint the type system about the type of the first argument.-hintType ∷ α → Proxy α → α-hintType a _ = a-{-# INLINE hintType #-}---- | Hint the type system about the type constructor.-hintType1 ∷ f α → Proxy f → f α-hintType1 f _ = f-{-# INLINE hintType1 #-}---- | Hint the type system about the type argument. -hintTypeArg ∷ f α → Proxy α → f α-hintTypeArg f _ = f-{-# INLINE hintTypeArg #-}--infixl 1 `hintType`, `hintType1`, `hintTypeArg`---- | /()/ proxy value.-aUnit ∷ Proxy ()-aUnit = Proxy---- | 'Char' proxy value.-aChar ∷ Proxy Char-aChar = Proxy---- | 'Integer' proxy value.-anInteger ∷ Proxy Integer-anInteger = Proxy---- | 'Int' proxy value.-anInt ∷ Proxy Int-anInt = Proxy---- | 'Int8' proxy value.-anInt8 ∷ Proxy Int8-anInt8 = Proxy---- | 'Int16' proxy value.-anInt16 ∷ Proxy Int16-anInt16 = Proxy---- | 'Int32' proxy value.-anInt32 ∷ Proxy Int32-anInt32 = Proxy---- | 'Int64' proxy value.-anInt64 ∷ Proxy Int64-anInt64 = Proxy---- | 'Word' proxy value.-aWord ∷ Proxy Word-aWord = Proxy---- | 'Word8' proxy value.-aWord8 ∷ Proxy Word8-aWord8 = Proxy---- | 'Word16' proxy value.-aWord16 ∷ Proxy Word16-aWord16 = Proxy---- | 'Word32' proxy value.-aWord32 ∷ Proxy Word32-aWord32 = Proxy---- | 'Word64' proxy value.-aWord64 ∷ Proxy Word64-aWord64 = Proxy---- | 'Ratio' proxy value.-aRatio ∷ Proxy Ratio-aRatio = Proxy---- | 'Ratio' /α/ proxy value.-aRatioOf ∷ Proxy α → Proxy (Ratio α)-aRatioOf _ = Proxy---- | 'Rational' proxy value.-aRational ∷ Proxy Rational-aRational = Proxy---- | 'Fixed' proxy value.-aFixed ∷ Proxy Fixed-aFixed = Proxy---- | 'Fixed' /α/ proxy value.-aFixedOf ∷ Proxy α → Proxy (Fixed α)-aFixedOf _ = Proxy---- | 'Uni' proxy value.-aUni ∷ Proxy Uni-aUni = Proxy---- | 'Deci' proxy value.-aDeci ∷ Proxy Deci-aDeci = Proxy---- | 'Centi' proxy value.-aCenti ∷ Proxy Centi-aCenti = Proxy---- | 'Milli' proxy value.-aMilli ∷ Proxy Milli-aMilli = Proxy---- | 'Micro' proxy value.-aMicro ∷ Proxy Micro-aMicro = Proxy---- | 'Nano' proxy value.-aNano ∷ Proxy Nano-aNano = Proxy---- | 'Pico' proxy value.-aPico ∷ Proxy Pico-aPico = Proxy---- | 'Float' proxy value.-aFloat ∷ Proxy Float-aFloat = Proxy---- | 'Double' proxy value.-aDouble ∷ Proxy Double-aDouble = Proxy---- | 'Maybe' proxy value.-aMaybe ∷ Proxy Maybe-aMaybe = Proxy---- | 'Maybe' /α/ proxy value.-aMaybeOf ∷ Proxy α → Proxy (Maybe α)-aMaybeOf _ = Proxy---- | List proxy value.-aList ∷ Proxy []-aList = Proxy---- | List of /α/ proxy value.-aListOf ∷ Proxy α → Proxy ([α])-aListOf _ = Proxy- -- | Parsing result. data Parsed α = Parsed α               | Malformed [String] String@@ -592,7 +407,7 @@ {-# INLINE parseString #-}  -- | Provide a hint for the type system when using 'parseString'.-parseStringAs ∷ Textual α ⇒ Proxy α → String → Parsed α+parseStringAs ∷ Textual α ⇒ p α → String → Parsed α parseStringAs _ = parseString {-# INLINE parseStringAs #-} @@ -602,7 +417,7 @@ {-# INLINE parseText #-}  -- | Provide a hint for the type system when using 'parseText'.-parseTextAs ∷ Textual α ⇒ Proxy α → TS.Text → Parsed α+parseTextAs ∷ Textual α ⇒ p α → TS.Text → Parsed α parseTextAs _ = parseText {-# INLINE parseTextAs #-} @@ -612,7 +427,7 @@ {-# INLINE parseLazyText #-}  -- | Provide a hint for the type system when using 'parseLazyText'.-parseLazyTextAs ∷ Textual α ⇒ Proxy α → TL.Text → Parsed α+parseLazyTextAs ∷ Textual α ⇒ p α → TL.Text → Parsed α parseLazyTextAs _ = parseLazyText {-# INLINE parseLazyTextAs #-} @@ -622,7 +437,7 @@ {-# INLINE parseAscii #-}  -- | Provide a hint for the type system when using 'parseAscii'.-parseAsciiAs ∷ Textual α ⇒ Proxy α → BS.ByteString → Parsed α+parseAsciiAs ∷ Textual α ⇒ p α → BS.ByteString → Parsed α parseAsciiAs _ = parseAscii {-# INLINE parseAsciiAs #-} @@ -643,7 +458,7 @@ {-# INLINE parseUtf8 #-}  -- | Provide a hint for the type system when using 'parseUtf8'.-parseUtf8As ∷ Textual α ⇒ Proxy α → BS.ByteString → Parsed α+parseUtf8As ∷ Textual α ⇒ p α → BS.ByteString → Parsed α parseUtf8As _ = parseUtf8 {-# INLINE parseUtf8As #-} @@ -654,7 +469,7 @@ {-# INLINE parseLazyUtf8 #-}  -- | Provide a hint for the type system when using 'parseLazyUtf8'.-parseLazyUtf8As ∷ Textual α ⇒ Proxy α → BL.ByteString → Parsed α+parseLazyUtf8As ∷ Textual α ⇒ p α → BL.ByteString → Parsed α parseLazyUtf8As _ = parseLazyUtf8 {-# INLINE parseLazyUtf8As #-} @@ -664,7 +479,7 @@ {-# INLINE fromString #-}  -- | Provide a hint for the type system when using 'fromString'.-fromStringAs ∷ Textual α ⇒ Proxy α → String → Maybe α+fromStringAs ∷ Textual α ⇒ p α → String → Maybe α fromStringAs _ = fromString {-# INLINE fromStringAs #-} @@ -674,7 +489,7 @@ {-# INLINE fromText #-}  -- | Provide a hint for the type system when using 'fromText'.-fromTextAs ∷ Textual α ⇒ Proxy α → TS.Text → Maybe α+fromTextAs ∷ Textual α ⇒ p α → TS.Text → Maybe α fromTextAs _ = fromText {-# INLINE fromTextAs #-} @@ -684,7 +499,7 @@ {-# INLINE fromLazyText #-}  -- | Provide a hint for the type system when using 'fromLazyText'.-fromLazyTextAs ∷ Textual α ⇒ Proxy α → TL.Text → Maybe α+fromLazyTextAs ∷ Textual α ⇒ p α → TL.Text → Maybe α fromLazyTextAs _ = fromLazyText {-# INLINE fromLazyTextAs #-} @@ -694,7 +509,7 @@ {-# INLINE fromAscii #-}  -- | Provide a hint for the type system when using 'fromAscii'.-fromAsciiAs ∷ Textual α ⇒ Proxy α → BS.ByteString → Maybe α+fromAsciiAs ∷ Textual α ⇒ p α → BS.ByteString → Maybe α fromAsciiAs _ = fromAscii {-# INLINE fromAsciiAs #-} @@ -704,7 +519,7 @@ {-# INLINE fromLazyAscii #-}  -- | Provide a hint for the type system when using 'fromLazyAscii'.-fromLazyAsciiAs ∷ Textual α ⇒ Proxy α → BL.ByteString → Maybe α+fromLazyAsciiAs ∷ Textual α ⇒ p α → BL.ByteString → Maybe α fromLazyAsciiAs _ = fromLazyAscii {-# INLINE fromLazyAsciiAs #-} @@ -714,7 +529,7 @@ {-# INLINE fromUtf8 #-}  -- | Provide a hint for the type system when using 'fromUtf8'.-fromUtf8As ∷ Textual α ⇒ Proxy α → BS.ByteString → Maybe α+fromUtf8As ∷ Textual α ⇒ p α → BS.ByteString → Maybe α fromUtf8As _ = fromUtf8 {-# INLINE fromUtf8As #-} @@ -724,7 +539,7 @@ {-# INLINE fromLazyUtf8 #-}  -- | Provide a hint for the type system when using 'fromLazyUtf8'.-fromLazyUtf8As ∷ Textual α ⇒ Proxy α → BL.ByteString → Maybe α+fromLazyUtf8As ∷ Textual α ⇒ p α → BL.ByteString → Maybe α fromLazyUtf8As _ = fromLazyUtf8 {-# INLINE fromLazyUtf8As #-} 
tests/Tests.hs view
@@ -10,7 +10,7 @@ import Prelude hiding (print) import Data.Word (Word) import Data.Fixed (Pico)-import Data.Proxy (Proxy)+import Type.Hint import Control.Applicative import Text.Printer (StringBuilder) import qualified Text.Printer as TP@@ -297,7 +297,7 @@ parse ∷ (∀ μ . (Monad μ, CharParsing μ) ⇒ μ α) → StringBuilder → Parsed α parse p b = builtInParser (p <* PC.eof) (TP.buildString b) -parseAs ∷ Proxy α → (∀ μ . (Monad μ, CharParsing μ) ⇒ μ α) → StringBuilder+parseAs ∷ p α → (∀ μ . (Monad μ, CharParsing μ) ⇒ μ α) → StringBuilder         → Parsed α parseAs _ = parse