On 6/16/07, David House <dmhouse@gmail.com> wrote:
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.
I've just promoted the test function to the class and it works the same, I missed it before.
However, haskell functions are partial. It could be generic and fail when some pattern does not exist as usual.