@@ -53,7 +53,7 @@ import Util.Pretty(pretty, text)
53data MArgTy = IA | EA | CA deriving Show
53data MArgTy = IA | EA | CA deriving Show
55elabClass :: ElabInfo -> SyntaxInfo -> Docstring (Either Err PTerm) ->
55elabClass :: ElabInfo -> SyntaxInfo -> Docstring (Either Err PTerm) ->
56− FC -> [PTerm] ->
56+ FC -> [(Name, PTerm)] ->
57 Name -> [(Name, PTerm)] -> [(Name, Docstring (Either Err PTerm))] -> [PDecl] -> Idris ()
57 Name -> [(Name, PTerm)] -> [(Name, Docstring (Either Err PTerm))] -> [PDecl] -> Idris ()
58elabClass info syn_in doc fc constraints tn ps pDocs ds
58elabClass info syn_in doc fc constraints tn ps pDocs ds
59 = do let cn = SN (InstanceCtorN tn) -- sUN ("instance" ++ show tn) -- MN 0 ("instance" ++ show tn)
59 = do let cn = SN (InstanceCtorN tn) -- sUN ("instance" ++ show tn) -- MN 0 ("instance" ++ show tn)
@@ -115,7 +115,7 @@ elabClass info syn_in doc fc constraints tn ps pDocs ds
115 $ tfail (At fc (Msg $ "Default superclass instances can't have constraints."))
115 $ tfail (At fc (Msg $ "Default superclass instances can't have constraints."))
116 i <- getIState
116 i <- getIState
117 let t = PApp fc (PRef fc n) (map pexp ps)
117 let t = PApp fc (PRef fc n) (map pexp ps)
118− let isConstrained = any (== t) constraints
118+ let isConstrained = any (== t) (map snd constraints)
119 when (not isConstrained) . tclift
119 when (not isConstrained) . tclift
120 $ tfail (At fc (Msg $ "Default instances must be for a superclass constraint on the containing class."))
120 $ tfail (At fc (Msg $ "Default instances must be for a superclass constraint on the containing class."))
121 return ()
121 return ()
@@ -124,8 +124,8 @@ elabClass info syn_in doc fc constraints tn ps pDocs ds
124 impbind [] x = x
124 impbind [] x = x
125 impbind ((n, ty): ns) x = PPi impl n ty (impbind ns x)
125 impbind ((n, ty): ns) x = PPi impl n ty (impbind ns x)
127− conbind :: [PTerm] -> PTerm -> PTerm
127+ conbind :: [(Name, PTerm)] -> PTerm -> PTerm
128− conbind (ty : ns) x = PPi constraint (sMN 0 "class") ty (conbind ns x)
128+ conbind ((c, ty) : ns) x = PPi constraint c ty (conbind ns x)
129 conbind [] x = x
129 conbind [] x = x
131 getMName (PTy _ _ _ _ _ n _) = nsroot n
131 getMName (PTy _ _ _ _ _ n _) = nsroot n
@@ -160,15 +160,15 @@ elabClass info syn_in doc fc constraints tn ps pDocs ds
160 clause _ = False
160 clause _ = False
162 -- Generate a function for chasing a dictionary constraint
162 -- Generate a function for chasing a dictionary constraint
163− cfun :: Name -> PTerm -> SyntaxInfo -> [a] -> PTerm -> Idris [PDecl' PTerm]
163+ cfun :: Name -> PTerm -> SyntaxInfo -> [a] -> (Name, PTerm) -> Idris [PDecl' PTerm]
164− cfun cn c syn all con
164+ cfun cn c syn all (cnm, con)
165 = do let cfn = sUN ('@':'@':show cn ++ "#" ++ show con)
165 = do let cfn = sUN ('@':'@':show cn ++ "#" ++ show con)
166 -- SN (ParentN cn (show con))
166 -- SN (ParentN cn (show con))
167 let mnames = take (length all) $ map (\x -> sMN x "meth") [0..]
167 let mnames = take (length all) $ map (\x -> sMN x "meth") [0..]
168 let capp = PApp fc (PRef fc cn) (map (pexp . PRef fc) mnames)
168 let capp = PApp fc (PRef fc cn) (map (pexp . PRef fc) mnames)
169 let lhs = PApp fc (PRef fc cfn) [pconst capp]
169 let lhs = PApp fc (PRef fc cfn) [pconst capp]
170 let rhs = PResolveTC (fileFC "HACK")
170 let rhs = PResolveTC (fileFC "HACK")
171− let ty = PPi constraint (sMN 0 "pc") c con
171+ let ty = PPi constraint cnm c con
172 iLOG (showTmImpls ty)
172 iLOG (showTmImpls ty)
173 iLOG (showTmImpls lhs ++ " = " ++ showTmImpls rhs)
173 iLOG (showTmImpls lhs ++ " = " ++ showTmImpls rhs)
174 i <- getIState
174 i <- getIState