theory Code imports Main begin locale A = fixes b :: 'b and ba :: "'b \ 'a :: linorder" and baa :: "'b \ 'a \ 'a :: linorder" assumes "baa b a = a" begin definition code :: "'a \ 'a" where "code a = baa b a" end definition my_code where [code del]: "my_code \ \a. A.code a (\_. id)" interpretation A as id "\_. id" where "A.code as (\_. id) = my_code as" sorry export_code my_code in SML end