-
Notifications
You must be signed in to change notification settings - Fork 13
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
Missing NFData instances #136
Comments
What instance in particular do you propose be added for |
OK. So this was a bit more involved than I originally thought, but not really too bad. Here is what I came up with: type family AllC c f xs where
AllC c f '[] = (() :: Constraint)
AllC c f (x : xs) = (c (f x), AllC c f xs)
instance (AllC NFData f sh) => NFData (List f sh) where
rnf Nil = ()
rnf (x :< xs) = rnf x `seq` rnf xs The auxiliary type family is annoying, but it seems generally useful in the context of this library anyway. An alternative is instance (forall s. NFData (f s)) => NFData (List f sh) where ... but that seems like it won't work for many structures, which would require some knowledge about instance (forall s. NFData s => NFData (f s), All NFData sh) => NFData (List f sh) where ... (for a suitable Maybe you could argue that clients should just write their own instance? But that's unsatisfying, because the instance would likely be an orphan. Or maybe the solution is to provide a I think if this were my library, I would write the first instance (exporting a suitably documented |
Right, those were the three options that I had in mind as well. The The reason why I'm hesitant to endorse that approach is that while it is in some sense the most powerful option, it doesn't quite fit the conventions used elsewhere in the library. For comparison, it's worth looking at the other instances for
Where From that perspective, my favorite of the three options is the |
That sounds reasonable to me, too. (For the record, the instance you propose fits my use case.) That said, I found |
Great! In that case, we should think carefully about whether we want to actually use quantified constraints to define
For what it's worth, the |
I missed |
I was surprised not to find an
NFData
instance forData.Parameterized.List.List
. Are there possibly otherNFData
instances also missing?The text was updated successfully, but these errors were encountered: