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 'Whnf{,1,2}' (or some better name) newtype #78

Open
Icelandjack opened this issue Mar 23, 2022 · 3 comments
Open

Add 'Whnf{,1,2}' (or some better name) newtype #78

Icelandjack opened this issue Mar 23, 2022 · 3 comments

Comments

@Icelandjack
Copy link

newtype Whnf a = Whnf a
newtype Whnf1 f a = Whnf1 (f a)
newtype Whnf2 bi a b = Whnf2 (bi a b)

instance NFData (Whnf a) where rnf (Whnf a) = a `seq` ()
instance NFData1 (Whnf1 f) where liftRnf _ (Whnf1 as) = as `seq` ()
instance NFData2 (Whnf2 bi) where liftRnf2 _ _ (Whnf2 as) = as `seq` ()
@Icelandjack
Copy link
Author

As well as

newtype Rnf1 f a = Rnf1 (f a)

instance (NFData1 f, NFData a) => NFData (Rnf1 f a) where
  rnf (Rnf1 as) = rnf1 as

@mixphix
Copy link
Collaborator

mixphix commented Jan 29, 2023

You want a newtype instance that will prevent NFData from fully evaluating it?

@treeowl
Copy link
Contributor

treeowl commented Apr 3, 2023

I think the nf package may have some stuff like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants