Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xandkar/8985090 to your computer and use it in GitHub Desktop.

Select an option

Save xandkar/8985090 to your computer and use it in GitHub Desktop.
Demonstration of how to write OCaml source files so that no double semicolons are ever required
let print_line =
let line = String.make 80 '-' in
fun () -> print_endline line
module UglyA =
struct
open Printf
let x = 5;;
printf "Hello from UglyA!\n";
printf "UglyA says x is %d\n" x;;
let x = 9;;
printf "UglyA says new x is %d\n" x;
print_line ()
end
module UglyB =
struct
open Printf;;
printf "Hello from UglyB!\n";;
let x = 18;;
printf "UglyB says x is %d\n" x;
print_line ()
end
module Pretty =
struct
open Printf
let x = 39
let y = 1
let z = 2
let () =
let sum = x + y + z in
printf "Hello from Pretty!\n";
printf "Pretty thinks that x + y + z = %d!\n" sum
let () =
printf "Pretty wants more side effects here\n";
print_line ()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment