Copyright | (c) Philip Cunningham, 2015 |
---|---|
License | MIT |
Maintainer | hello@filib.io |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Marshal monad provides an object cache over the Get monad.
- newtype Marshal a = Marshal {
- runMarshal :: StateT Cache Get a
- liftMarshal :: Get a -> Marshal a
- data Cache = Cache {
- objects :: !(Vector RubyObject)
- symbols :: !(Vector RubyObject)
- emptyCache :: Cache
- readCache :: Int -> (Cache -> Vector RubyObject) -> Marshal (Maybe RubyObject)
- readObject :: Int -> Marshal (Maybe RubyObject)
- readSymbol :: Int -> Marshal (Maybe RubyObject)
- writeCache :: RubyObject -> Marshal ()
Documentation
Marshal monad endows the underlying Get monad with State.
Marshal | |
|
liftMarshal :: Get a -> Marshal a Source
Lift Get monad into Marshal monad.
State that we must carry around during deserialisation.
Cache | |
|
Constructs an empty cache to store symbols and objects.
readCache :: Int -> (Cache -> Vector RubyObject) -> Marshal (Maybe RubyObject) Source
Look up value in cache.
readObject :: Int -> Marshal (Maybe RubyObject) Source
Look up object in object cache.
readSymbol :: Int -> Marshal (Maybe RubyObject) Source
Look up a symbol in symbol cache.
writeCache :: RubyObject -> Marshal () Source
Write an object to the appropriate cache.