diff options
| author | M Farkas-Dyck <mfdyck@google.com> | 2015-09-23 10:35:34 -0700 |
|---|---|---|
| committer | Austin Seipp <austin@well-typed.com> | 2015-10-16 14:25:18 -0500 |
| commit | 6a8ca65032c6b3ed61b5378765e70120083cf5da (patch) | |
| tree | 4c9b9d5988238df29dda19cae6e0e85c82737cb2 | |
| parent | 75492e7467ff962f2f2e29e5c8b2c588c94ae8a7 (diff) | |
| download | haskell-6a8ca65032c6b3ed61b5378765e70120083cf5da.tar.gz | |
Allow left ∨ (+++) as minimal definition of ArrowChoice instance
See #10911.
Reviewers: ekmett
Signed-off-by: Austin Seipp <austin@well-typed.com>
| -rw-r--r-- | libraries/base/Control/Arrow.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libraries/base/Control/Arrow.hs b/libraries/base/Control/Arrow.hs index 1cc6062516..2e2c4700a4 100644 --- a/libraries/base/Control/Arrow.hs +++ b/libraries/base/Control/Arrow.hs @@ -219,17 +219,14 @@ class Arrow a => ArrowChoice a where -- | Feed marked inputs through the argument arrow, passing the -- rest through unchanged to the output. left :: a b c -> a (Either b d) (Either c d) + left = (+++ id) -- | A mirror image of 'left'. -- -- The default definition may be overridden with a more efficient -- version if desired. right :: a b c -> a (Either d b) (Either d c) - right f = arr mirror >>> left f >>> arr mirror - where - mirror :: Either x y -> Either y x - mirror (Left x) = Right x - mirror (Right y) = Left y + right = (id +++) -- | Split the input between the two argument arrows, retagging -- and merging their outputs. @@ -238,7 +235,11 @@ class Arrow a => ArrowChoice a where -- The default definition may be overridden with a more efficient -- version if desired. (+++) :: a b c -> a b' c' -> a (Either b b') (Either c c') - f +++ g = left f >>> right g + f +++ g = left f >>> arr mirror >>> left g >>> arr mirror + where + mirror :: Either x y -> Either y x + mirror (Left x) = Right x + mirror (Right y) = Left y -- | Fanin: Split the input between the two argument arrows and -- merge their outputs. |
