@@ -72,7 +72,7 @@ elabInterface :: ElabInfo
72 -> Maybe (Name, FC) -- ^ implementation ctor name and location
72 -> Maybe (Name, FC) -- ^ implementation ctor name and location
73 -> Docstring (Either Err PTerm) -- ^ implementation ctor docs
73 -> Docstring (Either Err PTerm) -- ^ implementation ctor docs
74 -> Idris ()
74 -> Idris ()
75−elabInterface info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
75+elabInterface info_in syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
76 = do let cn = fromMaybe (SN (ImplementationCtorN tn)) (fst <$> mcn)
76 = do let cn = fromMaybe (SN (ImplementationCtorN tn)) (fst <$> mcn)
77 let constraint = PApp fc (PRef fc [] tn)
77 let constraint = PApp fc (PRef fc [] tn)
78 (map (pexp . PRef fc []) (map (\(n, _, _) -> n) ps))
78 (map (pexp . PRef fc []) (map (\(n, _, _) -> n) ps))
@@ -127,7 +127,7 @@ elabInterface info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
127 (map (\(n, _, _) -> n) ps)
127 (map (\(n, _, _) -> n) ps)
128 (map snd constraints)
128 (map snd constraints)
131 -- for each constraint, build a top level function to chase it
131 -- for each constraint, build a top level function to chase it
132 -- elaborate types now, bodies later (after we've done the constructor
132 -- elaborate types now, bodies later (after we've done the constructor
133 -- of the interface)
133 -- of the interface)
@@ -142,26 +142,27 @@ elabInterface info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
142 (map fst imethods)) imethods
142 (map fst imethods)) imethods
143 let (fnTyDecls, fnDefs) = unzip fns
143 let (fnTyDecls, fnDefs) = unzip fns
144 mapM_ (rec_elabDecl info EAll info) fnTyDecls
144 mapM_ (rec_elabDecl info EAll info) fnTyDecls
146 elabMethTys <- mapM getElabMethTy fullmnames
146 elabMethTys <- mapM getElabMethTy fullmnames
147 logElab 3 $ "Method types:\n" ++ showSep "\n" (map showTmImpls elabMethTys)
148 logElab 3 $ "Method types:\n" ++ showSep "\n" (map showTmImpls elabMethTys)
149 let cpos = map (\ (n, ty) -> (n, findConstraint ty))
150 let cpos = map (\ (n, ty) -> (n, findConstraint ty))
150 (zip fullmnames elabMethTys)
151 (zip fullmnames elabMethTys)
151 logElab 5 $ "Constraint pos: " ++ show cpos
152 logElab 5 $ "Constraint pos: " ++ show cpos
154+ -- Method types to store in the IState, taken from the elaborated
155+ -- types with the parameter removed
156+ let storemeths = map (mkMethTy True cpos) (zip fullmnames elabMethTys)
157+ updateIMethods tn storemeths
153 -- build implementation constructor type
159 -- build implementation constructor type
154 let cty = impbind [(pn, pt) | (pn, _, pt) <- impps ++ ps] $
160 let cty = impbind [(pn, pt) | (pn, _, pt) <- impps ++ ps] $
155 conbind constraints $
161 conbind constraints $
156− pibind (map (mkMethTy cpos) (zip fullmnames elabMethTys))
162+ pibind (map (mkMethTy False cpos) (zip fullmnames elabMethTys))
157 constraint
163 constraint
158− let ctyOld = impbind [(pn, pt) | (pn, _, pt) <- impps ++ ps] $ conbind constraints
159− $ pibind (map (\ (n, ty) -> (nsroot n, ty)) methods)
162 logElab 3 $ "Constraint constructor type: " ++ showTmImpls cty
164 logElab 3 $ "Constraint constructor type: " ++ showTmImpls cty
165 let cons = [(cd, pDocs ++ mapMaybe memberDocs ds, cn, NoFC, cty, fc, [])]
166 let cons = [(cd, pDocs ++ mapMaybe memberDocs ds, cn, NoFC, cty, fc, [])]
166 let ddecl = PDatadecl tn NoFC tty cons
167 let ddecl = PDatadecl tn NoFC tty cons
@@ -198,10 +199,15 @@ elabInterface info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
198 maybe [] (\(conN, conNFC) -> [(conNFC, AnnName conN Nothing Nothing Nothing)]) mcn
199 maybe [] (\(conN, conNFC) -> [(conNFC, AnnName conN Nothing Nothing Nothing)]) mcn
202+ info = info_in { noCaseLift = tn : noCaseLift info_in }
201 getElabMethTy :: Name -> Idris PTerm
204 getElabMethTy :: Name -> Idris PTerm
202 getElabMethTy n = do ist <- getIState
205 getElabMethTy n = do ist <- getIState
206+ let impls = case lookupCtxtExact n (idris_implicits ist) of
203 case lookupTyExact n (tt_ctxt ist) of
209 case lookupTyExact n (tt_ctxt ist) of
204− Just ty -> return (delabDirect ist ty)
210+ Just ty -> return (delabTy' ist impls ty False False False)
205 Nothing -> tclift $ tfail (At fc (InternalMsg "Can't happen, elabMethTy"))
211 Nothing -> tclift $ tfail (At fc (InternalMsg "Can't happen, elabMethTy"))
207 -- Find the argument position of the current interface in a method type
213 -- Find the argument position of the current interface in a method type
@@ -219,8 +225,9 @@ elabInterface info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
220 -- Make the method component of the constructor type by taking the
226 -- Make the method component of the constructor type by taking the
221 -- elaborated top level method and removing the implicits/constraint
227 -- elaborated top level method and removing the implicits/constraint
222− mkMethTy :: [(Name, Int)] -> (Name, PTerm) -> (Name, PTerm)
228+ mkMethTy :: Bool -> [(Name, Int)] -> (Name, PTerm) -> (Name, PTerm)
229+ mkMethTy keepns cpos (n, tm)
223− mkMethTy cpos (n, tm) = (nsroot n, dropPis num (mapPT dropImp tm))
230+ = (if keepns then n else nsroot n, dropPis num (mapPT dropImp tm))
225 num = case lookup n cpos of
232 num = case lookup n cpos of
226 Just i -> i + 1
233 Just i -> i + 1