regular-extras-0.2.0: Additional functions for regular: arbitrary, coarbitrary, and binary get/put.

Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org

Generics.Regular.Functions.Binary

Contents

Description

Generic Data.Binary instances.

These generic functions can be used to create a Data.Binary instance. For example, for a user-defined type MyType, the following code is necessary:

 import Data.Binary
 import Generics.Regular.Base
 import Generics.Regular.Binary

 data MyType = ...

 $(deriveAll ''MyType "PFMyType")
 type instance PF MyType = PFMyType

 instance Binary MyType where
   put = gput
   get = gget

Synopsis

Binary put and get

class Binary f Source

Instances

Binary I 
Binary U 
Binary a => Binary (K a) 
(Binary f, Binary g) => Binary (:+: f g) 
(Binary f, Binary g) => Binary (:*: f g) 
Binary f => Binary (C c f) 
Binary f => Binary (S s f) 

gput :: (Regular a, Binary (PF a)) => a -> PutSource

Generic binary put to be used with Data.Binary.Put.

gget :: (Regular a, Binary (PF a)) => Get aSource

Generic binary get to be used with Data.Binary.Get.