DeepArrow-0.4.0: Arrows for "deep application"

Safe HaskellNone




DeepArrow examples.

The types in the source code are formatted for easier reading.


Deep application

deep :: DeepArrow ar => (c `ar` c') -> (a -> (f, b -> (c, g)), e) `ar` (a -> (f, b -> (c', g)), e)Source

Given a value of type (a -> (f,b -> (c,g)),e), apply a function to just the c part and leave the rest intact.

deep = first . result . second . result . first

Function extraction

extF :: DeepArrow ar => (d `ar` (c -> b)) -> (e -> (a, d), f) `ar` (c -> (e -> (a, b), f))Source

Given a way to extract a function from a d value, create a way to extract a function from a (e -> (a,d), f) value.

extF = funFirst . funResult . funSecond

extFF :: DeepArrow ar => (e -> (a, c -> b), f) `ar` (c -> (e -> (a, b), f))Source

To make an extractor, simply apply the extractor-transformer extF to the identity arrow.

extFF = extF idA

Input extraction

extI :: DeepArrow ar => (((a, (b, e)), c) -> d) `ar` (b -> ((a, e), c) -> d)Source

Extract a b input from a ((a,(b,e)),c) argument.

extI = (inpFirst . inpSecond) inpF

extFI :: DeepArrow ar => (e -> (g, ((a, (b, e)), c) -> d), f) `ar` (b -> (e -> (g, ((a, e), c) -> d), f))Source

Typically, we will have to combine function and input extractors. For instance, combine extF and extI.

extFI = extF extI