[Haskell] class functional depency inference?

David House dmhouse at gmail.com
Sat Jun 16 11:22:06 EDT 2007

Hugo Pacheco writes:
 > test :: SomeClass a b => a -> b
 > test 1 = True

test, as you've written it, is only a function from Ints to Bools, not from any
a to any b where SomeClass a b holds. It is true that SomeClass Int Bool is the
only instance at the moment, but type classes are open and someone could come
along and add another instance (perhaps even in a different module), like
SomeClass () String, and your function promises to be able to deal with them; as
you've written it, it can't.

-David House, dmhouse at gmail.com

More information about the Haskell mailing list