# discrete: replacement for enum

A `Discrete`

type is a set X with at least one element, along with two
functions,

and `succ`

:: X -> `Maybe`

X

,
such that all inhabitants of the set X can be constructed given at least
a single element of the set and these two functions. The following must hold:`pred`

:: X -> `Maybe`

X

`pred`

`>=>`

`succ`

`>=>`

`pred`

=`pred`

`succ`

`>=>`

`pred`

`>=>`

`succ`

=`succ`

This means that `Int`

is a discrete type, because given any x :: `Int`

, one
can construct any other `Int`

with the following functions:

`succ`

x = if x`==`

`maxBound`

then`Nothing`

else`Just`

(x`+`

1)

`pred`

x = if x`==`

`minBound`

then`Nothing`

else`Just`

(x`-`

1)

This also means that something like `Double`

is *not* a discrete type, because
there are no such functions `succ`

and `pred`

that given any value of type `Double`

can allow the construction of all values of type `Double`

.

`Discrete`

acts as a replacement for `GHC.Enum.Enum`

. The motivation for
`Discrete`

is two-fold: firstly, totality of all typeclass instances, and
secondly, that `GHC.Enum.Enum`

is a typeclass that does too many things,
and does them poorly. If `succ`

or `pred`

are called on `maxBound`

or `minBound`

, respectively, the result will be `Nothing`

.

## Downloads

- discrete-0.1.0.0.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

#### Maintainer's Corner

For package maintainers and hackage trustees

Candidates

- No Candidates

Versions [RSS] | 0.1.0.0 |
---|---|

Change log | ChangeLog.md |

Dependencies | base (>=4.7 && <4.13) [details] |

License | BSD-3-Clause |

Author | chessai |

Maintainer | chessai1996@gmail.com |

Revised | Revision 1 made by chessai at 2018-09-17T18:35:30Z |

Category | Data |

Home page | https://github.com/chessai/discrete |

Uploaded | by chessai at 2018-09-17T17:24:12Z |

Distributions | |

Reverse Dependencies | 1 direct, 0 indirect [details] |

Downloads | 768 total (7 in the last 30 days) |

Rating | (no votes yet) [estimated by Bayesian average] |

Your Rating | |

Status | Docs available [build log] Last success reported on 2018-09-17 [all 2 reports] |