Re: [Haskell-cafe] Re: [Haskell] Swapping parameters and type classes

2007-09-19 Thread Jim Apple
On 9/18/07, Simon Marlow [EMAIL PROTECTED] wrote:
 Ian Lynagh wrote:
  I proposed renaming
  haskell@ - haskell-announce@
  haskell-cafe@ - haskell@
[snip]
 but now I have to admit I think haskell-cafe is a big win
 for the community.

To me this suggests renaming haskell@ to haskell-announce@ while
leaving haskell-cafe@ as is.

Jim
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell] Swapping parameters and type classes

2007-09-18 Thread Simon Peyton-Jones
This thread is certainly interesting, but it would be better on [EMAIL 
PROTECTED]  The Haskell@haskell.org list is intended as a low-bandwidth list 
for announcements and the like.  Thanks!

Simon

| -Original Message-
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
| On Behalf Of Bas van Dijk
| Sent: 17 September 2007 20:17
| To: Mads Lindstrøm
| Cc: haskell@haskell.org
| Subject: Re: [Haskell] Swapping parameters and type classes
|
| On 9/17/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
|  Hi Bas
| 
|  Thank you for the answer.
| 
|  I tried to fill in some blanks in the example you gave. And mostly
| got
|  a lot of context reduction stack overflows :(
| 
|  Here is my example (a little closer to what I actually need):
| 
|  data Foo a b = Foo { first :: a, second :: b }
| 
|  class Bar (x :: * - *) where
|  foo :: x a - a
| 
|  instance Bar (Foo a) where
|  foo x = second x
| 
|  type family BarB a b :: * - *
|  type instance BarB a b = Foo b
| 
|  instance Bar (BarB a b) where
|  foo x = second x -- this unexpectedly works!
|  --  foo x = first x  -- This unexpectedly gives context reduction
| stack overflow
| 
|  What surprises me is that I still need to look at `second`, even
| though
|  I use BarB. I thought I was swapping the parameters. Whats more
| changing
|  the line:
| 
|  type instance BarB a b = Foo b
| 
|  to
| 
|  type instance BarB a b = Foo a  -- the last letter changed
| 
|  has no effect.
| 
| 
|  Greetings,
| 
|  Mads Lindstrøm
| 
|  P.s. Why can we not just have the option of being explicit about
| which type parameters are applied? Something like:
| 
|  instance Bar (apply a. Foo a b) which would apply a and be
| identical to instance Bar (Foo a)
|  instance Bar (apply b. Foo a b) which would apply b and be what I
| am trying to achieve.
| 
|  It would seem a lot more natural to me. But maybe there are other
| reasons why type families are a better solution?
| 
|  I do not know if I use the right terminology when saying apply.
| Please correct if there is more correct terms.
| 
| 
|  Bas van Dijk:
|   On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
|But what if I want to apply the 'b' ? How do I do that ?
|  
|   The following uses type families (functions) and compiles under GHC
| HEAD:
|  
|   {-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -
| XTypeSynonymInstances #-}
|  
|   data Foo a b
|  
|   class Bar (x :: * - *)
|  
|   instance Bar (Foo a)
|  
|   type family BarB a b :: * - *
|   type instance BarB a b = Foo b
|  
|   instance Bar (BarB a b)
|  
|  
|   regards,
|  
|   Bas van Dijk
| 
| 
|
| Mads, my sollution was not correct.
|
| This is why:
|
| instance Bar (BarB a b)
|
| is equal to:
|
| instance Bar (Foo b)
|
| which is just equal to:
|
| instance Bar (Foo a)
|
| The 'b' in  'instance Bar (Foo b)' has nothing to do with the 'b' in
| 'Foo a b'. In fact the 'b' in 'BarB a b' is equal to the 'a' in 'Foo a
| b'.
|
| Sorry that I bothered you with this but like I said, it was late and I
| already consumed some wine. Not a good combination when programming
| ;-)
|
| Bas.
| ___
| Haskell mailing list
| Haskell@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Swapping parameters and type classes

2007-09-18 Thread Andrzej Jaworski
Well, the corridors are better known for the men in power:-)
Why don't leave this entry as Reception for the uninitiated and move on to
Announcements and ... Curiosity?

Regards,
-A.J.

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-18 Thread Andrzej Jaworski
Responding to Simon Peyton-Jones'  reminder that this is a low-bandwidth list I
was obscure and commited a blunder.

This one and many other threads here are started undoubtedly by experts [sorry
guys:-)] and coffee brake should work for them, but on numerous occasions
threads here spawn beginner type questions. So, my thinking was that it is
perhaps against the tide trying to stop them.
Why not to make the list Haskell a first contact general practitioner? Then
creating e.g. Announcements  Challenge or Announcements  ask guru list
could take the best from Haskell but also would make it less front line and
thus more elitist, which should imply the manner by itself. You could always
cross-post but subscribe or answer to one.

Cheers,
-A.J.

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-18 Thread Ian Lynagh
On Tue, Sep 18, 2007 at 03:48:06PM +0100, Andrzej Jaworski wrote:
 Responding to Simon Peyton-Jones'  reminder that this is a low-bandwidth list 
 I
 was obscure and commited a blunder.
 
 This one and many other threads here are started undoubtedly by experts [sorry
 guys:-)] and coffee brake should work for them, but on numerous occasions
 threads here spawn beginner type questions. So, my thinking was that it is
 perhaps against the tide trying to stop them.
 Why not to make the list Haskell a first contact general practitioner? Then
 creating e.g. Announcements  Challenge or Announcements  ask guru list
 could take the best from Haskell but also would make it less front line and
 thus more elitist, which should imply the manner by itself.

I proposed renaming
haskell@ - haskell-announce@
haskell-cafe@ - haskell@
in http://www.haskell.org/pipermail/haskell-cafe/2007-July/028719.html
but the only reply was
There are very few inappropriate posts to the haskell@ list.
I very much doubt that the list names are a problem.
in http://www.haskell.org/pipermail/haskell-cafe/2007-July/028727.html
so I dropped it.

I've just quickly categorised the haskell@ posts from August to see what
the numbers are really like. The posts I've marked off-topic are ones
that, as far as I can see, are no more suited to haskell@ than most of
the messages that are sent to [EMAIL PROTECTED] Other peoples'
categorisations might vary, but I'd be surprised if they did
significantly.

http://urchin.earth.li/~ian/haskell-list-categorisation.txt

Of 68 messages, 52 were off-topic and 16 were on-topic, so about a 75-25
split. 5 of the off-topic messages were replies to on-topic messages, so
would probably have been off-topic regardless of the list name unless we
set the haskell-announce@ reply-to address to be haskell@ or moderated
[EMAIL PROTECTED]

Of 28 threads, 13 were entirely off-topic while 15 were at least partly
on-topic, so about a 50-50 split. This is a much better ratio as it is
the chattier threads that tend to be off-topic, of course. There was
only 1 on-topic message that wasn't the start of a thread.

In response to
I very much doubt that the list names are a problem.
I fully understand why someone new to the community, and thus unfamiliar
with the lists' intended purposes, posted
http://www.haskell.org/pipermail/haskell/2007-August/019746.html
to a list called haskell@, but I'm sure they wouldn't have posted it to
[EMAIL PROTECTED]

Something I noticed is that, of the 15 on-topic threads, 9 (including
The Monad.Reader) were things like calls for papers and conference
announcements, which have a largely different audience than new-library
announcements. Maybe there's even an argument for splitting
haskell-announce in two? haskell-academic-announce?

 You could always
 cross-post but subscribe or answer to one.

Cross-posting to mailing lists doesn't work well, and there's really no
reason for haskell-cafe@ subscribers not to be subscribed to haskell@,
so you might as well only post to haskell@ if you think it should be
crossposted.


Thanks
Ian

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell-cafe] Re: [Haskell] Swapping parameters and type classes

2007-09-18 Thread Simon Marlow

Ian Lynagh wrote:

On Tue, Sep 18, 2007 at 03:48:06PM +0100, Andrzej Jaworski wrote:

Responding to Simon Peyton-Jones'  reminder that this is a low-bandwidth list I
was obscure and commited a blunder.

This one and many other threads here are started undoubtedly by experts [sorry
guys:-)] and coffee brake should work for them, but on numerous occasions
threads here spawn beginner type questions. So, my thinking was that it is
perhaps against the tide trying to stop them.
Why not to make the list Haskell a first contact general practitioner? Then
creating e.g. Announcements  Challenge or Announcements  ask guru list
could take the best from Haskell but also would make it less front line and
thus more elitist, which should imply the manner by itself.


I proposed renaming
haskell@ - haskell-announce@
haskell-cafe@ - haskell@
in http://www.haskell.org/pipermail/haskell-cafe/2007-July/028719.html


I suggested the same thing at the time we created haskell-cafe, but the 
concensus was in favour of haskell-cafe.  At the time I didn't think it 
would work - for a long time, the number of subscribers to both lists was 
almost the same - but now I have to admit I think haskell-cafe is a big win 
for the community.  The -cafe extension gives people the confidence to post 
any old chatter without fear of being off-topic, and I'm sure this has 
helped the community to grow.


Those of us who grew up with Usenet (RIP) are more at home with the 
foo/foo-announce split, and it's certainly quite conventional for 
mailing-list naming too, but on the whole I don't think doing things 
differently has really done us any harm and it may well have been a stroke 
of genius :-)


Cheers,
Simon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] Swapping parameters and type classes

2007-09-18 Thread Andrzej Jaworski
Salute Simon, hi everybody here!

Ian is scientific in his observations and has a valid point. I share his
objection to the Haskell list as unnecessarily misleading newcomers which, I
would add, sets precedents for others to be verbose. Then, creating a Beginner
list is less fortunate than creating Announcements list for obvious and not so
obvious reasons. There are things in this culture however that make the decision
difficoult. What stands out is that announcements gained in the Haskell list
much wider connotation and by renaming it into this name explicitly might kill
this overinterpretation and thus couple of interesting oservations might not
find its way to an audience. Ian's numbers tell however that this benefits
speakers more than the listeners;-)

Haskell-Cafe though deserves respect on the same scienific ground - the share
volume speeks for it!
I agree with you Simon that the name Cafe created sort of spiritual component to
the community which should not be underestimated. We are humans and even history
of mathematics is a stream of fashion between couple of great discoveries.

Cheers,
-Andrzej

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell] Swapping parameters and type classes

