-
Notifications
You must be signed in to change notification settings - Fork 6
Is the class definition of Dict
too restrictive?
#17
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
Comments
Can you say more about why you are wanting a type like this:
to fit an interface like this?
Also happy to chat on a call if that's less time consuming for you. |
Ah, I take it the |
I think I am getting it now. |
This just started with wanting to use the overloaded |
Ok let's chat about this, tomorrow, and quickly, if possible :) |
The definition of the
Dict
class mandates aToIter (k ∧ x) (d x)
superclass.While this makes some sense, it prevents writing an instance for e.g.:
since its
ToIter
instance ought to look likeToIter (k ∧ (x ∧ x)) (Dict k x)
.Unfortunately, the Haskell type system makes it unpleasant to try and introduce a type abstraction like:
since
v
cannot be the identity on types, or a non-fully-applied type synonym, which forces using anewtype
likeIdentity
, which makes everything worse.I am locally testing out an approach where we would remove the item type of collections from the type of classes like
ToIter
,Single
, etc., instead favoring an associated type family:It seems to work, though it sometimes need to manipulate explicit type equalities to match was was once achieved via unification, e.g.:
It also highlights that there needs to be a different notion for items as can be inserted in the data structure, and items as can be retrieved from the data structure. For list-likes, these notions match, but for dict-likes, they are distinct:
So you end up with:
I am still working out the details of how such a change would alter the type signature of the
Dict
class, it's definitely quite the change, so might not be desirable.There is an also in-between approach where we leave
ToIter
and such as they are, and bring the associated type family only forDict
, if that would be more acceptable.The text was updated successfully, but these errors were encountered: