[Haskell-cafe] type class question
Jules Bean
jules at jellybean.co.uk
Thu Dec 6 10:06:25 EST 2007
Peter Padawitz wrote:
> Yes, the recursive calls of compCommand are supposed to be calls of
> compBlock.
>
> The intention of the program is a generic evaluator comp... of
> Sigma-terms in arbitrary Sigma-algebras. The signature Sigma is given by
> the first 4 types (and the corresponding functions in the class
> declaration), the terms are the objects of the types, and the algebras
> are the class instances.
>
> The problem with my implementation in terms of multiple-parameter
> classes seems to be - I conclude this from Ryan's comment - that the
> intended dependency among the parameters is not reflected here. But what
> are the alternatives? Roughly said, I need a construct that allows me
> gather several type variables such that an instance is always an
> instance of all of them.
well, given
class Java a b c d where ....
if it is true that everything is determined by choice of any one of
them, you could write
class Java a b c d | a -> b, b -> c, c -> d, d -> a where...
otherwise, well you can express whatever dependency network you want...
Jules
More information about the Haskell-Cafe
mailing list