serialise-0.2.6.0: A binary serialisation library for Haskell values.

Copyright | (c) Duncan Coutts 2015-2017
License | BSD3-style (see LICENSE.txt)
Maintainer | duncan@community.haskell.org
Stability | experimental
Portability | non-portable (GHC extensions)
Safe Haskell | Safe-Inferred
Language | Haskell2010

Codec.Serialise.IO

Contents

- ``FilePath`` API
- ``Handle`` API

Description

High-level file-based API for serialising and deserialising values.

Synopsis

- writeFileSerialise :: Serialise a => FilePath -> a -> IO ()
- readFileDeserialise :: Serialise a => FilePath -> IO a
- hPutSerialise :: Serialise a => Handle -> a -> IO ()

# ``FilePath`` API

writeFileSerialise Source #

Arguments

:: Serialise a |
=> FilePath | The file to write to.
-> a | The value to be serialised and written.
-> IO () |

Serialise a ``ByteString`` and write it directly to the specified file.

Since: 0.2.0.0

readFileDeserialise Source #

Arguments

:: Serialise a |
=> FilePath | The file to read from.
-> IO a | The deserialised value.

Read the specified file (internally, by reading a ``ByteString``) and attempt to decode it into a Haskell value using ``deserialise`` (the type of which is determined by the choice of the result type).

Throws: ``DeserialiseFailure`` if the file fails to deserialise properly.

Since: 0.2.0.0

# ``Handle`` API

hPutSerialise Source #

Arguments

:: Serialise a |
=> Handle | The ``Handle`` to write to.
-> a | The value to be serialised and written.
-> IO () |

Serialise a ``ByteString`` (via ``serialise``) and write it directly to the specified ``Handle``.

Since: 0.2.0.0