first-class-patterns-0.3.2.2: First class patterns and pattern matching, using type families

LicenseBSD3
MaintainerBrent Yorgey <byorgey@cis.upenn.edu>
Stabilityexperimental
Portabilitynon-portable (see .cabal)
Safe HaskellNone
LanguageHaskell2010

Data.Pattern.Base.Tuple

Contents

Description

Various types defined inductively as type families or data families on type-lists.

Synopsis

Functions

type family Fun xs r Source

Curried functions. We have

Fun '[x1, ..., xn] r   =   x1 -> ... -> xn -> r

Instances

type Fun ([] *) r = r 
type Fun ((:) * h t) r = h -> Fun t r 

Tuples

data Tuple xs Source

Tuples with types given by xs.

zeroT :: Tuple [] Source

The empty tuple

oneT :: a -> Tuple `[a]` Source

The singleton tuple

(<>) :: Tuple xs -> Tuple ys -> Tuple (xs :++: ys) Source

Concatenation of tuples.

runTuple :: Tuple xs -> Fun xs r -> r Source

Runs a tuple by applying it to a curried function.

Mapping and distributing over tuples

type family Map f xs :: [*] Source

Instances

type Map f ([] *) = [] * 
type Map f ((:) * h t) = (:) * (f h) (Map f t) 

class Distribute xs where Source

Methods

distribute :: Functor f => f (Tuple xs) -> Tuple (Map f xs) Source

Instances

Distribute ([] *) 
(Uncurriable t, Tupable t, Distribute t) => Distribute ((:) * h t)