[vector] #54: Missing NFData instances for vector types
vector
vector at projects.haskell.org
Sun Jan 29 13:28:29 GMT 2012
#54: Missing NFData instances for vector types
------------------------+---------------------------------------------------
Reporter: hvr | Owner:
Type: enhancement | Status: reopened
Priority: blocker | Milestone: 0.10
Version: 0.7 | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment(by basvandijk):
Replying to [comment:22 rl]:
> That's the question. Having the dependency (or a type function) probably
makes more sense for things that actually live in monads. But as hvr
points out, you might also want to have something like this:
>
> {{{
> instance NFDataM [a] m
> }}}
Why should you want to do that? If you want to force immutable data use
`rnf`, if you want to force mutable data in its associated monad use
`rnfM`.
> Then there is also the question of what to do with monad transformers.
This seems like a not entirely trivial design question, perhaps it's worth
discussing on the libraries list.
Yes, I think that's a good idea.
BTW my last example wasn't fully correct and general enough. It should be:
{{{
instance (NFData a, PrimMonad m, s ~ PrimState m) => NFDataM (MVector s
a) m where
rnfM (MVector i n arr) = force i
where
force !ix | ix < n = do x <- readArray arr ix
rnf x `seq` force (ix+1)
| otherwise = return ()
}}}
(Note that this requires `UndecidableIntances`)
--
Ticket URL: <http://trac.haskell.org/vector/ticket/54#comment:23>
vector <http://trac.haskell.org/vector>
Package vector
More information about the vector
mailing list