Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rplace ≔ by := #15

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Stdlib/Data/Bool.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ infixr 2 &&;

if : {A : Type} → Bool → A → A → A;
if true a _ ≔ a;
if false _ b b;
if false _ b := b;

--------------------------------------------------------------------------------
-- Backend Booleans
Expand Down Expand Up @@ -61,6 +61,6 @@ compile bool {
};

from-backend-bool : BackendBool → Bool;
from-backend-bool bb bool bb true false;
from-backend-bool bb := bool bb true false;

end;
8 changes: 4 additions & 4 deletions Stdlib/Data/List.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ filter f (h ∷ hs) ≔ if (f h)
(h ∷ filter f hs)
(filter f hs);

length : {A : Type} → List A → ;
length : {A : Type} → List A → Nat;
length nil ≔ zero;
length (_ ∷ l) ≔ suc (length l);

reverse : {A : Type} → List A → List A;
reverse ≔ foldl (flip (∷)) nil;

replicate : {A : Type} → → A → List A;
replicate : {A : Type} → Nat → A → List A;
replicate zero _ ≔ nil;
replicate (suc n) x ≔ x ∷ replicate n x;

take : {A : Type} → → List A → List A;
take : {A : Type} → Nat → List A → List A;
take (suc n) (x ∷ xs) ≔ x ∷ take n xs;
take _ _ ≔ nil;

splitAt : {A : Type} → → List A → List A × List A;
splitAt : {A : Type} → Nat → List A → List A × List A;
splitAt _ nil ≔ nil , nil ;
splitAt zero xs ≔ nil , xs;
splitAt (suc zero) (x ∷ xs) ≔ x ∷ nil , xs;
Expand Down
8 changes: 4 additions & 4 deletions Stdlib/Data/Maybe.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ inductive Maybe (A : Type) {
};

fromMaybe : {A : Type} → A → Maybe A → A;
fromMaybe a nothing a;
fromMaybe _ (just a) a;
fromMaybe a nothing := a;
fromMaybe _ (just a) := a;

maybe : {A : Type} → {B : Type} → B → (A → B) → Maybe A → B;
maybe b _ nothing b;
maybe _ f (just a) f a;
maybe b _ nothing := b;
maybe _ f (just a) := f a;

end;
38 changes: 19 additions & 19 deletions Stdlib/Data/Nat.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@ module Stdlib.Data.Nat;
open import Stdlib.Data.String;

builtin natural
inductive {
zero : ;
suc : ;
inductive Nat {
zero : Nat;
suc : NatNat;
};

infixl 6 +;
builtin natural-plus
+ : ;
+ zero b b;
+ (suc a) b suc (a + b);
+ : NatNatNat;
+ zero b := b;
+ (suc a) b := suc (a + b);

infixl 7 *;
* : ;
* zero b zero;
* (suc a) b b + (a * b);
* : NatNatNat;
* zero b := zero;
* (suc a) b := b + (a * b);

one : ;
one : Nat;
one ≔ suc zero;

two : ;
two : Nat;
two ≔ suc one;

three : ;
three : Nat;
three ≔ suc two;

four : ;
four : Nat;
four ≔ suc three;

five : ;
five : Nat;
five ≔ suc four;

six : ;
six : Nat;
six ≔ suc five;

seven : ;
seven : Nat;
seven ≔ suc six;

eight : ;
eight : Nat;
eight ≔ suc seven;

nine : ;
nine : Nat;
nine ≔ suc eight;

axiom natToStr : → String;
axiom natToStr : Nat → String;
compile natToStr {
c ↦ "intToStr";
};
Expand Down
24 changes: 12 additions & 12 deletions Stdlib/Data/Nat/Ord.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ open import Stdlib.Data.Nat;
open import Stdlib.Data.Ord;
open import Stdlib.Data.Bool;

compare : → Ordering;
compare : NatNat → Ordering;
compare zero zero ≔ EQ;
compare zero _ ≔ LT;
compare (suc _) zero ≔ GT;
compare (suc a) (suc b) compare a b;
compare (suc a) (suc b) := compare a b;

infix 4 ==;
== : → Bool;
== a b isEQ (compare a b);
== : NatNat → Bool;
== a b := isEQ (compare a b);

infix 4 <;
< : → Bool;
< a b isLT (compare a b);
< : NatNat → Bool;
< a b := isLT (compare a b);

infix 4 <=;
<= : → Bool;
<= a b not (isGT (compare a b));
<= : NatNat → Bool;
<= a b := not (isGT (compare a b));

infix 4 >;
> : → Bool;
> a b isGT (compare a b);
> : NatNat → Bool;
> a b := isGT (compare a b);

infix 4 >=;
>= : → Bool;
>= a b not (isLT (compare a b));
>= : NatNat → Bool;
>= a b := not (isLT (compare a b));

end;
12 changes: 6 additions & 6 deletions Stdlib/Data/Product.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ inductive × (A : Type) (B : Type) {
};

uncurry : {A : Type} → {B : Type} → {C : Type} → (A → B → C) → A × B → C;
uncurry f (a , b) f a b;
uncurry f (a , b) := f a b;

fst : {A : Type} → {B : Type} → A × B → A;
fst (a , _) ≔ a;

snd : {A : Type} → {B : Type} → A × B → B;
snd (_ , b) b;
snd (_ , b) := b;

swap : {A : Type} → {B : Type} → A × B → B × A;
swap (a , b) b , a;
swap (a , b) := b , a;

first : {A : Type} → {B : Type} → {A' : Type} → (A → A') → A × B → A' × B;
first f (a , b) f a , b;
first f (a , b) := f a , b;

second : {A : Type} → {B : Type} → {B' : Type} → (B → B') → A × B → A × B';
second f (a , b) a , f b;
second f (a , b) := a , f b;

both : {A : Type} → {B : Type} → (A → B) → A × A → B × B;
both f (a , b) f a , f b;
both f (a , b) := f a , f b;

end;
2 changes: 1 addition & 1 deletion Stdlib/Data/String/Ord.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ compile eqString {

infix 4 ==;
== : String → String → Bool;
== s1 s2 from-backend-bool (eqString s1 s2);
== s1 s2 := from-backend-bool (eqString s1 s2);

end;
4 changes: 2 additions & 2 deletions Stdlib/Function.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ id : {A : Type} → A → A;
id a ≔ a;

flip : {A : Type} → {B : Type} → {C : Type} → (A → B → C) → B → A → C;
flip f b a f a b;
flip f b a := f a b;

infixr 0 $;
$ : {A : Type} → {B : Type} → (A → B) → A → B;
$ f x ≔ f x;

infixl 0 on;
on : {A : Type} → {B : Type} → {C : Type} → (B -> B -> C) -> (A -> B) -> A -> A -> C;
on f g a b f (g a) (g b);
on f g a b := f (g a) (g b);

end;
2 changes: 1 addition & 1 deletion Stdlib/System/IO.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ builtin IO axiom IO : Type;

infixl 1 >>;
builtin IO-sequence axiom >> : IO → IO → IO;
builtin natural-print axiom printNat : → IO;
builtin natural-print axiom printNat : Nat → IO;

axiom putStr : String → IO;
compile putStr {
Expand Down