-
Notifications
You must be signed in to change notification settings - Fork 19
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
Finite types can be ordered #56
Comments
What are you proposing? |
@phadej, I'm proposing to add the ability to make a newtype DefaultFiniteOrdered a = DO Int deriving (Eq, Ord)
defaultFiniteOrdering :: Finite a => Iso' a (DefaultFiniteOrdered a)
defaultFiniteOrdering = iso f g
where
f a = DO (fromJust (elemIndex a universeF))
g (DO i) = universeF !! i |
I think I lack some context |
I'm also worried about adding something as strict as
I understand that its also often useful to have something like |
Users who want this can do it themselves, though, right?
Is that actually more code than what they would have to do with your proposal? It seems like it can't be much more than one or two extra lines, if any; the |
Every finite type can be ordered (somehow). Here's one way to express that:
Another option would be to allow an arbitrary
Iso'
betweena
and a (possibly very different)Ordered a
, which might be better if the ordering onOrdered a
can't be expressed efficiently by directly comparing elements ofa
.The text was updated successfully, but these errors were encountered: