diff options
Diffstat (limited to 'stdlib/source/lux/data/number.lux')
-rw-r--r-- | stdlib/source/lux/data/number.lux | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index cb98f5624..ad37a01ca 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -8,7 +8,7 @@ enum interval codec) - (data ["E" error]))) + (data ["R" result]))) (def: (clean-separators input) (-> Text Text) @@ -159,10 +159,10 @@ (def: (decode input) (case (_lux_proc <decoder> [input]) (#;Some value) - (#;Right value) + (#R;Success value) #;None - (#;Left <error>))))] + (#R;Error <error>))))] [Real ["real" "encode"] ["real" "decode"] "Could not decode Real"] ) @@ -214,16 +214,16 @@ (_lux_proc ["char" "to-text"] [digit]) +0]) #;None - (#;Left (_lux_proc ["text" "append"] [<error> repr])) + (#R;Error (_lux_proc ["text" "append"] [<error> repr])) (#;Some index) (recur (n.inc idx) (|> output (n.* <base>) (n.+ index))))) - (#;Right output)))) + (#R;Success output)))) _ - (#;Left (_lux_proc ["text" "append"] [<error> repr]))) - (#;Left (_lux_proc ["text" "append"] [<error> repr]))))))] + (#R;Error (_lux_proc ["text" "append"] [<error> repr]))) + (#R;Error (_lux_proc ["text" "append"] [<error> repr]))))))] [Binary@Codec<Text,Nat> +2 "01" "Invalid binary syntax for Nat: "] [Octal@Codec<Text,Nat> +8 "01234567" "Invalid octal syntax for Nat: "] @@ -271,13 +271,13 @@ (_lux_proc ["char" "to-text"] [digit]) +0]) #;None - (#;Left <error>) + (#R;Error <error>) (#;Some index) (recur (n.inc idx) (|> output (i.* <base>) (i.+ (:! Int index)))))) - (#;Right (i.* sign output))))) - (#;Left <error>)))))] + (#R;Success (i.* sign output))))) + (#R;Error <error>)))))] [Binary@Codec<Text,Int> 2 "01" "Invalid binary syntax for Int: "] [Octal@Codec<Text,Int> 8 "01234567" "Invalid octal syntax for Int: "] @@ -311,11 +311,11 @@ (^=> (#;Some #".") [(:: <nat> decode (_lux_proc ["text" "append"] ["+" (de-prefix repr)])) (#;Some output)]) - (#;Right (:! Deg output)) + (#R;Success (:! Deg output)) _ - (#;Left (_lux_proc ["text" "append"] [<error> repr]))) - (#;Left (_lux_proc ["text" "append"] [<error> repr]))))))] + (#R;Error (_lux_proc ["text" "append"] [<error> repr]))) + (#R;Error (_lux_proc ["text" "append"] [<error> repr]))))))] [Binary@Codec<Text,Deg> Binary@Codec<Text,Nat> +1 "Invalid binary syntax: "] [Octal@Codec<Text,Deg> Octal@Codec<Text,Nat> +3 "Invalid octal syntax: "] @@ -362,19 +362,19 @@ (r.* <base> output)))) adjusted-decimal (|> decimal int-to-real (r./ div-power)) dec-deg (case (:: Hex@Codec<Text,Deg> decode (_lux_proc ["text" "append"] ["." decimal-part])) - (#;Right dec-deg) + (#R;Success dec-deg) dec-deg - (#;Left error) + (#R;Error error) (error! error))] - (#;Right (r.+ (int-to-real whole) - (r.* sign adjusted-decimal)))) + (#R;Success (r.+ (int-to-real whole) + (r.* sign adjusted-decimal)))) _ - (#;Left (_lux_proc ["text" "append"] [<error> repr])))) + (#R;Error (_lux_proc ["text" "append"] [<error> repr])))) _ - (#;Left (_lux_proc ["text" "append"] [<error> repr])))))] + (#R;Error (_lux_proc ["text" "append"] [<error> repr])))))] [Binary@Codec<Text,Real> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "] ) @@ -552,14 +552,14 @@ [(if (r.= -1.0 sign) "-" "")] (_lux_proc ["text" "append"]))] (case (:: Binary@Codec<Text,Real> decode as-binary) - (#;Left _) - (#;Left (_lux_proc ["text" "append"] [<error> repr])) + (#R;Error _) + (#R;Error (_lux_proc ["text" "append"] [<error> repr])) output output)) _ - (#;Left (_lux_proc ["text" "append"] [<error> repr]))))))] + (#R;Error (_lux_proc ["text" "append"] [<error> repr]))))))] [Octal@Codec<Text,Real> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary] [Hex@Codec<Text,Real> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary] @@ -571,26 +571,26 @@ (case tokens (#;Cons [meta (#;Text repr)] #;Nil) (case (:: <nat> decode repr) - (#;Right value) - (#;Right [state (list [meta (#;Nat value)])]) + (#R;Success value) + (#R;Success [state (list [meta (#;Nat value)])]) - (^=> (#;Left _) - [(:: <int> decode repr) (#;Right value)]) - (#;Right [state (list [meta (#;Int value)])]) + (^=> (#R;Error _) + [(:: <int> decode repr) (#R;Success value)]) + (#R;Success [state (list [meta (#;Int value)])]) - (^=> (#;Left _) - [(:: <deg> decode repr) (#;Right value)]) - (#;Right [state (list [meta (#;Deg value)])]) + (^=> (#R;Error _) + [(:: <deg> decode repr) (#R;Success value)]) + (#R;Success [state (list [meta (#;Deg value)])]) - (^=> (#;Left _) - [(:: <real> decode repr) (#;Right value)]) - (#;Right [state (list [meta (#;Real value)])]) + (^=> (#R;Error _) + [(:: <real> decode repr) (#R;Success value)]) + (#R;Success [state (list [meta (#;Real value)])]) _ - (#;Left <error>)) + (#R;Error <error>)) _ - (#;Left <error>)))] + (#R;Error <error>)))] [bin Binary@Codec<Text,Nat> Binary@Codec<Text,Int> Binary@Codec<Text,Deg> Binary@Codec<Text,Real> "Invalid binary syntax." @@ -811,9 +811,9 @@ (recur (digits-sub! power digits) (n.inc idx) (bit-set (n.- idx (n.dec deg-bits)) output)))) - (#E;Success (:! Deg output)))) + (#R;Success (:! Deg output)))) #;None - (#E;Error (_lux_proc ["text" "append"] ["Wrong syntax for Deg: " input]))) - (#E;Error (_lux_proc ["text" "append"] ["Wrong syntax for Deg: " input])))) + (#R;Error (_lux_proc ["text" "append"] ["Wrong syntax for Deg: " input]))) + (#R;Error (_lux_proc ["text" "append"] ["Wrong syntax for Deg: " input])))) )) |