Safe Haskell | None |
---|---|

Language | Haskell2010 |

Injective types. This module contains the `Injective`

typeclass and instances
for the following equivalence classes:

`{Strict Text, Lazy Text, String}`

.`ByteString`

s are not part of this, since there is more than one way to turn unicode text into a ByteString (see Data.Text.Encoding and Data.Text.Lazy.Encoding).`{Whole, Integer}`

. Be advised, though, that Peano numbers may contain unobservable infinities (i.e.`infinity = S infinity`

) and thus, the conversion to Integer may not terminate.`{Nat, Natural}`

. For finite values, they're extensionally equivalent, but`Nat`

has lazy infinity.`{Seq a, Vector a}`

. Supports all kinds of immutable vectors of elements: boxed, unboxed, primitive, storable.`[a]`

is not part of this, as typeclass`IsList`

provides`fromList`

and`toList`

.

Additional injections:

# Documentation

class Injective a b where Source #

The class relation between types `a`

and `b`

s.t. `a`

can be injected
into `b`

.

The following laws must be fulfilled:

`Injectivity`

x /= y ==> (to x) /= (to y)

`Totality`

`to`

should be a total function. No cheating by it undefined for parts of the set!

to :: forall b1 a1. (b1 ~ b, a1 ~ a) => a -> b Source #

Converts a value of type `a`

"losslessly" to one of type `b`

.

## Instances

Injective Integer Rational Source # | |

Injective Integer Whole Source # | |

Injective Natural Integer Source # | |

Injective Natural Rational Source # | |

Injective Natural Nat Source # | |

Injective Natural Whole Source # | |

Injective a a Source # | |

Defined in Data.Types.Injective | |

Injective String Text Source # | |

Injective String Text Source # | |

Injective Nat Integer Source # | |

Injective Nat Natural Source # | |

Injective Nat Rational Source # | |

Injective Nat Whole Source # | |

Injective Whole Integer Source # | |

Injective Whole Rational Source # | |

Injective Text String Source # | |

Injective Text Text Source # | |

Injective Text String Source # | |

Injective Text Text Source # | |

Vector v a => Injective (v a) (Seq a) Source # | |

Vector v a => Injective (Seq a) (v a) Source # | |

Default a => Injective (Maybe b) (Either a b) Source # | |