Problem with functional dependencies

Fergus Henderson fjh@cs.mu.oz.au
Thu, 4 Jan 2001 04:37:55 +1100


On 03-Jan-2001, Mark P Jones <mpj@cse.ogi.edu> wrote:
> ... the best way to deal with this is (probably):
>   (i) to infer simpler types whenever possible, but
>  (ii) to allow more polymorphic types when they are requested by
>       means of an explicit type signature.

I agree.

> (Incidentally, in the interests of consistency, such a system should
> also programmers to use types like  Num Int => Int -> Bool.)

Mercury uses the approach you've suggested above for constraints like
these.  That is, you can declare types like that, and the Mercury
type checker will accept them, but it won't try to infer such types.

This feature could be a bit more useful in Mercury than in Haskell,
since in Mercury instance declarations can be private to a particular
module.

(Unfortunately, though, the Mercury runtime system's RTTI
representation of instances is not able to handle such constraints, so
for such examples, the current implementation of the compiler reports
"sorry, not implemented: constraints may only constrain type variables".)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.