Commit a8e107d0 authored by Camil Staps's avatar Camil Staps 🐧

Clean.PrettyPrint: Better support for generics

parent cf4d37a1
......@@ -57,6 +57,12 @@ where
(TypeSpec _) = " :== "
(EmptyRhs _) = ""
_ = " = "
print st (PD_GenericCase {gc_type,gc_gcf=GCF id {gcf_body=GCB_ParsedBody [desc:args] rhs}} _)
= print st (id :+: "{|" :+: gc_type :+: desc` :+: "|} " :+: args :+: " = " :+: rhs)
where
desc` = case desc of
PE_WildCard -> PrintNil
_ -> " of " :+: desc
print _ _
= abort "UNKNOWN_PD"
......
......@@ -83,10 +83,11 @@ where
= printp st ("dynamic " :+: pe :+: " :: " :+: dt)
print st (PE_Dynamic pe No)
= printp st ("dynamic " :+: pe)
print st (PE_Generic id k)
= print st (id :+: "{|" :+: k :+: "|}")
// | PE_ArrayPattern ![ElemAssignment]
// | PE_Matches !Ident /*expr*/!ParsedExpr /*pattern*/!ParsedExpr !Position
// | PE_Any_Code !(CodeBinding Ident) !(CodeBinding Ident) ![String]
// | PE_Generic !Ident !TypeKind /* AA: For generics, kind indexed identifier */
// | PE_TypeSignature !ArrayKind !ParsedExpr
// | PE_Empty
print st pe
......@@ -216,6 +217,18 @@ compound_rhs (GuardedAlts _ _) = True
compound_rhs (UnGuardedExpr {ewl_nodes=[_:_]}) = True
compound_rhs _ = False
// Generics
instance print TypeKind
where
print st KindConst = "*"
print st (KindArrow ks) = printp st (intersperse "->" (map (print {st & cpp_parens=True}) ks))
where
intersperse :: !a ![a] -> [a]
intersperse i [] = []
intersperse i [x] = [x]
intersperse i [x:xs] = [x,i:intersperse i xs]
print st _ = abort "Unknown TypeKind"
// Dynamics
instance print DynamicType
where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment