Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typecheck listener #1346

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/parse/Preterm.sig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ sig
((term -> string) * (hol_type -> string)) option -> preterm -> term errM
val typecheckS : preterm -> term seqM

val typecheck_listener : (preterm -> Pretype.Env.t -> unit) ref
val last_tcerror : (tcheck_error * locn.locn) option ref

end
11 changes: 8 additions & 3 deletions src/parse/Preterm.sml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ fun remove_case_magic tm =
else tm

val post_process_term = ref (I : term -> term);
val typecheck_listener = ref (fn _:preterm => fn _:Pretype.Env.t => ());

fun typecheck pfns ptm0 =
let
Expand All @@ -866,8 +867,10 @@ fun typecheck pfns ptm0 =
lift remove_case_magic
(TC pfns ptm0 >>
overloading_resolution ptm0 >- (fn (ptm,b) =>
report_ovl_ambiguity b >> to_term ptm)) >- (fn t =>
fn e => errormonad.Some(e, !post_process_term t))
(report_ovl_ambiguity b >> to_term ptm) >- (fn t =>
fn e => (
!typecheck_listener ptm e;
errormonad.Some(e, !post_process_term t)))))
end

fun typecheckS ptm =
Expand All @@ -877,7 +880,9 @@ fun typecheckS ptm =
in
lift (!post_process_term o remove_case_magic)
(fromErr TC' >> overloading_resolutionS ptm >-
(fn ptm' => fromErr (to_term ptm')))
(fn ptm' => fromErr (errormonad.bind (to_term ptm', fn t => fn e => (
!typecheck_listener ptm' e;
errormonad.Some(e, t))))))
end


Expand Down