haste-compiler-0.4.4.4: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.Binary

Description

Handling of Javascript-native binary blobs.

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

Synopsis

Documentation

type Put = PutM () Source

skip :: Int -> Get () Source

Skip n bytes of input.

class Monad m => MonadBlob m where Source

Methods

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

Nothing

Methods

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