Created
April 20, 2026 09:12
-
-
Save avsm/13ae99c41eba9f0c561e28f8f66899b8 to your computer and use it in GitHub Desktop.
demonstrator of oi with Base/ppx
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
| [@@@opam base stdio ppx_jane] | |
| open Base | |
| open Stdio | |
| type t = { bar: float } [@@deriving sexp] | |
| let rec read_and_accumulate accum = | |
| let line = In_channel.input_line In_channel.stdin in | |
| match line with | |
| | None -> accum | |
| | Some x -> read_and_accumulate (accum +. Float.of_string x) | |
| let () = | |
| let t = { bar=read_and_accumulate 0. } in | |
| printf "Total: %s\n" (Sexp.to_string_hum (sexp_of_t t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment