Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class PatchRep a where
- toPatchRep :: a -> Either String ByteString
Documentation
class PatchRep a where Source #
Type has a binary representation for using in patchscripts.
Patchscripts are parsed parameterized over the type to edit. That type needs to become a bytestring for eventual patch application. We're forced into newtypes and typeclasses by Aeson already, so this just enables us to define some important patch generation behaviour in one place. Similarly to Aeson, if you require custom behaviour for existing types (e.g. length-prefixed strings instead of C-style null terminated), define a newtype over it.
Some values may not have valid patch representations, for example if you're
patching a 1-byte length-prefixed string and your string is too long (>255
encoded bytes). Thus, toPatchRep
is failable.
toPatchRep :: a -> Either String ByteString Source #
Instances
PatchRep ByteString Source # | Bytestrings are copied as-is. |
Defined in BytePatch.Pretty.PatchRep | |
PatchRep Text Source # | Text is converted to UTF-8 bytes and null-terminated. |
Defined in BytePatch.Pretty.PatchRep toPatchRep :: Text -> Either String ByteString Source # | |
PatchRep HexByteString Source # | |
Defined in BytePatch.Pretty.HexByteString | |
KnownNat n => PatchRep (PascalText n) Source # | |
Defined in BytePatch.Pretty.PascalText toPatchRep :: PascalText n -> Either String ByteString Source # |