Changes between Version 1 and Version 2 of GhcApiAstTraversals


Ignore:
Timestamp:
Jul 13, 2008 10:05:35 PM (7 years ago)
Author:
claus
Comment:

update showData (unfold Bags)

Legend:

Unmodified
Added
Removed
Modified
  • GhcApiAstTraversals

    v1 v2  
    3737{{{
    3838showData :: Data a => Int -> a -> String
    39 showData n = generic `ext1Q` list `extQ` string
    40                      `extQ` occName `extQ` moduleName `extQ` srcSpan
     39showData n = generic `ext1Q` list `extQ` string `extQ` bagName `extQ` bagRdrName
     40                     `extQ` name `extQ` occName `extQ` moduleName `extQ` srcSpan
    4141                     `extQ` postTcType `extQ` fixity
    4242  where generic :: Data a => a -> String
    43         generic t = "\n" ++ replicate n ' '
    44                  ++ "(" ++ showConstr (toConstr t)
     43        generic t = indent n ++ "(" ++ showConstr (toConstr t)
    4544                 ++ space (concat (intersperse " " (gmapQ (showData (n+1)) t))) ++ ")"
    4645        space "" = ""
    4746        space s  = ' ':s
     47        indent n = "\n" ++ replicate n ' '
    4848        string     = show :: String -> String
    49         list l     = "[" ++ concat (intersperse "," (map (showData (n+1)) l)) ++ "]"
     49        list l     = indent n ++ "[" ++ concat (intersperse "," (map (showData (n+1)) l)) ++ "]"
     50        name       = ("{Name: "++) . (++"}") . showSDoc . ppr :: Name -> String
    5051        occName    = ("{OccName: "++) . (++"}") .  OccName.occNameString
     52        moduleName = ("{ModuleName: "++) . (++"}") . showSDoc . ppr :: ModuleName -> String
    5153        srcSpan    = ("{"++) . (++"}") . showSDoc . ppr :: SrcSpan -> String
    52         moduleName = ("{"++) . (++"}") . showSDoc . ppr :: ModuleName -> String
     54        bagRdrName:: Bag (Located (HsBind RdrName)) -> String
     55        bagRdrName = ("{Bag(Located (HsBind RdrName)): "++) . (++"}") . list . bagToList
     56        bagName   :: Bag (Located (HsBind Name)) -> String
     57        bagName    = ("{Bag(Located (HsBind Name)): "++) . (++"}") . list . bagToList
    5358        postTcType = const "{!type placeholder here?!}" :: PostTcType -> String
    5459        fixity     = const "{!fixity placeholder here?!}" :: GHC.Fixity -> String