Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Util.Serialize

Contents

Description

This module implements a Serialize class and serializers for basic types.

It duplicates a lot from the standard Serialize class, but this one at least is under my control. The other one is not guaranteed to remain compatible. Of course, it's unlikely to change incompatibly and I use it myself rather than re-implementing String and Integer encoding, but that's the theory anyway.

At the least it lets me use a direct float encoding rather than hacking around the large and buggy default implementation.

Synopsis

Documentation

class Serialize a where Source #

Minimal complete definition

put, get

Methods

put :: Putter a Source #

get :: Get a Source #

Instances

Serialize Bool # 
Serialize Char # 
Serialize Double # 
Serialize Float # 
Serialize Int.Int # 
Serialize Int.Int64 # 
Serialize Integer # 
Serialize Word.Word8 # 
Serialize Word.Word32 # 
Serialize Word.Word64 # 
Serialize () # 

Methods

put :: Putter () Source #

get :: Get () Source #

Serialize ByteString.ByteString # 
Serialize UTCTime # 
Serialize Text # 
Serialize CallStack.Caller # 
Serialize Qualified # 
Serialize Control # 
Serialize Attributes # 
Serialize RulerId # 
Serialize TrackId # 
Serialize ViewId # 
Serialize BlockId # 
Serialize Namespace # 
Serialize Id # 
Serialize StyleId # 
Serialize Doc # 
Serialize Key # 
Serialize ScaleId # 
Serialize NoteNumber # 
Serialize Degree # 
Serialize Pitch # 
Serialize ScoreTime # 
Serialize RealTime # 
Serialize Key # 
Serialize WriteDevice # 
Serialize ReadDevice # 
Serialize Note # 
Serialize Frame # 
Serialize Stack # 
Serialize Priority # 
Serialize Msg # 
Serialize Skeleton # 
Serialize Type # 
Serialize PControl # 
Serialize Control # 
Serialize Instrument # 
Serialize Str # 
Serialize Symbol # 
Serialize Attributes # 
Serialize File # 
Serialize Editor # 
Serialize Result # 
Serialize CmdResult # 
Serialize Response # 
Serialize Query # 
Serialize Orientation # 
Serialize Stack # 
Serialize Event # 
Serialize Key # 
Serialize Events # 
Serialize Term # 
Serialize Call # 
Serialize Val # 
Serialize Environ # 
Serialize Flag # 
Serialize InstrumentDb # 
Serialize a => Serialize [a] # 

Methods

put :: Putter [a] Source #

get :: Get [a] Source #

Serialize a => Serialize (Maybe a) # 

Methods

put :: Putter (Maybe a) Source #

get :: Get (Maybe a) Source #

Serialize a => Serialize (NonEmpty.NonEmpty a) # 
(Ord a, Serialize a) => Serialize (Set a) # 

Methods

put :: Putter (Set a) Source #

get :: Get (Set a) Source #

Serialize a => Serialize (Vector.Vector a) # 
(Serialize a, Storable a) => Serialize (Vector.Storable.Vector a) # 
(Serialize a, Unbox a) => Serialize (Unboxed.Vector a) # 
Serialize y => Serialize (Sample y) # 

Methods

put :: Putter (Sample y) Source #

get :: Get (Sample y) Source #

Serialize (Signal y) # 

Methods

put :: Putter (Signal y) Source #

get :: Get (Signal y) Source #

Serialize a => Serialize (Typed a) # 

Methods

put :: Putter (Typed a) Source #

get :: Get (Typed a) Source #

Serialize a => Serialize (AttributeMap a) # 
(Serialize a, Serialize b) => Serialize (a, b) # 

Methods

put :: Putter (a, b) Source #

get :: Get (a, b) Source #

(Serialize i, Ix i, Serialize e) => Serialize (Array i e) # 

Methods

put :: Putter (Array i e) Source #

get :: Get (Array i e) Source #

(Ord k, Serialize k, Serialize v) => Serialize (Map k v) # 

Methods

put :: Putter (Map k v) Source #

get :: Get (Map k v) Source #

(Serialize val, Serialize control) => Serialize (Ref control val) # 

Methods

put :: Putter (Ref control val) Source #

get :: Get (Ref control val) Source #

(Serialize a, Serialize b, Serialize c) => Serialize (a, b, c) # 

Methods

put :: Putter (a, b, c) Source #

get :: Get (a, b, c) Source #

magic

data Magic a Source #

This is a four byte prefix to identify a particular file type, tagged with the serialized type. The Chars are just for syntactic convenience only, and must be ASCII.

The constructor is not exported, so all magics have to be defined here, which should make it easy to avoid collisions.

Constructors

Magic !Char !Char !Char !Char 

Instances

Show (Magic a) # 

Methods

showsPrec :: Int.Int -> Magic a -> ShowS #

show :: Magic a -> String #

showList :: [Magic a] -> ShowS #

serialize :: Serialize a => Magic a -> FilePath -> a -> IO () Source #

backupFile :: FilePath -> IO () Source #

Move file to file.last. Do this before writing a new one that may fail.

numeric

_encodef :: (Storable float, Storable word) => float -> word Source #

_decodef :: (Storable float, Storable word) => word -> float Source #

util

put_enum :: Enum a => a -> Put Source #

get_enum :: (Bounded a, Enum a) => Get a Source #

to_enum :: forall a. (Enum a, Bounded a) => Int.Int -> Maybe a Source #

A safe version of toEnum.

basic types

tuples

containers

versions

data Get a :: * -> * #

The Get monad is an Exception and State monad.

Instances

Monad Get 

Methods

(>>=) :: Get a -> (a -> Get b) -> Get b #

(>>) :: Get a -> Get b -> Get b #

return :: a -> Get a #

fail :: String -> Get a #

Functor Get 

Methods

fmap :: (a -> b) -> Get a -> Get b #

(<$) :: a -> Get b -> Get a #

MonadFail Get 

Methods

fail :: String -> Get a #

Applicative Get 

Methods

pure :: a -> Get a #

(<*>) :: Get (a -> b) -> Get a -> Get b #

(*>) :: Get a -> Get b -> Get b #

(<*) :: Get a -> Get b -> Get a #

Alternative Get 

Methods

empty :: Get a #

(<|>) :: Get a -> Get a -> Get a #

some :: Get a -> Get [a] #

many :: Get a -> Get [a] #

MonadPlus Get 

Methods

mzero :: Get a #

mplus :: Get a -> Get a -> Get a #

type Put = PutM () #

Put merely lifts Builder into a Writer monad, applied to ().

getWord8 :: Get Word.Word8 #

Read a Word8 from the monad state

putWord8 :: Putter Word.Word8 #

Efficiently write a byte into the output buffer