From f95748e82a354f2ac857359774ec3227705838af Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 26 Aug 2025 11:16:29 +0200 Subject: Prelude --- lib/ledger.ml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'lib/ledger.ml') diff --git a/lib/ledger.ml b/lib/ledger.ml index ba21e49..84a0146 100644 --- a/lib/ledger.ml +++ b/lib/ledger.ml @@ -1,4 +1,4 @@ -open Core +open Prelude type account_type = Asset | Equity | Liability | Expense | Income @@ -87,12 +87,6 @@ module Labels = struct Sexp.List [ Sexp.Atom "Unit_label"; [%sexp_of: unit_tag] tag ])) end -module Z = struct - include Z - - let sexp_of_t x = Sexp.Atom (Z.to_string x) -end - module Money : sig type t @@ -142,7 +136,15 @@ type bal_assert = { module Account_id_map = Map.Make (Account_id) module Tx : sig - type t + (* Private because we only want to allow constructing balanced transactions. *) + type t = private { + cleared : Date.t option; + commodity_id : commodity_id; + debit : scalar Account_id_map.t; + credit : scalar Account_id_map.t; + labels : Labels.t; + } + type error = Unbalanced val make : @@ -153,14 +155,8 @@ module Tx : sig labels:Labels.t -> (t, error) result - val cleared : t -> Date.t option - val commodity_id : t -> commodity_id - val debit : t -> scalar Account_id_map.t - val credit : t -> scalar Account_id_map.t - val labels : t -> Labels.t val sexp_of_t : t -> Sexp.t end = struct - (* We hide this because we only want to allow constructing balanced transactions *) type t = { cleared : Date.t option; commodity_id : commodity_id; @@ -168,7 +164,7 @@ end = struct credit : scalar Account_id_map.t; labels : Labels.t; } - [@@deriving fields, sexp_of] + [@@deriving sexp_of] type error = Unbalanced -- cgit v1.2.3