src/HOL/Library/Tools/termify_lazy.ocaml
author nipkow
Tue, 17 Jun 2025 14:11:40 +0200
changeset 82733 8b537e1af2ec
parent 82379 3f875966c3e1
permissions -rw-r--r--
reinstated intersection of lists as inter_list_set
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
module Termify_Lazy : sig
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     5
  val termify_lazy :
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     6
   (string -> 'typerep -> 'term) ->
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     7
   ('term -> 'term -> 'term) ->
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     8
   (string -> 'typerep -> 'term -> 'term) ->
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
     9
   'typerep -> ('typerep -> 'typerep -> 'typerep) -> ('typerep -> 'typerep) ->
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    10
   ('a -> 'term) -> 'typerep -> 'a Lazy.t -> 'term -> 'term
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    11
end = struct
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    12
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    13
let termify_lazy const app abs unitT funT lazyT term_of ty x _ =
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    14
  app (const "Code_Lazy.delay" (funT (funT unitT ty) (lazyT ty)))
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    15
    (if Lazy.is_val x then abs "_" unitT (term_of (Lazy.force x))
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    16
     else const "Pure.dummy_pattern" (funT unitT ty));;
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    17
3f875966c3e1 optional external files as code modules
haftmann
parents:
diff changeset
    18
end;;