@@ -44,6 +44,7 @@ elabType info syn fc opts n ty' = {- let ty' = piBind (params info) ty_in
4444 i <- get
4545 ty' <- implicit syn n ty'
4646 let ty = addImpl i ty'
47+ logLvl 3 $ show n ++ " pre-type " ++ showImp True ty'
4748 logLvl 2 $ show n ++ " type " ++ showImp True ty
4849 ((ty', defer, is), log) <- tclift $ elaborate ctxt n (Set (UVal 0)) []
4950 (erun fc (build i info False n ty))
@@ -112,6 +113,8 @@ elabRecord info syn fc tyn ty cn cty
112113 isNonImp (PExp _ _ _, a) = Just a
113114 isNonImp _ = Nothing
114115
116+ getImplB k (PPi (Imp l s) n Placeholder sc)
117+ = getImplB k sc
115118 getImplB k (PPi (Imp l s) n ty sc)
116119 = getImplB (\x -> k (PPi (Imp l s) n ty x)) sc
117120 getImplB k (PPi _ n ty sc)
@@ -635,7 +638,16 @@ elabInstance info syn fc cs n ps t ds
635638 iLOG ("Defaults inserted: " ++ show ds' ++ "\n" ++ show ci)
636639 mapM_ (warnMissing ds' ns) (map fst (class_methods ci))
637640 let wb = map mkTyDecl mtys ++ map (decorateid (decorate ns)) ds'
638− let lhs = PRef fc iname
641+ logLvl 3 $ "Method types " ++ showSep "\n" (map (showDeclImp True . mkTyDecl) mtys)
642+ -- get the implicit parameters that need passing through to the where block
643+ wparams <- mapM (\p -> case p of
644+ PApp _ _ args -> getWParams args
645+ _ -> return []) ps
646+ logLvl 3 $ "Instance is " ++ show ps ++ " implicits " ++
647+ show (concat (nub wparams))
648+ let lhs = case concat (nub wparams) of
649+ [] -> PRef fc iname
650+ as -> PApp fc (PRef fc iname) as
639651 let rhs = PApp fc (PRef fc (instanceName ci))
640652 (map (pexp . mkMethApp) mtys)
641653 let idecl = PClauses fc [Inlinable, TCGen] iname
@@ -659,6 +671,16 @@ elabInstance info syn fc cs n ps t ds
659671 papp fc f [] = f
660672 papp fc f as = PApp fc f as
661673
674+ getWParams [] = return []
675+ getWParams (p : ps)
676+ | PRef _ n <- getTm p
677+ = do ps' <- getWParams ps
678+ ctxt <- getContext
679+ case lookupP Nothing n ctxt of
680+ [] -> return (pimp n (PRef fc n) : ps')
681+ _ -> return ps'
682+ getWParams (_ : ps) = getWParams ps
683+
662684 decorate ns (UN n) = NS (UN ('!':n)) ns
663685 decorate ns (NS (UN n) s) = NS (UN ('!':n)) ns
664686
@@ -761,6 +783,7 @@ elabDecl' info (PDirective i) = i
761783
762784elabCaseBlock info d@(PClauses f o n ps)
763785 = do addIBC (IBCDef n)
786+-- iputStrLn $ "CASE BLOCK: " ++ show (n, d)
764787 elabDecl' info d
765788
766789-- elabDecl' info (PImport i) = loadModule i