Reading through various tutorials about Haskell\'s various category-themed classes, we find things like Monoid
, Functor
, Monad
and so on -
I like to think of Arrow
s as composable directed acyclic graphs. For example, an arrow of type:
SomeArrow (a, b, c) (d, e, f)
... you can think of as a graph that has three incoming edges of type a
, b
, and c
and three outgoing edges of type d
, e
, and f
.
Using this interpretation, the category composition operations for Arrow
s are like horizontal concatenation for graphs, connecting their edges together:
(.) :: SomeArrow b c -> SomeArrow a b -> Some Arrow a c
... where a
, b
, and c
may be themselves tuples. Similarly, id
is just the identity graph that forwards all incoming edges to outgoing edges:
id :: SomeArrow a a
The other key operation is (***)
which is like vertical concatenation of graphs:
(***) :: Arrow a b -> Arrow c d -> Arrow (a, c) (b, d)
You can think of that as putting two graphs side-by-side, combining their input edges and output edges.
So Arrow
commonly arise when working with typed directed acyclic graphs. However, the reason you usually don't see them that often is because most people mentally associate graphs with untyped and high-performance data structures.