<div dir="ltr">i dont think it would be unsafe relative to unsafe haskell, merely unsafe wrt the semantical guarantees of the NF type </div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 10, 2015 at 12:08 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1, generally. Two thoughts:<br>
<br>
1. There are, as far as I know, two reasonable senses of NF that one<br>
might care about. The weak sense is a guarantee that the structure has<br>
no accessible bottoms within it that would be reached if the structure<br>
were evaluated to normal form, along with a guarantee that it is<br>
impossible to use it to force lazy IO. A stronger sense offers some<br>
kind of performance guarantee, which seems much trickier to specify.<br>
Whether something is *actually* in normal form is not observable<br>
without using something like ticky-ticky profiling, so I don't think<br>
we're allowed to care about that. Since I support the idea of<br>
unsafeMakeNF, and perhaps other special NF-creation functions, I think<br>
it's important to be clear about just what it's supposed to mean.<br>
<br>
2. I think it makes a lot of sense to put unsafeMakeNF into a separate<br>
Unchecked module, presumably declared unsafe for Safe Haskell.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Feb 10, 2015 at 6:45 AM, Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>> wrote:<br>
> Forgot to mention: I'm +1 on the proposal in general, though it would be<br>
> nice if these types/functions were available from a compatibility library as<br>
> well, since deepseq is now bundled with GHC and therefore difficult to<br>
> upgrade on its own.<br>
><br>
> On Tue Feb 10 2015 at 1:43:52 PM Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>><br>
> wrote:<br>
>><br>
>> On Tue Feb 10 2015 at 1:41:48 PM Herbert Valerio Riedel <<a href="mailto:hvr@gnu.org">hvr@gnu.org</a>><br>
>> wrote:<br>
>>><br>
>>> On 2015-02-10 at 09:46:37 +0100, Edward Z. Yang wrote:<br>
>>> > I propose the following (abstract) data type, functions, and instance<br>
>>> > 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>
>><br>
>> If the real constructor was available, then someone would be free to write<br>
>> something like:<br>
>><br>
>>     let foo = NF $ 1 : undefined<br>
>><br>
>> which would break the guarantees that this type is trying to provide.<br>
>><br>
>>><br>
>>> 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>
>>><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/package/deepseq-th-0.1.0.4/docs/Control-DeepSeq-TH.html#v: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>
>>> _______________________________________________<br>
>>> Libraries mailing list<br>
>>> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
>>> <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
><br>
><br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>