Proposal: Add an analogue of $! to deepseq

Simon Marlow marlowsd at gmail.com
Thu Jul 7 14:34:39 CEST 2011


On 01/07/2011 08:55, Ivan Lazar Miljenovic wrote:
> I propose we add a operator - tentatively labelled $!! (and which
> Hayoo reports isn't currently exported by a Hackage package) - as a
> deepseq analogue $! to the deepseq library:
>
> ($!!) :: (NFData a) =>  (a ->  b) ->a ->  b
> f $!! x = x `deepseq` f x
>
> infixr 0 $!!

+1

> As a sub-proposal, I also propose that we add a "force" function (the
> name of which also seems to be unused) to make it easier to test
> forcing of values:
>
> force :: (NFData a) =>  a ->  a
> force x = x `deepseq` x

Yes, this is what I called "deep" in my parallelism tutorial [1], but 
"force" is a better name.  If it goes in, I'll update the tutorial.

Cheers,
	Simon

[1] http://community.haskell.org/~simonmar/par-tutorial.pdf



More information about the Libraries mailing list