-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generic binary serialisation using binary and syb. -- -- Instead of manual or semi-automated generation of instances of -- Data.Binary.Binary you just derive Data.Data.Data and -- the library automatically figures out how to (de-)serialize the type. -- You may also define your own type-specific stack of serialisation -- functions. @package binary-generic @version 0.2 -- | You can build your own type-specific stacks. For example the default -- stack looks like this, whereas the ordering determines, which function -- matches first for a specific type. This especially allows you to -- override the default choices: -- --
-- getExtDefault :: Typeable a => Get a -> Get a -- getExtDefault = getExtInteger -- . getExtChar -- . getExtWord -- . getExtInt -- . getExtFloat -- . getExtText -- . getExtByteString -- -- putExtDefault :: Typeable a => (a -> Put) -> a -> Put -- putExtDefault = putExtInteger -- . putExtChar -- . putExtWord -- . putExtInt -- . putExtFloat -- . putExtText -- . putExtByteString ---- -- Notice that these stacks have to be grounded, ideally with something -- that handles algebraic types. Have a look at -- Data.Binary.Generic how this is done for the default stack. -- -- IMPORTANT: You cannot simply apply an extension to getGeneric -- or putGeneric, since these do a recursive call at the bottom -- level which points to the top of the stack. module Data.Binary.Generic.Extensions extGet :: (Monad m, Typeable a, Typeable b) => m b -> m a -> m a extPut :: (Typeable a, Typeable b) => (b -> q) -> (a -> q) -> a -> q getExtDefault :: Typeable a => Get a -> Get a putExtDefault :: Typeable a => (a -> Put) -> a -> Put getExtInteger :: Typeable a => Get a -> Get a putExtInteger :: Typeable a => (a -> Put) -> a -> Put getExtChar :: Typeable a => Get a -> Get a putExtChar :: Typeable a => (a -> Put) -> a -> Put getExtWord :: Typeable a => Get a -> Get a putExtWord :: Typeable a => (a -> Put) -> a -> Put getExtInt :: Typeable a => Get a -> Get a putExtInt :: Typeable a => (a -> Put) -> a -> Put getExtFloat :: Typeable a => Get a -> Get a putExtFloat :: Typeable a => (a -> Put) -> a -> Put getExtText :: Typeable a => Get a -> Get a putExtText :: Typeable a => (a -> Put) -> a -> Put getExtByteString :: Typeable a => Get a -> Get a putExtByteString :: Typeable a => (a -> Put) -> a -> Put -- | For any algebraic datatype just make it an instance of class -- Data.Data.Data by simply deriving Data on definition -- or try stand-alone-deriving. This allows the library to enumerate the -- value constructors and thereby encoding their index. Notice that -- serialisation depends on a type's structure. Serialisations might get -- unreadable if the type is altered. -- -- getGeneric and putGeneric implement a selection of -- type-specific defaults and are grounded by a canonical serialisation -- for all algebraic types that instantiate Data. Have a look at -- Data.Binary.Generic.Extensions for details. -- -- If you want to ground your own type-specific stack myStack of -- extensions write the following for the Get-part (the -- Put-part follows analogously): -- --
-- getMyStack :: Data a => Get a -- getMyStack = myStack (getGenericByCallback getMyStack) --module Data.Binary.Generic getAlgebraic :: Data a => Get a putAlgebraic :: Data a => a -> Put getGeneric :: Data a => Get a putGeneric :: Data a => a -> Put getGenericByCallback :: Data a => (forall d. Data d => Get d) -> Get a putGenericByCallback :: Data a => (forall d. Data d => d -> Put) -> a -> Put