Arrows can be used in ?FunctionalReactiveProgramming.
In Control.Arrow, we see that an Arrow class has the following functions:
class Arrow a where arr :: (b -> c) -> a b c -- the same as "pure" pure :: (b -> c) -> a b c -- the same as "arr" (>>>) :: a b c -> a c d -> a b d first :: a b c -> a (b, d) (c, d) second :: a b c -> a (d, b) (d, c) (***) :: a b c -> a b' c' -> a (b, b') (c, c') (&&&) :: a b c -> a b c' -> a b (c, c')
A description offered on the HaskellIrcChannel follows:
<kosmikus> well, it still is vague, but one can say that a monad represents "things" which can produce values of a type, whereas an arrow represents "things" that can consume values of one type and produce values of another ... <kosmikus> shapr: as to syntax, the <- represents the "production" part <kosmikus> whereas the "-<" represents the consumption ... <kosmikus> that's why monad syntax just uses "<-", whereas arrow syntax uses both
By way of example, here's the add function lifted to arrows, and using ?RossPaterson's arrow syntax:
addA :: Arrow a => a b Int -> a b Int -> a b Int addA f g = proc x -> do y <- f -< x z <- g -< x returnA -< y + z
How does one learn more about Arrows? Are there any tutorials? What are the best papers to read? Are there small examples using Control.Arrow like for StateMonad? I understand that there are some inconsistancies in the names of the functions which might cause confusion?