Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created December 5, 2010 13:32
Show Gist options
  • Save debasishg/729080 to your computer and use it in GitHub Desktop.
Save debasishg/729080 to your computer and use it in GitHub Desktop.
ascii artwork for arrows
// joining of 2 arrows
(>>>) :: arr a b -> arr b c -> arr a c
(>>>)
a -- (f) --> b -- (g) --> c
// works on pairs
// f: a -> b
// g: a -> c
+---------> a -> (f) -> b
| \
a ->| (&&&) +--> (b, c)
| /
+---------> a -> (g) -> c
(&&&) :: arr a b -> arr a c -> arr a (b,c)
// works on pairs
// f: a -> b
// g: c -> d
+----------> a -> (f) -> b ---+
| |
(a, c) ->| (***) +--> (b, d)
| |
+----------> c -> (g) -> d ---+
(***) :: arr a b -> arr c d -> arr (a,c) (b,d)
// works on pairs
// f: a -> c
// g: b -> c
+------> a -> (f) -> c
|
(a or b) ->| (|||)
|
+------> b -> (g) -> c
(|||) :: arr a c -> arr b c -> arr (Either a b) c
// works on pairs
// f: a -> b
// g: c -> d
+------> a -> (f) -> b
| \
(a or c) ->| (+++) + -- (b or d)
| /
+------> c -> (g) -> d
(+++) :: arr a b -> arr c d -> arr (Either a c) (Either b d)
// works on pairs
// f: a -> b
// c
+----------> a -> (f) -> b ---+
| |
(a, c) ->| (first) +--> (b, c)
| |
+----------> c ---------------+
first :: arr a b -> arr (a,c) (b,c)
// works on pairs
// c
// f: a -> b
+----------> c ---------------+
| |
(c, a) ->| (second) +--> (c, b)
| |
+----------> a -> (f) -> b ---+
second :: arr a b -> arr (c,a) (c,b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment