-
Notifications
You must be signed in to change notification settings - Fork 3
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
0726a11
commit 5682e95
Showing
12 changed files
with
465 additions
and
348 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,8 +144,9 @@ update (Just a) _ = a | |
update Nothing a = a | ||
updateUser4 : User4Update -> User4DB -> User4DB | ||
updateUser4 upd old = let upd' = setAt' () Int Nothing upd | ||
in hliftA2 update upd' old | ||
updateUser4 upd old = | ||
let upd' := setAt' () Int Nothing upd | ||
in hliftA2 update upd' old | ||
``` | ||
|
||
Let's break this down a bit: Function `setAt` replaces the | ||
|
@@ -164,8 +165,10 @@ Let's see how this works out. | |
```idris | ||
export | ||
testUpd : User4DB | ||
testUpd = updateUser4 [Nothing,Nothing,Nothing,Just 44,Nothing] | ||
[12,"hock","[email protected]",42,"top secret"] | ||
testUpd = | ||
updateUser4 | ||
[Nothing,Nothing,Nothing,Just 44,Nothing] | ||
[12,"hock","[email protected]",42,"top secret"] | ||
``` | ||
|
||
We'll have to inspect the result at | ||
|
@@ -197,11 +200,12 @@ data IdField = IdYes | IdNo | |
data PasswordField = PwYes | PwNo | ||
||| Fields of a user data type | ||
data UserField = Id IdField | ||
| Name | ||
| Age | ||
| PW PasswordField | ||
data UserField : Type where | ||
Id : IdField -> UserField | ||
Name : UserField | ||
EMail : UserField | ||
Age : UserField | ||
PW : PasswordField -> UserField | ||
||| Converts a `UserField` to the corresponding | ||
||| value type | ||
|
@@ -231,8 +235,9 @@ UserUpdate : Type | |
UserUpdate = User IdNo PwYes Maybe | ||
updateUser : UserUpdate -> UserDB -> UserDB | ||
updateUser upd old = let upd' = setAt' (Id IdNo) (Id IdYes) Nothing upd | ||
in hliftA2 update upd' old | ||
updateUser upd old = | ||
let upd' := setAt' (Id IdNo) (Id IdYes) Nothing upd | ||
in hliftA2 update upd' old | ||
``` | ||
|
||
While the syntax is a bit more verbose that with proper | ||
|
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
Oops, something went wrong.