-
Notifications
You must be signed in to change notification settings - Fork 53
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
e274add
commit 317abf0
Showing
2 changed files
with
38 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- Deriving Eq | ||
module test085; | ||
|
||
import Stdlib.Data.Fixity open; | ||
import Stdlib.Data.Bool open; | ||
import Stdlib.System.IO open; | ||
|
||
builtin eq | ||
trait | ||
type Eq A := mkEq@{builtin isEqual isEqual : A -> A -> Bool}; | ||
|
||
open Eq; | ||
|
||
syntax operator == comparison; | ||
|
||
== {A} {{Eq A}} : A -> A -> Bool := Eq.isEqual; | ||
|
||
syntax operator , pair; | ||
|
||
deriving instance | ||
eqBoolI : Eq Bool; | ||
|
||
type Pair (A B : Type) := , : A → B → Pair A B; | ||
|
||
deriving instance | ||
eqPairI {A} {B} {{Eq A}} {{Eq B}} : Eq (Pair A B); | ||
|
||
main : IO := | ||
printLn (isEqual true true) | ||
>>> printLn (not (isEqual false true)) | ||
>>> printLn (isEqual (false, true) (false, true)) | ||
>>> printLn (not (isEqual (false, true) (false, false))); |