aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math/ratio.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/math/ratio.lux')
-rw-r--r--stdlib/source/lux/math/ratio.lux10
1 files changed, 3 insertions, 7 deletions
diff --git a/stdlib/source/lux/math/ratio.lux b/stdlib/source/lux/math/ratio.lux
index 1baa9a206..c0e077c8a 100644
--- a/stdlib/source/lux/math/ratio.lux
+++ b/stdlib/source/lux/math/ratio.lux
@@ -13,6 +13,7 @@
monad)
(data [number "n/" Number<Nat> Codec<Text,Nat>]
[text "Text/" Monoid<Text>]
+ text/format
error
[product])
[compiler]
@@ -133,14 +134,9 @@
(-> Nat Text)
(|>. n/encode (text;split +1) (default (undefined)) product;right))
-(def: (part-decode part)
+(def: part-decode
(-> Text (Error Nat))
- (case (text;split-with "+" part)
- (#;Some [_ part])
- (n/decode part)
-
- _
- (fail "Invalid format for ratio part.")))
+ (|>. (format "+") n/decode))
(struct: #export _ (Codec Text Ratio)
(def: (encode (^slots [#numerator #denominator]))