[Haskell] class functional depency inference?
hpacheco at gmail.com
Sat Jun 16 12:07:23 EDT 2007
On 6/16/07, David House <dmhouse at 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
> >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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell