Safe Haskell | None |
---|---|

Language | Haskell2010 |

This module tries to be as efficient as possible, type safe and easy to use. If you have a "sink" like

sink :: Stuffed 0 -> IO () sink = undefined

You'd then simply be able to encode a Bytestring with

sink $ stuff bytes

You can try this out in ghci with:

`>>>`

`:set -XOverloadedStrings`

`>>>`

`:set -XDataKinds`

`>>>`

`import Data.Stuffed`

`>>>`

`let stuffedBytes = stuff "a\0b\0c" :: Stuffed 0`

`>>>`

[2,97,2,98,2,99]`unpack $ unwrap stuffedBytes -- directly access the underlying bytestring`

`>>>`

[97,0,98,0,99]`unpack $ unstuff stuffedBytes`

## Synopsis

- data Stuffed (a :: Nat)
- stuff :: forall a. IsByte a => ByteString -> Stuffed a
- unstuff :: forall a. IsByte a => Stuffed a -> ByteString
- unwrap :: Stuffed a -> ByteString

# Documentation

data Stuffed (a :: Nat) Source #

Wrapper for Lazy Bytestrings, parametrized on the Byte (Word8, represented as a type-level `Nat`

) to be encoded away.

## Instances

Eq (Stuffed a) Source # | |

Ord (Stuffed a) Source # | |

Defined in Data.Stuffed | |

Show (Stuffed a) Source # | |

Generic (Stuffed a) Source # | |

Semigroup (Stuffed a) Source # | |

Monoid (Stuffed a) Source # | |

type Rep (Stuffed a) Source # | |

Defined in Data.Stuffed type Rep (Stuffed a) = D1 (MetaData "Stuffed" "Data.Stuffed" "hcobs-0.1.0.1-F00nRvWXBEHLlicQFVOXTU" True) (C1 (MetaCons "Stuffed" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) |

unwrap :: Stuffed a -> ByteString Source #

Extract the encoded bytestring from a Stuffed