diff options
Diffstat (limited to 'stdlib/source/library/lux/time/duration.lux')
-rw-r--r-- | stdlib/source/library/lux/time/duration.lux | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 1b37584bf..020ba0275 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -26,16 +26,16 @@ (primitive .public Duration Int - (def: .public of_millis + (def .public of_millis (-> Int Duration) (|>> abstraction)) - (def: .public millis + (def .public millis (-> Duration Int) (|>> representation)) (with_template [<op> <name>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Duration Duration Duration) (abstraction (<op> (representation param) (representation subject))))] @@ -44,7 +44,7 @@ ) (with_template [<op> <name>] - [(def: .public (<name> scalar) + [(def .public (<name> scalar) (-> Nat Duration Duration) (|>> representation (<op> (.int scalar)) abstraction))] @@ -52,29 +52,29 @@ [i./ down] ) - (def: .public inverse + (def .public inverse (-> Duration Duration) (|>> representation (i.* -1) abstraction)) - (def: .public (ticks param subject) + (def .public (ticks param subject) (-> Duration Duration Int) (i./ (representation param) (representation subject))) - (def: .public equivalence + (def .public equivalence (Equivalence Duration) (implementation - (def: (= param subject) + (def (= param subject) (i.= (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Duration) (implementation - (def: equivalence ..equivalence) - (def: (< param subject) + (def equivalence ..equivalence) + (def (< param subject) (i.< (representation param) (representation subject))))) (with_template [<op> <name>] - [(def: .public <name> + [(def .public <name> (-> Duration Bit) (|>> representation (<op> +0)))] @@ -84,14 +84,14 @@ ) ) -(def: .public empty +(def .public empty (..of_millis +0)) -(def: .public milli_second +(def .public milli_second (..of_millis +1)) (with_template [<name> <scale> <base>] - [(def: .public <name> + [(def .public <name> (..up <scale> <base>))] [second 1,000 milli_second] @@ -103,17 +103,17 @@ [normal_year //year.days day] ) -(def: .public leap_year +(def .public leap_year (..composite ..day ..normal_year)) -(def: .public monoid +(def .public monoid (Monoid Duration) (implementation - (def: identity ..empty) - (def: composite ..composite))) + (def identity ..empty) + (def composite ..composite))) (with_template [<value> <definition>] - [(def: <definition> <value>)] + [(def <definition> <value>)] ["D" day_suffix] ["h" hour_suffix] @@ -125,7 +125,7 @@ ["-" negative_sign] ) -(def: (encoded duration) +(def (encoded duration) (if (at ..equivalence = ..empty duration) (all text#composite ..positive_sign @@ -152,7 +152,7 @@ (if (i.= +0 millis) "" (text#composite (nat#encoded (.nat millis)) ..milli_second_suffix)) )))) -(def: parser +(def parser (Parser Duration) (let [section (is (-> Text Text (Parser Nat)) (function (_ suffix false_suffix) @@ -181,21 +181,21 @@ {.#Left _} (..inverse span) {.#Right _} span))))) -(def: .public codec +(def .public codec (Codec Text Duration) (implementation - (def: encoded ..encoded) - (def: decoded (<text>.result ..parser)))) + (def encoded ..encoded) + (def decoded (<text>.result ..parser)))) -(def: .public (difference from to) +(def .public (difference from to) (-> Duration Duration Duration) (|> from ..inverse (..composite to))) -(def: .public enum +(def .public enum (Enum Duration) (implementation - (def: order ..order) - (def: succ + (def order ..order) + (def succ (..composite ..milli_second)) - (def: pred + (def pred (..composite (..inverse ..milli_second))))) |