-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for postfix control flow. -- -- Concatenative gives haskell factor style combinators and arrows for -- postfix notation. For more information on stack based languages, see -- http://concatenative.org @package concatenative @version 1.0.0 -- | Control.Concatenative brings concatenative combinators in the style of -- factor (see -- http://docs.factorcode.org/content/article-dataflow-combinators.html) -- to haskell in a variety of interfaces, allowing a terse, pointfree -- style. module Control.Concatenative -- | Apply both arguments to a and combine the results bi :: (a -> b) -> (a -> c) -> (b -> c -> d) -> a -> d -- | Apply each of three arguments to a and combine the results tri :: (a -> b) -> (a -> c) -> (a -> d) -> (b -> c -> d -> e) -> a -> e -- | Apply the first argument to a, the second to b, and combine the -- results biSp :: (a -> c) -> (b -> d) -> (c -> d -> e) -> a -> b -> e -- | Apply the first argument to a, the second to b, and the third to c, -- combining the results triSp :: (a -> d) -> (b -> e) -> (c -> f) -> (d -> e -> f -> g) -> a -> b -> c -> g -- | Apply a function to two values and combine the results biAp :: (t -> t1) -> (t1 -> t1 -> t2) -> t -> t -> t2 -- | Apply a function to three values and combine the results triAp :: (a -> b) -> (b -> b -> b -> c) -> a -> a -> a -> c ifte :: (a -> Bool) -> (a -> b) -> (a -> b) -> a -> b -- | Like bi, but functions can return monadic values biM :: (Monad m) => (a -> m b) -> (a -> m c) -> (b -> c -> m d) -> a -> m d -- | Like tri, but functions can return monadic values triM :: (Monad m) => (a -> m b) -> (a -> m c) -> (a -> m d) -> (b -> c -> d -> m e) -> a -> m e -- | Like biSp, but functions can return monadic values biSpM :: (Monad m) => (a -> m c) -> (b -> m d) -> (c -> d -> m e) -> a -> b -> m e -- | Like triSp, but functions can return monadic values triSpM :: (Monad m) => (a -> m d) -> (b -> m e) -> (c -> m f) -> (d -> e -> f -> m g) -> a -> b -> c -> m g -- | Like biAp, but functions can return monadic values biApM :: (Monad m) => (t -> m t1) -> (t1 -> t1 -> m t2) -> t -> t -> m t2 -- | Like triAp, but functions can return monadic values triApM :: (Monad m) => (a -> m b) -> (b -> b -> b -> m c) -> a -> a -> a -> m c -- | Like biM, but throws away the end result biM_ :: (Monad m) => (a -> m b) -> (a -> m c) -> a -> m () -- | Like triM, but throws away the end result triM_ :: (Monad m) => (a -> m b) -> (a -> m c) -> (a -> m d) -> a -> m () -- | Like biApM, but throws away the end result biApM_ :: (Monad m) => (t -> m t1) -> t -> t -> m () -- | Like triApM, but throws away the end result triApM_ :: (Monad m) => (a -> m b) -> a -> a -> a -> m () -- | Combine with a binary function (>>@) :: (Arrow a) => a b (x, y) -> (x -> y -> z) -> a b z dup :: (Arrow a) => a b (b, b) swap :: (Arrow a) => a (x, y) (y, x) -- | Arrow version of biAp both :: (Arrow a) => a b c -> a (b, b) (c, c) -- | Left-to-right composition (>>>) :: (Category cat) => cat a b -> cat b c -> cat a c -- | Fanout: send the input to both argument arrows and combine their -- output. -- -- The default definition may be overridden with a more efficient version -- if desired. (&&&) :: (Arrow a) => forall b c c'. a b c -> a b c' -> a b (c, c') -- | Split the input between the two argument arrows and combine their -- output. Note that this is in general not a functor. -- -- The default definition may be overridden with a more efficient version -- if desired. (***) :: (Arrow a) => forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c') -- | 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) -- | Concatenative continuation newtype Concatenative a b c d Concatenative :: ((b -> c) -> (a -> d)) -> Concatenative a b c d with :: Concatenative a b c d -> (b -> c) -> (a -> d) -- | Lifts a function into Concatenative cat :: (a -> b) -> Concatenative a b c c -- | Lift a function and add it to a Concatenative for cleaving (&.) :: (a -> b) -> (a -> e) -> Concatenative a b (e -> c) c -- | Construct a Concatenative for cleaving (.&.) :: Concatenative a b c d -> (a -> e) -> Concatenative a b (e -> c) d -- | Lift a function and add it to a Concatenative for spreading (*.) :: (t -> b) -> (a -> b1) -> Concatenative a b (b1 -> c) (t -> c) -- | Construct a Concatenative for spreading (.*.) :: Concatenative a b c d -> (e -> f) -> Concatenative e b (f -> c) (a -> d) -- | Lift a monadic function to a Concatenative catM :: (Monad m) => (a -> m b) -> Concatenative a b (m c) (m c) -- | Construct a Concatenative for spreading monadic functions clM :: (Monad m) => Concatenative a b c (m d) -> (a -> m e) -> Concatenative a b (e -> c) (m d) -- | Lift a monadic function and add it to a Concatenative for -- cleaving cl :: (Monad m) => (a -> m b) -> (a -> m e) -> Concatenative a b (e -> m d) (m d) -- | Construct a Concatenative for spreading monadic functions spM :: (Monad m) => Concatenative a b c (m d) -> (e -> m f) -> Concatenative e b (f -> c) (a -> m d) -- | Lift a monadic function and add it to a Concatenative for -- spreading sp :: (Monad m) => (a -> m b) -> (e -> m f) -> Concatenative e b (f -> m d) (a -> m d) -- | Create a Concatenative for applying a function n times -- --
--   biAp (+1)
--   
-- -- translates to -- --
--   $(apN 2) (+1)
--   
apN :: Int -> Q Exp -- | Create a Concatenative for applying a monadic function n times -- --
--   biApM (+1)
--   
-- -- translates to -- --
--   $(apM 2) (+1)
--   
apM :: Int -> Q Exp -- | Convenience synonym for replicateM_ apM_ :: (Monad m) => Int -> m a -> m ()