Created
February 13, 2014 22:18
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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