src/HOL/Library/Tools/termify_lazy.ML
author haftmann
Fri, 27 Jun 2025 08:09:26 +0200
changeset 82775 61c39a9e5415
parent 82379 3f875966c3e1
permissions -rw-r--r--
typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82379
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     1
(* Author: Pascal Stoop, ETH Zurich
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     2
   Author: Andreas Lochbihler, Digital Asset *)
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     3
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     4
structure Termify_Lazy =
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     5
struct
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     6
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     7
fun termify_lazy
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     8
  (_: string -> typ -> term) (_: term -> term -> term)  (_: string -> typ -> term -> term)
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     9
  (_: typ) (_: typ -> typ -> typ) (_: typ -> typ)
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    10
  (term_of: 'a -> term) (T: typ) (x: 'a Lazy.lazy) (_: term) =
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    11
  Const ("Code_Lazy.delay", (HOLogic.unitT --> T) --> Type ("Code_Lazy.lazy", [T])) $
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    12
  (case Lazy.peek x of
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    13
    SOME (Exn.Res x) => absdummy HOLogic.unitT (term_of x)
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    14
  | _ => Const ("Pure.dummy_pattern", HOLogic.unitT --> T));
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    15
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    16
end