pointless-haskell-0.0.9: Pointless Haskell library

Copyright(c) 2008 University of Minho
LicenseBSD3
Maintainerhpacheco@di.uminho.pt
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Generics.Pointless.Combinators

Contents

Description

Pointless Haskell: point-free programming with recursion patterns as hylomorphisms

This module defines many standard combinators used for point-free programming.

Synopsis

Type annotations

data Ann a Source

Instances

Show (Ann a) 

ann :: a Source

vnn :: a -> Ann a Source

Terminal object

_L :: a Source

The bottom value for any type. It is many times used just for type annotations.

data One Source

The final object. The only possible value of type One is _L.

Points

bang :: a -> One Source

Creates a point to the terminal object.

pnt :: a -> One -> a Source

Converts elements into points.

Products

(/\) :: (a -> b) -> (a -> c) -> a -> (b, c) infix 6 Source

The infix split combinator.

(><) :: (a -> b) -> (c -> d) -> (a, c) -> (b, d) infix 7 Source

Sums

inl :: a -> Either a b Source

Injects a value to the left of a sum.

inr :: b -> Either a b Source

Injects a value to the right of a sum.

(\/) :: (b -> a) -> (c -> a) -> Either b c -> a infix 4 Source

The infix either combinator.

(-|-) :: (a -> b) -> (c -> d) -> Either a c -> Either b d infix 5 Source

The infix sum combinator.

(<>) :: (a -> b) -> (c -> d) -> Either a c -> Either b d infix 5 Source

Alias for the infix sum combinator.

Exponentials

app :: (a -> b, a) -> b Source

The application combinator.

lexp :: (a -> b) -> (b -> c) -> a -> c Source

The left exponentiation combinator.

rexp :: (b -> c) -> (a -> b) -> a -> c Source

The right exponentiation combinator.

(!) :: a -> b -> a infix 0 Source

The infix combinator for a constant point.

Guards

grd :: (a -> Bool) -> a -> Either a a Source

Guard combinator that operates on Haskell booleans.

(?) :: (a -> Bool) -> a -> Either a a Source

Infix guard combinator that simulates the postfix syntax.

(??) :: (a -> Either One One) -> a -> Either a a infix 1 Source

Point-free definitions of uncurried versions of the basic combinators

split :: (a -> b, a -> c) -> a -> (b, c) Source

The uncurried split combinator.

eithr :: (a -> c, b -> c) -> Either a b -> c Source

The uncurried either combinator.

comp :: (b -> c, a -> b) -> a -> c Source

The uncurried composition combinator.

orf :: (a -> Bool, a -> Bool) -> a -> Bool Source

Binary or of boolean functions.

andf :: (a -> Bool, a -> Bool) -> a -> Bool Source

Binary and of boolean functions.

or :: (Bool, Bool) -> Bool Source

Binary or point-free combinator.

and :: (Bool, Bool) -> Bool Source

Binary and point-free combinator.

eq :: Eq a => (a, a) -> Bool Source

Binary equality point-free combinator.

neq :: Eq a => (a, a) -> Bool Source

Binary inequality point-free combinator.

Point-free isomorphic combinators

swap :: (a, b) -> (b, a) Source

Swap the elements of a product.

coswap :: Either a b -> Either b a Source

Swap the elements of a sum.

distl :: (Either a b, c) -> Either (a, c) (b, c) Source

Distribute products over the left of sums.

undistl :: Either (a, c) (b, c) -> (Either a b, c) Source

Distribute sums over the left of products.

distr :: (c, Either a b) -> Either (c, a) (c, b) Source

Distribute products over the right of sums.

undistr :: Either (c, a) (c, b) -> (c, Either a b) Source

Distribute sums over the right of products.

assocl :: (a, (b, c)) -> ((a, b), c) Source

Associate nested products to the left.

assocr :: ((a, b), c) -> (a, (b, c)) Source

Associates nested products to the right.

coassocl :: Either a (Either b c) -> Either (Either a b) c Source

Associates nested sums to the left.

coassocr :: Either (Either a b) c -> Either a (Either b c) Source

Associates nested sums to the right.

subr :: (a, (b, c)) -> (b, (a, c)) Source

Shifts the an element to the right of a nested pair.

subl :: ((a, b), c) -> ((a, c), b) Source

Shifts the an element to the left of a nested pair.

cosubr :: Either a (Either b c) -> Either b (Either a c) Source

Shifts an option to the right of a nested sum.

cosubl :: Either (Either a b) c -> Either (Either a c) b Source

Shifts an option to the left of a nested sum.

distp :: ((c, d), (a, b)) -> ((c, a), (d, b)) Source

The product distribution combinator

dists :: (Either a b, Either c d) -> Either (Either (a, c) (a, d)) (Either (b, c) (b, d)) Source

The sum distribution combinator.