<div dir="ltr">Forgot to mention: I'm +1 on the proposal in general, though it would be nice if these types/functions were available from a compatibility library as well, since deepseq is now bundled with GHC and therefore difficult to upgrade on its own.<br></div><br><div class="gmail_quote">On Tue Feb 10 2015 at 1:43:52 PM Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote">On Tue Feb 10 2015 at 1:41:48 PM Herbert Valerio Riedel <<a href="mailto:hvr@gnu.org" target="_blank">hvr@gnu.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2015-02-10 at 09:46:37 +0100, Edward Z. Yang wrote:<br>
> I propose the following (abstract) data type, functions, and instance be<br>
> added to deepseq (naming amenable to bikeshedding):<br>
><br>
>     newtype NF a = NF a -- abstract<br>
>     makeNF :: NFData a => a -> NF a<br>
>     getNF :: NF a -> a<br>
<br>
>     instance NFData (NF a) where<br>
>         rnf x = x `seq` ()<br>
<br>
I generally like it, so count me as +1<br>
<br>
bikeshed-wondering though, why did you make it abstract w/ separate<br>
construct/deconstructors?<br>
<br>
<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>If the real constructor was available, then someone would be free to write something like:</div><div><br></div><div>    let foo = NF $ 1 : undefined</div><div><br></div><div>which would break the guarantees that this type is trying to provide.</div></div></div><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
as a related concept (and hoping not to derail the discussion too much),<br>
I had attempted some time ago to implement TH predicates  that could<br>
infer if WHNF=NF holds:<br>
<br>
 <a href="http://hackage.haskell.org/package/deepseq-th-0.1.0.4/docs/Control-DeepSeq-TH.html#v:typeWhnfIsNf" target="_blank">http://hackage.haskell.org/<u></u>pa<u></u>ckage/deepseq-th-0.1.0.4/<u></u>docs/<u></u>Control-DeepSeq-TH.html#<u></u>v:<u></u>typeWhnfIsNf</a><br>
<br>
and back then I was wondering, if GHC couldn't help us out here (maybe<br>
by providing an implicit NF=WHNF class-instance -- and btw, I recently<br>
found out, Haskell 1.4 had an implicit 'Eval'-class declaring<br>
`seq`-ability)<br>
<br>
I'm not sure though if WHNF=NF can always be decided...<br>
<br>
<br>
Cheers,<br>
  hvr<br>
______________________________<u></u><u></u>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/<u></u>mailman<u></u>/listinfo/libraries</a><br>
</blockquote></div></div></blockquote></div>