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.
gtoEnum :: (Generic a, GEnum StandardEnum (Rep a)) => Int -> ageneric-data Generic.Data Generic toEnum generated with the StandardEnum option.
instance Enum MyType where toEnum = gtoEnum fromEnum = gfromEnum enumFrom = genumFrom enumFromThen = genumFromThen enumFromTo = genumFromTo enumFromThenTo = genumFromThenTo
gtoFiniteEnum :: (Generic a, GEnum FiniteEnum (Rep a)) => Int -> ageneric-data Generic.Data Generic toEnum generated with the FiniteEnum option.
instance Enum MyType where toEnum = gtoFiniteEnum fromEnum = gfromFiniteEnum enumFrom = gfiniteEnumFrom enumFromThen = gfiniteEnumFromThen enumFromTo = gfiniteEnumFromTo enumFromThenTo = gfiniteEnumFromThenTo
-
generic-data Generic.Data.Internal.Enum 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
class
GEnum opts (f :: Type -> Type)generic-data Generic.Data.Internal.Enum Generic representation of Enum types. The opts parameter is a type-level option to select different implementations.
-
generic-data Generic.Data.Internal.Enum Standard option for GEnum: derive Enum for types with only nullary constructors (the same restrictions as in the Haskell 2010 report).
gFromEnum :: GEnum opts f => f p -> Intgeneric-data Generic.Data.Internal.Enum No documentation available.
gToEnum :: GEnum opts f => Int -> f pgeneric-data Generic.Data.Internal.Enum No documentation available.
genumFrom :: (Generic a, GEnum StandardEnum (Rep a)) => a -> [a]generic-data Generic.Data.Internal.Enum Generic enumFrom generated with the StandardEnum option. See also gtoEnum.
genumFrom' :: forall opts a . (Generic a, GEnum opts (Rep a)) => a -> [a]generic-data Generic.Data.Internal.Enum Generic enumFrom. Use genumFrom or gfiniteEnumFrom instead.
genumFromThen :: (Generic a, GEnum StandardEnum (Rep a)) => a -> a -> [a]generic-data Generic.Data.Internal.Enum Generic enumFromThen generated with the StandardEnum option. See also gtoEnum.