src/Tools/Code/code_haskell.ML
changeset 52435 6646bb548c6b
parent 52138 e21426f244aa
child 52519 598addf65209
equal deleted inserted replaced
52434:cbb94074682b 52435:6646bb548c6b
   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 if target = target' then
   467     thy
   467     thy
   468     |> Code_Target.add_const_syntax target c_bind
   468     |> Code_Target.set_printings (Code_Symbol.Constant (c_bind, [(target,
   469         (SOME (Code_Printer.complex_const_syntax (pretty_haskell_monad c_bind)))
   469       SOME (Code_Printer.complex_const_syntax (pretty_haskell_monad c_bind)))]))
   470   else error "Only Haskell target allows for monad syntax" end;
   470   else error "Only Haskell target allows for monad syntax" end;
   471 
   471 
   472 
   472 
   473 (** Isar setup **)
   473 (** Isar setup **)
   474 
   474 
   482     (target, { serializer = serializer, literals = literals,
   482     (target, { serializer = serializer, literals = literals,
   483       check = { env_var = "ISABELLE_GHC", make_destination = I,
   483       check = { env_var = "ISABELLE_GHC", make_destination = I,
   484         make_command = fn module_name =>
   484         make_command = fn module_name =>
   485           "\"$ISABELLE_GHC\" " ^ language_params  ^ " -odir build -hidir build -stubdir build -e \"\" " ^
   485           "\"$ISABELLE_GHC\" " ^ language_params  ^ " -odir build -hidir build -stubdir build -e \"\" " ^
   486             module_name ^ ".hs" } })
   486             module_name ^ ".hs" } })
   487   #> Code_Target.add_tyco_syntax target "fun" (SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] =>
   487   #> Code_Target.set_printings (Code_Symbol.Type_Constructor ("fun",
       
   488     [(target, SOME (2, fn print_typ => fn fxy => fn [ty1, ty2] =>
   488       brackify_infix (1, R) fxy (
   489       brackify_infix (1, R) fxy (
   489         print_typ (INFX (1, X)) ty1,
   490         print_typ (INFX (1, X)) ty1,
   490         str "->",
   491         str "->",
   491         print_typ (INFX (1, R)) ty2
   492         print_typ (INFX (1, R)) ty2
   492       )))
   493       )))]))
   493   #> fold (Code_Target.add_reserved target) [
   494   #> fold (Code_Target.add_reserved target) [
   494       "hiding", "deriving", "where", "case", "of", "infix", "infixl", "infixr",
   495       "hiding", "deriving", "where", "case", "of", "infix", "infixl", "infixr",
   495       "import", "default", "forall", "let", "in", "class", "qualified", "data",
   496       "import", "default", "forall", "let", "in", "class", "qualified", "data",
   496       "newtype", "instance", "if", "then", "else", "type", "as", "do", "module"
   497       "newtype", "instance", "if", "then", "else", "type", "as", "do", "module"
   497     ]
   498     ]