ppPorts x = lineParens $ commasep $ map (ppPortDecl (getMaxLen x)) x
  where
    ppPortDecl l (PortDecl dir mb_type mb_range name c) = 
        ppItem c <> text (ppPortSub dir mb_type mb_range) <+> 
        text (replicate (l - length (ppPortSub dir mb_type mb_range)) ' ') <+> ppIdent name
    ppPortSub dir mb_type mb_range = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    ppPortSubDecl (PortDecl dir mb_type mb_range name c) = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    getMaxLen xs = (maximum (map length $ map ppPortSubDecl xs))
ppPorts x = lineParens $ commasep $ map (ppPortDecl (getMaxLen x)) x
  where
    ppPortDecl l (PortDecl dir mb_type mb_range name c) = 
        ppItem c <> text (ppPortSub dir mb_type mb_range) <+> 
        text (replicate (l - length (ppPortSub dir mb_type mb_range)) ' ') <+> ppIdent name
    ppPortSub dir mb_type mb_range = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    ppPortSubDecl (PortDecl dir mb_type mb_range name c) = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    getMaxLen xs = (maximum (map length $ map ppPortSubDecl xs))
ppPorts x = lineParens $ commasep $ map (ppPortDecl (getMaxLen x)) x
  where
    ppPortDecl l (PortDecl dir mb_type mb_range name c) = 
        ppItem c <> text (ppPortSub dir mb_type mb_range) <+> 
        text (replicate (l - length (ppPortSub dir mb_type mb_range)) ' ') <+> ppIdent name
    ppPortSub dir mb_type mb_range = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    ppPortSubDecl (PortDecl dir mb_type mb_range name c) = render (ppPortDir dir  <+> maybe (text "wire") ppPortType mb_type <+> mb ppRange mb_range)
    getMaxLen xs = (maximum (map length $ map ppPortSubDecl xs))