Skip to content

Instantly share code, notes, and snippets.

@DrBoolean
Last active January 24, 2016 21:58
Show Gist options
  • Select an option

  • Save DrBoolean/0bce198678166de23609 to your computer and use it in GitHub Desktop.

Select an option

Save DrBoolean/0bce198678166de23609 to your computer and use it in GitHub Desktop.
lens6
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>' ]
@cust0dian-old
Copy link
Copy Markdown

Aren't numbers in the second address replaced with **** as well?

[ '<span>**** Walnut Dr.<span>', '<span>**** Crane Way<span>' ]

As a sidenote: amazing article, thanks so much for it, Brian!

@DrBoolean
Copy link
Copy Markdown
Author

Thanks for the correction!

@paparga
Copy link
Copy Markdown

paparga commented Jan 24, 2016

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