[Haskell-cafe] Type classes... popular for newbies, isn't it?

Arjun Guha guhaarju at grinnell.edu
Sat Aug 7 02:15:08 EDT 2004


I'd rather not do that, but even if I did, the type-variable action 
would not be reachable in the terminal function.  I could specify a 
functional dependency st -> action (though I've never used it, it would 
be a fun to learn).  I'm curious as to why my class declaration 
compiles in GHC, as there doesn't seem to be any way to use it.

-Arjun

On Aug 7, 2004, at 01:06, camarao at dcc.ufmg.br wrote:

> Hi Arjun.
>
> How about inserting one more parameter, "action", in your class 
> definition:
>
> class (Ord st) => MinimaxState st action where
>    successors:: st -> [(action,st)]
>    terminal:: st -> Bool
>
> instance MinimaxState Int Int where
>    terminal i = i == 0
>    successors i = [(1,i+1), (-1,i-1)]
>
> Then don't forget to start the compiler/interpreter with 
> -fglasgow-exts.
>
> Hope this helps.
>
> Regards,
>
> Carlos
>
>



More information about the Haskell-Cafe mailing list