Re: classes and instances

1998-06-08 Thread Arjan van IJzendoorn
Hi Peter, Sorry for the previous, incomplete reply. Eudora thinks that Ctrl-E should mean: Send immediatEly instead of End-of-line... >class ResourcePool p where >newp :: p -> e -> p -- adds new element e to the resource pool p If you want to add the element of type e to the pool, the type

Re: classes and instances

1998-06-08 Thread Koen Claessen
On Mon, 8 Jun 1998, Peter White wrote: | What I really want is to define a pool of reusable resources. So | I want a class declaration something like: | | class ResourcePool p where | newp :: p -> e -> p -- adds new element e to the resource pool p Don't you want to use constructor cla

Exceptions are too return values!

1998-06-08 Thread Alex Ferguson
Alex Jacobson: > In the backchannel, Alastair Reid and Adrian Hey, have convinced me > that the return values of functions and cannot be represented using > algebraic types. I'm not clear what you mean by this. > I am not sure of syntax, but I am describing something like: > > fun:: a->b->c :

Re: classes and instances

1998-06-08 Thread Peter White
Thank you to Arjan and Koen. The solution proposed is: class ResourcePool p where newp :: p e -> e -> p e or in Arjan's notation: newp :: poolOf elem -> elem -> poolOf elem This looks like it will solve my problem. - Begin Included Message - Comments: ( Received on ftpbox.mo

circular module imports

1998-06-08 Thread S. Alexander Jacobson
I wanted to represent a reasonably small list of Publishers. So I created: > module Publisher where > data Publisher = Publisher { name::String, func::Registration->Bool} > data Registration = > Registration { data::String, pub::Publisher} deriving (Read,Show) Notice that the Publisher da

Re: Exceptions are too return values!

1998-06-08 Thread S. Alexander Jacobson
On Mon, 8 Jun 1998, Alex Ferguson wrote: > > In the backchannel, Alastair Reid and Adrian Hey, have convinced me > > that the return values of functions and cannot be represented using > > algebraic types. > > I'm not clear what you mean by this. Ooops, I forgot to remove the "and". Anyway, my

Exceptions are not return values

1998-06-08 Thread S. Alexander Jacobson
In the backchannel, Alastair Reid and Adrian Hey, have convinced me that the return values of functions and cannot be represented using algebraic types. In a lazy language, a function may have an error/exception either because it actually uses the value of one of its arguments (whose evaluation c

Re: classes and instances

1998-06-08 Thread Simon L Peyton Jones
> data Weirder a b = Weirdest a b > > class Weird c where > f1 :: c -> c > f2 :: Weirder a b -> c -> Weirder a b > f3 :: Weirder a c -> Weirder c a > f4 :: c -> c -> Bool > > instance Weird (d,e) where > f1 (x,y) = (x,y) > f2 w (x,y) = Weirdest x y > f3 (Weirdest x y

Re: classes and instances

1998-06-08 Thread Peter White
Simon writes: > You correctly say that you want a still more specific type. Without > understanding your application better I am nervous about recommending > this, but you *can* get what you say you want by using a multi-parameter class > > class Weird a b c where > ... >