quipper-utils-0.9.0.0: Utility libraries for Quipper.

Safe HaskellSafe
LanguageHaskell98

Quipper.Utils.Tuple

Description

This module provides isomorphisms between n-tuples and repeated pairs. It is used to be able to write type classes for n-tuples more generically. Essentially we want to be able to write code for 17-tuples once and for all, rather than once for each type class we define. Ideally there would be a standard Haskell library for this.

Two type classes are provided: Tuple, and TupleOrUnary. Tuple is recommended for most uses.

Synopsis

Documentation

class TupleOrUnary t s | s -> t where Source #

This type class relates types of the form t = (a,b,c,d) (“tupled form”) to types of the form s = (a,(b,(c,(d,())))) (“standard form”), and provides a way to convert between the two representations.

The tupled form can always be deduced from the standard form.

Methods

weak_tuple :: s -> t Source #

For example, maps (a,(b,(c,(d,())))) to (a,b,c,d).

weak_untuple :: t -> s Source #

For example, maps (a,b,c,d) to (a,(b,(c,(d,())))).

Instances
TupleOrUnary () () Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: () -> () Source #

weak_untuple :: () -> () Source #

TupleOrUnary a (a, ()) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, ()) -> a Source #

weak_untuple :: a -> (a, ()) Source #

TupleOrUnary (a, b) (a, (b, ())) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, ())) -> (a, b) Source #

weak_untuple :: (a, b) -> (a, (b, ())) Source #

TupleOrUnary (a, b, c) (a, (b, (c, ()))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, ()))) -> (a, b, c) Source #

weak_untuple :: (a, b, c) -> (a, (b, (c, ()))) Source #

TupleOrUnary (a, b, c, d) (a, (b, (c, (d, ())))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, ())))) -> (a, b, c, d) Source #

weak_untuple :: (a, b, c, d) -> (a, (b, (c, (d, ())))) Source #

TupleOrUnary (a, b, c, d, e) (a, (b, (c, (d, (e, ()))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, ()))))) -> (a, b, c, d, e) Source #

weak_untuple :: (a, b, c, d, e) -> (a, (b, (c, (d, (e, ()))))) Source #

TupleOrUnary (a, b, c, d, e, f) (a, (b, (c, (d, (e, (f, ())))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, (f, ())))))) -> (a, b, c, d, e, f) Source #

weak_untuple :: (a, b, c, d, e, f) -> (a, (b, (c, (d, (e, (f, ())))))) Source #

TupleOrUnary (a, b, c, d, e, f, g) (a, (b, (c, (d, (e, (f, (g, ()))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, (f, (g, ()))))))) -> (a, b, c, d, e, f, g) Source #

weak_untuple :: (a, b, c, d, e, f, g) -> (a, (b, (c, (d, (e, (f, (g, ()))))))) Source #

TupleOrUnary (a, b, c, d, e, f, g, h) (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) -> (a, b, c, d, e, f, g, h) Source #

weak_untuple :: (a, b, c, d, e, f, g, h) -> (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) Source #

TupleOrUnary (a, b, c, d, e, f, g, h, i) (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) -> (a, b, c, d, e, f, g, h, i) Source #

weak_untuple :: (a, b, c, d, e, f, g, h, i) -> (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) Source #

TupleOrUnary (a, b, c, d, e, f, g, h, i, j) (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

weak_tuple :: (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) -> (a, b, c, d, e, f, g, h, i, j) Source #

weak_untuple :: (a, b, c, d, e, f, g, h, i, j) -> (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) Source #

class TupleOrUnary t s => Tuple t s | s -> t, t -> s where Source #

In almost all instances, the standard form can also be deduced from the tupled form; the only exception is the unary case. The Tuple class includes no new methods, adding just this functional dependency.

While the methods of Tuple are always copied from those of TupleOrUnary, they are renamed, so that use of these methods tells the type checker it can use the extra functional dependency.

Minimal complete definition

Nothing

Methods

tuple :: s -> t Source #

untuple :: t -> s Source #

Instances
Tuple () () Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: () -> () Source #

untuple :: () -> () Source #

Tuple (a, b) (a, (b, ())) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, ())) -> (a, b) Source #

untuple :: (a, b) -> (a, (b, ())) Source #

Tuple (a, b, c) (a, (b, (c, ()))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, ()))) -> (a, b, c) Source #

untuple :: (a, b, c) -> (a, (b, (c, ()))) Source #

Tuple (a, b, c, d) (a, (b, (c, (d, ())))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, ())))) -> (a, b, c, d) Source #

untuple :: (a, b, c, d) -> (a, (b, (c, (d, ())))) Source #

Tuple (a, b, c, d, e) (a, (b, (c, (d, (e, ()))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, ()))))) -> (a, b, c, d, e) Source #

untuple :: (a, b, c, d, e) -> (a, (b, (c, (d, (e, ()))))) Source #

Tuple (a, b, c, d, e, f) (a, (b, (c, (d, (e, (f, ())))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, (f, ())))))) -> (a, b, c, d, e, f) Source #

untuple :: (a, b, c, d, e, f) -> (a, (b, (c, (d, (e, (f, ())))))) Source #

Tuple (a, b, c, d, e, f, g) (a, (b, (c, (d, (e, (f, (g, ()))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, (f, (g, ()))))))) -> (a, b, c, d, e, f, g) Source #

untuple :: (a, b, c, d, e, f, g) -> (a, (b, (c, (d, (e, (f, (g, ()))))))) Source #

Tuple (a, b, c, d, e, f, g, h) (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) -> (a, b, c, d, e, f, g, h) Source #

untuple :: (a, b, c, d, e, f, g, h) -> (a, (b, (c, (d, (e, (f, (g, (h, ())))))))) Source #

Tuple (a, b, c, d, e, f, g, h, i) (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) -> (a, b, c, d, e, f, g, h, i) Source #

untuple :: (a, b, c, d, e, f, g, h, i) -> (a, (b, (c, (d, (e, (f, (g, (h, (i, ()))))))))) Source #

Tuple (a, b, c, d, e, f, g, h, i, j) (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) Source # 
Instance details

Defined in Quipper.Utils.Tuple

Methods

tuple :: (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) -> (a, b, c, d, e, f, g, h, i, j) Source #

untuple :: (a, b, c, d, e, f, g, h, i, j) -> (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, ())))))))))) Source #