elision-0.1.0.2: A data structure over two functions to be linked together at a later time.

Copyright(c) 2016 Alex Crough
LicenseBSD2
Maintaineralex@crough.io
StabilityExperimental
PortabilityRankNTypes, TupleSection, TypeOperators
Safe HaskellSafe
LanguageHaskell2010

Control.Arrow.Elision

Contents

Description

 

Synopsis

Types

data Elision f a b Source #

A lens-esque type that can be used to "skip" part of a function.

An Elision can be used in the common interpreter pattern, in which case f represents the DSL type, a represents the input of a function and b represents the output.

Use complete or unelide to deconstruct the type.

Instances

Arrow (Elision f) Source # 

Methods

arr :: (b -> c) -> Elision f b c #

first :: Elision f b c -> Elision f (b, d) (c, d) #

second :: Elision f b c -> Elision f (d, b) (d, c) #

(***) :: Elision f b c -> Elision f b' c' -> Elision f (b, b') (c, c') #

(&&&) :: Elision f b c -> Elision f b c' -> Elision f b (c, c') #

ArrowChoice (Elision f) Source # 

Methods

left :: Elision f b c -> Elision f (Either b d) (Either c d) #

right :: Elision f b c -> Elision f (Either d b) (Either d c) #

(+++) :: Elision f b c -> Elision f b' c' -> Elision f (Either b b') (Either c c') #

(|||) :: Elision f b d -> Elision f c d -> Elision f (Either b c) d #

ArrowApply (Elision f) Source # 

Methods

app :: Elision f (Elision f b c, b) c #

Profunctor (Elision f) Source # 

Methods

dimap :: (a -> b) -> (c -> d) -> Elision f b c -> Elision f a d #

lmap :: (a -> b) -> Elision f b c -> Elision f a c #

rmap :: (b -> c) -> Elision f a b -> Elision f a c #

(#.) :: Coercible * c b => (b -> c) -> Elision f a b -> Elision f a c #

(.#) :: Coercible * b a => Elision f b c -> (a -> b) -> Elision f a c #

Category * (Elision f) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Monad (Elision f a) Source # 

Methods

(>>=) :: Elision f a a -> (a -> Elision f a b) -> Elision f a b #

(>>) :: Elision f a a -> Elision f a b -> Elision f a b #

return :: a -> Elision f a a #

fail :: String -> Elision f a a #

Functor (Elision f a) Source # 

Methods

fmap :: (a -> b) -> Elision f a a -> Elision f a b #

(<$) :: a -> Elision f a b -> Elision f a a #

Applicative (Elision f a) Source # 

Methods

pure :: a -> Elision f a a #

(<*>) :: Elision f a (a -> b) -> Elision f a a -> Elision f a b #

(*>) :: Elision f a a -> Elision f a b -> Elision f a b #

(<*) :: Elision f a a -> Elision f a b -> Elision f a a #

type Elision' f a = Elision f (f a) a Source #

The type of the simplist elision, where unelide eli f = f

Elision manipulation functions

complete :: Monad m => (forall c. f c -> m c) -> a -> Elision f a b -> m b Source #

Construct an interpreter for an elision out of a function an initial argument.

complete' :: Monad m => (forall c. f c -> m c) -> Elision f () b -> m b Source #

Like complete, but the unit type never has to be provided.

elide :: (a -> f c) -> (c -> b) -> Elision f a b Source #

Create an elision out of two functions to be completed at a later date.

initial :: f a -> Elision f () a Source #

Apply a value to an elision immediately.

simple :: Elision' f a Source #

The simplest elision, effectively the identity function.

unelide :: Monad m => Elision f a b -> (forall c. f c -> m c) -> a -> m b Source #

Deconstruct an Elision, returning its inner type.

unelide' :: Monad m => Elision f () b -> (forall c. f c -> m c) -> m b Source #

Like unelide, but applies the unit type to the function immediately.

Combining Interpreters

data Sum f g a Source #

Either f a or g a.

type (//) a b = Sum a b Source #

A type synonym for Sum to create harmony with the // function.

(//) :: (forall b. f b -> m b) -> (forall b. g b -> m b) -> Sum f g a -> m a Source #

Create a function that can complete an elision of a sum out of two functions that can complete each individual parts.

left' :: Elision f a b -> Elision (f // g) a b Source #

Like left, but over the first type argument.

right' :: Elision g a b -> Elision (f // g) a b Source #

Like right, but over the first type argument.

(/>) :: Elision f a b -> Elision g b c -> Elision (f // g) a c Source #

Send the output of the left to the input of right, and add their f types together.

(</) :: Elision f b c -> Elision g a b -> Elision (f // g) a c Source #

Send the output of the right to the input of the left, and add their f types together.

Reexports

apply :: ArrowApply a => a b c -> b -> a () c Source #