[Haskell-cafe] Question related to Multi Param Type Classes
Alfonso Acosta
alfonso.acosta at gmail.com
Mon May 5 12:13:23 EDT 2008
2008/5/5 Sai Hemanth K <saihemanth at gmail.com>:
> Hi,
>
> I declared a multi param type class as below:
> class MyString m c where
> zIndex :: m -> Int -> c
> zLength :: m -> Int
> zPack :: [c] -> m
> zEquals :: c ->c -> Bool
> zWrap :: [c] -> (m,AnExistingDataType)
I infer from your questions that you probably missed setting a
functional dependency, that is
> class MyString m c | m -> c where
> zIndex :: m -> Int -> c
> zLength :: m -> Int
> zPack :: [c] -> m
> zEquals :: c ->c -> Bool
> zWrap :: [c] -> (m,AnExistingDataType)
which means, "c is univocaly determined by m". You'll need
-XFunctionalDependencies to make it work in GHC.
More information about the Haskell-Cafe
mailing list