[Haskell] The two-class trick

2004-06-15 Thread oleg
The two-class trick helps us indirectly write desirable multi-parameter classes with functional dependencies or overlapping. The example below happens to have both. The example illustrates that an attempt to write desired instances directly runs into problems of bad overlapping or violations of fu

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Esa Pulkkinen
In message <[EMAIL PROTECTED] com>, [EMAIL PROTECTED] writes: >it is nice to use 'maybe', 'either' functions. However, with data types >with more than 2 constructors, using such function tends to be tedious than >pattern match, where, you can pick specific constructors of interest. > >And in order

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Ben . Yu
> Don't export your data constructors because you then expose the > internals of your module, which is bad for abstraction; export function > names which serve as the data constructors instead. Actually this is another thing that I'm wondering about. it is nice to use 'maybe', 'either' functi

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Georg Martius
On Tue, 15 Jun 2004 12:05:46 +0100, Graham Klyne <[EMAIL PROTECTED]> wrote: At 11:30 15/06/04 +0200, Wolfgang Jeltsch wrote: I'd say, classes in Haskell are similar to interfaces in Java. I started my Haskell programming with that viewpoint, but got tripped up by it. A Java interface can be used as

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Graham Klyne
At 11:30 15/06/04 +0200, Wolfgang Jeltsch wrote: I'd say, classes in Haskell are similar to interfaces in Java. I started my Haskell programming with that viewpoint, but got tripped up by it. A Java interface can be used as a type in its own right, but a Haskell class cannot. For example, you can

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread John Meacham
On Tue, Jun 15, 2004 at 11:30:24AM +0200, Wolfgang Jeltsch wrote: > Am Dienstag, 15. Juni 2004 04:05 schrieb John Meacham: > > [...] > > > now classes are a bit trickier, the main thing is that classes in > > haskell are not like classes in other languages. A class in haskell is > > nothing more t

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Wolfgang Jeltsch
Am Dienstag, 15. Juni 2004 04:05 schrieb John Meacham: > [...] > now classes are a bit trickier, the main thing is that classes in > haskell are not like classes in other languages. A class in haskell is > nothing more than a construct allowing you to reuse the same syntax on > different types. (t

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread Johannes Waldmann
John Meacham wrote: 1. define the data structures you think you will need or 2. define the class/interface your data structures will have if you want to take the "prototyping" route, then indeed do 1. first and then 2., but of course first 2. then 1. gives better code right from the start. I mean,

Re: [Haskell] Annoying naming clashes

2004-06-15 Thread John Meacham
On Tue, Jun 15, 2004 at 07:35:44AM +0100, Alastair Reid wrote: > I don't think I agree with that at all. > > John Hughes' "Why Functional Programming Matters" makes it very clear how much > power you gain from adding intermediate data structures. > > I personally find them extremely valuable in

Re: [Haskell] IO, exceptions and error handling

2004-06-15 Thread Ketil Malde
"Tim Docker" <[EMAIL PROTECTED]> writes: > Of course... that was my second alternative error strategy. I'm > interest in how/when people decide when to throw exceptions versus > when to thread errors using monads, given that changing code from > one to the other could be quite a big deal. I gener