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.
toEnums :: (Enum a, Bits w) => T w a -> [a]enumset Data.EnumBitSet No documentation available.
fromEnum :: (Enum a, Bits w) => a -> MaskedValue w aenumset 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.
fromEnum :: Enum a => a -> Intfoundation 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.
-
foundation Foundation Convert from an Int.
-
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.
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
-
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) :} FiniteEnumeration :: a -> FiniteEnumeration ageneric-data Generic.Data No documentation available.
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.
-
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).
conIdEnum :: Constructors a => [ConId a]generic-data Generic.Data All constructor identifiers.
gconNum @a = length (conIdEnum @a)