Stability | experimental |
---|---|
Maintainer | Lars Petersen <[email protected]> |
Safe Haskell | Safe-Infered |
Data.Binary.Generic
Description
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)
Documentation
getAlgebraic :: Data a => Get aSource
putAlgebraic :: Data a => a -> PutSource
getGeneric :: Data a => Get aSource
putGeneric :: Data a => a -> PutSource