Hoogle Search

Within LTS Haskell 24.38 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. package prelude-safeenum

    A redefinition of the Prelude's Enum class in order to render it safe. 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.

  2. module Prelude.SafeEnum

    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[1], but this is unacceptable. So these classes are offered as a replacement, correcting the types of those functions. We intentionally clash with the names of the Prelude's class; if you wish to use both in the same file, then import this module (or the Prelude) qualified. While we're at it, we also generalize the notion of enumeration. Rather than requiring that the type is linearly enumerable, we distinguish between forward enumeration (which allows for multiple predecessors) and backward enumeration (which allows for multiple successors). Moreover, we do not require that the enumeration order coincides with the Ord ordering (if one exists), though it's advisable that they do (for your sanity). However, we also ensure that the notion of enumeration (in either direction) is well-defined, which rules out instances for Float and Double, and renders instances for Ratio problematic. Ratio instances can be provided so long as the base type is integral and enumerable; but they must be done in an obscure order[2] that does not coincide with Ord. Since this is not what people may expect, we only provide an instance for the newtype CalkinWilf, not for Ratio itself. The MagicHash extension is only actually required if on GHC. This extension is used only so that the implementation of the instances for Char match those of the Prelude's Enum. I have not benchmarked to determine whether this low-level hackery is actually still necessary.

  3. class DownwardEnum a

    prelude-safeenum Prelude.SafeEnum

    A class for downward enumerable types. That is, we can enumerate smaller and smaller values, eventually getting every one of them; i.e., given any x, for all y such that y `precedes` x, it must be the case that y occurs within some finite prefix of enumDownFrom x. We require that precedes forms a strict partial order. That is, it must obey the following laws (N.B., if the first two laws hold, then the third one follows for free):

    if x `precedes` y && y `precedes` z then x `precedes` z
    if x `precedes` y then not (y `precedes` x)
    not (x `precedes` x)
    
    Moreover, we require that precedes agrees with pred, and that pred is exhaustive for precedes (assuming Eq a, by magic if need be):
    if pred x == Just y then y `precedes` x
    if x `precedes` y   then x `elem` enumDownFrom y
    
    Minimal complete definition: pred, precedes.

  4. class UpwardEnum a

    prelude-safeenum Prelude.SafeEnum

    A class for upward enumerable types. That is, we can enumerate larger and larger values, eventually getting every one of them; i.e., given any x, for all y such that y `succeeds` x, it must be the case that y occurs within some finite prefix of enumFrom x. We require that succeeds forms a strict partial order. That is, it must obey the following laws (N.B., if the first two laws hold, then the third one follows for free):

    if x `succeeds` y && y `succeeds` z then x `succeeds` z
    if x `succeeds` y then not (y `succeeds` x)
    not (x `succeeds` x)
    
    Moreover, we require that succeeds agrees with succ, and that succ is exhaustive for succeeds (assuming Eq a, by magic if need be):
    if succ x == Just y then y `succeeds` x
    if x `succeeds` y   then x `elem` enumFrom y
    
    Minimal complete definition: succ, succeeds.

  5. fromEnum :: Enum a => a -> Maybe Int

    prelude-safeenum Prelude.SafeEnum

    Convert to an Int.

  6. toEnum :: Enum a => Int -> Maybe a

    prelude-safeenum Prelude.SafeEnum

    Convert from an Int.

  7. protoEnum :: MessageEnum a => ReadM a

    proto-lens-optparse Data.ProtoLens.Optparse

    An optparse-applicative ReadM for an enum name or number.

  8. FeatureSet'ENUM_TYPE_UNKNOWN :: FeatureSet'EnumType

    proto-lens-protobuf-types Proto.Google.Protobuf.Descriptor

    No documentation available.

  9. data FeatureSet'EnumType

    proto-lens-protobuf-types Proto.Google.Protobuf.Descriptor

    No documentation available.

  10. data FeatureSet'EnumType

    proto-lens-protobuf-types Proto.Google.Protobuf.Descriptor

    No documentation available.

Page 307 of many | Previous | Next