StrategyLib - need help
Dmitry Astapov
adept@umc.com.ua
Thu, 24 Jul 2003 20:52:26 +0300
I want to write generic traversal which prints everything on the way:
uglyPrint :: (Term t, Show t) => t -> [(String)]
uglyPrint = (map snd) . runIdentity . applyTU (full_tdTU uglyPrintStep)
uglyPrintStep :: (Show t, Term t) => TU [(t, String)] Identity
uglyPrintStep = constTU [] `adhocTU` (return . uglyPrintAny)
uglyPrintAny x = [(x,show x)]
ugliestPrintEver :: (Term t, Show t) => t -> IO ()
ugliestPrintEver x = do { putStrLn $ show x }
Compiler (GHC 6.0) gives me:
Ambiguous type variable `t' in these top-level constraints:
`Term t'
arising from use of `uglyPrintStep' at ...
`Show t'
arising from use of `uglyPrintStep' at ...
All data types which are instances of Term are instances of Show as well -
I know it. Question is - how to persuade GHC?
I there any want to use typeclass restrictions with traversal, or there is
no luck for me?
--
Dmitry Astapov //ADEpt
GPG KeyID/fprint: F5D7639D/CA36 E6C4 815D 434D 0498 2B08 7867 4860 F5D7 639D