
Control.Arrow.DeepArrow  Portability  portable  Stability  experimental  Maintainer  conal@conal.net 





Description 
"Deep arrows" as an Arrow subclass.


Synopsis 

class Arrow ~> => DeepArrow (~>) where  result :: (b ~> b') > (a > b) ~> (a > b')  idA :: a ~> a  dupA :: a ~> (a, a)  fstA :: (a, b) ~> a  sndA :: (a, b) ~> b  funF :: (c > a, b) ~> (c > (a, b))  funS :: (a, c > b) ~> (c > (a, b))  funR :: (a > c > b) ~> (c > a > b)  curryA :: ((a, b) > c) ~> (a > b > c)  uncurryA :: (a > b > c) ~> ((a, b) > c)  swapA :: (a, b) ~> (b, a)  lAssocA :: (a, (b, c)) ~> ((a, b), c)  rAssocA :: ((a, b), c) ~> (a, (b, c)) 
  funFirst :: DeepArrow ~> => (d ~> (c > a)) > (d, b) ~> (c > (a, b))   funSecond :: DeepArrow ~> => (d ~> (c > b)) > (a, d) ~> (c > (a, b))   funResult :: DeepArrow ~> => (d ~> (c > b)) > (a > d) ~> (c > a > b)   inpF :: DeepArrow ~> => ((a, b) > c) ~> (a > b > c)   inpS :: DeepArrow ~> => ((a, b) > c) ~> (b > a > c)   inpFirst :: DeepArrow ~> => ((a > c) ~> (d > a' > c)) > ((a, b) > c) ~> (d > (a', b) > c)   inpSecond :: DeepArrow ~> => ((b > c) ~> (d > b' > c)) > ((a, b) > c) ~> (d > (a, b') > c)   flipA :: DeepArrow ~> => (a > c > b) ~> (c > a > b)   unzipA :: DeepArrow ~> => (a ~> (b, c)) > (a ~> b, a ~> c)   (>) :: (DeepArrow ~>, FunArr ~> w) => w (a > b) > w (b > c) > w (a > c) 



The DeepArrow class



Arrows for deep application. Most of these methods could be defined
using arr, but arr is not definable for some types. If your
DeepArrow instance has arr, you might want to use these
implementations
idA = arr id
fstA = arr fst
dupA = arr (\ x > (x,x))
sndA = arr snd
funF = arr (\ (f,b) > \ c > (f c, b))
funS = arr (\ (a,f) > \ c > (a, f c))
funR = arr flip
curryA = arr curry
uncurryA = arr uncurry
swapA = arr (\ (a,b) > (b,a))
lAssocA = arr (\ (a,(b,c)) > ((a,b),c))
rAssocA = arr (\ ((a,b),c) > (a,(b,c)))
If your DeepArrow instance does not have arr, you'll have to come up
with other definitions. In any case, I recommend the following
definitions, which mirror Arrow defaults while avoiding arr. Be sure
also to define arr or pure to yield an error message (rather than
pingponging infinitely between them via the Arrow default definitions).
second f = swapA >>> first f >>> swapA
f &&& g = dupA >>> f *** g
In a few cases, there are default methods, as noted below. The
defaults do not use arr.
  Methods  result :: (b ~> b') > (a > b) ~> (a > b')  Source 
 Apply arrow in a function's result. Analogous to first and
second.
   Identity.
   Duplicate.
   Extract first.
   Extract second.
  funF :: (c > a, b) ~> (c > (a, b))  Source 
 Extract function from first element.
  funS :: (a, c > b) ~> (c > (a, b))  Source 
 Extract function from second element.
  funR :: (a > c > b) ~> (c > a > b)  Source 
 Extract function from result.
  curryA :: ((a, b) > c) ~> (a > b > c)  Source 
 Curry arrow.
  uncurryA :: (a > b > c) ~> ((a, b) > c)  Source 
 Uncurry arrow.
  swapA :: (a, b) ~> (b, a)  Source 
 Swap elements. Has default.
  lAssocA :: (a, (b, c)) ~> ((a, b), c)  Source 
 Leftassociate. Has default.
  rAssocA :: ((a, b), c) ~> (a, (b, c))  Source 
 Rightassociate. Has default.

  Instances  


Composable function extractors


funFirst :: DeepArrow ~> => (d ~> (c > a)) > (d, b) ~> (c > (a, b))  Source 

Promote a function extractor into one that reaches into the first
element of a pair.


funSecond :: DeepArrow ~> => (d ~> (c > b)) > (a, d) ~> (c > (a, b))  Source 

Promote a function extractor into one that reaches into the second
element of a pair.


funResult :: DeepArrow ~> => (d ~> (c > b)) > (a > d) ~> (c > a > b)  Source 

Promote a function extractor into one that reaches into the result
element of a function.


Composable input extractors



Extract the first component of a pair input.



Extract the second component of a pair input.


inpFirst :: DeepArrow ~> => ((a > c) ~> (d > a' > c)) > ((a, b) > c) ~> (d > (a', b) > c)  Source 


inpSecond :: DeepArrow ~> => ((b > c) ~> (d > b' > c)) > ((a, b) > c) ~> (d > (a, b') > c)  Source 


Misc functions



Flip argument order



Like unzip but for DeepArrow arrows instead of lists.


Some utilities



Compose wrapped functions


Produced by Haddock version 2.3.0 