Proposal: NF newtype

Edward Z. Yang ezyang at mit.edu
Wed Apr 22 20:38:34 UTC 2015


OK, perhaps not :)

Edward

Excerpts from Roman Cheplyaka's message of 2015-04-22 21:28:10 +0100:
> On 22/04/15 21:54, Edward Z. Yang wrote:
> > But it is an interesting question whether or not 'UnsafeNF' should be
> > used, since the value read in is known to be in normal form.
> 
> Is it?
> 
> newtype X = X Int
>   deriving Show
> instance Read X where
>   readsPrec n = map (first $ X . trace "eval") . readsPrec n
> 
> > length (read "[1,2,3]" :: [X])
> 3
> > read "[1,2,3]" :: [X]
> [X eval
> 1,X eval
> 2,X eval
> 3]
> 
> Or did you mean something else?
> 
> > Excerpts from Henning Thielemann's message of 2015-04-22 19:49:56 +0100:
> >>
> >> On Wed, 22 Apr 2015, Dan Burton wrote:
> >>
> >>> A hand-written read makes more sense to me in this case:
> >>> read = makeNF . read
> >>> show = show . getNF
> >>
> >> Show and Read instances should process Strings representing Haskell code, 
> >> and I guess, Haskell code with the same type as the represented value. 
> >> Thus the NF should be part of the formatted value.
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> > 


More information about the Libraries mailing list