compound-types-0.1.4.1: Sum and Product types and such

Safe HaskellNone
LanguageHaskell2010

CompoundTypes.Lazy

Contents

Description

Implementations of the lazy data-structures.

Synopsis

Sum-types

data Sum2 _1 _2 Source #

Constructors

Sum2_1 _1 
Sum2_2 _2 

data Sum3 _1 _2 _3 Source #

Constructors

Sum3_1 _1 
Sum3_2 _2 
Sum3_3 _3 

data Sum4 _1 _2 _3 _4 Source #

Constructors

Sum4_1 _1 
Sum4_2 _2 
Sum4_3 _3 
Sum4_4 _4 

data Sum5 _1 _2 _3 _4 _5 Source #

Constructors

Sum5_1 _1 
Sum5_2 _2 
Sum5_3 _3 
Sum5_4 _4 
Sum5_5 _5 

data Sum6 _1 _2 _3 _4 _5 _6 Source #

Constructors

Sum6_1 _1 
Sum6_2 _2 
Sum6_3 _3 
Sum6_4 _4 
Sum6_5 _5 
Sum6_6 _6 

data Sum7 _1 _2 _3 _4 _5 _6 _7 Source #

Constructors

Sum7_1 _1 
Sum7_2 _2 
Sum7_3 _3 
Sum7_4 _4 
Sum7_5 _5 
Sum7_6 _6 
Sum7_7 _7 

type family a + b where ... infixl 0 Source #

Automatically derives the sum-type of the according arity from expressions such as:

Int + Char + Bool

In that case it will resolve to:

Sum3 Int Char Bool

Equations

(Sum6 _1 _2 _3 _4 _5 _6) + _7 = Sum7 _1 _2 _3 _4 _5 _6 _7 
(Sum5 _1 _2 _3 _4 _5) + (Sum2 _6 _7) = Sum7 _1 _2 _3 _4 _5 _6 _7 
(Sum5 _1 _2 _3 _4 _5) + _6 = Sum6 _1 _2 _3 _4 _5 _6 
(Sum4 _1 _2 _3 _4) + (Sum3 _5 _6 _7) = Sum7 _1 _2 _3 _4 _5 _6 _7 
(Sum4 _1 _2 _3 _4) + (Sum2 _5 _6) = Sum6 _1 _2 _3 _4 _5 _6 
(Sum4 _1 _2 _3 _4) + _5 = Sum5 _1 _2 _3 _4 _5 
(Sum3 _1 _2 _3) + (Sum4 _4 _5 _6 _7) = Sum7 _1 _2 _3 _4 _5 _6 _7 
(Sum3 _1 _2 _3) + (Sum3 _4 _5 _6) = Sum6 _1 _2 _3 _4 _5 _6 
(Sum3 _1 _2 _3) + (Sum2 _4 _5) = Sum5 _1 _2 _3 _4 _5 
(Sum3 _1 _2 _3) + _4 = Sum4 _1 _2 _3 _4 
(Sum2 _1 _2) + (Sum5 _3 _4 _5 _6 _7) = Sum7 _1 _2 _3 _4 _5 _6 _7 
(Sum2 _1 _2) + (Sum4 _3 _4 _5 _6) = Sum6 _1 _2 _3 _4 _5 _6 
(Sum2 _1 _2) + (Sum3 _3 _4 _5) = Sum5 _1 _2 _3 _4 _5 
(Sum2 _1 _2) + (Sum2 _3 _4) = Sum4 _1 _2 _3 _4 
(Sum2 _1 _2) + _3 = Sum3 _1 _2 _3 
(Unsubtracted _1 _2) + _2 = _1 
(Unsubtracted _1 _2) + _3 = Unsubtracted (_1 + _3) _2 
_1 + (Sum6 _2 _3 _4 _5 _6 _7) = Sum7 _1 _2 _3 _4 _5 _6 _7 
_1 + (Sum5 _2 _3 _4 _5 _6) = Sum6 _1 _2 _3 _4 _5 _6 
_1 + (Sum4 _2 _3 _4 _5) = Sum5 _1 _2 _3 _4 _5 
_1 + (Sum3 _2 _3 _4) = Sum4 _1 _2 _3 _4 
_1 + (Sum2 _2 _3) = Sum3 _1 _2 _3 
_1 + (Unsubtracted _2 _1) = _2 
_1 + (Unsubtracted _2 _3) = Unsubtracted (_1 + _2) _3 
_1 + _2 = Sum2 _1 _2 

Subtraction

type family a - b where ... infixl 0 Source #

