-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/lenses #25
Feature/lenses #25
Conversation
(I couldn't utilize the advantages I hoped for by using make Fields)
Thank you for the explanation @timunkulus. Nice work! |
Fix some warnings, add meaningful errors
cellsToReveal = filter (not . isFlagged)(toList board) | ||
cellCoordinates = map coordinate cellsToReveal | ||
cellsToReveal = filter (not . _isFlagged)(toList board) | ||
cellCoordinates = map _coordinate cellsToReveal | ||
resultBoard = foldl setCellToRevealed board cellCoordinates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@griase94 wenn checkst wie man hier und weiter unten die Lense Syntax anwendet, gerne anpassen ;)
I think we can simplyfy the revealing and flagging syntax quite a lot by using https://hackage.haskell.org/package/matrix-lens, I will give it a try after implementing the mutable state with TVars |
Sounds good! Nice find. |
…logic for storing paused and finished games in the database
Co-authored-by: Andreas Ellwanger <andreas.ellwanger@campus.lmu.de>
In-memory mutable state for ongoing games
I added lenses to our project.
For the yesod models they can be added automatically by adding
mpsGenerateLenses = True
inModel.hs
.For the other models they have to be generated manually.
After adding lenses, fields of records can be read and manipulated using this syntax:
See also:
https://riptutorial.com/haskell/example/2987/lenses-for-records
Updating multiple fields trick:
https://mail.haskell.org/pipermail/haskell-cafe/2013-November/111288.html
I didn't use the lenses syntax for all the yesod template files as I think we are going to remove them soon anyways.