Proposal: Add an analogue of $! to deepseq

Malcolm Wallace malcolm.wallace at
Fri Jul 1 10:40:34 CEST 2011

> ($!!) :: (NFData a) => (a -> b) ->a -> b
> f $!! x = x `deepseq` f x

Could be useful.

> force :: (NFData a) => a -> a
> force x = x `deepseq` x

I'm not convinced this forces x at the point where you want it to.  For instance,

    foldlw f a (x:xs) = foldlw f (force (f a x)) xs

would not give you the foldl' you might be looking for - indeed it is identical to the space-leaking foldl, apart from the extra class constraint.


More information about the Libraries mailing list