prelude-safeenum: A redefinition of the Prelude's Enum class in order to render it safe.

[ bsd3, library, prelude ] [ Propose Tags ] [ Report a vulnerability ]

A redefinition of the Prelude's Enum class in order to render it safe. That is, the Haskell Language Report defines pred, succ, fromEnum, and toEnum to be partial functions when the type is Bounded, but this is unacceptable. We define a new type-class hierarchy for enumeration which is safe and also generalizes to cover types which can only be enumerated in one direction.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.0.1, 0.1.1, 0.1.1.1, 0.1.1.2, 0.1.1.3
Change log CHANGELOG
Dependencies base (>=4 && <5) [details]
Tested with ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.4, ghc ==8.10.3, ghc ==9.0.1
License BSD-3-Clause
Copyright Copyright (c) 2012–2021 wren gayle romano
Author wren gayle romano
Maintainer wren@cpan.org
Category Prelude
Home page https://wrengr.org/software/hackage.html
Bug tracker https://github.com/wrengr/prelude-safeenum/issues
Source repo head: git clone https://github.com/wrengr/prelude-safeenum.git
Uploaded by WrenRomano at 2021-10-18T05:59:28Z
Distributions LTSHaskell:0.1.1.3, NixOS:0.1.1.3, Stackage:0.1.1.3
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 5390 total (21 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-10-18 [all 1 reports]

Readme for prelude-safeenum-0.1.1.3

[back to package description]

prelude-safeenum

Hackage version Build Status Dependencies

A redefinition of the Prelude's Enum class in order to render it safe. That is, the Haskell Language Report defines pred, succ, fromEnum, and toEnum to be partial functions when the type is Bounded. This is unacceptable. We define a new type-class hierarchy for enumeration which is safe and also generalizes to cover types which can only be enumerated in one direction.

Install

This is a very simple package and should be easy to install. You should be able to use the standard:

$> cabal install prelude-safeenum

Portability

An attempt has been made to keep this library portable; however, it does rely on a few language extensions. All the required language extensions are:

  • CPP
  • GeneralizedNewtypeDeriving
  • MagicHash - only for GHC
  • Trustworthy - only for GHC >= 7.1

The GeneralizedNewtypeDeriving extension is used for brevity in Data.Number.CalkinWilf. If you'd like to use this package with a compiler that does not support that extension, contact the maintainer and it can be removed.

This package is only "Trustworthy" rather than "Safe" for two reasons: (1) Data.Number.CalkinWilf uses GeneralizedNewtypeDeriving, and (2) Prelude.SafeEnum imports GHC.Exts for build/foldr fusion and for the Char instances.