DefaultSignatures and MultiParamTypeClasses

Hi all, I just tried, and it appears that the new DefaultSignatures extension doesn't work with multi parameter type classes. For example, when I compile this file: ---- {-# LANGUAGE DefaultSignatures, MultiParamTypeClasses #-} module Test where class C a b where conv :: a -> b default conv :: D a b => a -> b conv = dconv class D a b where dconv :: a -> b ----- I get the error message: ----- /tmp/Test.hs:4:1: The multi-parameter class `C' cannot have generic methods In the class declaration for `C' Failed, modules loaded: none. ----- Is there a reason for this restriction, or is it merely an accident? Cheers, Reiner

Hello Reiner,
On Mon, Jan 16, 2012 at 06:32, Reiner Pope
Hi all,
I just tried, and it appears that the new DefaultSignatures extension doesn't work with multi parameter type classes.
Is there a reason for this restriction, or is it merely an accident?
I don't think the original design explicitly excluded MPTCs; I don't think there were any use cases for it either, though. I think Simon introduced this restriction, so he might have a good reason for it. Cheers, Pedro
Cheers, Reiner _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

| /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C' Aha. Trawling the commit logs, this test is simply a vestige of the PREVIOUS generic-class story, now long gone. So we can lift the restriction easily. I'll commit a patch shortly; I hope it'll be in time for 7.4 Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell- | users-bounces@haskell.org] On Behalf Of Reiner Pope | Sent: 16 January 2012 05:32 | To: glasgow-haskell-users@haskell.org | Subject: DefaultSignatures and MultiParamTypeClasses | | Hi all, | | I just tried, and it appears that the new DefaultSignatures extension doesn't | work with multi parameter type classes. For example, when I compile this | file: | | ---- | {-# LANGUAGE DefaultSignatures, MultiParamTypeClasses #-} | module Test where | | class C a b where | conv :: a -> b | | default conv :: D a b => a -> b | conv = dconv | | class D a b where | dconv :: a -> b | ----- | | I get the error message: | | ----- | /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C' | Failed, modules loaded: none. | ----- | | Is there a reason for this restriction, or is it merely an accident? | | Cheers, | Reiner | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

I thought that might be the case. Thanks for that! Cheers, Reiner On 17/01/2012, at 1:15 AM, Simon Peyton-Jones wrote:
| /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C'
Aha. Trawling the commit logs, this test is simply a vestige of the PREVIOUS generic-class story, now long gone. So we can lift the restriction easily.
I'll commit a patch shortly; I hope it'll be in time for 7.4
Simon
| -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell- | users-bounces@haskell.org] On Behalf Of Reiner Pope | Sent: 16 January 2012 05:32 | To: glasgow-haskell-users@haskell.org | Subject: DefaultSignatures and MultiParamTypeClasses | | Hi all, | | I just tried, and it appears that the new DefaultSignatures extension doesn't | work with multi parameter type classes. For example, when I compile this | file: | | ---- | {-# LANGUAGE DefaultSignatures, MultiParamTypeClasses #-} | module Test where | | class C a b where | conv :: a -> b | | default conv :: D a b => a -> b | conv = dconv | | class D a b where | dconv :: a -> b | ----- | | I get the error message: | | ----- | /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C' | Failed, modules loaded: none. | ----- | | Is there a reason for this restriction, or is it merely an accident? | | Cheers, | Reiner | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Great! This will greatly reduce the boilerplate in the constraints package.
Sent from my iPhone
On Jan 16, 2012, at 9:15 AM, Simon Peyton-Jones
| /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C'
Aha. Trawling the commit logs, this test is simply a vestige of the PREVIOUS generic-class story, now long gone. So we can lift the restriction easily.
I'll commit a patch shortly; I hope it'll be in time for 7.4
Simon
| -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell- | users-bounces@haskell.org] On Behalf Of Reiner Pope | Sent: 16 January 2012 05:32 | To: glasgow-haskell-users@haskell.org | Subject: DefaultSignatures and MultiParamTypeClasses | | Hi all, | | I just tried, and it appears that the new DefaultSignatures extension doesn't | work with multi parameter type classes. For example, when I compile this | file: | | ---- | {-# LANGUAGE DefaultSignatures, MultiParamTypeClasses #-} | module Test where | | class C a b where | conv :: a -> b | | default conv :: D a b => a -> b | conv = dconv | | class D a b where | dconv :: a -> b | ----- | | I get the error message: | | ----- | /tmp/Test.hs:4:1: | The multi-parameter class `C' cannot have generic methods | In the class declaration for `C' | Failed, modules loaded: none. | ----- | | Is there a reason for this restriction, or is it merely an accident? | | Cheers, | Reiner | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (4)
-
Edward Kmett
-
José Pedro Magalhães
-
Reiner Pope
-
Simon Peyton-Jones