views:

17

answers:

0

Consider next declaration:

:- type wrap(T) ---> wrap(T).
:- inst wrap(I) ---> wrap(I).

:- typeclass infer_wrap(A, B) <= ((A -> B)).
:- instance infer_wrap(A, wrap(A)).

Mercury (10.04) produces:

monad.m:011: In instance declaration for `monad.infer_wrap(A, monad.wrap(A))':
monad.m:011:   the first arg is a type variable

Even without functional dependency it will not allow to declare instance with type variables.
Am I missing something or Mercury doesn't allow instances which doesn't end with ground instance?
Is there any way to declare instance for polymorphic type which is wrapper for any type (without constraints)? Maybe there exists some special typeclass like all_types(T)?