@@ -767,6 +767,17 @@ elabPE info fc r =
767767 let sa = getSpecApps ist [] r
768768 mapM_ (mkSpecialised ist) sa
769769 where
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)
773+
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
777+ -- transformation.
778+
779+ -- Apply that transformation after every PClauses elaboration
780+
770781 mkSpecialised ist specapp = do
771782 let specTy = getSpecTy ist specapp
772783 let (n, newnm, [(lhs, rhs)]) = getSpecClause ist specapp
@@ -822,7 +833,8 @@ elabValBind :: ElabInfo -> Bool -> PTerm -> Idris (Term, Type, [(Name, Type)])
822833elabValBind info aspat tm_in
823834 = do ctxt <- getContext
824835 i <- getIState
825− let tm = addImpl i tm_in
836+ let tm = if aspat then addImplPat i tm_in
837+ else addImpl i tm_in
826838 logLvl 10 (showImp Nothing True False tm)
827839 -- try:
828840 -- * ordinary elaboration
@@ -833,18 +845,19 @@ elabValBind info aspat tm_in
833845-- tctry (elaborate ctxt (MN 0 "val") (TType (UVal 0)) []
834846-- (build i info aspat (MN 0 "val") tm))
835847 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)))
837849 let vtm = orderPats (getInferTerm tm')
838− let bargs = getPBtys vtm
839850
840851 def' <- checkDef (fileFC "(input)") defer
841852 addDeferred def'
842853 mapM_ (elabCaseBlock info []) is
843854
844− logLvl 3 ("Value: " ++ show tm')
845− recheckC (fileFC "(input)") [] tm'
846− logLvl 2 (show vtm)
855+ logLvl 3 ("Value: " ++ show vtm)
856+-- recheckC (fileFC "(input)") [] tm'
857+-- logLvl 2 (show vtm)
847858 (vtm, vty) <- recheckC (fileFC "(input)") [] vtm
859+ let bargs = getPBtys vtm
860+
848861 return (vtm, vty, bargs)
849862
850863elabVal :: ElabInfo -> Bool -> PTerm -> Idris (Term, Type)