haste-compiler- Haskell To ECMAScript compiler

Safe HaskellNone



Handling of Javascript-native binary blobs.

Generics borrowed from the binary package by Lennart Kolmodin (released under BSD3)



type Put = PutM () Source

skip :: Int -> Get () Source

Skip n bytes of input.

class Monad m => MonadBlob m where Source


getBlobData :: Blob -> m BlobData Source

Retrieve the raw data from a blob.

getBlobText' :: Blob -> m JSString Source

Interpret a blob as UTF-8 text, as a JSString.

class Binary a where Source

Somewhat efficient serializationdeserialization tofrom binary Blobs. The layout of the binaries producedread by getput and encode/decode may change between versions. If you need a stable binary format, you should make your own using the primitives in Haste.Binary.Get/Put.

Minimal complete definition



get :: Get a Source

put :: a -> Put Source

getBlobText :: MonadBlob m => Blob -> m String Source

Interpret a blob as UTF-8 text.

blobSize :: Blob -> Int Source

The size, in bytes, of the contents of the given blob.

blobDataSize :: BlobData -> Int Source

The size, in bytes, of the contents of the given blob data.

toByteString :: BlobData -> ByteString Source

Convert a BlobData to a ByteString. Only usable server-side.

toBlob :: BlobData -> Blob Source

Convert a piece of BlobData back into a Blob.

strToBlob :: JSString -> Blob Source

Create a Blob from a JSString.

encode :: Binary a => a -> Blob Source