-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sustainable serialisation library -- -- Please see the README on GitHub at -- https://github.com/fumieval/winery#readme @package winery @version 1 -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- Internal functions and datatypes module Data.Winery.Internal unsignedVarInt :: (Bits a, Integral a) => a -> Builder varInt :: (Bits a, Integral a) => a -> Builder type Decoder = State ByteString evalDecoder :: Decoder a -> ByteString -> a -- | A state monad. The reason being not State from transformers -- is to allow coercion for newtype deriving and DerivingVia. newtype State s a State :: (s -> (a, s)) -> State s a [runState] :: State s a -> s -> (a, s) evalState :: State s a -> s -> a decodeVarInt :: (Num a, Bits a) => Decoder a decodeVarIntFinite :: forall a. (Num a, FiniteBits a) => Decoder a getWord8 :: Decoder Word8 getWord16 :: Decoder Word16 getWord32 :: Decoder Word32 getWord64 :: Decoder Word64 data DecodeException InsufficientInput :: DecodeException IntegerOverflow :: DecodeException InvalidTag :: DecodeException indexDefault :: a -> [a] -> Int -> a unsafeIndexV :: Unbox a => String -> Vector a -> Int -> a lookupWithIndexV :: Eq k => k -> Vector (k, v) -> Maybe (Int, v) -- | A monad with Reader [r] and Either WineryException -- combined, used internally to build an extractor. r is used to -- share environment such as extractors for fixpoints. newtype Strategy e r a Strategy :: (r -> Either e a) -> Strategy e r a [unStrategy] :: Strategy e r a -> r -> Either e a throwStrategy :: e -> Strategy e r a -- | A Bazaar (chain of indexed store comonad)-like structure which instead -- works for natural transformations. newtype TransFusion f g a TransFusion :: (forall h. Applicative h => (forall x. f x -> h (g x)) -> h a) -> TransFusion f g a [unTransFusion] :: TransFusion f g a -> forall h. Applicative h => (forall x. f x -> h (g x)) -> h a instance GHC.Base.Functor (Data.Winery.Internal.Strategy e r) instance GHC.Read.Read Data.Winery.Internal.DecodeException instance GHC.Show.Show Data.Winery.Internal.DecodeException instance GHC.Classes.Eq Data.Winery.Internal.DecodeException instance GHC.Base.Functor (Data.Winery.Internal.State s) instance GHC.Base.Functor (Data.Winery.Internal.TransFusion f g) instance GHC.Base.Applicative (Data.Winery.Internal.TransFusion f g) instance GHC.Base.Applicative (Data.Winery.Internal.Strategy e r) instance GHC.Base.Monad (Data.Winery.Internal.Strategy e r) instance Data.String.IsString e => GHC.Base.Alternative (Data.Winery.Internal.Strategy e r) instance Control.Monad.Fix.MonadFix (Data.Winery.Internal.Strategy e r) instance GHC.Exception.Type.Exception Data.Winery.Internal.DecodeException instance GHC.Base.Applicative (Data.Winery.Internal.State s) instance GHC.Base.Monad (Data.Winery.Internal.State s) instance Control.Monad.Fix.MonadFix (Data.Winery.Internal.State s) -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- Basic types module Data.Winery.Base -- | Tag is an extra value that can be attached to a schema. data Tag TagInt :: !Int -> Tag TagStr :: !Text -> Tag TagList :: ![Tag] -> Tag -- | A schema preserves structure of a datatype, allowing users to inspect -- the data regardless of the current implementation. -- -- "Yeah, it’s just a memento. Just, you know, from the first time we -- met." type Schema = SchemaP Int data SchemaP a -- | binds a fixpoint SFix :: !SchemaP a -> SchemaP a -- | SVar n refers to the n-th innermost fixpoint SVar :: !a -> SchemaP a SVector :: !SchemaP a -> SchemaP a SProduct :: !Vector (SchemaP a) -> SchemaP a SRecord :: !Vector (Text, SchemaP a) -> SchemaP a SVariant :: !Vector (Text, SchemaP a) -> SchemaP a SBool :: SchemaP a SChar :: SchemaP a SWord8 :: SchemaP a SWord16 :: SchemaP a SWord32 :: SchemaP a SWord64 :: SchemaP a SInt8 :: SchemaP a SInt16 :: SchemaP a SInt32 :: SchemaP a SInt64 :: SchemaP a SInteger :: SchemaP a SFloat :: SchemaP a SDouble :: SchemaP a SBytes :: SchemaP a SText :: SchemaP a -- | nanoseconds from POSIX epoch SUTCTime :: SchemaP a STag :: !Tag -> !SchemaP a -> SchemaP a SLet :: !SchemaP a -> !SchemaP a -> SchemaP a currentSchemaVersion :: Word8 bootstrapSchema :: Word8 -> Schema -- | Common representation for any winery data. Handy for prettyprinting -- winery-serialised data. data Term TBool :: !Bool -> Term TChar :: !Char -> Term TWord8 :: !Word8 -> Term TWord16 :: !Word16 -> Term TWord32 :: !Word32 -> Term TWord64 :: !Word64 -> Term TInt8 :: !Int8 -> Term TInt16 :: !Int16 -> Term TInt32 :: !Int32 -> Term TInt64 :: !Int64 -> Term TInteger :: !Integer -> Term TFloat :: !Float -> Term TDouble :: !Double -> Term TBytes :: !ByteString -> Term TText :: !Text -> Term TUTCTime :: !UTCTime -> Term TVector :: !Vector Term -> Term TProduct :: !Vector Term -> Term TRecord :: !Vector (Text, Term) -> Term TVariant :: !Int -> !Text -> Term -> Term -- | Extractor is a Plan that creates a function to extract a -- value from Term. -- -- The Applicative instance can be used to build a user-defined -- extractor. This is also Alternative, meaning that fallback -- plans may be added. -- -- "Don't get set into one form, adapt it and build your own, and let -- it grow, be like water." newtype Extractor a Extractor :: Plan (Term -> a) -> Extractor a [getExtractor] :: Extractor a -> Plan (Term -> a) type Strategy' = Strategy WineryException StrategyEnv data StrategyBind -- | A fixpoint of a decoder DynDecoder :: !Dynamic -> StrategyBind -- | schema bound by SLet. Int is a basis of the variables BoundSchema :: !Int -> !Schema -> StrategyBind data StrategyEnv StrategyEnv :: !Int -> ![StrategyBind] -> StrategyEnv -- | Plan is a monad for computations which interpret Schema. newtype Plan a Plan :: (Schema -> Strategy' a) -> Plan a [unPlan] :: Plan a -> Schema -> Strategy' a unwrapExtractor :: Extractor a -> Schema -> Strategy' (Term -> a) data WineryException UnexpectedSchema :: !Doc AnsiStyle -> !Doc AnsiStyle -> !Schema -> WineryException FieldNotFound :: !Doc AnsiStyle -> !Text -> ![Text] -> WineryException TypeMismatch :: !Int -> !TypeRep -> !TypeRep -> WineryException ProductTooSmall :: !Int -> WineryException UnboundVariable :: !Int -> WineryException EmptyInput :: WineryException WineryMessage :: !Doc AnsiStyle -> WineryException prettyWineryException :: WineryException -> Doc AnsiStyle instance GHC.Base.Functor Data.Winery.Base.Extractor instance GHC.Base.Functor Data.Winery.Base.Plan instance GHC.Show.Show Data.Winery.Base.WineryException instance GHC.Show.Show Data.Winery.Base.Term instance Data.Traversable.Traversable Data.Winery.Base.SchemaP instance Data.Foldable.Foldable Data.Winery.Base.SchemaP instance GHC.Base.Functor Data.Winery.Base.SchemaP instance GHC.Generics.Generic (Data.Winery.Base.SchemaP a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Winery.Base.SchemaP a) instance GHC.Read.Read a => GHC.Read.Read (Data.Winery.Base.SchemaP a) instance GHC.Show.Show a => GHC.Show.Show (Data.Winery.Base.SchemaP a) instance GHC.Generics.Generic Data.Winery.Base.Tag instance GHC.Classes.Eq Data.Winery.Base.Tag instance GHC.Read.Read Data.Winery.Base.Tag instance GHC.Show.Show Data.Winery.Base.Tag instance GHC.Base.Applicative Data.Winery.Base.Extractor instance GHC.Base.Alternative Data.Winery.Base.Extractor instance GHC.Base.Applicative Data.Winery.Base.Plan instance GHC.Base.Monad Data.Winery.Base.Plan instance GHC.Base.Alternative Data.Winery.Base.Plan instance GHC.Exception.Type.Exception Data.Winery.Base.WineryException instance Data.String.IsString Data.Winery.Base.WineryException instance Data.Aeson.Types.ToJSON.ToJSON Data.Winery.Base.Term instance Data.Text.Prettyprint.Doc.Internal.Pretty Data.Winery.Base.Term instance Data.Text.Prettyprint.Doc.Internal.Pretty a => Data.Text.Prettyprint.Doc.Internal.Pretty (Data.Winery.Base.SchemaP a) instance Data.String.IsString Data.Winery.Base.Tag instance GHC.Exts.IsList Data.Winery.Base.Tag instance Data.Text.Prettyprint.Doc.Internal.Pretty Data.Winery.Base.Tag -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- The standard interface of winery serialisation library module Data.Winery -- | A schema preserves structure of a datatype, allowing users to inspect -- the data regardless of the current implementation. -- -- "Yeah, it’s just a memento. Just, you know, from the first time we -- met." type Schema = SchemaP Int data SchemaP a -- | binds a fixpoint SFix :: !SchemaP a -> SchemaP a -- | SVar n refers to the n-th innermost fixpoint SVar :: !a -> SchemaP a SVector :: !SchemaP a -> SchemaP a SProduct :: !Vector (SchemaP a) -> SchemaP a SRecord :: !Vector (Text, SchemaP a) -> SchemaP a SVariant :: !Vector (Text, SchemaP a) -> SchemaP a SBool :: SchemaP a SChar :: SchemaP a SWord8 :: SchemaP a SWord16 :: SchemaP a SWord32 :: SchemaP a SWord64 :: SchemaP a SInt8 :: SchemaP a SInt16 :: SchemaP a SInt32 :: SchemaP a SInt64 :: SchemaP a SInteger :: SchemaP a SFloat :: SchemaP a SDouble :: SchemaP a SBytes :: SchemaP a SText :: SchemaP a -- | nanoseconds from POSIX epoch SUTCTime :: SchemaP a STag :: !Tag -> !SchemaP a -> SchemaP a SLet :: !SchemaP a -> !SchemaP a -> SchemaP a -- | Tag is an extra value that can be attached to a schema. data Tag TagInt :: !Int -> Tag TagStr :: !Text -> Tag TagList :: ![Tag] -> Tag -- | Serialisable datatype class Typeable a => Serialise a -- | Obtain the schema of the datatype. schemaGen :: Serialise a => Proxy a -> SchemaGen Schema -- | Serialise a value. toBuilder :: Serialise a => a -> Builder -- | A value of 'Extractor a' interprets a schema and builds a function -- from Term to a. This must be equivalent to -- decodeCurrent when the schema is the current one. -- -- If extractor s returns a function, the function must -- return a non-bottom for any Term decodeTerm s -- returns. -- -- It must not return a function if an unsupported schema is supplied. -- -- getDecoderBy extractor (schema (Proxy a)) must be -- Right d where d@ is equivalent to decodeCurrent. extractor :: Serialise a => Extractor a -- | Decode a value with the current schema. -- -- decodeCurrent evalDecoder toBuilder x ≡ -- x decodeCurrent :: Serialise a => Decoder a -- | Check the integrity of a Serialise instance. -- -- "No tears in the writer, no tears in the reader. No surprise in the -- writer, no surprise in the reader." testSerialise :: forall a. (Eq a, Show a, Serialise a) => a -> Property data DecodeException InsufficientInput :: DecodeException IntegerOverflow :: DecodeException InvalidTag :: DecodeException -- | Obtain the schema of the datatype. -- -- "Tell me what you drink, and I will tell you what you are." schema :: forall proxy a. Serialise a => proxy a -> Schema toBuilderWithSchema :: forall a. Serialise a => a -> Builder -- | Serialise a value along with its schema. -- -- "Write the vision, and make it plain upon tables, that he may run -- that readeth it." serialise :: Serialise a => a -> ByteString -- | Deserialise a serialised Bytestring. -- -- "Old wood to burn! Old wine to drink! Old friends to trust! Old -- authors to read!" deserialise :: Serialise a => ByteString -> Either WineryException a -- | Deserialise a serialised Bytestring using an -- Extractor. deserialiseBy :: Extractor a -> ByteString -> Either WineryException a -- | Deserialise a serialised Bytestring. deserialiseTerm :: ByteString -> Either WineryException (Schema, Term) splitSchema :: ByteString -> Either WineryException (Schema, ByteString) -- | Serialise a value along with its schema. writeFileSerialise :: Serialise a => FilePath -> a -> IO () -- | Serialise a schema. serialiseSchema :: Schema -> ByteString -- | Serialise a schema. deserialiseSchema :: ByteString -> Either WineryException Schema -- | Extractor is a Plan that creates a function to extract a -- value from Term. -- -- The Applicative instance can be used to build a user-defined -- extractor. This is also Alternative, meaning that fallback -- plans may be added. -- -- "Don't get set into one form, adapt it and build your own, and let -- it grow, be like water." newtype Extractor a Extractor :: Plan (Term -> a) -> Extractor a [getExtractor] :: Extractor a -> Plan (Term -> a) unwrapExtractor :: Extractor a -> Schema -> Strategy' (Term -> a) type Decoder = State ByteString evalDecoder :: Decoder a -> ByteString -> a -- | Serialise a value without its schema. -- -- "Any unsaved progress will be lost." serialiseOnly :: Serialise a => a -> ByteString -- | Obtain a decoder from a schema. -- -- "A reader lives a thousand lives before he dies... The man who -- never reads lives only one." getDecoder :: forall a. Serialise a => Schema -> Either WineryException (Decoder a) -- | Get a decoder from a Extractor and a schema. getDecoderBy :: Extractor a -> Schema -> Either WineryException (Decoder a) -- | Common representation for any winery data. Handy for prettyprinting -- winery-serialised data. data Term TBool :: !Bool -> Term TChar :: !Char -> Term TWord8 :: !Word8 -> Term TWord16 :: !Word16 -> Term TWord32 :: !Word32 -> Term TWord64 :: !Word64 -> Term TInt8 :: !Int8 -> Term TInt16 :: !Int16 -> Term TInt32 :: !Int32 -> Term TInt64 :: !Int64 -> Term TInteger :: !Integer -> Term TFloat :: !Float -> Term TDouble :: !Double -> Term TBytes :: !ByteString -> Term TText :: !Text -> Term TUTCTime :: !UTCTime -> Term TVector :: !Vector Term -> Term TProduct :: !Vector Term -> Term TRecord :: !Vector (Text, Term) -> Term TVariant :: !Int -> !Text -> Term -> Term newtype Subextractor a Subextractor :: Extractor a -> Subextractor a [unSubextractor] :: Subextractor a -> Extractor a buildExtractor :: Typeable a => Subextractor a -> Extractor a -- | Extract a list or an array of values. extractListBy :: Typeable a => Extractor a -> Extractor (Vector a) -- | Extract a field of a record. extractField :: Serialise a => Text -> Subextractor a -- | Extract a field using the supplied Extractor. extractFieldBy :: Extractor a -> Text -> Subextractor a -- | Tries to match on a constructor. If it doesn't match (or constructor -- doesn't exist at all), leave it to the successor. -- --
--   extractor = (Just, Just) extractConstructor (Nothing, () -> Nothing) extractConstructor extractVoid
--   
extractConstructor :: Serialise a => (Text, a -> r) -> Subextractor r -> Subextractor r infixr 1 `extractConstructor` -- | Tries to extract a specific constructor of a variant. Useful for -- implementing backward-compatible extractors. extractConstructorBy :: Typeable a => (Extractor a, Text, a -> r) -> Subextractor r -> Subextractor r infixr 1 `extractConstructorBy` extractVoid :: Typeable r => Subextractor r -- | This may be thrown if illegal Term is passed to an extractor. data ExtractException InvalidTerm :: !Term -> ExtractException -- | Encoded in variable-length quantity. newtype VarInt a VarInt :: a -> VarInt a [getVarInt] :: VarInt a -> a data WineryException UnexpectedSchema :: !Doc AnsiStyle -> !Doc AnsiStyle -> !Schema -> WineryException FieldNotFound :: !Doc AnsiStyle -> !Text -> ![Text] -> WineryException TypeMismatch :: !Int -> !TypeRep -> !TypeRep -> WineryException ProductTooSmall :: !Int -> WineryException UnboundVariable :: !Int -> WineryException EmptyInput :: WineryException WineryMessage :: !Doc AnsiStyle -> WineryException prettyWineryException :: WineryException -> Doc AnsiStyle unexpectedSchema :: forall f a. Serialise a => Doc AnsiStyle -> Schema -> Strategy' (f a) -- | Schema generator data SchemaGen a -- | Obtain a schema on SchemaGen, binding a fixpoint when -- necessary. If you are hand-rolling a definition of schemaGen, -- you should call this instead of schemaGen. getSchema :: forall proxy a. Serialise a => proxy a -> SchemaGen Schema -- | Plan is a monad for computations which interpret Schema. newtype Plan a Plan :: (Schema -> Strategy' a) -> Plan a [unPlan] :: Plan a -> Schema -> Strategy' a -- | Construct a plan, expanding fixpoints and let bindings. mkPlan :: forall a. Typeable a => (Schema -> Strategy' (Term -> a)) -> Plan (Term -> a) -- | The Serialise instance is generically defined for records. -- -- /"Remember thee! Yea, from the table of my memory I'll wipe away all -- trivial fond records."/ newtype WineryRecord a WineryRecord :: a -> WineryRecord a [unWineryRecord] :: WineryRecord a -> a -- | The Serialise instance is generically defined for variants. -- -- "The one so like the other as could not be distinguish'd but by -- names." newtype WineryVariant a WineryVariant :: a -> WineryVariant a [unWineryVariant] :: WineryVariant a -> a -- | Serialise a value as a product (omits field names). -- -- "I get ideas about what's essential when packing my suitcase." newtype WineryProduct a WineryProduct :: a -> WineryProduct a [unWineryProduct] :: WineryProduct a -> a class GSerialiseRecord f -- | Generic implementation of schemaGen for a record. gschemaGenRecord :: forall proxy a. (GSerialiseRecord (Rep a), Generic a, Typeable a) => proxy a -> SchemaGen Schema class GEncodeProduct f -- | Generic implementation of toBuilder for a record. gtoBuilderRecord :: (GEncodeProduct (Rep a), Generic a) => a -> Builder -- | Generic implementation of extractor for a record. gextractorRecord :: forall a. (GSerialiseRecord (Rep a), Generic a, Typeable a) => Maybe a -> Extractor a gdecodeCurrentRecord :: (GSerialiseRecord (Rep a), Generic a) => Decoder a class GSerialiseVariant f -- | Generic implementation of schemaGen for an ADT. gschemaGenVariant :: forall proxy a. (GSerialiseVariant (Rep a), Typeable a, Generic a) => proxy a -> SchemaGen Schema -- | Generic implementation of toBuilder for an ADT. gtoBuilderVariant :: (GSerialiseVariant (Rep a), Generic a) => a -> Builder -- | Generic implementation of extractor for an ADT. gextractorVariant :: forall a. (GSerialiseVariant (Rep a), Generic a, Typeable a) => Extractor a gschemaGenProduct :: forall proxy a. (Generic a, GSerialiseProduct (Rep a)) => proxy a -> SchemaGen Schema gtoBuilderProduct :: (Generic a, GEncodeProduct (Rep a)) => a -> Builder gdecodeCurrentVariant :: (GSerialiseVariant (Rep a), Generic a) => Decoder a -- | Generic implementation of extractor for a record. gextractorProduct :: forall a. (GSerialiseProduct (Rep a), Generic a, Typeable a) => Extractor a -- | Generic implementation of extractor for a record. gdecodeCurrentProduct :: forall a. (GSerialiseProduct (Rep a), Generic a) => Decoder a bootstrapSchema :: Word8 -> Schema instance GHC.Base.Alternative Data.Winery.Subextractor instance GHC.Base.Applicative Data.Winery.Subextractor instance GHC.Base.Functor Data.Winery.Subextractor instance Data.Bits.Bits a => Data.Bits.Bits (Data.Winery.VarInt a) instance GHC.Real.Integral a => GHC.Real.Integral (Data.Winery.VarInt a) instance GHC.Real.Real a => GHC.Real.Real (Data.Winery.VarInt a) instance GHC.Num.Num a => GHC.Num.Num (Data.Winery.VarInt a) instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Winery.VarInt a) instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Winery.VarInt a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Winery.VarInt a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Winery.VarInt a) instance GHC.Read.Read a => GHC.Read.Read (Data.Winery.VarInt a) instance GHC.Show.Show a => GHC.Show.Show (Data.Winery.VarInt a) instance GHC.Show.Show Data.Winery.ExtractException instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Functor.Identity.Identity a) instance forall k a (b :: k). (Data.Winery.Serialise a, Data.Typeable.Internal.Typeable b, Data.Typeable.Internal.Typeable k) => Data.Winery.Serialise (Data.Functor.Const.Const a b) instance Data.Winery.Serialise Data.Semigroup.Internal.Any instance Data.Winery.Serialise Data.Semigroup.Internal.All instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Ord.Down a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Internal.Product a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Internal.Sum a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Internal.Dual a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Monoid.Last a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Monoid.First a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Last a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.First a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Control.Applicative.ZipList a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Option a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Max a) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Semigroup.Min a) instance forall k (f :: k -> *) (a :: k). (Data.Typeable.Internal.Typeable k, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable a, Data.Winery.Serialise (f a)) => Data.Winery.Serialise (Data.Semigroup.Internal.Alt f a) instance forall j k (f :: k -> *) (g :: j -> k) (a :: j). (Data.Typeable.Internal.Typeable j, Data.Typeable.Internal.Typeable k, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable a, Data.Winery.Serialise (f (g a))) => Data.Winery.Serialise (Data.Functor.Compose.Compose f g a) instance forall k (f :: k -> *) (a :: k). (Data.Typeable.Internal.Typeable k, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable a, Data.Winery.Serialise (f a)) => Data.Winery.Serialise (Data.Monoid.Ap f a) instance (Data.Winery.GSerialiseVariant (GHC.Generics.Rep a), GHC.Generics.Generic a, Data.Typeable.Internal.Typeable a) => Data.Winery.Serialise (Data.Winery.WineryVariant a) instance forall k (f :: k -> *) (g :: k -> *). (Data.Winery.GSerialiseVariant f, Data.Winery.GSerialiseVariant g) => Data.Winery.GSerialiseVariant (f GHC.Generics.:+: g) instance forall k (f :: k -> *) (name :: GHC.Types.Symbol) (fixity :: GHC.Generics.FixityI). (Data.Winery.GSerialiseProduct f, Data.Winery.GEncodeProduct f, GHC.TypeLits.KnownSymbol name) => Data.Winery.GSerialiseVariant (GHC.Generics.C1 ('GHC.Generics.MetaCons name fixity 'GHC.Types.False) f) instance forall k (f :: k -> *) (name :: GHC.Types.Symbol) (fixity :: GHC.Generics.FixityI). (Data.Winery.GSerialiseRecord f, Data.Winery.GEncodeProduct f, GHC.TypeLits.KnownSymbol name) => Data.Winery.GSerialiseVariant (GHC.Generics.C1 ('GHC.Generics.MetaCons name fixity 'GHC.Types.True) f) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GSerialiseVariant f => Data.Winery.GSerialiseVariant (GHC.Generics.S1 c f) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GSerialiseVariant f => Data.Winery.GSerialiseVariant (GHC.Generics.D1 c f) instance (Data.Winery.GEncodeProduct (GHC.Generics.Rep a), Data.Winery.GSerialiseProduct (GHC.Generics.Rep a), GHC.Generics.Generic a, Data.Typeable.Internal.Typeable a) => Data.Winery.Serialise (Data.Winery.WineryProduct a) instance Data.Winery.GSerialiseProduct GHC.Generics.U1 instance Data.Winery.Serialise a => Data.Winery.GSerialiseProduct (GHC.Generics.K1 i a) instance forall k (f :: k -> *) i (c :: GHC.Generics.Meta). Data.Winery.GSerialiseProduct f => Data.Winery.GSerialiseProduct (GHC.Generics.M1 i c f) instance forall k (f :: k -> *) (g :: k -> *). (Data.Winery.GSerialiseProduct f, Data.Winery.GSerialiseProduct g) => Data.Winery.GSerialiseProduct (f GHC.Generics.:*: g) instance (Data.Winery.GEncodeProduct (GHC.Generics.Rep a), Data.Winery.GSerialiseRecord (GHC.Generics.Rep a), GHC.Generics.Generic a, Data.Typeable.Internal.Typeable a) => Data.Winery.Serialise (Data.Winery.WineryRecord a) instance forall k (f :: k -> *) (g :: k -> *). (Data.Winery.GSerialiseRecord f, Data.Winery.GSerialiseRecord g) => Data.Winery.GSerialiseRecord (f GHC.Generics.:*: g) instance (Data.Winery.Serialise a, GHC.Generics.Selector c) => Data.Winery.GSerialiseRecord (GHC.Generics.S1 c (GHC.Generics.K1 i a)) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GSerialiseRecord f => Data.Winery.GSerialiseRecord (GHC.Generics.C1 c f) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GSerialiseRecord f => Data.Winery.GSerialiseRecord (GHC.Generics.D1 c f) instance Data.Winery.GEncodeProduct GHC.Generics.U1 instance forall k (f :: k -> *) (g :: k -> *). (Data.Winery.GEncodeProduct f, Data.Winery.GEncodeProduct g) => Data.Winery.GEncodeProduct (f GHC.Generics.:*: g) instance Data.Winery.Serialise a => Data.Winery.GEncodeProduct (GHC.Generics.S1 c (GHC.Generics.K1 i a)) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GEncodeProduct f => Data.Winery.GEncodeProduct (GHC.Generics.C1 c f) instance forall k (f :: k -> *) (c :: GHC.Generics.Meta). Data.Winery.GEncodeProduct f => Data.Winery.GEncodeProduct (GHC.Generics.D1 c f) instance Data.Winery.Serialise GHC.Types.Int instance (Data.Typeable.Internal.Typeable a, Data.Bits.Bits a, GHC.Real.Integral a) => Data.Winery.Serialise (Data.Winery.VarInt a) instance Data.Winery.Serialise GHC.Integer.Type.Integer instance Data.Winery.Serialise Data.Winery.Base.Tag instance Data.Winery.Serialise Data.Winery.Base.Schema instance Data.Winery.Serialise () instance Data.Winery.Serialise GHC.Types.Bool instance Data.Winery.Serialise GHC.Word.Word8 instance Data.Winery.Serialise GHC.Word.Word16 instance Data.Winery.Serialise GHC.Word.Word32 instance Data.Winery.Serialise GHC.Word.Word64 instance Data.Winery.Serialise GHC.Types.Word instance Data.Winery.Serialise GHC.Int.Int8 instance Data.Winery.Serialise GHC.Int.Int16 instance Data.Winery.Serialise GHC.Int.Int32 instance Data.Winery.Serialise GHC.Int.Int64 instance Data.Winery.Serialise GHC.Types.Float instance Data.Winery.Serialise GHC.Types.Double instance Data.Winery.Serialise Data.Text.Internal.Text instance Data.Winery.Serialise GHC.Natural.Natural instance Data.Winery.Serialise GHC.Types.Char instance Data.Winery.Serialise a => Data.Winery.Serialise (GHC.Maybe.Maybe a) instance Data.Winery.Serialise Data.ByteString.Internal.ByteString instance Data.Winery.Serialise Data.ByteString.Lazy.Internal.ByteString instance Data.Winery.Serialise Data.Time.Clock.Internal.UTCTime.UTCTime instance Data.Winery.Serialise Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime instance Data.Winery.Serialise a => Data.Winery.Serialise [a] instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Vector.Vector a) instance (Foreign.Storable.Storable a, Data.Winery.Serialise a) => Data.Winery.Serialise (Data.Vector.Storable.Vector a) instance (Data.Vector.Unboxed.Base.Unbox a, Data.Winery.Serialise a) => Data.Winery.Serialise (Data.Vector.Unboxed.Base.Vector a) instance (GHC.Classes.Ord k, Data.Winery.Serialise k, Data.Winery.Serialise v) => Data.Winery.Serialise (Data.Map.Internal.Map k v) instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Data.Winery.Serialise k, Data.Winery.Serialise v) => Data.Winery.Serialise (Data.HashMap.Base.HashMap k v) instance Data.Winery.Serialise v => Data.Winery.Serialise (Data.IntMap.Internal.IntMap v) instance (GHC.Classes.Ord a, Data.Winery.Serialise a) => Data.Winery.Serialise (Data.Set.Internal.Set a) instance Data.Winery.Serialise Data.IntSet.Internal.IntSet instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Sequence.Internal.Seq a) instance (GHC.Real.Integral a, Data.Winery.Serialise a) => Data.Winery.Serialise (GHC.Real.Ratio a) instance Data.Winery.Serialise Data.Scientific.Scientific instance (Data.Winery.Serialise a, Data.Winery.Serialise b) => Data.Winery.Serialise (a, b) instance (Data.Winery.Serialise a, Data.Winery.Serialise b, Data.Winery.Serialise c) => Data.Winery.Serialise (a, b, c) instance (Data.Winery.Serialise a, Data.Winery.Serialise b, Data.Winery.Serialise c, Data.Winery.Serialise d) => Data.Winery.Serialise (a, b, c, d) instance (Data.Winery.Serialise a, Data.Winery.Serialise b, Data.Winery.Serialise c, Data.Winery.Serialise d, Data.Winery.Serialise e) => Data.Winery.Serialise (a, b, c, d, e) instance (Data.Winery.Serialise a, Data.Winery.Serialise b, Data.Winery.Serialise c, Data.Winery.Serialise d, Data.Winery.Serialise e, Data.Winery.Serialise f) => Data.Winery.Serialise (a, b, c, d, e, f) instance (Data.Winery.Serialise a, Data.Winery.Serialise b) => Data.Winery.Serialise (Data.Either.Either a b) instance Data.Winery.Serialise GHC.Types.Ordering instance forall k (a :: k) (b :: k). (Data.Typeable.Internal.Typeable k, Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable b, a Data.Type.Equality.~ b) => Data.Winery.Serialise (a Data.Type.Equality.:~: b) instance (Data.Winery.Serialise a, Data.Winery.Serialise b) => Data.Winery.Serialise (Data.Semigroup.Arg a b) instance Data.Winery.Serialise a => Data.Winery.Serialise (Data.Complex.Complex a) instance Data.Winery.Serialise Data.Void.Void instance GHC.Base.Functor Data.Winery.SchemaGen instance GHC.Base.Applicative Data.Winery.SchemaGen instance GHC.Exception.Type.Exception Data.Winery.ExtractException -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- Building blocks for winery queries. module Data.Winery.Query -- | Query is a transformation between Extractors. Like jq, this -- returns a list of values. newtype Query a b Query :: (Extractor [a] -> Extractor [b]) -> Query a b [runQuery] :: Query a b -> Extractor [a] -> Extractor [b] -- | Throw an error. invalid :: WineryException -> Query a b -- | Takes a list and traverses on it. list :: Typeable a => Query a a -- | Takes a list and enumerates elements in the specified range. Like -- Python's array slicing, negative numbers counts from the last element. range :: Typeable a => Int -> Int -> Query a a -- | Takes a record and extracts the specified field. field :: Typeable a => Text -> Query a a -- | Takes a variant and returns a value when the constructor matches. con :: Typeable a => Text -> Query a a -- | Propagate values if the supplied Query doesn't return False. select :: Query a Bool -> Query a a instance GHC.Base.Functor (Data.Winery.Query.Query a) instance Control.Category.Category Data.Winery.Query.Query instance GHC.Base.Applicative (Data.Winery.Query.Query a) instance GHC.Base.Alternative (Data.Winery.Query.Query a) -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- The language for winery queries -- -- See the Pretty-printing section of README.md for examples. module Data.Winery.Query.Parser parseQuery :: Typeable a => Parser (Query (Doc a) (Doc a)) -- | Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com -- -- A test framework that allows you to test all related Serialise -- instances with automatically-generated test cases module Data.Winery.Test -- | A class to provide test values and gather tests for its components. It -- is recommended to use the generic default methods. class Typeable a => TestGen a -- | A list of values that can be used as test cases. It should contain at -- least one value as long as there is a non-bottom value in the type. genTestCases :: TestGen a => [a] -- | Inherited set of test cases for each type it involves. inheritedTests :: TestGen a => Proxy a -> Map TypeRep [Test] -- | A list of values that can be used as test cases. It should contain at -- least one value as long as there is a non-bottom value in the type. genTestCases :: (TestGen a, Generic a, GTestGen (Rep a)) => [a] -- | Inherited set of test cases for each type it involves. inheritedTests :: (TestGen a, GTestGen (Rep a)) => Proxy a -> Map TypeRep [Test] -- | Generate test cases and print them to the standard output. printTests :: forall a. (TestGen a, Serialise a, Show a) => IO () -- | Types with concrete test cases. -- -- /"Doubt is useful, it keeps faith a living thing. After all, you -- cannot know the strength of your faith until it has been tested."/ class TestGen a => Tested a -- | List of test cases for the type. testCases :: Tested a => [Test] -- | Construct a test case. testCase :: (Show a, Eq a, Serialise a) => Schema -> ByteString -> a -> Test -- | Gather all test cases involved in the specified type. allTests :: forall a. (TestGen a, Tested a) => Map TypeRep [Test] -- | Merge multiple tests into one. mergeTests :: Map TypeRep [Test] -> Test instance Data.Winery.Test.TestGen a => Data.Winery.Test.TestGen (Data.Functor.Identity.Identity a) instance Data.Winery.Test.Tested GHC.Types.Bool instance Data.Winery.Test.Tested GHC.Types.Int instance Data.Winery.Test.Tested GHC.Types.Double instance Data.Winery.Test.Tested () instance Data.Winery.Test.Tested GHC.Types.Char instance Data.Winery.Test.Tested a => Data.Winery.Test.Tested (Data.Functor.Identity.Identity a) instance Data.Winery.Test.Tested a => Data.Winery.Test.Tested (Data.Sequence.Internal.Seq a) instance Data.Winery.Test.Tested a => Data.Winery.Test.Tested [a] instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b) => Data.Winery.Test.Tested (Data.Either.Either a b) instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b) => Data.Winery.Test.Tested (a, b) instance Data.Winery.Test.Tested a => Data.Winery.Test.Tested (Data.Vector.Vector a) instance (Data.Vector.Unboxed.Base.Unbox a, Data.Winery.Test.Tested a) => Data.Winery.Test.Tested (Data.Vector.Unboxed.Base.Vector a) instance (Data.Hashable.Class.Hashable k, Data.Winery.Test.Tested k, Data.Winery.Test.Tested a) => Data.Winery.Test.Tested (Data.HashMap.Base.HashMap k a) instance (Data.Winery.Test.Tested c, Data.Winery.Test.TestGen c) => Data.Winery.Test.GTestGen (GHC.Generics.K1 i c) instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b) => Data.Winery.Test.TestGen (a, b) instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b, Data.Winery.Test.Tested c) => Data.Winery.Test.TestGen (a, b, c) instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b, Data.Winery.Test.Tested c, Data.Winery.Test.Tested d) => Data.Winery.Test.TestGen (a, b, c, d) instance (Data.Winery.Test.Tested a, Data.Winery.Test.Tested b) => Data.Winery.Test.TestGen (Data.Either.Either a b) instance Data.Winery.Test.Tested a => Data.Winery.Test.TestGen [a] instance Data.Winery.Test.Tested a => Data.Winery.Test.TestGen (Data.Sequence.Internal.Seq a) instance Data.Winery.Test.Tested a => Data.Winery.Test.TestGen (Data.Vector.Vector a) instance (Data.Vector.Unboxed.Base.Unbox a, Data.Winery.Test.Tested a) => Data.Winery.Test.TestGen (Data.Vector.Unboxed.Base.Vector a) instance (Data.Hashable.Class.Hashable k, Data.Winery.Test.Tested k, Data.Winery.Test.Tested a) => Data.Winery.Test.TestGen (Data.HashMap.Base.HashMap k a) instance Data.Winery.Test.TestGen () instance Data.Winery.Test.TestGen GHC.Types.Bool instance Data.Winery.Test.TestGen GHC.Types.Int instance Data.Winery.Test.TestGen GHC.Types.Double instance Data.Winery.Test.TestGen GHC.Types.Char instance Data.Winery.Test.GTestGen GHC.Generics.V1 instance Data.Winery.Test.GTestGen GHC.Generics.U1 instance Data.Winery.Test.GTestGen f => Data.Winery.Test.GTestGen (GHC.Generics.Rec1 f) instance Data.Winery.Test.GTestGen f => Data.Winery.Test.GTestGen (GHC.Generics.M1 i c f) instance (Data.Winery.Test.GTestGen f, Data.Winery.Test.GTestGen g) => Data.Winery.Test.GTestGen (f GHC.Generics.:+: g) instance (Data.Winery.Test.GTestGen f, Data.Winery.Test.GTestGen g) => Data.Winery.Test.GTestGen (f GHC.Generics.:*: g)