<div dir="ltr">A hand-written read makes more sense to me in this case:<div><br></div><div>read = makeNF . read<br></div><div>show = show . getNF</div><div><br></div><div>Other instances where a "new value" is created can be written similarly:</div><div><br></div><div>instance (Monoid m) => Monoid (NF m) where</div><div>  mempty = makeNF mempty</div><div>  mappend aNF bNF = makeNF (mappend (getNF aNF) (getNF bNF))</div><div><br></div><div>Whether the pattern of using NF this way is a good idea... I don't know. It just seems nice if data of type `NF a` can be used as a drop-in replacement for data of type `a`.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">-- Dan Burton</div></div>
<br><div class="gmail_quote">On Wed, Apr 22, 2015 at 1:10 AM, Michael Snoyman <span dir="ltr"><<a href="mailto:michael@snoyman.com" target="_blank">michael@snoyman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Only thing I can think of is adding a bunch of `deriving`s to NF. I can picture people wanting to just plot an `NF` into the middle of their data structures and still be able to `show` it for debugging. I'm guessing a minimal list may be Show, Read, Eq, Ord, Typeable. Data and Generic seem like an interesting case, since- on the one hand- it would be nice to have the instances (especially the latter) for auto-deriving mechanisms, but in theory it can be used to break the abstraction. However, given that you're already giving people an escape route via the .Internal module, I don't think that's as big a concern.</div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote">On Wed, Apr 22, 2015 at 11:04 AM Edward Z. Yang <<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That's what I get for guessing syntax. Fixed.<br>
<br>
Edward<br>
<br>
Excerpts from Michael Snoyman's message of 2015-04-22 08:54:32 +0100:<br>
> Small request: could you bump the upper bound to allow base 4? ;)<br>
><br>
> On Wed, Apr 22, 2015 at 10:50 AM Edward Z. Yang <<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>> wrote:<br>
><br>
> > Hello all,<br>
> ><br>
> > Taking the appropriate suggestion, I have created a small<br>
> > package to provide this functionality:<br>
> ><br>
> >     <a href="https://hackage.haskell.org/package/nf" target="_blank">https://hackage.haskell.org/package/nf</a><br>
> ><br>
> > If it migrates into deepseq, we can update this package to reexport<br>
> > the appropriate modules from deepseq when it is available.<br>
> ><br>
> > Please let me know if there's anything (e.g. version bounds) which<br>
> > I can do to make this more "enterprise" ready.<br>
> ><br>
> > Cheers,<br>
> > Edward<br>
> ><br>
> > Excerpts from Edward Z. Yang's message of 2015-02-10 08:46:37 +0000:<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>
> > >     instance NFData (NF a) where<br>
> > >         rnf x = x `seq` ()<br>
> > ><br>
> > > NF is an abstract data type representing data which has been evaluated<br>
> > > to normal form; the guarantee specifically is, if NF is in whnf, then<br>
> > > it is in nf.  Crucially, when we have 'NF a', we ONLY need to seq it<br>
> > > in order to assure that it is fully evaluated.<br>
> > ><br>
> > > This guarantee is sufficient for a variety of cases where<br>
> > > normal data is necessary, e.g. when transmitting data over Channels.<br>
> > > For example, from the monad-par library 'put_' could be used in place<br>
> > > of 'put' with this type signature.<br>
> > ><br>
> > >     put_ :: IVar (NF a) -> (NF a) -> Par ()<br>
> > ><br>
> > > Cheers,<br>
> > > Edward<br>
> > _______________________________________________<br>
> > Libraries mailing list<br>
> > <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
> ><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>