DeepArrow-0.3.4: Arrows for "deep application"

Portabilityportable
Stabilityexperimental
Maintainerconal@conal.net
Safe HaskellSafe-Infered

Control.Arrow.DeepArrow.Examples

Contents

Description

DeepArrow examples.

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

Synopsis

Deep application

deep :: DeepArrow ~> => (c ~> c') -> (a -> (f, b -> (c, g)), e) ~> (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 ~> => (d ~> (c -> b)) -> (e -> (a, d), f) ~> (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 ~> => (e -> (a, c -> b), f) ~> (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 ~> => (((a, (b, e)), c) -> d) ~> (b -> ((a, e), c) -> d)Source

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

extI = (inpFirst . inpSecond) inpF

extFI :: DeepArrow ~> => (e -> (g, ((a, (b, e)), c) -> d), f) ~> (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