-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinators that allow for a more functional/monadic style of Arrow programming -- -- If you program with Arrows you have two choices: Use the plain Arrow -- combinators, that are cumbersome to use, or use special Arrow syntax, -- that is built into all Haskell compilers and is still not very -- functional programming style. The arrow syntax still forces you to -- introduce temporary names, that you would not need in a functional -- notation. -- -- Where you would write things like -- --
-- mix <<< (id &&& delay) <<< lowpass ---- -- using plain Arrow combinators, you can now write -- --
-- lowpass >>>= \x -> -- mix <<< (listen x &&& (delay <<< listen x)) ---- -- where the (>>>=) resembles the monadic bind and -- allows you for shared access to an arrow result. Thus it can be used -- like a let. @package functional-arrow @version 0.0 -- | This module is an attempt to simplify the use of arrow combinators. If -- I have f :: arrow a b, then subsequent arrows can only access -- the b, but often I also want to access the a. Thus I -- often write -- --
-- f &&& arr id :: arrow a (b,a) . ---- -- If I repeat this, it yields -- --
-- g &&& arr id <<< f &&& arr id :: arrow a (c,(b,a)) -- h &&& arr id <<< g &&& arr id <<< f &&& arr id :: arrow a (d,(c,(b,a))) . ---- -- However accessing the particular inputs of type d, -- c, b from within h and g is -- cumbersome. Thus I wrote a little support for this style of arrow -- programming. First I use HList instead of nested pairs. Using -- type level Peano numbers and reverse HList index access I can -- use the same expression (say listen x) in both g and -- h although in both contexts they refer to different -- HLists. E.g. g expects the b input at the -- HList head, whereas h gets it one position later. module Control.Arrow.Monad -- | This bind-like operator allows you to a share an interim -- arrow result between various following arrow inputs. -- -- Instead of -- --
-- mix <<< id &&& delay <<< lowpass ---- -- you can write -- --
-- (\x -> HL.hCons x HL.hNil) ^>> -- ((HL.hHead ^>> lowpass) >>>= \x -> -- mix <<< listen x &&& (delay <<< listen x)) --(>>>=) :: (Arrow arrow, HLength list n) => arrow list a -> (n -> arrow (HCons a list) b) -> arrow list b (=<<<) :: (Arrow arrow, HLength list n) => (n -> arrow (HCons a list) b) -> arrow list a -> arrow list b class (HNat x, HNat y, HNat z) => HAdd x y z | x y -> z, x z -> y listen :: (Arrow arrow, HLength list len, HAdd n m len, HLookupByHNat m list a) => n -> arrow list a instance HAdd x y z => HAdd (HSucc x) y (HSucc z) instance HNat x => HAdd HZero x x module Control.Arrow.Let class Index t envi envo ref :: (Index t envi envo, Arrow arr) => arr envi t -> arr envo t (<<<&) :: Arrow arrow => arrow (b, a) c -> arrow a b -> arrow a c input :: Arrow arrow => arrow () Int f :: Arrow arrow => arrow (Int, ()) Char g :: Arrow arrow => arrow (Char, (Int, ())) Bool c1 :: Arrow arrow => arrow (Int, ()) Bool c2 :: Arrow arrow => arrow (Int, ()) Bool instance [overlap ok] Index t envi envo => Index t envi (h, envo) instance [overlap ok] Index t envi (t, envi)