
TP
symbolToInfixLevel :: String -> Int symbolToInfixLevel s = infixLevel $ (symbolToConstructor s) undefined
Now, I obtain:
$ runghc test_typeclass_without_typevariable.hs test_typeclass_without_typevariable.hs:7:24: No instance for (Foo a0) arising from a use of `infixLevel' In the expression: infixLevel In the expression: infixLevel $ (symbolToConstructor s) undefined undefined In an equation for `symbolToInfixLevel': symbolToInfixLevel s = infixLevel $ (symbolToConstructor s) undefined undefined
How to get rid from this situation?
Your `symbolToConstructor' function is too specific for both cases you describe. You'd need to change the `String' argument to `a' and put it back in the type class or write it like this: symbolToInfixLevel :: (Foo a) => a -> Int symbolToInfixLevel s = infixLevel $ (symbolToConstructor s) undefined -- Peter Jones, Founder, Devalot.com Defending the honor of good code