summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/dune2
-rw-r--r--bin/main.ml40
2 files changed, 41 insertions, 1 deletions
diff --git a/bin/dune b/bin/dune
index b82e38f..34c3866 100644
--- a/bin/dune
+++ b/bin/dune
@@ -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 @@
1let () = print_endline "Hello, World!" 1open Core
2module Time_ns = Time_ns_unix
3
4module 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
17end
18
19module Result = struct
20 include Result
21
22 let unwrap = function
23 | Error _ -> failwith "Result.unwrap: unexpected (Error _)"
24 | Ok v -> v
25end
26
27let () =
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))