Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Add NFData instances to Closure #4

Closed
wants to merge 2 commits into from

Conversation

qnikst
Copy link
Contributor

@qnikst qnikst commented Mar 18, 2015

No description provided.

@facundominguez
Copy link
Contributor

What is this needed for?

Also, the NFData instance is not forcing the arguments of the Closure data constructor.

@@ -348,6 +349,8 @@ instance Typeable a => Binary (Closure a) where
put (Closure static env) = put static >> put env
get = Closure <$> get <*> get

instance NFData (Closure a) where rnf x = x `seq` ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting something like:

instance NFData (Closure a) where rnf (Closure st b) = rnf st `seq` rnf b

@qnikst
Copy link
Contributor Author

qnikst commented Mar 18, 2015

This instance is required in order to write correct NFData instances in order packages, namely distributed-process-extra.

@qnikst
Copy link
Contributor Author

qnikst commented Mar 30, 2015

@facundominguez can you recheck this Pull request?

@qnikst
Copy link
Contributor Author

qnikst commented Mar 30, 2015

According to travis it doesn't work for 7.4 because ByteString.Lazy do not have NFData instance. The only way to fix it is to add a condition on the ByteString version and manyally force all chunks by taking length, or forbid old versions.

@@ -257,10 +258,17 @@ data StaticLabel =
| StaticApply StaticLabel StaticLabel
deriving (Eq, Ord, Typeable, Show)

instance NFData StaticLabel where
rnf (StaticLabel s) = rnf s `seq` ()
rnf (StaticApply a b) = rnf a `seq` rnf b `seq` ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- rnf (StaticApply a b) = rnf a `seq` rnf b `seq` ()
+ rnf (StaticApply a b) = rnf a `seq` rnf b

@facundominguez
Copy link
Contributor

add a condition on the ByteString version and manually force all chunks by taking length

I'd prefer this.

@qnikst
Copy link
Contributor Author

qnikst commented Mar 30, 2015

@facundominguez comments were addressed and now PR pass tests.

@facundominguez
Copy link
Contributor

Merged as feef72e.

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

Successfully merging this pull request may close these issues.

2 participants