src/Tools/code/code_thingol.ML
changeset 28708 a1a436f09ec6
parent 28706 3fef773ae6b1
child 28724 4656aacba2bc
equal deleted inserted replaced
28707:548703affff5 28708:a1a436f09ec6
   665     val dty = nth tys n;
   665     val dty = nth tys n;
   666     fun is_undefined (Const (c, _)) = Code.is_undefined thy c
   666     fun is_undefined (Const (c, _)) = Code.is_undefined thy c
   667       | is_undefined _ = false;
   667       | is_undefined _ = false;
   668     fun mk_case (co, n) t =
   668     fun mk_case (co, n) t =
   669       let
   669       let
       
   670         val _ = if (is_some o Code.get_datatype_of_constr thy) co then ()
       
   671           else error ("Non-constructor " ^ quote co
       
   672             ^ " encountered in case pattern"
       
   673             ^ (case thm of NONE => ""
       
   674               | SOME thm => ", in equation\n" ^ Display.string_of_thm thm))
   670         val (vs, body) = Term.strip_abs_eta n t;
   675         val (vs, body) = Term.strip_abs_eta n t;
   671         val selector = list_comb (Const (co, map snd vs ---> dty), map Free vs);
   676         val selector = list_comb (Const (co, map snd vs ---> dty), map Free vs);
   672       in if is_undefined body then NONE else SOME (selector, body) end;
   677       in if is_undefined body then NONE else SOME (selector, body) end;
   673     fun mk_ds [] =
   678     fun mk_ds [] =
   674           let
   679           let