console¶
In [ ]:
//// test
open testing
fsharp¶
console_color¶
In [ ]:
nominal console_color = $'System.ConsoleColor'
reset_color¶
In [ ]:
inl reset_color () : () =
run_target function
| Fsharp => fun () => $'System.Console.ResetColor ()'
| _ => fun () => ()
set_foreground_color¶
In [ ]:
inl set_foreground_color (color : console_color) : () =
run_target function
| Fsharp => fun () => $'System.Console.ForegroundColor <- !color '
| _ => fun () => ()
console¶
write_line¶
In [ ]:
inl write_line obj : () =
backend_switch {
Fsharp = fun () =>
fun () => obj |> $'System.Console.WriteLine'
|> exec_unit
Python = fun () => $'print(!obj)' : ()
}
write¶
In [ ]:
inl write forall t. (x : t) : () =
inl s = x |> sm'.format
backend_switch {
Python = fun () => $'print(!s, end="")' : ()
Fsharp = fun () => $'!s |> System.Console.Write' : ()
}
write_ln¶
In [ ]:
inl write_ln l : () =
write l
backend_switch {
Cuda = fun () => $'printf("\\n")' : ()
Python = fun () => $"print()" : ()
Fsharp = fun () => write_line () : ()
}