Closed chshersh closed 6 years ago
@neongreen @int-index Could you please comment on this?
I do not have a strong opinion either way. An associated type family should work for this use case.
One more reason to have associated type family:
We can implement WrappedList
wrapper in more general way:
newtype WrappedList t = WrappedList t
instance ToList t => ToList (WrappedList t) where
type Element (WrappedList t) = Element t
Now it's not possible because of conflicting instance:
type instance Element (f a) = a
type instance Element (f a) = a
Do we have this instance at top level at the moment? Yes, it should be made into a default definition of the associated type family.
It's not possible to implement this in current universum
design because we have {-# OVERLAPPABLE #-}
instance and open type families can't be overlappable (as @int-index explained me). Related SO question:
It was suggested under comments to this answer on SO.