-
Notifications
You must be signed in to change notification settings - Fork 178
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
NFData1,NFData2 instances (#767) #992
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,7 +294,7 @@ import Data.Semigroup (Semigroup((<>))) | |
import Data.Semigroup (stimesIdempotentMonoid) | ||
import Data.Functor.Classes | ||
|
||
import Control.DeepSeq (NFData(rnf)) | ||
import Control.DeepSeq (NFData(rnf),NFData1(liftRnf)) | ||
import Data.Bits | ||
import qualified Data.Foldable as Foldable | ||
import Data.Maybe (fromMaybe) | ||
|
@@ -518,6 +518,14 @@ instance NFData a => NFData (IntMap a) where | |
rnf (Tip _ v) = rnf v | ||
rnf (Bin _ l r) = rnf l `seq` rnf r | ||
|
||
-- | @since 0.7.1 | ||
instance NFData1 IntMap where | ||
liftRnf rnfx = go | ||
where | ||
go Nil = () | ||
go (Tip _ v) = rnfx v | ||
go (Bin _ l r) = go l `seq` go r | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use a helper function to allow this to inline? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added one here - but possibly there are other instances that could benefit? Also not sure if there's any need for any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably wouldn't add pragmas for this. The function is small enough that I'd expect GHC to do a decent job of deciding when to inline it. Letting others inline would probably be good too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's now done for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like it would be a good to have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @meooow25 , that sounds clever. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to see if this exists in/could be added to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened haskell/deepseq#105 |
||
#if __GLASGOW_HASKELL__ | ||
|
||
{-------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data.Graph
could be misunderstood,SCC
got the instance (notGraph
). AndIntSet
is not affected.We can also just drop the
Data.
and say "...forIntMap
,Map
,Set
,Tree
,SCC
", I think that's good enough.