diff --git a/Stdlib/Data/Ordering.juvix b/Stdlib/Data/Ordering.juvix new file mode 100644 index 00000000..b399d754 --- /dev/null +++ b/Stdlib/Data/Ordering.juvix @@ -0,0 +1,38 @@ +module Stdlib.Data.Ordering; + +import Stdlib.Trait.Eq open; +import Stdlib.Data.Bool.Base open; +import Stdlib.Trait.Show open; + +builtin ordering +type Ordering := + | LessThan + | Equal + | GreaterThan; + +isLessThan (ordering : Ordering) : Bool := + case ordering of + | LessThan := true + | _ := false; + +isEqual (ordering : Ordering) : Bool := + case ordering of + | Equal := true + | _ := false; + +isGreaterThan (ordering : Ordering) : Bool := + case ordering of + | GreaterThan := true + | _ := false; + +deriving instance +orderingEqI : Eq Ordering; + +instance +orderingShowI : Show Ordering := + mkShow@{ + show : Ordering -> String + | Equal := "Equal" + | LessThan := "LessThan" + | GreaterThan := "GreaterThan"; + }; diff --git a/Stdlib/Trait/Ord.juvix b/Stdlib/Trait/Ord.juvix index d1222b6e..f79a5ee4 100644 --- a/Stdlib/Trait/Ord.juvix +++ b/Stdlib/Trait/Ord.juvix @@ -3,30 +3,7 @@ module Stdlib.Trait.Ord; import Stdlib.Data.Fixity open; import Stdlib.Data.Bool.Base open; import Stdlib.Trait.Eq open; - -builtin ordering -type Ordering := - | LessThan - | Equal - | GreaterThan; - -isLessThan (ordering : Ordering) : Bool := - case ordering of - | LessThan := true - | _ := false; - -isEqual (ordering : Ordering) : Bool := - case ordering of - | Equal := true - | _ := false; - -isGreaterThan (ordering : Ordering) : Bool := - case ordering of - | GreaterThan := true - | _ := false; - -deriving instance -orderingEqI : Eq Ordering; +import Stdlib.Data.Ordering open public; --- A trait for defining a total order builtin ord diff --git a/Stdlib/Trait/Show.juvix b/Stdlib/Trait/Show.juvix index 099513b0..07319430 100644 --- a/Stdlib/Trait/Show.juvix +++ b/Stdlib/Trait/Show.juvix @@ -1,6 +1,6 @@ module Stdlib.Trait.Show; -import Stdlib.Data.String.Base open; +import Juvix.Builtin.V1.String open public; trait type Show A := mkShow@{show : A -> String};