package async_unix

  1. Overview
  2. Docs
Monadic concurrency library

Install

Dune Dependency

Authors

Maintainers

Sources

async_unix-v0.16.0.tar.gz
sha256=a6a86202acea433b5c739ac20190a9a364da9d9eb7ebd402f517b8c58983839b

doc/src/async_unix/async_print.ml.html

Source file async_print.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
open Core

let stdout () = Lazy.force Writer.stdout
let stderr () = Lazy.force Writer.stderr
let do_printf writer = ksprintf (fun s -> Writer.write (writer ()) s)
let printf fmt = do_printf stdout fmt
let fprintf writer fmt = Printf.ksprintf (fun s -> Writer.write writer s) fmt
let eprintf fmt = do_printf stderr fmt
let print_char c = Writer.write_char (stdout ()) c
let prerr_char c = Writer.write_char (stderr ()) c
let print_string s = Writer.write (stdout ()) s
let prerr_string s = Writer.write (stderr ()) s
let print_newline () = Writer.write_char (stdout ()) '\n'
let prerr_newline () = Writer.write_char (stderr ()) '\n'

let print_endline s =
  print_string s;
  print_newline ()
;;

let prerr_endline s =
  prerr_string s;
  prerr_newline ()
;;

let print_int i = print_string (Int.to_string i)
let prerr_int i = prerr_string (Int.to_string i)
let print_float f = print_string (Float.to_string_12 f)
let prerr_float f = prerr_string (Float.to_string_12 f)

let print_s ?mach sexp =
  print_endline
    (match mach with
     | Some () -> Sexp.to_string_mach sexp
     | None -> Sexp.to_string_hum sexp)
;;

let eprint_s ?mach sexp =
  prerr_endline
    (match mach with
     | Some () -> Sexp.to_string_mach sexp
     | None -> Sexp.to_string_hum sexp)
;;
OCaml

Innovation. Community. Security.