[Haskell-cafe] Ambiguous type signature in class declaration
Bo Herlin
bo at gcab.net
Thu Apr 28 02:42:44 EDT 2005
Doh, i have another question:
Lets say i do as you wrote:
> class CRank a b where
> rank :: a -> b -> Maybe Integer -- Nothing means b is out of range
or badly constructed
> unrank :: a -> Integer -> Maybe b -- Nothing means rank is out of range
>
> class CCountable a where
> count :: a -> Maybe Integer -- Nothing means infinity
how do i make a test-class like this:
> class (CRank a b,CCountable a) => CTestable a where
> testOne :: a -> Integer -> Bool
> testUpTo :: a -> Integer -> Bool
> testOne x r = ((unrank x r) >>= (rank x)) == (Just r)
> testUpTo x mr = foldr1 (&&) (map (testOne x) [0..m])
> where
> m = f (count x)
> f Nothing = mr
> f (Just y) = min (y-1) mr
this gives me:
ERROR "./Cafe.lhs":14 - Undefined type variable "b"
If i remove the b like "class (CRank a,CCountable a) => CTestable a
where" i get:
ERROR "./Cafe.lhs":14 - Wrong number of arguments for class "CRank"
As a Haskell-newbee i get totally confused.
/Bo
More information about the Haskell-Cafe
mailing list