-
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
11f8aae
commit e37b4ee
Showing
8 changed files
with
8 additions
and
124 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,23 +1,3 @@ | ||
module Stdlib.Data.Fixity; | ||
|
||
syntax fixity none := none; | ||
|
||
syntax fixity rapp := binary {assoc := right}; | ||
syntax fixity lapp := binary {assoc := left; same := rapp}; | ||
syntax fixity seq := binary {assoc := left; above := [lapp]}; | ||
|
||
syntax fixity functor := binary {assoc := right}; | ||
|
||
syntax fixity logical := binary {assoc := right; above := [seq]}; | ||
syntax fixity comparison := binary {assoc := none; above := [logical]}; | ||
|
||
syntax fixity pair := binary {assoc := right}; | ||
syntax fixity cons := binary {assoc := right; above := [pair]}; | ||
|
||
syntax fixity step := binary {assoc := right}; | ||
syntax fixity range := binary {assoc := right; above := [step]}; | ||
|
||
syntax fixity additive := binary {assoc := left; above := [comparison; range; cons]}; | ||
syntax fixity multiplicative := binary {assoc := left; above := [additive]}; | ||
|
||
syntax fixity composition := binary {assoc := right; above := [multiplicative]}; | ||
import Juvix.Builtin.V1.Fixity open public; |
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
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,47 +1,3 @@ | ||
module Stdlib.Data.Nat.Base; | ||
|
||
import Stdlib.Data.Fixity open; | ||
|
||
--- Inductive natural numbers. I.e. whole non-negative numbers. | ||
builtin nat | ||
type Nat := | ||
| zero | ||
| suc Nat; | ||
|
||
syntax operator + additive; | ||
|
||
--- Addition for ;Nat;s. | ||
builtin nat-plus | ||
+ : Nat → Nat → Nat | ||
| zero b := b | ||
| (suc a) b := suc (a + b); | ||
|
||
syntax operator * multiplicative; | ||
|
||
--- Multiplication for ;Nat;s. | ||
builtin nat-mul | ||
* : Nat → Nat → Nat | ||
| zero _ := zero | ||
| (suc a) b := b + a * b; | ||
|
||
--- Truncated subtraction for ;Nat;s. | ||
builtin nat-sub | ||
sub : Nat → Nat → Nat | ||
| zero _ := zero | ||
| n zero := n | ||
| (suc n) (suc m) := sub n m; | ||
|
||
--- Division for ;Nat;s. Returns ;zero; if the first element is ;zero;. | ||
builtin nat-udiv | ||
terminating | ||
udiv : Nat → Nat → Nat | ||
| zero _ := zero | ||
| n m := suc (udiv (sub n m) m); | ||
|
||
--- Division for ;Nat;s. | ||
builtin nat-div | ||
div (n m : Nat) : Nat := udiv (sub (suc n) m) m; | ||
|
||
--- Modulo for ;Nat;s. | ||
builtin nat-mod | ||
mod (n m : Nat) : Nat := sub n (div n m * m); | ||
import Juvix.Builtin.V1.Nat.Base open public; |
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,19 +1,3 @@ | ||
module Stdlib.Trait.Natural; | ||
|
||
import Stdlib.Data.Nat.Base open using {Nat}; | ||
import Stdlib.Data.Fixity open; | ||
|
||
trait | ||
type Natural A := | ||
mkNatural { | ||
syntax operator + additive; | ||
+ : A -> A -> A; | ||
syntax operator * multiplicative; | ||
* : A -> A -> A; | ||
div : A -> A -> A; | ||
mod : A -> A -> A; | ||
builtin from-nat | ||
fromNat : Nat -> A | ||
}; | ||
|
||
open Natural public; | ||
import Juvix.Builtin.V1.Trait.Natural open public; |