- result :: (b -> b') -> (a -> b) -> a -> b'
- first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)
- second :: Arrow a => forall b c d. a b c -> a (d, b) (d, c)
- each :: (a -> b) -> [a] -> [b]
- editIf :: (a -> Bool) -> (a -> a) -> a -> a
- set :: a -> b -> a
- argument :: (a' -> a) -> (a -> b) -> a' -> b
- left :: ArrowChoice a => forall b c d. a b c -> a (Either b d) (Either c d)
- right :: ArrowChoice a => forall b c d. a b c -> a (Either d b) (Either d c)
- ioref :: (a -> a) -> IORef a -> IO ()
- maybe :: b -> (a -> b) -> Maybe a -> b
- just :: (a -> b) -> Maybe a -> Maybe b
- monad :: Monad m => (a -> b) -> m a -> m b
- bind :: Monad m => (a -> m b) -> m a -> m b
- applicative :: Applicative f => (a -> b) -> f a -> f b
- mkEditors :: [Name] -> Q [Dec]
- mkEditor :: Name -> Q [Dec]
- mkConstrTests :: [Name] -> Q [Dec]
Documentation
result :: (b -> b') -> (a -> b) -> a -> b'Source
Semantic Editor Combinator on the result of an unary function
first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
second :: Arrow a => forall b c d. a b c -> a (d, b) (d, c)
A mirror image of first
.
The default definition may be overridden with a more efficient version if desired.
editIf :: (a -> Bool) -> (a -> a) -> a -> aSource
Semantic Editor Combinator applying the given function only when the given predicate yields true for an input value.
Using set
one can set instead of modify a value using Semantic Editor Combinators
for example '(first.set) 1' will set the first value of a tuple to 1
argument :: (a' -> a) -> (a -> b) -> a' -> bSource
Semantic Editor Combinator on argument of an unary function
left :: ArrowChoice a => forall b c d. a b c -> a (Either b d) (Either c d)
Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.
right :: ArrowChoice a => forall b c d. a b c -> a (Either d b) (Either d c)
A mirror image of left
.
The default definition may be overridden with a more efficient version if desired.
bind :: Monad m => (a -> m b) -> m a -> m bSource
Semantic Editor Combinator for monadicaly transforming a monadic value
applicative :: Applicative f => (a -> b) -> f a -> f bSource
Semantic Editor Combinator for applicatives
mkEditors :: [Name] -> Q [Dec]Source
mkEditors creates Semantic Editor Combinators for each data type given. More information see mkEditor
mkEditor :: Name -> Q [Dec]Source
mkEditor creates Semantic Editor Combinators for each named field in a given data type by appending the fields name (first letter is converted to uppercase) to the name "edit". If a fields name starts with an underscore '_' no editor will be generated
for example:
data Person = Person { age :: Integer, name :: String, _sex :: String }
will generate the lifters editAge and editName:
editAge f p = p { age = f (age p) } editName f p = p { name = f (name p) }
mkConstrTests :: [Name] -> Q [Dec]Source
Template Haskell function for automatically creating predicates testing the constructors of a given data type. for example:
data Color = Red | Green | Blue $(mkConstrTests [''Color])
will generate the following functions:
isRed Red = True isRed _ = False isGreen Green = True isGreen _ = False isBlue Blue = True isBlue _ = False