#5679: Provide Arrow lift functions for Control.Arrow
---------------------------------+------------------------------------------
Reporter: A1kmm | Owner:
Type: feature request | Status: new
Priority: normal | Component: libraries/base
Version: 7.2.1 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
It is currently difficult to build complex datastructures by combining
arrows, because there are no lift functions defined on Arrow. These can be
built easily from the class functions:
{{{
liftArrow :: Arrow a => (c -> d) -> a b c -> a b d
liftArrow = (^>>)
liftArrow2 :: Arrow a => (c -> c' -> d) -> a b c -> a b c' -> a b d
liftArrow2 f a1 a2 = arr (\a -> (a, a)) >>> (a1 *** a2) >>> arr (\(a, b)
-> f a b)
liftArrow3 :: Arrow a => (c -> c' -> c'' -> d) -> a b c -> a b c' -> a b
c'' -> a b d
liftArrow3 f a1 a2 a3 = arr (\a -> (a, (a, a))) >>> (a1 *** a2 *** a3) >>>
arr (\(a, (b, c)) -> f a b c)
liftArrow4 :: Arrow a => (c -> c' -> c'' -> c''' -> d) -> a b c -> a b c'
-> a b c'' -> a b c''' -> a b d
liftArrow4 f a1 a2 a3 a4 = arr (\a -> (a, (a, (a, a)))) >>> (a1 *** a2 ***
a3 *** a4) >>> arr (\(a, (b, (c, d))) -> f a b c d)
liftArrow5 :: Arrow a => (c -> c' -> c'' -> c''' -> c'''' -> d) -> a b c
-> a b c' -> a b c'' -> a b c''' -> a b d
liftArrow5 f a1 a2 a3 a4 a5 = arr (\a -> (a, (a, (a, (a, a))))) >>> (a1
*** a2 *** a3 *** a4 *** a5) >>> arr (\(a, (b, (c, (d, e)))) -> f a b c d
e)
}}}
I suggest these be added to Control.Arrow.
elliott suggested (on #haskell on Freenode) that something like arr2 = arr
. uncurry could be defined as a building block, from which the lift
functions could be defined.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5679>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs