-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix name signature bug and extend test for instance fields (#2928)
- Closes #2923 This pr fixes a bug where all fields were assigned to be explicit arguments in the NameSignature Builder. A single line change was enough to fix it. ```diff - RecordStatementField RecordField {..} -> addSymbol @s Explicit Nothing _fieldName _fieldType + RecordStatementField RecordField {..} -> addSymbol @s (fromIsImplicitField _fieldIsImplicit) Nothing _fieldName _fieldType ``` I've also added a compilation test for instance fields.
- Loading branch information
1 parent
1e9850c
commit 178bc53
Showing
8 changed files
with
116 additions
and
46 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nothing | ||
just 1 |
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,67 @@ | ||
-- Instance Fields | ||
module test077; | ||
|
||
import Stdlib.Data.Nat.Base open; | ||
import Stdlib.Data.Fixity open; | ||
import Stdlib.System.IO open; | ||
import Stdlib.Data.Maybe open; | ||
|
||
trait | ||
type Functor (f : Type -> Type) := mkFunctor {map : {A B : Type} -> (A -> B) -> f A -> f B}; | ||
|
||
trait | ||
type Applicative (f : Type -> Type) := | ||
mkApplicative { | ||
{{ApplicativeFunctor}} : Functor f; | ||
pure : {A : Type} -> A -> f A; | ||
ap : {A B : Type} -> f (A -> B) -> f A -> f B | ||
}; | ||
|
||
trait | ||
type Monad (f : Type -> Type) := | ||
mkMonad { | ||
{{MonadApplicative}} : Applicative f; | ||
bind : {A B : Type} -> f A -> (A -> f B) -> f B | ||
}; | ||
|
||
open Functor; | ||
open Applicative; | ||
open Monad; | ||
|
||
syntax operator >>= seq; | ||
>>= {A B} {f : Type -> Type} {{Monad f}} (x : f A) (g : A -> f B) : f B := bind x g; | ||
|
||
monadMap {A B} {f : Type -> Type} {{Monad f}} (g : A -> B) (x : f A) : f B := map g x; | ||
|
||
instance | ||
maybeFunctor : Functor Maybe := | ||
mkFunctor@{ | ||
map {A B} (f : A -> B) : Maybe A -> Maybe B | ||
| nothing := nothing | ||
| (just x) := just (f x) | ||
}; | ||
|
||
instance | ||
maybeApplicative : Applicative Maybe := | ||
mkApplicative@{ | ||
pure := just; | ||
ap {A B} : Maybe (A -> B) -> Maybe A -> Maybe B | ||
| (just f) (just x) := just (f x) | ||
| _ _ := nothing | ||
}; | ||
|
||
instance | ||
maybeMonad : Monad Maybe := | ||
mkMonad@{ | ||
bind {A B} : Maybe A -> (A -> Maybe B) -> Maybe B | ||
| nothing _ := nothing | ||
| (just a) f := f a | ||
}; | ||
|
||
minusOne : Nat -> Maybe Nat | ||
| zero := nothing | ||
| (suc n) := just n; | ||
|
||
minusThree (n : Nat) : Maybe Nat := pure n >>= minusOne >>= minusOne >>= minusOne; | ||
|
||
main : IO := printLn (minusThree 1) >>> printLn (minusThree 4); |
This file was deleted.
Oops, something went wrong.