Hoogle Search

Within LTS Haskell 24.32 (ghc-9.10.3)

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

  1. toEnums :: (Enum a, Bits w) => T w a -> [a]

    enumset Data.EnumBitSet

    No documentation available.

  2. fromEnum :: (Enum a, Bits w) => a -> MaskedValue w a

    enumset Data.FlagSet

    fromEnum should return an integer that represents the position of the a value in the list of all enumeration items. In contrast to that, fromEnum must return the according bit pattern.

  3. fromEnum :: Enum a => a -> Int

    foundation Foundation

    Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.

  4. toEnum :: Enum a => Int -> a

    foundation Foundation

    Convert from an Int.

  5. data FiniteEnum

    generic-data Generic.Data

    Extends the StandardEnum option for GEnum to allow all constructors to have arbitrary many fields. Each field type must be an instance of both Enum and Bounded. Avoid fields of types Int and Word.

    Details

    Two restrictions require the user's attention:
    • The Enum instances of the field types need to start enumerating from 0. In particular, Int is an unfit field type, because the enumeration of the negative values starts before 0.
    • There can only be up to maxBound :: Int values (because the implementation represents the cardinality explicitly as an Int). This restriction makes Word an invalid field type as well. Notably, it is insufficient for each individual field types to stay below this limit. Instead it applies to the generic type as a whole.
    Elements are numbered by toEnum, from 0 up to (cardinality - 1). The resulting ordering matches the generic Ord instance defined by gcompare. The values from different constructors are enumerated sequentially.
    data Example = C0 Bool Bool | C1 Bool
    deriving (Eq, Ord, Show, Generic)
    
    cardinality = 6  -- 2    * 2    + 2
    -- Bool * Bool | Bool
    
    enumeration =
    [ C0 False False
    , C0 False  True
    , C0  True False
    , C0  True  True
    , C1 False
    , C1 True
    ]
    
    enumeration == map gtoFiniteEnum [0 .. 5]
    [0 .. 5] == map gfromFiniteEnum enumeration
    

  6. newtype FiniteEnumeration a

    generic-data Generic.Data

    Type with Enum instance derived via Generic with FiniteEnum option. This allows deriving Enum for types whose constructors have fields. Some caution is advised; see details in FiniteEnum.

    Example

    >>> :{
    data Booool = Booool Bool Bool
    deriving Generic
    deriving (Enum, Bounded) via (FiniteEnumeration Booool)
    :}
    

  7. FiniteEnumeration :: a -> FiniteEnumeration a

    generic-data Generic.Data

    No documentation available.

  8. class GEnum opts (f :: Type -> Type)

    generic-data Generic.Data

    Generic representation of Enum types. The opts parameter is a type-level option to select different implementations.

  9. data StandardEnum

    generic-data Generic.Data

    Standard option for GEnum: derive Enum for types with only nullary constructors (the same restrictions as in the Haskell 2010 report).

  10. conIdEnum :: Constructors a => [ConId a]

    generic-data Generic.Data

    All constructor identifiers.

    gconNum @a = length (conIdEnum @a)
    

Page 153 of many | Previous | Next