External Core: print function types correctly, improve newtype pretty-printing
[ghc-hetmet.git] / compiler / coreSyn / PprExternalCore.lhs
index 22449df..791e36b 100644 (file)
@@ -61,7 +61,7 @@ ptdef (Newtype tcon tbinds (coercion,k) rep) =
 -- At the same time, we need the newtype decl to declare the tycon itself.
 -- Sigh.
   text "%newtype" <+> pqname tcon <+> (hsep (map ptbind tbinds)) 
-    <+> axiomclause <+> repclause
+    $$ indent (axiomclause $$ repclause)
        where  axiomclause = char '^' <+> parens (pqname coercion <+> text "::"
                                      <+> pkind k)
               repclause   = case rep of
@@ -80,7 +80,10 @@ pname id = text (zEncodeString id)
 
 pqname :: Qual Id -> Doc
 pqname ("",id) = pname id
-pqname (m,id)  = text m <> char '.' <> pname id
+-- We print out a special character before a qualified name so as to
+-- disambiguate unqualified names like "m" from qualified names like
+-- "m:Foo.Bar.y". This makes the ext-core parser easier.
+pqname (m,id)  = char '^' <> text m <> char '.' <> pname id
 
 ptbind, pattbind :: Tbind -> Doc
 ptbind (t,Klifted) = pname t
@@ -187,7 +190,9 @@ palt (Adefault e) =
 
 plit :: Lit -> Doc
 plit (Lint i t) = parens (integer i <> text "::" <> pty t)
-plit (Lrational r t) = parens (rational r <>  text "::" <> pty t)  -- might be better to print as two integers
+-- we use (text (show r)) because "(rational r)" was printing out things
+-- like "2.0e-2" (which isn't External Core)
+plit (Lrational r t) = parens (text (show r) <>  text "::" <> pty t)
 plit (Lchar c t) = parens (text ("\'" ++ escape [c] ++ "\'") <> text "::" <> pty t)
 plit (Lstring s t) = parens (pstring s <> text "::" <> pty t)