-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Semantic Editor Combinators. -- -- Semantic Editor Combinators as described by Conal Elliott (See: -- http://conal.net/blog/posts/semantic-editor-combinators/) and -- Template Haskell support for automatically creating semantic editor -- combinators from Algebraic Data Types. @package sec @version 0.0.1 module Data.SemanticEditors -- | Semantic Editor Combinator on the result of an unary function result :: (b -> b') -> ((a -> b) -> (a -> b')) -- | Send the first component of the input through the argument arrow, and -- copy the rest unchanged to the output. first :: (Arrow a) => forall b c d. a b c -> a (b, d) (c, d) -- | A mirror image of first. -- -- The default definition may be overridden with a more efficient version -- if desired. second :: (Arrow a) => forall b c d. a b c -> a (d, b) (d, c) -- | Semantic Editor Combinator on each value of a list each :: (a -> b) -> ([a] -> [b]) -- | Semantic Editor Combinator applying the given function only when the -- given predicate yields true for an input value. editIf :: (a -> Bool) -> (a -> a) -> (a -> a) -- | 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 set :: a -> b -> a -- | Semantic Editor Combinator on argument of an unary function argument :: (a' -> a) -> ((a -> b) -> (a' -> b)) -- | Feed marked inputs through the argument arrow, passing the rest -- through unchanged to the output. left :: (ArrowChoice a) => forall b c d. a b c -> a (Either b d) (Either c d) -- | A mirror image of left. -- -- The default definition may be overridden with a more efficient version -- if desired. right :: (ArrowChoice a) => forall b c d. a b c -> a (Either d b) (Either d c) ioref :: (a -> a) -> IORef a -> IO () -- | The maybe function takes a default value, a function, and a -- Maybe value. If the Maybe value is Nothing, the -- function returns the default value. Otherwise, it applies the function -- to the value inside the Just and returns the result. maybe :: b -> (a -> b) -> Maybe a -> b -- | Semantic Editor Combinator for Maybe just :: (a -> b) -> Maybe a -> Maybe b -- | Semantic Editor Combinator for monads monad :: (Monad m) => (a -> b) -> m a -> m b -- | Semantic Editor Combinator for monadicaly transforming a monadic value bind :: (Monad m) => (a -> m b) -> m a -> m b -- | Semantic Editor Combinator for applicatives applicative :: (Applicative f) => (a -> b) -> f a -> f b -- | mkEditors creates Semantic Editor Combinators for each data type -- given. More information see mkEditor mkEditors :: [Name] -> Q [Dec] -- | 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) }
--   
mkEditor :: Name -> Q [Dec] -- | 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
--   
mkConstrTests :: [Name] -> Q [Dec]