This commit is contained in:
swrup 2025-10-13 04:15:58 +02:00
parent e37802e9dc
commit 959ccc1d1f
2 changed files with 10 additions and 5 deletions

View file

@ -17,8 +17,9 @@ type t = {
fraction: Int64.t; fraction: Int64.t;
} }
let ( let* ) o f = match o with Ok v -> f v | Error _ as e -> e
let make ~sign ~currency ~value ~fraction = let make ~sign ~currency ~value ~fraction =
let open Syntax in
let value_upper_bound = Z.(pow (of_int 2) 52) |> Z.to_int64 in let value_upper_bound = Z.(pow (of_int 2) 52) |> Z.to_int64 in
let fraction_upper_bound = Int64.of_int 99_999_999 in let fraction_upper_bound = Int64.of_int 99_999_999 in
let* () = if value < Int64.zero then Error "value is negative" else Ok () in let* () = if value < Int64.zero then Error "value is negative" else Ok () in

View file

@ -7,8 +7,9 @@
(library (library
(name mte) (name mte)
(wrapped false) (wrapped false)
(modules :standard \ mte base_32) (modules :standard \ mte base_32 amount)
(libraries (libraries
amount
base_32 base_32
; ;
include include
@ -23,13 +24,16 @@
jsont jsont
cohttp)) cohttp))
; crockford base32, as a lib to use [Base32] by accident *) (library ; crockford base32
(library
(name base_32) (name base_32)
(modules base_32) (modules base_32)
(libraries base32)) (libraries base32))
(library
(name amount)
(modules amount)
(libraries angstrom fmt zarith))
(rule (rule
(target assets_crunch.ml) (target assets_crunch.ml)
(deps (deps