RE: simulating dynamic dispatch

2003-03-23 Thread oleg
Hal Daume wrote: > -- *Main> test $ MkFoo (0::Int) > -- Just True > -- *Main> test $ MkBar 'a' > -- Just True > i forgot to mention the constraint > that i don't want the user to have to use the MkFoo/MkBar > constructors. if i could use them internally to 'test', that would be > great, bu

RE: simulating dynamic dispatch

2003-03-21 Thread Hal Daume III
#x27;cast' function in Section 3 of "Scrap your > boilerplate" useful. > http://research.microsoft.com/~simonpj/papers/hmap/ > I'm not certain, but it has the right smell. > Simon > > | -Original Message- > | From: [EMAIL PROTECTED] [mailto:[EMAIL PRO

RE: simulating dynamic dispatch

2003-03-21 Thread Simon Peyton-Jones
| Sent: 21 March 2003 04:19 | To: [EMAIL PROTECTED]; [EMAIL PROTECTED] | Subject: Re: simulating dynamic dispatch | | | > i'm hoping to be able to simulate a sort of dynamic dispatch based on | > class instances. | | It seems you want to dispatch based not on a type but on the |

Re: simulating dynamic dispatch

2003-03-20 Thread Fergus Henderson
On 20-Mar-2003, Hal Daume III <[EMAIL PROTECTED]> wrote: > i'm hoping to be able to simulate a sort of dynamic dispatch based on > class instances. basically a function which takes a value and depending > on what classes it is an instance of, does something. I call this feature "dynamic type clas

Re: simulating dynamic dispatch

2003-03-20 Thread Hal Daume III
> -- *Main> test $ MkFoo (0::Int) > -- Just True > -- *Main> test $ MkFoo (10::Int) > -- Just False > -- *Main> test $ MkBar 'a' > -- Just True > -- *Main> test $ MkBar 'b' > -- Just False ah, yes. i was aware that would work. i forgot to mention the constraint that i don't want the user t

Re: simulating dynamic dispatch

2003-03-20 Thread oleg
> i'm hoping to be able to simulate a sort of dynamic dispatch based on > class instances. It seems you want to dispatch based not on a type but on the constraint of a type. You code almost worked. Here's the a bit updated and working version. class Foo a where { foo :: a -> Bool } class Bar a