Open
Description
With type-level ints, we can actually specify what the bounds are for a given type. For example...
class (Bounded a, Enum a) <= BoundedEnumTL min step max a where
toEnumTL :: Proxy Int -> a
This would enable one to use toEnum
without incurring the Maybe
wrapper.
instance BoundedEnumTL 0 1 23 Hour where
toEnumTL p = Hour $ reflectType p
-- cardinality could likely be calculated
cardinalityTL :: BoundedEnumTL min step max => ... => Proxy Int
toEnumTL (Proxy :: Proxy 4) == Hour 4
toEnumTL (Proxy :: Proxy 26) -- compiler error
See also purescript/purescript-datetime#96
Metadata
Metadata
Assignees
Labels
No labels