[Fwd: Re: [Haskell-cafe] Implicit newtype unwrapping]

Holger Siegel holgersiegel74 at yahoo.de
Thu Dec 3 05:47:07 EST 2009


Am Donnerstag, den 03.12.2009, 01:40 +0100 schrieb Sjoerd Visscher:
> The idea is that there's just enough unwrapping such that you don't
>  need to use getDual and appEndo.

Yes, but what does

  Dual [1] `mappend Dual [2]

mean then? Should it use the Monoid instance of Dual and return

  Dual [2, 1]

? Should it unwrap the lists beforehand and re-wrap them afterwards and
return

  Dual [1, 2]

? Should it unwrap the resulting list afterwards and return [1, 2] or
even [2,1] ?

That's not obvious to me.


> On Dec 3, 2009, at 1:25 AM, Holger Siegel wrote:
> 
> > Am Donnerstag, den 03.12.2009, 01:16 +0100 schrieb Martijn van
> > Steenbergen:
> >> So here's a totally wild idea Sjoerd and I came up with.
> >> 
> >> What if newtypes were unwrapped implicitly?
> >> 
> >> What advantages and disadvantages would it have?
> >> In what cases would this lead to ambiguous code?
> > 
> > 1)
> > instance Monoid a => Monoid (Dual a)
> > 
> > 2)
> > instance Monoid (Endo a)
> > instance Monoid b => Monoid (a -> b)
> > 
> > 
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> --
> Sjoerd Visscher
> sjoerd at w3future.com
> 
> 
> 



More information about the Haskell-Cafe mailing list