RE: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy?

2009-07-23 Thread Simon Peyton-Jones
| Now, I am scared. This should be regarded as a bug in generalised | newtype deriving, shouldn't it? I would expect newtype deriving to be | unable to come up with instances that cannot be written by hand. | | I would have expected people out on the streets marching to GHC | headquarters

Re: [Haskell-cafe] is closing a class this easy?

2009-07-19 Thread Miguel Mitrofanov
On 18 Jul 2009, at 16:49, Wolfgang Jeltsch wrote: Am Samstag, 18. Juli 2009 08:58 schrieb Miguel Mitrofanov: Oops... Sorry, wrong line. Should be isAB :: forall p. p A - p B - p x Is this a well-known approach for closing classes? I have an impression that this is kinda folklore. But I

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Miguel Mitrofanov
What is it for? Yes, you would know that only A and B are Public, but you have no way of telling that to the compiler. I usually prefer something like that: class Public x where blah :: ... isAB :: forall y. (A - y) - (B - y) - x - y Both solutions, however, allow the user to declare some

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Miguel Mitrofanov
Oops... Sorry, wrong line. Should be isAB :: forall p. p A - p B - p x On 18 Jul 2009, at 10:51, Miguel Mitrofanov wrote: What is it for? Yes, you would know that only A and B are Public, but you have no way of telling that to the compiler. I usually prefer something like that: class

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Conor McBride
Hi Miguel On 18 Jul 2009, at 07:58, Miguel Mitrofanov wrote: Oops... Sorry, wrong line. Should be isAB :: forall p. p A - p B - p x Yep, dependent case analysis, the stuff of my thesis,... On 18 Jul 2009, at 10:51, Miguel Mitrofanov wrote: What is it for? I have a different purpose in

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Stefan Holdermans
Conor, I'm scared. What about this? data EQ :: * - * - * where Refl :: EQ x x class Public x where blah :: EQ x Fred instance Public Fred where blah = Refl What happens when I say newtype Jim = Hide Fred deriving Public ? I tried it. I get blah :: EQ Jim Fred It's clear that

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Conor McBride
On 18 Jul 2009, at 01:43, Lennart Augustsson wrote: As far as I know it works. It's an old Oleg trick. Then it probably does work. The only drawback is that error messages may refer to Private. As I found out when probing its security. No instance for Moo.Private shows up. I guess that's

newtype deriving, was Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Conor McBride
Hi Stefan On 18 Jul 2009, at 09:42, Stefan Holdermans wrote: Conor, What happens when I say newtype Jim = Hide Fred deriving Public ? I tried it. I get blah :: EQ Jim Fred It's clear that GeneralizedNewtypeDeriving goes too far. Now, I am scared. This should be regarded as a bug in

Re: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Stefan Holdermans
Conor, What happens when I say newtype Jim = Hide Fred deriving Public ? I tried it. I get blah :: EQ Jim Fred Thinking of it; this *does* make sense in System FC. The newtype- declaration gives you as an axiom Hide :: Jim ~ Fred To give an instance of Public for Jim, we have to

Re: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Wolfgang Jeltsch
Am Samstag, 18. Juli 2009 11:43 schrieb Conor McBride: The trouble here is that somewhere along the line (GADTs? earlier?) it became possible to construct candidates for p :: * - * which don't respect isomorphism. Hello Conor, I’m not sure whether I exactly understand what you mean here. I

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Dougal Stanton
On Fri, Jul 17, 2009 at 4:38 PM, Conor McBrideco...@strictlypositive.org wrote: class Private x where public :: (forall x. Public x = x - y) - y public f = f Pike data Pike = Pike instance Private Pike instance Public Pike -- But if I don't tell 'em

Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Wolfgang Jeltsch
Am Samstag, 18. Juli 2009 08:58 schrieb Miguel Mitrofanov: Oops... Sorry, wrong line. Should be isAB :: forall p. p A - p B - p x Is this a well-known approach for closing classes? I came across the same idea and implemented a generic framework for closing classes in this way. I did this to

Re: newtype deriving, was Re: [Haskell-cafe] is closing a class this easy?

2009-07-18 Thread Conor McBride
Hi Wolfgang On 18 Jul 2009, at 13:42, Wolfgang Jeltsch wrote: Am Samstag, 18. Juli 2009 11:43 schrieb Conor McBride: The trouble here is that somewhere along the line (GADTs? earlier?) it became possible to construct candidates for p :: * - * which don't respect isomorphism. Hello Conor,

[Haskell-cafe] is closing a class this easy?

2009-07-17 Thread Conor McBride
Friends Is closing a class this easy? -- module Moo ( Public(..) ) where class Private x = Public x where blah :: ... class Private x where instance Private A where instance Public A where blah = ... instance Private B where instance Public B

Re: [Haskell-cafe] is closing a class this easy?

2009-07-17 Thread Edward Kmett
I've used a similar approach for a while, for instance in http://comonad.com/haskell/type-int/src/Data/Type/Boolean.hs http://comonad.com/haskell/type-int/src/Data/Type/Boolean.hs But I think your approach is cleaner than mine, because it doesn't need my seemingly superfluous closure term or