Skip to content

Commit

Permalink
run make format-juvix-files
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Dec 6, 2023
1 parent 2f99729 commit fe92c26
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
12 changes: 9 additions & 3 deletions examples/milestone/Bank/Bank.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ issue : Address -> Address -> Nat -> Token
assert (caller == bankAddress) (mkToken owner 0 amount);

--- Deposits some amount of money into the bank.
deposit (bal : Balances) (token : Token) (amount : Nat)
: Token :=
deposit
(bal : Balances) (token : Token) (amount : Nat) : Token :=
let
difference : Nat := sub (getAmount token) amount;
remaining : Token :=
Expand All @@ -111,7 +111,13 @@ deposit (bal : Balances) (token : Token) (amount : Nat)
in runOnChain (commitBalances bal') remaining;

--- Returns a new ;Token; containing the amount of money withdrawn.
withdraw (bal : Balances) (caller : Address) (recipient : Address) (amount : Nat) (rate : Nat) (periods : Nat)
withdraw
(bal : Balances)
(caller : Address)
(recipient : Address)
(amount : Nat)
(rate : Nat)
(periods : Nat)
: Token :=
assert
(caller == bankAddress)
Expand Down
8 changes: 5 additions & 3 deletions tests/negative/Internal/DefaultArgCycleArity.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module DefaultArgCycleArity;

import Stdlib.Data.Nat open;

fun {a : Nat := 1} {b : Nat := fun + a + 1} {c : Nat := b
+ a
+ 1} : Nat := a * b + c;
fun
{a : Nat := 1}
{b : Nat := fun + a + 1}
{c : Nat := b + a + 1}
: Nat := a * b + c;
13 changes: 7 additions & 6 deletions tests/positive/ConstructorWildcard.juvix
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
module ConstructorWildcard;

type Bool :=
false | true;
| false
| true;

type either (A B : Type) :=
left A
| left A
| right B;

isLeft {A B} : either A B → Bool
| left@{} := true
| right@{} := false;
| left@{} := true
| right@{} := false;

not : Bool → Bool
| false@{} := true
| true := false;
| false@{} := true
| true := false;
14 changes: 12 additions & 2 deletions tests/positive/DefaultValues.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ axiom c : C;

axiom d : D;

mk {f1 : A := a} {f2 : Type} {f3 : C := c} (x : f2)
mk
{f1 : A := a}
{f2 : Type}
{f3 : C := c}
(x : f2)
: A × f2 × C := f1, x, f3;

x1 : A × B × C := mk (x := b);

mk2 {f1 : A := a} {f2 : Type} {f3 : C := c} (x : f2) {f4 : D := d} (y : f2)
mk2
{f1 : A := a}
{f2 : Type}
{f3 : C := c}
(x : f2)
{f4 : D := d}
(y : f2)
: A × f2 × C := f1, x, f3;

x2 : A × B × C := mk2 (x := b) (y := b);
Expand Down
20 changes: 12 additions & 8 deletions tests/positive/Traits2.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ syntax operator >>= bind;
-> (A -> M B)
-> M B := Monad.bind;

Maybe-bind {A B : Type}
: Maybe A -> (A -> Maybe B) -> Maybe B
Maybe-bind
{A B : Type} : Maybe A -> (A -> Maybe B) -> Maybe B
| nothing _ := nothing
| (just a) f := f a;

Expand All @@ -74,13 +74,16 @@ import Stdlib.Data.Product open;
×-Functor : {A : Type} -> Functor ((×) A) :=
mkFunctor ×-fmap;

×-bind {A : Type} {{Semigroup A}} {B C : Type}
×-bind
{A : Type}
{{Semigroup A}}
{B C : Type}
: A × B -> (B -> A × C) -> A × C
| (a, b) f := case f b of {a', b' := a <> a', b'};

instance
×-Monad {A : Type} {{Semigroup A}} {{Monoid A}}
: Monad ((×) A) :=
×-Monad
{A : Type} {{Semigroup A}} {{Monoid A}} : Monad ((×) A) :=
mkMonad@{
bind := ×-bind;
return := λ {b := Monoid.mempty, b};
Expand All @@ -89,8 +92,8 @@ instance

type Reader (r a : Type) := mkReader {runReader : r -> a};

Reader-fmap {R A B : Type} (f : A -> B)
: Reader R A -> Reader R B
Reader-fmap
{R A B : Type} (f : A -> B) : Reader R A -> Reader R B
| (mkReader ra) := mkReader (f ∘ ra);

Reader-Functor-NoNamed {R : Type} : Functor (Reader R) :=
Expand All @@ -109,7 +112,8 @@ Reader-Monad {R : Type} : Monad (Reader R) :=
functor := Reader-Functor;
return {A : Type} (a : A) : Reader R A :=
mkReader (const a);
bind {A B : Type}
bind
{A B : Type}
: Reader R A -> (A -> Reader R B) -> Reader R B
| (mkReader ra) arb :=
let
Expand Down

0 comments on commit fe92c26

Please sign in to comment.