Created
May 11, 2012 23:36
-
-
Save kaja47/2663111 to your computer and use it in GitHub Desktop.
lenses
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
// without lenses | |
val _board = chan.boards(bIdx) | |
val _thread = chan.boards(bIdx).threads(tIdx) | |
val _posts = chan.boards(bIdx).threads(tIdx).posts | |
Right(chan.copy(boards = chan.boards.updated(bIdx, _board.copy(threads = _board.threads.updated(tIdx, _thread.copy(posts = _posts :+ newPost.post)))))) | |
// with lenses | |
Right(boardsLens.at(bIdx).mod(chan, b => threadsLens.at(tIdx).mod(b, t => t.copy(posts = t.posts :+ newPost.post)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment