hosc-0.16: Haskell Open Sound Control

Safe HaskellSafe
LanguageHaskell98

Sound.OSC.Datum.Datem

Contents

Description

A class for translating to and from Datum.

Synopsis

Documentation

class Datem a where Source #

Class for translating to and from Datum. There are instances for the direct Datum field types.

d_put (1::Int32) == Int32 1
d_put (1::Int64) == Int64 1
d_put (1::Float) == Float 1
d_put (1::Double) == Double 1
d_put (Char8.pack "str") == ASCII_String (Char8.pack "str")
d_put (Lazy.pack [37,37]) == Blob (blob_pack [37,37])
d_put (MIDI 0 0 0 0) == Midi (MIDI 0 0 0 0)

There are also instances for standard Haskell types.

d_put (1::Int) == Int64 1
d_put (1::Integer) == Int64 1

Minimal complete definition

d_put, d_get

Methods

d_put :: a -> Datum Source #

d_get :: Datum -> Maybe a Source #

d_get_err :: Datem a => Datum -> a Source #

Error variant of d_get.

Type specialised

datum_int32 :: Datum -> Maybe Int32 Source #

Type specialised d_get.

map datum_int32 [Int32 1,Float 1] == [Just 1,Nothing]

datum_int64 :: Datum -> Maybe Int64 Source #

Type specialised d_get.

datum_float :: Datum -> Maybe Float Source #

Type specialised d_get.

datum_double :: Datum -> Maybe Double Source #

Type specialised d_get.

datum_ascii :: Datum -> Maybe ASCII Source #

Type specialised d_get.

datum_ascii (d_put (Char8.pack "string")) == Just (Char8.pack "string")

datum_string :: Datum -> Maybe String Source #

unpack of d_get.

datum_string (d_put (Char8.pack "string")) == Just "string"
map datum_string [string "string",Int32 5] == [Just "string",Nothing]

datum_blob :: Datum -> Maybe ByteString Source #

Type specialised d_get.

datum_midi :: Datum -> Maybe MIDI Source #

Type specialised d_get.

datum_sequence :: Datum -> Maybe [Word8] Source #

Datum as sequence of Word8 if ASCII_String, Blob or Midi.

let d = [string "5",Blob (Lazy.pack [53]),midi (0x00,0x90,0x40,0x60)]
in Data.Maybe.mapMaybe datum_sequence d == [[53],[53],[0,144,64,96]]