-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | MOre directional operators -- -- Please see README.md @package flow-er @version 1.0.2 module Control.Flower.Applicative.Lazy -- | A simple alias for <*> -- --
--   >>> ap (Just (+1)) (Just 4)
--   Just 5
--   
ap :: Applicative f => f (a -> b) -> f a -> f b -- | An alias for lift2, updating with unified "lift" naming -- --
--   >>> lift2 (+) (Just 4) (Just 1)
--   Just 5
--   
lift2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | An alias for lift3, updating with unified "lift" naming -- --
--   >>> lift3 (\x y z -> x * y * z) (Just 4) (Just 3) (Just 2)
--   Just 24
--   
lift3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d -- | Right-associative, left-flowing applicative operator -- --
--   >>> Just (+1) <* Just 4
--   Just 5
--   
(<*) :: Applicative f => f (a -> b) -> f a -> f b infixr 4 <* -- | Left-associative, right-flowing applicative operator -- --
--   >>> Just 4 *> Just (+1)
--   Just 5
--   
(*>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 *> -- | Right-associative, left-flowing lift2 operator -- --
--   >>> (+) <$* Just 4 |< Just 1
--   Just 5
--   
(<$*) :: Applicative f => (a -> b -> c) -> f a -> f b -> f c infixr 4 <$* -- | Left-associative, right-flowing lift2 operator -- --
--   >>> Just 4 >| Just 1 *$> (+)
--   Just 5
--   
(*$>) :: Applicative f => f a -> (a -> b -> c) -> f b -> f c infixl 4 *$> -- | Right-associative, left-flowing lift3 operator -- --
--   >>> (\x y z -> x * y * z) <$** Just 4 |< Just 3 |< Just 2
--   Just 24
--   
(<$**) :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d infixr 4 <$** -- | Left-associative, right-flowing lift3 operator -- --
--   >>> Just 2 >| Just 3 >| Just 4 **$> \x y z -> x * y * z
--   Just 24
--   
(**$>) :: Applicative f => f a -> (a -> b -> c -> d) -> f b -> f c -> f d infixl 4 **$> module Control.Flower.Functor.Lazy -- | Rename fmap to lift for consistency -- --
--   >>> lift (+1) <| Just 0
--   Just 1
--   
-- --
--   >>> lift (lift (+1)) [[1,2,3],[4,5,6]]
--   [[2,3,4],[5,6,7]]
--   
lift :: Functor f => (a -> b) -> f a -> f b -- | Alias for apply, for readability (especially when teaching) -- --
--   >>> lift (+1) `over` Just 0
--   Just 1
--   
-- --
--   >>> Just 0 $> (+1) $> (+2)
--   Just 3
--   
-- --
--   >>> (*2) <$ ([1,2,3] $> (+1))
--   [4,6,8]
--   
-- --
--   >>> (+8) .> (*2) <$ Just 0
--   Just 16
--   
-- --
--   >>> (*3) <. (+8) <$ Just 0
--   Just 24
--   
over :: (a -> b) -> a -> b -- | Operator for lift highlighting the direction of data flow -- --
--   >>> (+1) <$ Just 0
--   Just 1
--   
-- --
--   >>> (+2) <$ (+1) <$ Just 0
--   Just 3
--   
-- --
--   >>> ((*2) <$ [1,2,3]) $> (+1)
--   [3,5,7]
--   
-- --
--   >>> Just 0 $> (+8) .> (*2)
--   Just 16
--   
-- --
--   >>> Just 0 $> (*3) <. (+8)
--   Just 24
--   
(<$) :: Functor f => (a -> b) -> f a -> f b infixr 4 <$ -- | Operator for lift highlighting the reversed direction of data -- flow -- --
--   >>> Just 0 $> (+1)
--   Just 1
--   
($>) :: Functor f => f a -> (a -> b) -> f b infixl 4 $> module Control.Flower.Apply.Strict -- | Right-flowing strict application, equivalent to 'prelude.$'. -- -- Read as "forward strict application" or "strict pipe into". -- --
--   >>> (x !> f) == f x
--   True
--   
-- --
--   >>> (x !> f !> g) == g (f x)
--   True
--   
-- -- This operator can be chained together to show the dataflow through a -- series of functions -- --
--   >>> 3 !> succ !> negate :: Int
--   -4
--   
( b) -> a -> b infixr 0 -- >>> (f <! x) == f x -- True -- -- --
--   >>> (g <! f <! x) == g (f x)
--   True
--   
-- -- This operator can be chained together to show the dataflow through a -- series of functions -- --
--   >>> negate <! succ <! 3 :: Int
--   -4
--   
(!>) :: a -> (a -> b) -> b infixl 0 !> -- | Left-flowing, left-associative strict application -- -- Read as "strictly pipe into the result of". It may seem odd in trivial -- cases, but is useful for functions that take more than one argument, -- as it will partially apply arguments one at a time. -- --
--   >>> (f !< x) == f x
--   True
--   
-- --
--   >>> (h !< y !< x) == ((h <! y) <! x)
--   True
--   
-- -- Can be chained together to show the dataflow through a series of -- functions -- --
--   >>> (+) !< 3 !< 5 :: Int
--   8
--   
(!<) :: (a -> b) -> a -> b infixl 1 !< -- | Right-flowing, right-associative strict application -- -- Read as "strictly pipe from the result of", or "strictly pull from the -- result from". It may seem odd in trivial cases, but is useful for -- functions that take more than one argument. -- --
--   >>> (x >! f) == f x
--   True
--   
-- --
--   >>> (x >! y >! h) == (x !> (y !> h))
--   True
--   
-- -- Can be chained together to show the dataflow through a series of -- functions -- --
--   >>> 3 >! 5 >! (+)
--   8
--   
(>!) :: a -> (a -> b) -> b infixr 1 >! module Control.Flower.Apply.Lazy -- | Left-flowing application, equivalent to 'prelude.$'. -- -- Read as "backwards application", "pipe from", or "pull from". -- --
--   >>> (f <| x) == f x
--   True
--   
-- --
--   >>> (g <| f <| x) == g (f x)
--   True
--   
-- -- This operator can be chained together to show the dataflow through a -- series of functions -- --
--   >>> negate <| succ <| 3 :: Int
--   -4
--   
(<|) :: (a -> b) -> a -> b infixr 0 <| -- | Right-flowing application, equivalent to 'prelude.$'. -- -- Read as "forwards application" or "pipe into". -- --
--   >>> (x |> f) == f x
--   True
--   
-- --
--   >>> (x |> f |> g) == g (f x)
--   True
--   
-- -- This operator can be chained together to show the dataflow through a -- series of functions -- --
--   >>> 3 |> succ |> negate :: Int
--   -4
--   
(|>) :: a -> (a -> b) -> b infixl 0 |> -- | Left-flowing, left-associative application -- -- Read as "pipe into the result of". It may seem odd in trivial cases, -- but is useful for functions that take more than one argument, as it -- will partially apply arguments one at a time. -- --
--   >>> (f |< x) == f x
--   True
--   
-- --
--   >>> (h |< y |< x) == ((h <| y) <| x)
--   True
--   
-- -- Can be chained together to show the dataflow through a series of -- functions -- --
--   >>> (+) |< 3 |< 5 :: Int
--   8
--   
(|<) :: (a -> b) -> a -> b infixl 0 |< -- | Right-flowing, right-associative application -- -- Read as "pipe from the result of", or "pull from the result from". It -- may seem odd in trivial cases, but is useful for functions that take -- more than one argument. -- --
--   >>> (x >| f) == f x
--   True
--   
-- --
--   >>> (x >| y >| h) == (x |> (y |> h))
--   True
--   
-- -- Can be chained together to show the dataflow through a series of -- functions -- --
--   >>> 3 >| 5 >| (+)
--   8
--   
(>|) :: a -> (a -> b) -> b infixr 0 >| module Control.Flower.Monad -- | A left-associative operator alias for mapM -- --
--   >>> putStrLn <. show <<$ [1,2,3]
--   1
--   2
--   3
--   
(<<$) :: (Foldable f, Monad m) => (a -> m b) -> f a -> m () infixl 4 <<$ -- | An operator alias for mapM -- --
--   >>> [1,2,3] $>> show .> putStrLn
--   1
--   2
--   3
--   
($>>) :: (Foldable f, Monad m) => f a -> (a -> m b) -> m () infixr 4 $>> -- | A left-associative operator alias for mapM -- --
--   >>> (\x -> [x+1]) =<<$ [1,2,3]
--   [[2,3,4]]
--   
(=<<$) :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) infixl 4 =<<$ -- | An operator alias for mapM -- --
--   >>> [1,2,3] $>>= \x -> [x+1]
--   [[2,3,4]]
--   
($>>=) :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) infixr 4 $>>= module Control.Flower.Compose -- | Left-flowing, right-associative composition -- --
--   >>> (g <. f) x == (g . f) x
--   True
--   
-- -- Can be combined with application combinators -- --
--   >>> (+1) <. (*10) <| 5 :: Int
--   51
--   
(<.) :: (b -> c) -> (a -> b) -> a -> c infixr 9 <. -- | Right-flowing, left-associative composition -- -- Note that this is the opposite direction from typical composition -- --
--   >>> (f .> g) x == (g . f) x
--   True
--   
-- -- Can be combined with application combinators -- --
--   >>> 5 |> (+1) .> (*10) :: Int
--   60
--   
(.>) :: (a -> b) -> (b -> c) -> a -> c infixl 9 .> module Control.Flower.Apply module Control.Flower.Functor.Strict -- | A strict version of lift -- --
--   >>> lift' (+1) <| Just 0
--   Just 1
--   
-- --
--   >>> lift' (lift' (+1)) [[1,2,3],[4,5,6]]
--   [[2,3,4],[5,6,7]]
--   
lift' :: Monad m => (a -> b) -> m a -> m b -- | Alias for apply', for readability (especially when teaching) -- --
--   >>> lift' (+1) `over'` Just 0
--   Just 1
--   
over' :: (a -> b) -> a -> b -- | Operator for lift' highlighting the direction of data flow -- --
--   >>> (+1) <!$ Just 0
--   Just 1
--   
( (a -> b) -> f a -> f b infixr 4 lift' highlighting the reversed direction of data -- flow -- --
--   >>> Just 0 $!> (+1)
--   Just 1
--   
($!>) :: Monad f => f a -> (a -> b) -> f b infixl 4 $!> module Control.Flower.Functor module Control.Flower.Applicative.Strict -- | An alias for lift2, updating with unified "lift" naming -- --
--   >>> lift2' (+) (Just 4) (Just 1)
--   Just 5
--   
lift2' :: Monad m => (a -> b -> c) -> m a -> m b -> m c -- | Right-associative, left-flowing lift2' operator -- --
--   >>> (+) <!$* Just 4 |< Just 1
--   Just 5
--   
( (a -> b -> c) -> m a -> m b -> m c infixr 4 lift2' operator -- --
--   >>> Just 1 >| Just 4 *$!> (+)
--   Just 5
--   
(*$!>) :: Monad m => m a -> (a -> b -> c) -> m b -> m c infixl 4 *$!> -- | Right-associative, left-flowing lift3' operator -- --
--   >>> (\x y z -> x * y * z) <!$** Just 4 |< Just 3 |< Just 2
--   Just 24
--   
( (a -> b -> c -> d) -> m a -> m b -> m c -> m d infixr 4 lift3' operator -- --
--   >>> Just 2 >| Just 3 >| Just 4 **$!> \x y z -> x * y * z
--   Just 24
--   
(**$!>) :: Monad m => m a -> (a -> b -> c -> d) -> m b -> m c -> m d infixl 4 **$!> module Control.Flower.Applicative -- |

Use

-- --
--   >>> import Control.Flower
--   
-- --

Rationale

-- --
--   Mathematics, rightly viewed, possesses not only truth,
--   but supreme beauty -- a beauty cold and austere, like that of sculpture,
--   without appeal to any part of our weaker nature, without the gorgeous
--   trappings of painting or music, yet sublimely pure, and capable of a stern
--   perfection such as only the greatest art can show. The true spirit of delight,
--   the exaltation, the sense of being more than Man, which is the touchstone of
--   the highest excellence, is to be found in mathematics as surely as poetry.
--   - Bertrand Russell, "The Study of Mathematics"
--   
-- -- Inspired by the wonderful Flow package, Flower provides -- directional operators for many common Haskell functions. -- -- With the pipe operator (|>) proliferating through OCaml, F#, -- and Elixir, it's becoming clear which way the wind is blowing. A -- dataflow model is very natural to functional programming. -- -- Thinking in Haskell is multidimensional, reading forwards and -- backwards, and through levels of abstraction. This is extremely -- powerful, but does introduce a leaning curve (in grade school, when -- starting with Haskell, or both). -- -- Here, instead of $, we use <|, or reversed with -- |>. Instead of <$>, we use <$, and -- reversed $>. Many of the combinators are built up from -- meaningful character combinations. One such example is lift2, -- which is translated into <$**. <$**, as 'f <$ a -- <* b <* c'. -- -- Please do note that Flower exposes conflicting combinators -- versus the standard Prelude. -- --

Teaching

-- -- Teaching concepts becomes simplified by providing a visual aid. Many -- of the operators are made up of simpler symbols, much in the same way -- as the Lens library. -- -- One common challenge when teaching Haskell is showing what an -- applicative or monad "mean". By using a progressive, modular picture -- of each abstraction, we help build the intuition. -- --

Reading

-- -- A focus on a single direction of data flow makes code easy to follow. -- --

Simplify

-- -- All lifts (fmap, `liftA*` and `liftM*`) are unified as -- `lift*`. module Control.Flower