Last active
January 24, 2016 21:58
-
-
Save DrBoolean/0bce198678166de23609 to your computer and use it in GitHub Desktop.
lens6
This file contains hidden or 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
| const addresses = lensProp('addresses') | |
| const street = lensProp('street') | |
| const allStreets = compose(addresses, mapped, street) | |
| // :: Int -> Task Error User | |
| const getUser = id => new Task((rej, res) => setTimeout(() => res(user), 400)) | |
| // profilePage :: User -> Html | |
| const profilePage = compose(map(x => `<span>${x.street}<span>`), view(addresses)) | |
| // updateUser :: User -> User | |
| const updateUser = over(allStreets, replace(/\d+/, '****')) | |
| // renderProfile :: User -> Html | |
| const renderProfile = compose(map(compose(profilePage, updateUser)), getUser) | |
| renderProfile(1).fork(console.log, console.log) | |
| // [ '<span>**** Walnut Dr.<span>', '<span>**** Crane Way<span>' ] |
Author
Thanks for the correction!
renderProfile type anotation should be: Int -> Task Err Html?
Ps: thanks for the article!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aren't numbers in the second address replaced with
****as well?As a sidenote: amazing article, thanks so much for it, Brian!