bond-0.4.0.1: Bond schema compiler and code generator

Copyright(c) Microsoft
LicenseMIT
Maintaineradamsap@microsoft.com
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

Language.Bond.Util

Description

Helper functions for combining elements into common constructs. These functions can be used in code generation to lazily combine Text elements but they are more generic and work for any Monoid.

Synopsis

Documentation

sepBy :: (Monoid a, Eq a) => a -> (b -> a) -> [b] -> a Source

Maps elements of a list and combines them with mappend using given separator.

sepEndBy :: (Monoid a, Eq a) => a -> (b -> a) -> [b] -> a Source

Maps elements of a list and combines them with mappend using given separator, ending with a separator.

sepBeginBy :: (Monoid a, Eq a) => a -> (b -> a) -> [b] -> a Source

Maps elements of a list and combines them with mappend using given separator, starting with a separator.

optional :: Monoid m => (a -> m) -> Maybe a -> m Source

The function takes a function and a Maybe value. If the Maybe value is Nothing, the function returns mempty, otherwise, it applies the function to the value inside Just and returns the result.

angles :: (Monoid a, IsString a, Eq a) => a -> a Source

Wraps the string argument between < and >, unless the argument is mempty in which case the function returns mempty.

brackets :: (Monoid a, IsString a, Eq a) => a -> a Source

Wraps the string argument between [ and ], unless the argument is mempty in which case the function returns mempty.

braces :: (Monoid a, IsString a, Eq a) => a -> a Source

Wraps the string argument between { and }, unless the argument is mempty in which case the function returns mempty.

parens :: (Monoid a, IsString a, Eq a) => a -> a Source

Wraps the string argument between ( and ), unless the argument is mempty in which case the function returns mempty.

between :: (Monoid a, Eq a) => a -> a -> a -> a Source

If the 3rd argument is not mempty the function wraps it between the first and second argument using mappend, otherwise it return mempty.