Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a SmallBounded type #38

Open
bbarker opened this issue Jul 10, 2019 · 0 comments
Open

Consider a SmallBounded type #38

bbarker opened this issue Jul 10, 2019 · 0 comments
Labels
status: needs more info This issue needs more info before any action can be done.

Comments

@bbarker
Copy link

bbarker commented Jul 10, 2019

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
@JordanMartinez JordanMartinez added the status: needs more info This issue needs more info before any action can be done. label Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info This issue needs more info before any action can be done.
Projects
None yet
Development

No branches or pull requests

2 participants