On 5/20/06, Bas van Dijk <[EMAIL PROTECTED]> wrote:
How can I make this work?
As far as I know, you can't. To see the problem, rewrite it using dictionaries:
data Simplify a = Simplify { simplify :: a -> a }
simplify_HsExp (HsInfixApp e1 op e2) = HsApp (HsApp (opToExp op) e1) e2
simplify_HsExp (HsLeftSection e op)= HsApp (opToExp op) e
simplify_HsExp (HsRightSection op e) = HsApp (opToExp op) e
simplify_HsExp (HsParen e) = e
simplify_HsExp e = e
Simplify_HsExp = Simplify simplify_HsExp
etc.
You will end up with a bunch of Simplify_* objects. Now in the application:
preProcess = everywhere (mkT simplify)
how do you convert this? If you use (mkT (simplify ...)), you're
fixing simplify to only one type. If you use (mkT simplify), you get a
type error.
GHC is telling you that you need to tell it which instance of simplify
to use. In your example, you can use:
everywhere (mkT (simplify :: HsExp -> HsExp))
. everywhere (mkT (simplify :: HsPat -> HsPat))
. everywhere (mkT (simplify :: HsRhs -> HsRhs))
Of course, that's not any simpler.
--
Taral <[EMAIL PROTECTED]>
"You can't prove anything."
-- Gödel's Incompetence Theorem
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell