@@ -612,13 +612,15 @@ data PDecl' t
612 -- ^ Record declaration
612 -- ^ Record declaration
613 | PClass (Docstring (Either Err PTerm)) SyntaxInfo FC
613 | PClass (Docstring (Either Err PTerm)) SyntaxInfo FC
614 [(Name, t)] -- constraints
614 [(Name, t)] -- constraints
615− Name
615+ Name -- class name
616 [(Name, t)] -- parameters
616 [(Name, t)] -- parameters
617 [(Name, Docstring (Either Err PTerm))] -- parameter docstrings
617 [(Name, Docstring (Either Err PTerm))] -- parameter docstrings
618 [Name] -- determining parameters
618 [Name] -- determining parameters
619 [PDecl' t] -- declarations
619 [PDecl' t] -- declarations
620+ (Maybe Name) -- instance constructor name
621+ (Docstring (Either Err PTerm)) -- instance constructor docs
620 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
622 -- ^ Type class: arguments are documentation, syntax info, source location, constraints,
621− -- class name, parameters, method declarations
623+ -- class name, parameters, method declarations, optional constructor name
622 | PInstance
624 | PInstance
623 (Docstring (Either Err PTerm)) -- Instance docs
625 (Docstring (Either Err PTerm)) -- Instance docs
624 [(Name, Docstring (Either Err PTerm))] -- Parameter docs
626 [(Name, Docstring (Either Err PTerm))] -- Parameter docs
@@ -739,7 +741,7 @@ declared (PData _ _ _ _ _ (PLaterdecl n _ _)) = [n]
739declared (PParams _ _ ds) = concatMap declared ds
741declared (PParams _ _ ds) = concatMap declared ds
740declared (PNamespace _ ds) = concatMap declared ds
742declared (PNamespace _ ds) = concatMap declared ds
741declared (PRecord _ _ _ _ n _ _ _ cn _ _) = n : maybeToList cn
743declared (PRecord _ _ _ _ n _ _ _ cn _ _) = n : maybeToList cn
742−declared (PClass _ _ _ _ n _ _ _ ms) = n : concatMap declared ms
744+declared (PClass _ _ _ _ n _ _ _ ms cn cd) = n : (maybeToList cn ++ concatMap declared ms)
743declared (PInstance _ _ _ _ _ _ _ _ _ _) = []
745declared (PInstance _ _ _ _ _ _ _ _ _ _) = []
744declared (PDSL n _) = [n]
746declared (PDSL n _) = [n]
745declared (PSyntax _ _) = []
747declared (PSyntax _ _) = []
@@ -759,7 +761,7 @@ tldeclared (PData _ _ _ _ _ (PDatadecl n _ _ ts)) = n : map fstt ts
759tldeclared (PParams _ _ ds) = []
761tldeclared (PParams _ _ ds) = []
760tldeclared (PMutual _ ds) = concatMap tldeclared ds
762tldeclared (PMutual _ ds) = concatMap tldeclared ds
761tldeclared (PNamespace _ ds) = concatMap tldeclared ds
763tldeclared (PNamespace _ ds) = concatMap tldeclared ds
762−tldeclared (PClass _ _ _ _ n _ _ _ ms) = concatMap tldeclared ms
764+tldeclared (PClass _ _ _ _ n _ _ _ ms cn _) = n : (maybeToList cn ++ concatMap tldeclared ms)
763tldeclared (PInstance _ _ _ _ _ _ _ _ _ _) = []
765tldeclared (PInstance _ _ _ _ _ _ _ _ _ _) = []
764tldeclared _ = []
766tldeclared _ = []
@@ -775,7 +777,7 @@ defined (PData _ _ _ _ _ (PLaterdecl n _ _)) = []
775defined (PParams _ _ ds) = concatMap defined ds
777defined (PParams _ _ ds) = concatMap defined ds
776defined (PNamespace _ ds) = concatMap defined ds
778defined (PNamespace _ ds) = concatMap defined ds
777defined (PRecord _ _ _ _ n _ _ _ cn _ _) = n : maybeToList cn
779defined (PRecord _ _ _ _ n _ _ _ cn _ _) = n : maybeToList cn
778−defined (PClass _ _ _ _ n _ _ _ ms) = n : concatMap defined ms
780+defined (PClass _ _ _ _ n _ _ _ ms cn _) = n : (maybeToList cn ++ concatMap defined ms)
779defined (PInstance _ _ _ _ _ _ _ _ _ _) = []
781defined (PInstance _ _ _ _ _ _ _ _ _ _) = []
780defined (PDSL n _) = [n]
782defined (PDSL n _) = [n]
781defined (PSyntax _ _) = []
783defined (PSyntax _ _) = []
@@ -1076,7 +1078,7 @@ highestFC (PQuoteName _) = Nothing
1077-- Type class data
1079-- Type class data
1079−data ClassInfo = CI { instanceName :: Name,
1081+data ClassInfo = CI { instanceCtorName :: Name,
1080 class_methods :: [(Name, (FnOpts, PTerm))],
1082 class_methods :: [(Name, (FnOpts, PTerm))],
1081 class_defaults :: [(Name, (Name, PDecl))], -- method name -> default impl
1083 class_defaults :: [(Name, (Name, PDecl))], -- method name -> default impl
1082 class_default_superclasses :: [PDecl],
1084 class_default_superclasses :: [PDecl],
@@ -1286,7 +1288,7 @@ getInferType (App _ (App _ _ ty) _) = ty
1287-- Handy primitives: Unit, False, Pair, MkPair, =, mkForeign
1289-- Handy primitives: Unit, False, Pair, MkPair, =, mkForeign
1289−primNames = [eqTy, eqCon, inferTy, inferCon]
1291+primNames = [inferTy, inferCon]
1291unitTy = sUN "Unit"
1293unitTy = sUN "Unit"
1292unitCon = sUN "MkUnit"
1294unitCon = sUN "MkUnit"
@@ -1350,7 +1352,7 @@ modDocName = sMN 0 "ModuleDocs"
1351-- Defined in builtins.idr
1353-- Defined in builtins.idr
1352sigmaTy = sNS (sUN "Sigma") ["Builtins"]
1354sigmaTy = sNS (sUN "Sigma") ["Builtins"]
1353−existsCon = sNS (sUN "MkSigma") ["Builtins"]
1355+sigmaCon = sNS (sUN "MkSigma") ["Builtins"]
1355piBind :: [(Name, PTerm)] -> PTerm -> PTerm
1357piBind :: [(Name, PTerm)] -> PTerm -> PTerm
1356piBind = piBindp expl
1358piBind = piBindp expl
@@ -1601,10 +1603,10 @@ pprintPTerm ppo bnd docArgs infixes = prettySe startPrec bnd
1601 annotated rparen
1603 annotated rparen
1602 where annotated = case pun of
1604 where annotated = case pun of
1603 IsType -> annName sigmaTy
1605 IsType -> annName sigmaTy
1604− IsTerm -> annName existsCon
1606+ IsTerm -> annName sigmaCon
1605 TypeOrTerm -> id
1607 TypeOrTerm -> id
1606 (left, addBinding) = case (l, pun) of
1608 (left, addBinding) = case (l, pun) of
1607− (PRef _ n, IsType) -> (bindingOf n False, ((n, False) :))
1609+ (PRef _ n, IsType) -> (bindingOf n False <+> text ":" <+> prettySe startPrec bnd t, ((n, False) :))
1608 _ -> (prettySe startPrec bnd l, id )
1610 _ -> (prettySe startPrec bnd l, id )
1609 prettySe p bnd (PAlternative a as) =
1611 prettySe p bnd (PAlternative a as) =
1610 lparen <> text "|" <> prettyAs <> text "|" <> rparen
1612 lparen <> text "|" <> prettyAs <> text "|" <> rparen
@@ -1788,7 +1790,7 @@ showDeclImp o (PData _ _ _ _ _ d) = showDImp o { ppopt_impl = True } d
1788showDeclImp o (PParams _ ns ps) = text "params" <+> braces (text (show ns) <> line <> showDecls o ps <> line)
1790showDeclImp o (PParams _ ns ps) = text "params" <+> braces (text (show ns) <> line <> showDecls o ps <> line)
1789showDeclImp o (PNamespace n ps) = text "namespace" <+> text n <> braces (line <> showDecls o ps <> line)
1791showDeclImp o (PNamespace n ps) = text "namespace" <+> text n <> braces (line <> showDecls o ps <> line)
1790showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1792showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
1791−showDeclImp o (PClass _ _ _ cs n ps _ _ ds)
1793+showDeclImp o (PClass _ _ _ cs n ps _ _ ds _ _)
1792 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1794 = text "class" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
1793showDeclImp o (PInstance _ _ _ _ cs n _ t _ ds)
1795showDeclImp o (PInstance _ _ _ _ cs n _ t _ ds)
1794 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
1796 = text "instance" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds