tuple-ops-0.0.0.2: various operations on n-ary tuples via GHC.Generics

Copyright(c) 2018 Jiasen Wu
LicenseBSD-style (see the file LICENSE)
MaintainerJiasen Wu <jiasenwu@hotmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Tuple.Ops.Cons

Description

This module define cons. Examples are given below:

>>> cons (1::Int) ()
1
>>> cons (1::Int) 'a'
(1,'a')
>>> cons (True,'a') "S"
((True,'a'),"S")
>>> cons "S" (True,'a')
("S",True,'a')

Synopsis

Documentation

cons :: Consable a b c => a -> b -> c Source #

cons takes two datatype, and produces a tuple of them. if b is unit, then a is returned. if b is not a tuple, then a pair of (a,b) is returned. otherwise, a is placed in front of b.

type family Cons a b where ... Source #

calculate the result type of cons

Equations

Cons z (a, b) = (z, a, b) 
Cons z (a, b, c) = (z, a, b, c) 
Cons z (a, b, c, d) = (z, a, b, c, d) 
Cons z (a, b, c, d, e) = (z, a, b, c, d, e) 
Cons z (a, b, c, d, e, f) = (z, a, b, c, d, e, f) 
Cons z (a, b, c, d, e, f, g) = (z, a, b, c, d, e, f, g) 
Cons z (a, b, c, d, e, f, g, h) = (z, a, b, c, d, e, f, g, h) 
Cons z (a, b, c, d, e, f, g, h, i) = (z, a, b, c, d, e, f, g, h, i) 
Cons z (a, b, c, d, e, f, g, h, i, j) = (z, a, b, c, d, e, f, g, h, i, j) 
Cons z (a, b, c, d, e, f, g, h, i, j, k) = (z, a, b, c, d, e, f, g, h, i, j, k) 
Cons z (a, b, c, d, e, f, g, h, i, j, k, l) = (z, a, b, c, d, e, f, g, h, i, j, k, l) 
Cons z (a, b, c, d, e, f, g, h, i, j, k, l, m) = (z, a, b, c, d, e, f, g, h, i, j, k, l, m) 
Cons z (a, b, c, d, e, f, g, h, i, j, k, l, m, n) = (z, a, b, c, d, e, f, g, h, i, j, k, l, m, n) 
Cons z (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) = (z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) 
Cons z () = z 
Cons z a = (z, a) 

type Consable a b c = (Generic a, Generic b, Generic c, Cons a b ~ c, Rep b ~ D1 (MetaOfD1 (Rep b)) (UnD1 (Rep b)), Rep c ~ D1 (MetaOfD1 (Rep c)) (UnD1 (Rep c)), ConsableR a (UnD1 (Rep b)), ConsR a (UnD1 (Rep b)) b ~ UnD1 (Rep c)) Source #

A constraint on any consable data type, where a and b are the input, and c is the output.