Skip to content

Add support for multiple parameters in type-classes.

Manllus requested to merge MultiParamTypeClasses into master

Currently Hask3's typeclasses allow a single type parameter (as plain Haskell98 report allows). GHC has an extension MultiParamTypeclasses.

There seem to be other alternatives:

The problem I'd like to solve is that of a heterogeneous composite:

--- A composite `a` allows to get its children of type `c` using a *container* `f`.
class Composite a f c where
    children :: a -> f c

Example using an homogeneous tree type:

data Tree a = Empty | Node a [Tree a]
      deriving (Show, Eq)

instance Composite (Tree a) Maybe [Tree a] where
   children Empty        = Nothing
   children (Node _ xs)  = Just xs
Edited by Manllus

Merge request reports