Skip to content

Commit

Permalink
typecheck listener
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 authored and mn200 committed Nov 17, 2024
1 parent 833b239 commit 714696d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 714696d

Please sign in to comment.