An operator for removing elements from the sum-types. E.g.,

Int + Char + Bool - Char

is the same type as

Int + Bool

Equations

(Sum7 _1 _2 _3 _4 _5 _6 _7) - _1 = Sum6 _2 _3 _4 _5 _6 _7 
(Sum7 _1 _2 _3 _4 _5 _6 _7) - _2 = Sum6 _1 _3 _4 _5 _6 _7 
(Sum7 _1 _2 _3 _4 _5 _6 _7) - _3 = Sum6 _1 _2 _4 _5 _6 _7 
(Sum7 _1 _2 _3 _4 _5 _6 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- _3 = Unsubtracted (_1 - _3) _2 
_1 - (Sum7 _2 _3 _4 _5 _6 _7 _8) = ((((((_1 - _2) - _3) - _4) - _5) - _6) - _7) - _8 
_1 - (Sum6 _2 _3 _4 _5 _6 _7) = (((((_1 - _2) - _3) - _4) - _5) - _6) - _7 
_1 - (Sum5 _2 _3 _4 _5 _6) = ((((_1 - _2) - _3) - _4) - _5) - _6 
_1 - (Sum4 _2 _3 _4 _5) = (((_1 - _2) - _3) - _4) - _5 
_1 - (Sum3 _2 _3 _4) = ((_1 - _2) - _3) - _4 
_1 - (Sum2 _2 _3) = (_1 - _2) - _3 
_1 - _2 = Unsubtracted _1 _2 

data Unsubtracted minuend subtrahend Source #

What you get, when the subtraction cannot yet be performed.

Happens when the minuend doesn't contain the subtrahend. E.g.,

Char - Bool

produces

Unsubtracted Char Bool

However it's possible to get back to the normal type, when you perform the required addition afterwards. E.g.,

Char - Bool + Bool

produces

Char

This construct actually exists primarily for that purpose.

Product-types

data Product2 _1 _2 Source #

Constructors

Product2 _1 _2 

data Product3 _1 _2 _3 Source #

Constructors

Product3 _1 _2 _3 

data Product4 _1 _2 _3 _4 Source #

Constructors

Product4 _1 _2 _3 _4 

data Product5 _1 _2 _3 _4 _5 Source #

Constructors

Product5 _1 _2 _3 _4 _5 

data Product6 _1 _2 _3 _4 _5 _6 Source #

Constructors

Product6 _1 _2 _3 _4 _5 _6 

data Product7 _1 _2 _3 _4 _5 _6 _7 Source #

Constructors

Product7 _1 _2 _3 _4 _5 _6 _7 

type family a * b where ... infixl 1 Source #

Automatically derives the product-type of the according arity from expressions such as:

Int * Char * Bool

In that case it will resolve to:

Product3 Int Char Bool

Equations

(Product6 _1 _2 _3 _4 _5 _6) * _7 = Product7 _1 _2 _3 _4 _5 _6 _7 
(Product5 _1 _2 _3 _4 _5) * (Product2 _6 _7) = Product7 _1 _2 _3 _4 _5 _6 _7 
(Product5 _1 _2 _3 _4 _5) * _6 = Product6 _1 _2 _3 _4 _5 _6 
(Product4 _1 _2 _3 _4) * (Product3 _5 _6 _7) = Product7 _1 _2 _3 _4 _5 _6 _7 
(Product4 _1 _2 _3 _4) * (Product2 _5 _6) = Product6 _1 _2 _3 _4 _5 _6 
(Product4 _1 _2 _3 _4) * _5 = Product5 _1 _2 _3 _4 _5 
(Product3 _1 _2 _3) * (Product4 _4 _5 _6 _7) = Product7 _1 _2 _3 _4 _5 _6 _7 
(Product3 _1 _2 _3) * (Product3 _4 _5 _6) = Product6 _1 _2 _3 _4 _5 _6 
(Product3 _1 _2 _3) * (Product2 _4 _5) = Product5 _1 _2 _3 _4 _5 
(Product3 _1 _2 _3) * _4 = Product4 _1 _2 _3 _4 
(Product2 _1 _2) * (Product5 _3 _4 _5 _6 _7) = Product7 _1 _2 _3 _4 _5 _6 _7 
(Product2 _1 _2) * (Product4 _3 _4 _5 _6) = Product6 _1 _2 _3 _4 _5 _6 
(Product2 _1 _2) * (Product3 _3 _4 _5) = Product5 _1 _2 _3 _4 _5 
(Product2 _1 _2) * (Product2 _3 _4) = Product4 _1 _2 _3 _4 
(Product2 _1 _2) * _3 = Product3 _1 _2 _3 
(Undivided _1 _2) * _2 = _1 
(Undivided _1 _2) * _3 = Undivided (_1 * _3) _2 
_1 * (Product6 _2 _3 _4 _5 _6 _7) = Product7 _1 _2 _3 _4 _5 _6 _7 
_1 * (Product5 _2 _3 _4 _5 _6) = Product6 _1 _2 _3 _4 _5 _6 
_1 * (Product4 _2 _3 _4 _5) = Product5 _1 _2 _3 _4 _5 
_1 * (Product3 _2 _3 _4) = Product4 _1 _2 _3 _4 
_1 * (Product2 _2 _3) = Product3 _1 _2 _3 
_1 * (Undivided _2 _1) = _2 
_1 * (Undivided _2 _3) = Undivided (_1 * _2) _3 
_1 * _2 = Product2 _1 _2 

Division

type family a / b where ... infixl 1 Source #

An operator for removing elements from the product-types. E.g.,

Int * Char * Bool / Char

is the same type as

Int * Bool

Equations

(Product7 _1 _2 _3 _4 _5 _6 _7) / _1 = Product6 _2 _3 _4 _5 _6 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _2 = Product6 _1 _3 _4 _5 _6 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _3 = Product6 _1 _2 _4 _5 _6 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _4 = Product6 _1 _2 _3 _5 _6 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _5 = Product6 _1 _2 _3 _4 _6 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _6 = Product6 _1 _2 _3 _4 _5 _7 
(Product7 _1 _2 _3 _4 _5 _6 _7) / _7 = Product6 _1 _2 _3 _4 _5 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _1 = Product5 _2 _3 _4 _5 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _2 = Product5 _1 _3 _4 _5 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _3 = Product5 _1 _2 _4 _5 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _4 = Product5 _1 _2 _3 _5 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _5 = Product5 _1 _2 _3 _4 _6 
(Product6 _1 _2 _3 _4 _5 _6) / _6 = Product5 _1 _2 _3 _4 _5 
(Product5 _1 _2 _3 _4 _5) / _1 = Product4 _2 _3 _4 _5 
(Product5 _1 _2 _3 _4 _5) / _2 = Product4 _1 _3 _4 _5 
(Product5 _1 _2 _3 _4 _5) / _3 = Product4 _1 _2 _4 _5 
(Product5 _1 _2 _3 _4 _5) / _4 = Product4 _1 _2 _3 _5 
(Product5 _1 _2 _3 _4 _5) / _5 = Product4 _1 _2 _3 _4 
(Product4 _1 _2 _3 _4) / _1 = Product3 _2 _3 _4 
(Product4 _1 _2 _3 _4) / _2 = Product3 _1 _3 _4 
(Product4 _1 _2 _3 _4) / _3 = Product3 _1 _2 _4 
(Product4 _1 _2 _3 _4) / _4 = Product3 _1 _2 _3 
(Product3 _1 _2 _3) / _1 = Product2 _2 _3 
(Product3 _1 _2 _3) / _2 = Product2 _1 _3 
(Product3 _1 _2 _3) / _3 = Product2 _1 _2 
(Product2 _1 _2) / _1 = _2 
(Product2 _1 _2) / _2 = _1 
(Undivided _1 _2) / _3 = Undivided (_1 / _3) _2 
_1 / (Product7 _2 _3 _4 _5 _6 _7 _8) = ((((((_1 / _2) / _3) / _4) / _5) / _6) / _7) / _8 
_1 / (Product6 _2 _3 _4 _5 _6 _7) = (((((_1 / _2) / _3) / _4) / _5) / _6) / _7 
_1 / (Product5 _2 _3 _4 _5 _6) = ((((_1 / _2) / _3) / _4) / _5) / _6 
_1 / (Product4 _2 _3 _4 _5) = (((_1 / _2) / _3) / _4) / _5 
_1 / (Product3 _2 _3 _4) = ((_1 / _2) / _3) / _4 
_1 / (Product2 _2 _3) = (_1 / _2) / _3 
_1 / _2 = Undivided _1 _2 

data Undivided dividend divisor Source #

What you get, when the division cannot yet be performed.

Happens when the dividend doesn't contain the divisor. E.g.,

Char / Bool

produces

Undivided Char Bool

However it's possible to get back to the normal type, when you perform the required multiplication afterwards. E.g.,

Char / Bool * Bool

produces

Char

This construct actually exists primarily for that purpose.