Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created May 11, 2012 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaja47/2663111 to your computer and use it in GitHub Desktop.
Save kaja47/2663111 to your computer and use it in GitHub Desktop.
lenses
// 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