[Haskell] class functional depency inference?

Hugo Pacheco 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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell/attachments/20070616/ce0bf7b7/attachment.htm


More information about the Haskell mailing list