src/Tools/Code/code_haskell.ML
changeset 52801 6f88e379aa3e
parent 52519 598addf65209
child 55145 2bb3cd36bcf7
equal deleted inserted replaced
52800:1baa5d19ac44 52801:6f88e379aa3e
   461   in (2, ([c_bind], pretty)) end;
   461   in (2, ([c_bind], pretty)) end;
   462 
   462 
   463 fun add_monad target' raw_c_bind thy =
   463 fun add_monad target' raw_c_bind thy =
   464   let
   464   let
   465     val c_bind = Code.read_const thy raw_c_bind;
   465     val c_bind = Code.read_const thy raw_c_bind;
   466   in if target = target' then
   466   in
   467     thy
   467     if target = target' then
   468     |> Code_Target.set_printings (Code_Symbol.Constant (c_bind, [(target,
   468       thy
   469       SOME (Code_Printer.complex_const_syntax (pretty_haskell_monad c_bind)))]))
   469       |> Code_Target.set_printings (Code_Symbol.Constant (c_bind, [(target,
   470   else error "Only Haskell target allows for monad syntax" end;
   470         SOME (Code_Printer.complex_const_syntax (pretty_haskell_monad c_bind)))]))
       
   471     else error "Only Haskell target allows for monad syntax"
       
   472   end;
   471 
   473 
   472 
   474 
   473 (** Isar setup **)
   475 (** Isar setup **)
   474 
   476 
   475 val _ =
   477 val _ =
   476   Outer_Syntax.command @{command_spec "code_monad"} "define code syntax for monads"
   478   Outer_Syntax.command @{command_spec "code_monad"} "define code syntax for monads"
   477     (Parse.term_group -- Parse.name >> (fn (raw_bind, target) =>
   479     (Parse.term -- Parse.name >> (fn (raw_bind, target) =>
   478       Toplevel.theory  (add_monad target raw_bind)));
   480       Toplevel.theory (add_monad target raw_bind)));
   479 
   481 
   480 val setup =
   482 val setup =
   481   Code_Target.add_target
   483   Code_Target.add_target
   482     (target, { serializer = serializer, literals = literals,
   484     (target, { serializer = serializer, literals = literals,
   483       check = { env_var = "ISABELLE_GHC", make_destination = I,
   485       check = { env_var = "ISABELLE_GHC", make_destination = I,