Skip to content

Commit

Permalink
move Ordering to its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Nov 26, 2024
1 parent 09c0bb7 commit 9534bd2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
38 changes: 38 additions & 0 deletions Stdlib/Data/Ordering.juvix
Original file line number Diff line number Diff line change
@@ -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";
};
25 changes: 1 addition & 24 deletions Stdlib/Trait/Ord.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Stdlib/Trait/Show.juvix
Original file line number Diff line number Diff line change
@@ -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};

0 comments on commit 9534bd2

Please sign in to comment.