RE: [Haskell] deriving with newtypes
Your word is my command. 'Tis done. Simon | -----Original Message----- | From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Wolfgang | Jeltsch | Sent: 21 March 2004 17:55 | To: The Haskell Mailing List | Subject: [Haskell] deriving with newtypes | | Hello, | | I'm trying to use GHC's deriving mechanism for newtypes in the following way: | class C a b | instance C [a] Char | newtype T = T Char deriving C [a] | Unfortunately, this isn't possible. Is there a reason for this? Can I | circumvent this restriction? | | Wolfgang | | _______________________________________________ | Haskell mailing list | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell
Am Freitag, 2. April 2004 18:49 schrieben Sie:
Your word is my command. 'Tis done.
Simon
Thank you very much. In which GHC release will this be available? Wolfgang
| -----Original Message----- | From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org]
On Behalf Of Wolfgang
| Jeltsch | Sent: 21 March 2004 17:55 | To: The Haskell Mailing List | Subject: [Haskell] deriving with newtypes | | Hello, | | I'm trying to use GHC's deriving mechanism for newtypes in the
following way: | class C a b | instance C [a] Char | newtype T = T Char deriving C [a] | Unfortunately, this isn't possible. Is there a reason for this? Can I | circumvent this restriction? | | Wolfgang | | _______________________________________________ | Haskell mailing list | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell
On Fri, 2 Apr 2004, Simon Peyton-Jones wrote:
Your word is my command. 'Tis done.
Simon
| -----Original Message----- | From: haskell-bounces@haskell.org [mailto:haskell-bounces@haskell.org] On Behalf Of Wolfgang | Jeltsch | Sent: 21 March 2004 17:55 | To: The Haskell Mailing List | Subject: [Haskell] deriving with newtypes | | Hello, | | I'm trying to use GHC's deriving mechanism for newtypes in the following way: | class C a b | instance C [a] Char | newtype T = T Char deriving C [a] | Unfortunately, this isn't possible. Is there a reason for this? Can I | circumvent this restriction? | | Wolfgang
It looks like this lets you use partially applied type classes in a deriving clause, always apllying that class to the new type last. This looks nice, but wouldn't work so well if your newtype was supposed to go first class C a b instance Char [a] newtype T = T Char deriving C ?? Maybe a deriving clause should allow full instance heads instead as well as class names, so you could write "deriving C T [a]". (Maybe with some restrictions, like ensuring the new type appears, or is one of the class arguments). It seems more regular to allow you to derive an instance of a multi-paramater typeclass with your class in any position rather than just the last. Brandon
participants (3)
-
Brandon Michael Moore -
Simon Peyton-Jones -
Wolfgang Jeltsch