summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Arrow.hs
diff options
context:
space:
mode:
authorross <unknown>2004-09-06 17:20:02 +0000
committerross <unknown>2004-09-06 17:20:02 +0000
commit82839653d432b985fe0338bc9e2e6de3c8f0c472 (patch)
treec216a245e879f823b46404d7a0af70b270989cff /libraries/base/Control/Arrow.hs
parent585004abb19e5bf4009ce349ad77b3be19215bef (diff)
downloadhaskell-82839653d432b985fe0338bc9e2e6de3c8f0c472.tar.gz
[project @ 2004-09-06 17:20:02 by ross]
add some RULES
Diffstat (limited to 'libraries/base/Control/Arrow.hs')
-rw-r--r--libraries/base/Control/Arrow.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/libraries/base/Control/Arrow.hs b/libraries/base/Control/Arrow.hs
index f6ee713d37..316ef06de0 100644
--- a/libraries/base/Control/Arrow.hs
+++ b/libraries/base/Control/Arrow.hs
@@ -93,6 +93,23 @@ class Arrow a where
(&&&) :: a b c -> a b c' -> a b (c,c')
f &&& g = arr (\b -> (b,b)) >>> f *** g
+{-# RULES
+"compose/arr" forall f g .
+ arr f >>> arr g = arr (f >>> g)
+"first/arr" forall f .
+ first (arr f) = arr (first f)
+"second/arr" forall f .
+ second (arr f) = arr (second f)
+"product/arr" forall f g .
+ arr f *** arr g = arr (f *** g)
+"fanout/arr" forall f g .
+ arr f &&& arr g = arr (f &&& g)
+"compose/first" forall f g .
+ first f >>> first g = first (f >>> g)
+"compose/second" forall f g .
+ second f >>> second g = second (f >>> g)
+ #-}
+
-- Ordinary functions are arrows.
instance Arrow (->) where
@@ -175,6 +192,21 @@ class Arrow a => ArrowChoice a where
where untag (Left x) = x
untag (Right y) = y
+{-# RULES
+"left/arr" forall f .
+ left (arr f) = arr (left f)
+"right/arr" forall f .
+ right (arr f) = arr (right f)
+"sum/arr" forall f g .
+ arr f +++ arr g = arr (f +++ g)
+"fanin/arr" forall f g .
+ arr f ||| arr g = arr (f ||| g)
+"compose/left" forall f g .
+ left f >>> left g = left (f >>> g)
+"compose/right" forall f g .
+ right f >>> right g = right (f >>> g)
+ #-}
+
instance ArrowChoice (->) where
left f = f +++ id
right f = id +++ f