Skip to content

Commit

Permalink
Merge branch 'codef-2' into codef-3-deepThunk
Browse files Browse the repository at this point in the history
  • Loading branch information
William Sørensen committed Aug 8, 2024
2 parents 5befbab + 432649e commit d8be71e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Qpf/Macro/Data.lean
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ open Elab.Term (TermElabM)


def CtorView.declReplacePrefix (pref new_pref : Name) (ctor: CtorView) : CtorView :=
let declName := Name.replacePrefix ctor.declName pref new_pref
let declName := ctor.declName.replacePrefix pref new_pref
{
declName,
ref := ctor.ref
Expand Down
14 changes: 6 additions & 8 deletions Qpf/Macro/Data/Constructors.lean
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@ def mkConstructorsWithNameAndType
trace[QPF] "mkConstructors\n{ctor.declName} : {ctor.type?}"
let n_args := (ctor.type?.map countConstructorArgs).getD 0

let args ← (List.range n_args).mapM fun _ =>
do pure <| mkIdent <|← Elab.Term.mkFreshBinderName
let args := args.toArray
let args := (← (List.range n_args).mapM
fun _ => do pure <| mkIdent <|← Elab.Term.mkFreshBinderName).toArray

let mk := mkIdent ((DataCommand.fixOrCofix view.command).getId ++ `mk)
let pointConstructor := mkIdent ((DataCommand.fixOrCofix view.command).getId ++ `mk)
let shapeCtor := mkIdent <| Name.replacePrefix ctor.declName view.declName shape
trace[QPF] "shapeCtor = {shapeCtor}"



let body := if n_args = 0 then
`($mk $shapeCtor)
let body if n_args = 0 then
`($pointConstructor $shapeCtor)
else
`(fun $args:ident* => $mk ($shapeCtor $args:ident*))
let body ← body
`(fun $args:ident* => $pointConstructor ($shapeCtor $args:ident*))

let recType := view.getExpectedType
let forms := RecursionForm.extract ctor recType
Expand Down

0 comments on commit d8be71e

Please sign in to comment.