Fix optics tutorial sample code (2) #98
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rename
_address
to_workAddress
so the Prism sample code works.As discussed in #95.
Regarding the documentation: I was wondering if the Composite tutorial could be expanded with sample code. As far as I understand, Composite would be useful to create a single, reusable form. For example, a form could be created to edit a Todo item, which could then be used in other contexts. The current Todo example not implemented this way. Instead each
TodoRow
directly uses the main model, hence it returns aTodoNode
. In a different implementation a Todo could be edited inline and a single Todo would be overlayed with an edit form when its pencil is clicked. That would also mean that multiple Todo's could be in edit mode simultaneously and each Todo item would have its own state. Am I correct that composites would be used for this? In Elm this would be simple, but there are two locations where glue code is required. I could easily create a subModel (e.g.SingleTodo
), subMessages (e.g.EditTodo
) and correspondingview: SingleTodo -> Html SubMessage
(in Monomer:buildUi
) andupdate: SubMessage -> SingleTodo -> (SingleTodo, Cmd SubMessage)
(in Monomer:handleEvent
). When using it in the main application'sview
, I could use the subview
function andHtml.map
it to a parent'sMessage
and similarly I could useCmd.map
in the parent'supdate
function. How is this done in Monomer? What are these two "magic" functions in Monomer? Or is it discouraged? All I could find was in theTextField.hs
source, but this probably isn't the way to do it. Maybe I have the wrong mindset of Composite, otherwise it would probably be useful to have some documentation about this "glue" code or a link to some example code.At this point I just wanted to thank you for the library 🎉. In addition to a great design and extensive functionality it's been really helpful to have so much documentation and helpful responses and code samples to questions here on github 😊. This makes the library really accessible, even for beginners.