@@ -767,6 +767,17 @@ elabPE info fc r =
767 let sa = getSpecApps ist [] r
767 let sa = getSpecApps ist [] r
768 mapM_ (mkSpecialised ist) sa
768 mapM_ (mkSpecialised ist) sa
770+ -- TODO: Freeze the newly defined name, make sure it never gets
771+ -- reduced when specialising (not quite the same as an 'abstract' name
772+ -- so may need a new class (public/abstract/private/specialised)
774+ -- Add a PTerm level transformation rule, which is basically the
775+ -- new definition in reverse (before specialising it).
776+ -- RHS => LHS where implicit arguments are left blank in the
779+ -- Apply that transformation after every PClauses elaboration
770 mkSpecialised ist specapp = do
781 mkSpecialised ist specapp = do
771 let specTy = getSpecTy ist specapp
782 let specTy = getSpecTy ist specapp
772 let (n, newnm, [(lhs, rhs)]) = getSpecClause ist specapp
783 let (n, newnm, [(lhs, rhs)]) = getSpecClause ist specapp
@@ -822,7 +833,8 @@ elabValBind :: ElabInfo -> Bool -> PTerm -> Idris (Term, Type, [(Name, Type)])
822elabValBind info aspat tm_in
833elabValBind info aspat tm_in
823 = do ctxt <- getContext
834 = do ctxt <- getContext
824 i <- getIState
835 i <- getIState
836+ let tm = if aspat then addImplPat i tm_in
825− let tm = addImpl i tm_in
837+ else addImpl i tm_in
826 logLvl 10 (showImp Nothing True False tm)
838 logLvl 10 (showImp Nothing True False tm)
828 -- * ordinary elaboration
840 -- * ordinary elaboration
@@ -833,18 +845,19 @@ elabValBind info aspat tm_in
833-- tctry (elaborate ctxt (MN 0 "val") (TType (UVal 0)) []
845-- tctry (elaborate ctxt (MN 0 "val") (TType (UVal 0)) []
834-- (build i info aspat (MN 0 "val") tm))
846-- (build i info aspat (MN 0 "val") tm))
835 tclift (elaborate ctxt (MN 0 "val") infP []
847 tclift (elaborate ctxt (MN 0 "val") infP []
836− (build i info aspat (MN 0 "val") (infTerm tm)))
848+ (buildTC i info aspat False (MN 0 "val") (infTerm tm)))
837 let vtm = orderPats (getInferTerm tm')
849 let vtm = orderPats (getInferTerm tm')
838− let bargs = getPBtys vtm
840 def' <- checkDef (fileFC "(input)") defer
851 def' <- checkDef (fileFC "(input)") defer
841 addDeferred def'
852 addDeferred def'
842 mapM_ (elabCaseBlock info []) is
853 mapM_ (elabCaseBlock info []) is
844− logLvl 3 ("Value: " ++ show tm')
855+ logLvl 3 ("Value: " ++ show vtm)
845− recheckC (fileFC "(input)") [] tm'
856+-- recheckC (fileFC "(input)") [] tm'
846− logLvl 2 (show vtm)
857+-- logLvl 2 (show vtm)
847 (vtm, vty) <- recheckC (fileFC "(input)") [] vtm
858 (vtm, vty) <- recheckC (fileFC "(input)") [] vtm
859+ let bargs = getPBtys vtm
848 return (vtm, vty, bargs)
861 return (vtm, vty, bargs)
850elabVal :: ElabInfo -> Bool -> PTerm -> Idris (Term, Type)
863elabVal :: ElabInfo -> Bool -> PTerm -> Idris (Term, Type)