From eef4422b1f16be2b8c651461f2c006dc4c11f314 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 11 Dec 2022 16:07:39 -0400 Subject: Added support for fixed-point arithmetic. --- stdlib/source/format/lux/data/text.lux | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'stdlib/source/format') diff --git a/stdlib/source/format/lux/data/text.lux b/stdlib/source/format/lux/data/text.lux index 532edba75..43117912e 100644 --- a/stdlib/source/format/lux/data/text.lux +++ b/stdlib/source/format/lux/data/text.lux @@ -16,13 +16,14 @@ [collection ["[0]" list (.use "[1]#[0]" monad)]]] [math - ["[0]" modular] [number ["[0]" nat] ["[0]" int] ["[0]" rev] ["[0]" frac] - ["[0]" ratio]]] + ["[0]" ratio]] + [arithmetic + ["[0]" modular]]] [meta ["[0]" location] ["[0]" symbol] @@ -40,8 +41,9 @@ ["[0]" day] ["[0]" month]]]]]) -(.type .public (Format a) - (-> a Text)) +(.type .public (Format of) + (-> of + Text)) (def .public functor (contravariant.Functor Format) @@ -113,18 +115,23 @@ ) (def .public (mod modular) - (All (_ m) (Format (modular.Mod m))) + (All (_ %) + (Format (modular.Mod %))) (let [codec (modular.codec (modular.modulus modular))] (of codec encoded modular))) (def .public (list formatter) - (All (_ a) (-> (Format a) (Format (List a)))) + (All (_ of) + (-> (Format of) + (Format (List of)))) (|>> (list#each (|>> formatter (format " "))) text.together (text.enclosed ["(list" ")"]))) (def .public (maybe format) - (All (_ a) (-> (Format a) (Format (Maybe a)))) + (All (_ of) + (-> (Format of) + (Format (Maybe of)))) (function (_ value) (when value {.#None} -- cgit v1.2.3