src/HOL/Fun.thy
changeset 25886 7753e0d81b7a
parent 24286 7619080e49f0
child 26105 ae06618225ec
equal deleted inserted replaced
25885:6fbc3f54f819 25886:7753e0d81b7a
   495 *}
   495 *}
   496 
   496 
   497 
   497 
   498 subsection {* Code generator setup *}
   498 subsection {* Code generator setup *}
   499 
   499 
       
   500 types_code
       
   501   "fun"  ("(_ ->/ _)")
       
   502 attach (term_of) {*
       
   503 fun term_of_fun_type _ aT _ bT _ = Free ("<function>", aT --> bT);
       
   504 *}
       
   505 attach (test) {*
       
   506 fun gen_fun_type aF aT bG bT i =
       
   507   let
       
   508     val tab = ref [];
       
   509     fun mk_upd (x, (_, y)) t = Const ("Fun.fun_upd",
       
   510       (aT --> bT) --> aT --> bT --> aT --> bT) $ t $ aF x $ y ()
       
   511   in
       
   512     (fn x =>
       
   513        case AList.lookup op = (!tab) x of
       
   514          NONE =>
       
   515            let val p as (y, _) = bG i
       
   516            in (tab := (x, p) :: !tab; y) end
       
   517        | SOME (y, _) => y,
       
   518      fn () => Basics.fold mk_upd (!tab) (Const ("arbitrary", aT --> bT)))
       
   519   end;
       
   520 *}
       
   521 
   500 code_const "op \<circ>"
   522 code_const "op \<circ>"
   501   (SML infixl 5 "o")
   523   (SML infixl 5 "o")
   502   (Haskell infixr 9 ".")
   524   (Haskell infixr 9 ".")
   503 
   525 
   504 code_const "id"
   526 code_const "id"