diff options
| author | Rutger Broekhoff | 2025-08-26 00:35:27 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2025-08-26 00:35:27 +0200 |
| commit | e6873458facadea0dfb228bb33291d6baf68c427 (patch) | |
| tree | 9ca19e2bbb12d92447f654a92280a6048383ebba /bin | |
| parent | b8fbaa53b912347b3b50cac3e913a142db460b0a (diff) | |
| download | rdcapsis-e6873458facadea0dfb228bb33291d6baf68c427.tar.gz rdcapsis-e6873458facadea0dfb228bb33291d6baf68c427.zip | |
Basic import seems to be working
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/dune | 2 | ||||
| -rw-r--r-- | bin/main.ml | 40 |
2 files changed, 41 insertions, 1 deletions
| @@ -1,4 +1,6 @@ | |||
| 1 | (executable | 1 | (executable |
| 2 | (public_name rdcapsis) | 2 | (public_name rdcapsis) |
| 3 | (name main) | 3 | (name main) |
| 4 | (preprocess | ||
| 5 | (pps ppx_jane)) | ||
| 4 | (libraries rdcapsis)) | 6 | (libraries rdcapsis)) |
diff --git a/bin/main.ml b/bin/main.ml index 7bf6048..1c6c6c9 100644 --- a/bin/main.ml +++ b/bin/main.ml | |||
| @@ -1 +1,39 @@ | |||
| 1 | let () = print_endline "Hello, World!" | 1 | open Core |
| 2 | module Time_ns = Time_ns_unix | ||
| 3 | |||
| 4 | module List = struct | ||
| 5 | include List | ||
| 6 | |||
| 7 | let map_result ~(f : 'a -> ('b, 'c) result) : 'a list -> ('b list, 'c) result | ||
| 8 | = | ||
| 9 | let open Result.Let_syntax in | ||
| 10 | let rec go = function | ||
| 11 | | [] -> return [] | ||
| 12 | | x :: xs -> | ||
| 13 | let%map x' = f x and xs' = go xs in | ||
| 14 | x' :: xs' | ||
| 15 | in | ||
| 16 | go | ||
| 17 | end | ||
| 18 | |||
| 19 | module Result = struct | ||
| 20 | include Result | ||
| 21 | |||
| 22 | let unwrap = function | ||
| 23 | | Error _ -> failwith "Result.unwrap: unexpected (Error _)" | ||
| 24 | | Ok v -> v | ||
| 25 | end | ||
| 26 | |||
| 27 | let () = | ||
| 28 | let ams_tz = Time_ns.Zone.find_exn "Europe/Amsterdam" in | ||
| 29 | let prim_txs = | ||
| 30 | In_channel.with_file ~binary:true "test.csv" | ||
| 31 | ~f:(Rdcapsis.Ingcsv.read_channel ~ams_tz) | ||
| 32 | |> Result.unwrap | ||
| 33 | in | ||
| 34 | let euc_id = "EUC" in | ||
| 35 | let ledger = | ||
| 36 | List.map_result ~f:(Rdcapsis.Convert.les_from_current_acc euc_id) prim_txs | ||
| 37 | |> Result.unwrap |> List.concat | ||
| 38 | in | ||
| 39 | print_endline (Sexp.to_string_hum ([%sexp_of: Rdcapsis.Ledger.t] ledger)) | ||