I realized that recursive newtypes no longer have to be
distinguished in the External Core AST, because explicit coercions
allow the typechecker to typecheck newtypes without ever
expanding newtypes. So, now all newtypes in External Core have
a representation clause. O frabjous day!
data Tdef
= Data (Qual Tcon) [Tbind] [Cdef]
data Tdef
= Data (Qual Tcon) [Tbind] [Cdef]
- | Newtype (Qual Tcon) (Qual Tcon) [Tbind] (Maybe Ty)
+ | Newtype (Qual Tcon) (Qual Tcon) [Tbind] Ty
data Cdef
= Constr (Qual Dcon) [Tbind] [Ty]
data Cdef
= Constr (Qual Dcon) [Tbind] [Ty]
Nothing -> pprPanic ("MkExternalCore: newtype tcon\
should have a coercion: ") (ppr tcon))
(map make_tbind tyvars)
Nothing -> pprPanic ("MkExternalCore: newtype tcon\
should have a coercion: ") (ppr tcon))
(map make_tbind tyvars)
+ (make_ty (snd (newTyConRhs tcon)))
| otherwise =
C.Data (qtc tcon) (map make_tbind tyvars)
(map make_cdef (tyConDataCons tcon))
| otherwise =
C.Data (qtc tcon) (map make_tbind tyvars)
(map make_cdef (tyConDataCons tcon))
- where repclause | isRecursiveTyCon tcon || isOpenTyCon tcon= Nothing
- | otherwise = Just (make_ty (snd (newTyConRhs tcon)))
tyvars = tyConTyVars tcon
collect_tdefs _ tdefs = tdefs
tyvars = tyConTyVars tcon
collect_tdefs _ tdefs = tdefs
ptdef (Newtype tcon coercion tbinds rep) =
text "%newtype" <+> pqname tcon <+> pqname coercion
<+> (hsep (map ptbind tbinds)) $$ indent repclause
ptdef (Newtype tcon coercion tbinds rep) =
text "%newtype" <+> pqname tcon <+> pqname coercion
<+> (hsep (map ptbind tbinds)) $$ indent repclause
- where repclause = case rep of
- Just ty -> char '=' <+> pty ty
- Nothing -> empty
-
+ where repclause = char '=' <+> pty rep
pcdef :: Cdef -> Doc
pcdef (Constr dcon tbinds tys) =
pcdef :: Cdef -> Doc
pcdef (Constr dcon tbinds tys) =