[Haskell-cafe] Implicit newtype unwrapping

Joachim Breitner mail at joachim-breitner.de
Thu Dec 3 16:34:12 EST 2009


Am Donnerstag, den 03.12.2009, 13:03 -0500 schrieb David Menendez:
> On Thu, Dec 3, 2009 at 6:28 AM, Joachim Breitner
> <mail at joachim-breitner.de> wrote:
> > Am Donnerstag, den 03.12.2009, 11:13 +0000 schrieb Matthew Pocock:
> >> Perhaps what you are looking for is a more powerful "defining"
> >> semantics?
> >>
> >> newtype MyFoo = Foo defining (Foo(..)) -- all class instances that Foo
> >> has are delegated through from MyFoo
> >
> > it goes into the right direction, but I’d also like to have this also
> > capeable to derive single functions (giving them a new name), and not
> > only class instances.
> Something like the restricted type synonym extension in Hugs?
> <http://cvs.haskell.org/Hugs/pages/users_guide/restricted-synonyms.html>

yes, this is very close to what I’d hope for. Last minor (but really
minor) wish: I don’t think it would hurt to allow the use of this
feature independent of the definition of the newtype:

I could have a
newtype Foo = Foo Int
somewhere, possibly in a different module, and write something like

myFoo :: Foo -> (Foo,Foo) resolving Foo
myFoo a = (a,a+a)

(syntax and wording very ad hoc and not thought through).

But yes, I think I’d be happy to have hugs’ extension here at hand


Joachim Breitner
  e-Mail: mail at joachim-breitner.de
  Homepage: http://www.joachim-breitner.de
  ICQ#: 74513189
  Jabber-ID: nomeata at joachim-breitner.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091203/13893b2b/attachment.bin

More information about the Haskell-Cafe mailing list