-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ac952b
commit 548f3b5
Showing
31 changed files
with
674 additions
and
577 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
module Stdlib.Data.Bool; | ||
|
||
import Stdlib.Data.Bool.Base open public; | ||
import Stdlib.Data.Pair.Base open; | ||
import Stdlib.Data.String.Base open; | ||
import Stdlib.Trait.Eq open; | ||
import Stdlib.Trait.Ord open; | ||
import Stdlib.Trait.Show open; | ||
|
||
{-# specialize: true, inline: case #-} | ||
instance | ||
boolEqI : Eq Bool := | ||
mkEq | ||
λ { | ||
| true true := true | ||
| false false := true | ||
| _ _ := false | ||
}; | ||
mkEq@{ | ||
eq (x y : Bool) : Bool := | ||
case x, y of | ||
| true, true := true | ||
| false, false := true | ||
| _ := false | ||
}; | ||
|
||
{-# specialize: true, inline: case #-} | ||
instance | ||
boolOrdI : Ord Bool := | ||
mkOrd | ||
λ { | ||
| false false := EQ | ||
| false true := LT | ||
| true false := GT | ||
| true true := EQ | ||
}; | ||
mkOrd@{ | ||
cmp (x y : Bool) : Ordering := | ||
case x, y of | ||
| false, false := Equal | ||
| false, true := LessThan | ||
| true, false := GreaterThan | ||
| true, true := Equal | ||
}; | ||
|
||
instance | ||
showBoolI : Show Bool := | ||
mkShow | ||
λ { | ||
| true := "true" | ||
| false := "false" | ||
}; | ||
mkShow@{ | ||
show (x : Bool) : String := | ||
if | ||
| x := "true" | ||
| else := "false" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.