Context(..), ClassAssertion(..)
#ifdef COMPILING_GHC
+ , pprParendPolyType
, pprParendMonoType, pprContext
, extractMonoTyNames, extractCtxtTyNames
, cmpPolyType, cmpMonoType, cmpContext
instance (Outputable name) => Outputable (PolyType name) where
ppr sty (HsPreForAllTy ctxt ty)
= print_it sty ppNil ctxt ty
+ ppr sty (HsForAllTy [] ctxt ty)
+ = print_it sty ppNil ctxt ty
ppr sty (HsForAllTy tvs ctxt ty)
= print_it sty
(ppBesides [ppStr "_forall_ ", interppSP sty tvs, ppStr " => "])
= ppCat [ifnotPprForUser sty pp_forall, -- print foralls unless PprForUser
pprContext sty ctxt, ppr sty ty]
+pprParendPolyType :: Outputable name => PprStyle -> PolyType name -> Pretty
+pprParendPolyType sty ty = ppr sty ty -- ToDo: more later
+
instance (Outputable name) => Outputable (MonoType name) where
ppr = pprMonoType
#ifdef COMPILING_GHC
extractCtxtTyNames :: Eq name => Context name -> [name]
-extractMonoTyNames :: Eq name => MonoType name -> [name]
+extractMonoTyNames :: Eq name => (name -> Bool) -> MonoType name -> [name]
extractCtxtTyNames ctxt
= foldr get [] ctxt
is_elem = isIn "extractCtxtTyNames"
-extractMonoTyNames ty
+extractMonoTyNames is_tyvar_name ty
= get ty []
where
- get (MonoTyApp con tys) acc = foldr get acc tys
+ get (MonoTyApp con tys) acc = let
+ rest = foldr get acc tys
+ in
+ if is_tyvar_name con && not (con `is_elem` rest)
+ then con : rest
+ else rest
get (MonoListTy ty) acc = get ty acc
get (MonoFunTy ty1 ty2) acc = get ty1 (get ty2 acc)
get (MonoDictTy _ ty) acc = get ty acc