[Haskell] Partially applied type class functions

Roberto Zunino roberto.zunino at sns.it
Fri Aug 5 13:55:39 EDT 2005

Paul Govereau wrote:
>>instance AbSyn Constraint where
>>    subst e n constr =
>>        let sub = subst e n   -- :: AbSyn a => a -> a
>>        in case constr
>>           of Zero expr -> Zero (sub expr)
>>              AndL cs   -> AndL (sub cs)
>It looks sort of like sub is being monomorphised -- or something?

I think you just hit the monomorphism restriction. For the details, see:
http://www.haskell.org/onlinereport/decls.html   -  Sect. 4.5.5

Possible solutions for your specific case are:

1) add an explicit type signature for sub

    let sub :: AbSyn a => a -> a
         sub = subst e n
    in ...

2) eta-expand sub, so its definition becomes a function binding

    let sub c = subst e n c
    in ...

Roberto Zunino.

More information about the Haskell mailing list