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

Add `rwhnf` helper for NF=WHNF instances #3

hvr opened this issue Nov 15, 2014 · 2 comments


Copy link

commented Nov 15, 2014

Here's an idea for a helper I wanted to document:

-- | Reduce to weak head normal form
-- Useful for defining 'NFData' for types for which NF=WHNF holds.
-- > data T = C1 | C2 | C3
-- > instance NFData T where rnf = rwhnf
rwhnf :: a -> ()
rwhnf !_ = ()

@hvr hvr added the enhancement label Nov 17, 2014


This comment has been minimized.

Copy link

commented Feb 18, 2016

As of GHC 8.0, it would be possible to enforce such a property via GHC generics!


This comment has been minimized.

Copy link

commented Feb 18, 2016

Actually, you may even be able to automatically choose from between deep and shallow seq (although I don't quite know how to deal with the Rec0 case while avoiding potentially sending the typechecker into a loop):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.