2007-09-17 Thread Ian Lynagh
On Sun, Sep 16, 2007 at 01:59:02PM -0700, Stefan O'Rear wrote:
  
  {-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -XTypeSynonymInstances #-}
 
 {-# LANGUAGE TypeFamilies, EmptyDataDecls, TypeSynonymInstances #-}
 
 (Ian/Simon: I've seen this several times now.  Maybe there should be a
 warning for -X in OPTIONS?  Is that even feasable?)

Currently we can't even give a warning when completely deprecated flags
are used, but when fixing that I think we should also do as you suggest.


Thanks
Ian

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-17 Thread Mads Lindstrøm
Hi Bas

Thank you for the answer.

I tried to fill in some blanks in the example you gave. And mostly got
a lot of context reduction stack overflows :(

Here is my example (a little closer to what I actually need):

data Foo a b = Foo { first :: a, second :: b }

class Bar (x :: * - *) where
foo :: x a - a

instance Bar (Foo a) where
foo x = second x

type family BarB a b :: * - *
type instance BarB a b = Foo b

instance Bar (BarB a b) where
foo x = second x -- this unexpectedly works! 
--  foo x = first x  -- This unexpectedly gives context reduction stack 
overflow

What surprises me is that I still need to look at `second`, even though
I use BarB. I thought I was swapping the parameters. Whats more changing
the line:

type instance BarB a b = Foo b

to

type instance BarB a b = Foo a  -- the last letter changed

has no effect.


Greetings,

Mads Lindstrøm

P.s. Why can we not just have the option of being explicit about which type 
parameters are applied? Something like:

instance Bar (apply a. Foo a b) which would apply a and be identical to 
instance Bar (Foo a)
instance Bar (apply b. Foo a b) which would apply b and be what I am trying 
to achieve.

It would seem a lot more natural to me. But maybe there are other reasons why 
type families are a better solution?

I do not know if I use the right terminology when saying apply. Please 
correct if there is more correct terms.


Bas van Dijk:
 On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
  But what if I want to apply the 'b' ? How do I do that ?
 
 The following uses type families (functions) and compiles under GHC HEAD:
 
 {-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -XTypeSynonymInstances #-}
 
 data Foo a b
 
 class Bar (x :: * - *)
 
 instance Bar (Foo a)
 
 type family BarB a b :: * - *
 type instance BarB a b = Foo b
 
 instance Bar (BarB a b)
 
 
 regards,
 
 Bas van Dijk

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-17 Thread Bas van Dijk
On 9/17/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
 Hi Bas

 Thank you for the answer.

 I tried to fill in some blanks in the example you gave. And mostly got
 a lot of context reduction stack overflows :(

 Here is my example (a little closer to what I actually need):

 data Foo a b = Foo { first :: a, second :: b }

 class Bar (x :: * - *) where
 foo :: x a - a

 instance Bar (Foo a) where
 foo x = second x

 type family BarB a b :: * - *
 type instance BarB a b = Foo b

 instance Bar (BarB a b) where
 foo x = second x -- this unexpectedly works!
 --  foo x = first x  -- This unexpectedly gives context reduction stack 
 overflow

 What surprises me is that I still need to look at `second`, even though
 I use BarB. I thought I was swapping the parameters. Whats more changing
 the line:

 type instance BarB a b = Foo b

 to

 type instance BarB a b = Foo a  -- the last letter changed

 has no effect.


 Greetings,

 Mads Lindstrøm

 P.s. Why can we not just have the option of being explicit about which type 
 parameters are applied? Something like:

 instance Bar (apply a. Foo a b) which would apply a and be identical to 
 instance Bar (Foo a)
 instance Bar (apply b. Foo a b) which would apply b and be what I am trying 
 to achieve.

 It would seem a lot more natural to me. But maybe there are other reasons why 
 type families are a better solution?

 I do not know if I use the right terminology when saying apply. Please 
 correct if there is more correct terms.


 Bas van Dijk:
  On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
   But what if I want to apply the 'b' ? How do I do that ?
 
  The following uses type families (functions) and compiles under GHC HEAD:
 
  {-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -XTypeSynonymInstances #-}
 
  data Foo a b
 
  class Bar (x :: * - *)
 
  instance Bar (Foo a)
 
  type family BarB a b :: * - *
  type instance BarB a b = Foo b
 
  instance Bar (BarB a b)
 
 
  regards,
 
  Bas van Dijk



Mads, my sollution was not correct.

This is why:

instance Bar (BarB a b)

is equal to:

instance Bar (Foo b)

which is just equal to:

instance Bar (Foo a)

The 'b' in  'instance Bar (Foo b)' has nothing to do with the 'b' in
'Foo a b'. In fact the 'b' in 'BarB a b' is equal to the 'a' in 'Foo a
b'.

Sorry that I bothered you with this but like I said, it was late and I
already consumed some wine. Not a good combination when programming
;-)

Bas.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell-cafe] Re: [Haskell] Swapping parameters and type classes

2007-09-17 Thread Bas van Dijk
On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
 Hi all

 If I have this type:

   data Foo a b = ...

 and this class

   class Bar (x :: * - *) where ...

 I can imagine two ways to make Foo an instance of Bar. Either I must
 apply the 'a' or the 'b' in (Foo a b). Otherwise it will not have the
 right kind. To apply the 'a' I can do:

   instance Bar (Foo a) where ...

 But what if I want to apply the 'b' ? How do I do that ?


 Greetings,

 Mads Lindstrøm


 ___
 Haskell mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/haskell



(Redirecting to Haskell-Cafe)

I think the easiest way to make it work is with a newtype wrapper
around 'Foo a b' that swaps the arguments, like Brent mentioned.

Without it you need some kind of type level lambda abstraction. Something like:

instance Bar (\x - Foo x b) where ...

But this is not valid Haskell.

cheers,

Bas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell] Swapping parameters and type classes

2007-09-16 Thread Mads Lindstrøm
Hi all

If I have this type:

  data Foo a b = ...

and this class

  class Bar (x :: * - *) where ...

I can imagine two ways to make Foo an instance of Bar. Either I must
apply the 'a' or the 'b' in (Foo a b). Otherwise it will not have the
right kind. To apply the 'a' I can do:

  instance Bar (Foo a) where ...

But what if I want to apply the 'b' ? How do I do that ?


Greetings,

Mads Lindstrøm


___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-16 Thread Brent Yorgey
On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:

 Hi all

 If I have this type:

   data Foo a b = ...

 and this class

   class Bar (x :: * - *) where ...

 I can imagine two ways to make Foo an instance of Bar. Either I must
 apply the 'a' or the 'b' in (Foo a b). Otherwise it will not have the
 right kind. To apply the 'a' I can do:

   instance Bar (Foo a) where ...

 But what if I want to apply the 'b' ? How do I do that ?


One easy way would be to create a newtype with the type parameters swapped:

  newtype Oof b a = Oof (Foo a b)
  instance Bar (Oof b) where ...

Of course, if you want to partially apply the second parameter of a
function, you use 'flip'.  I thought for a while about whether there's some
sort of typeclass hackery which is directly parallel to the use of 'flip',
but couldn't come up with anything.  Anyone?

-Brent
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-16 Thread Bas van Dijk
On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
 But what if I want to apply the 'b' ? How do I do that ?

The following uses type families (functions) and compiles under GHC HEAD:

{-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -XTypeSynonymInstances #-}

data Foo a b

class Bar (x :: * - *)

instance Bar (Foo a)

type family BarB a b :: * - *
type instance BarB a b = Foo b

instance Bar (BarB a b)


regards,

Bas van Dijk
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-16 Thread Bas van Dijk
On 9/16/07, Bas van Dijk [EMAIL PROTECTED] wrote:
 The following uses type families (functions) and compiles under GHC HEAD:
 ...

Oops this is not correct! Its getting late... oh well

Bas
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Swapping parameters and type classes

2007-09-16 Thread Stefan O'Rear
On Sun, Sep 16, 2007 at 10:45:39PM +0200, Bas van Dijk wrote:
 On 9/16/07, Mads Lindstrøm [EMAIL PROTECTED] wrote:
  But what if I want to apply the 'b' ? How do I do that ?
 
 The following uses type families (functions) and compiles under GHC HEAD:
 
 {-# OPTIONS_GHC -XTypeFamilies -XEmptyDataDecls -XTypeSynonymInstances #-}

Eek!

That should be:

{-# LANGUAGE TypeFamilies, EmptyDataDecls, TypeSynonymInstances #-}

Modulo the fact that only GHC support type families at the moment, the
latter will be portable...

(Ian/Simon: I've seen this several times now.  Maybe there should be a
warning for -X in OPTIONS?  Is that even feasable?)

Stefan


signature.asc
Description: Digital signature
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell