genericserialize-0.1: Serialization library using Data.Generics

Data.Generics.Serialization.Standard

Description

This module provides a small number of tricky functions used to implement (de)serializers. User code should not need to import this library.

Synopsis

Documentation

ext2Q :: (Data d, Typeable2 t) => (d -> q) -> (forall d1 d2. (Data d1, Data d2) => t d1 d2 -> q) -> d -> qSource

Like ext1Q, except for a binary type constructor

gSerial :: (Data d, MonadWStream m c) => (forall a. Data a => a -> m ()) -> d -> (Constr, m ())Source

Run a monadic action over each element in an existing data object; also return the Constr.

gDeser :: (Data d, Monad m) => (DataType -> m Constr) -> (forall a. Data a => m a) -> m dSource

Build an object using monadic actions to read the Constr and all children.

(=>>) :: Monad m => m a -> m b -> m aSource

Execute two monadic actions in sequence, returning the value of the first. This is mainly useful with parser combinators.

(>>$) :: Monad m => m a -> (a -> b) -> m bSource

Execute a monadic action, piping the result through a pure function. This is the same as flip liftM, and has the same fixity as >>=.

unfoldM :: Monad m => m (Maybe a) -> m [a]Source

Run a monadic action repeatedly until it returns Nothing; all Just values are returned in a list.

match :: MonadRStream m Char => Char -> m ()Source

Parse a designated character, error on a different character.

manySat :: MonadRStream m a => (a -> Bool) -> m [a]Source

Parse and return one or more characters parsed using a recognition function.

matchs :: MonadRStream m Char => [Char] -> m ()Source

Match a string, error on discrepancy.

getv_t :: MonadRStream m a => m b -> m aSource

Get one character, then run a parser (e.g. space).

getcase :: (Eq a, MonadRStream m a) => (a -> m b) -> [(a, m b)] -> m bSource

Get one character and process it using a list of actions.

peekcase :: (Eq a, MonadRStream m a) => m b -> (a -> m b) -> [(a, m b)] -> m bSource

Peek at one character and process it using a list of actions.

matchws :: MonadRStream m Char => Char -> m ()Source

Parse a designated character, then any amount of whitespace.

space :: MonadRStream m Char => m ()Source

Parse as many spaces as possible.

readM :: (Monad m, Read a, Typeable a) => String -> m aSource

Parse a value using a Read instance. This differs from read in that it uses a general monad and type infromation for error reporting.

fromMaybeM :: Monad m => String -> Maybe a -> m aSource

Convert a Maybe object into any monad, using the imbedding defined by fail and return.

escape :: Char -> [Char] -> [Char] -> String -> StringSource

Escape a string.

unescape :: Char -> [Char] -> [Char] -> String -> Maybe StringSource

Unescape a string.

mkescape :: Char -> [Char] -> [Char] -> (String -> String, String -> Maybe String)Source

Create an escape and unescape function at the same time. This allows you to only type the translations once.

breakr :: (a -> Bool) -> [a] -> ([a], [a])Source

Split a string at the rightmost occurence of a character matching a predicate.