Open
Description
As an alternative to #35 that is a bit easier to deal with but slightly less safe (though unless you are doing some crazy stuff, should be fine most of the time), I would like to ask if we could do the following, and thus resurrect e.g. boundedEnumMaybe
:
-- | A lawful class to denote Cardinality a << Cardinality Int
class Bounded a <= SmallBounded a
instance boundedEnumMaybe :: (SmallBounded a, BoundedEnum a)
=> BoundedEnum (MaybeWrapped a) where
cardinality = Cardinality $ unwrap (cardinality :: Cardinality a) + 1
toEnum 0 = wrap Nothing
toEnum n = wrap $ Just <$> toEnum (n - 1)
fromEnum Nothing = 0
fromEnum (Just e) = fromEnum e + 1