-
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
It would be nice having a toString : List Block -> String function which is a "reverse" of the parser.
Of course some data as indentation could be lost, but I think this manageable.
My use case and wished workflow is the following:
- an admin writes some article in a form. This content of the textarea is transformed to
List Block - this
List Blockis stored as it in the persistence layer (I'm using Lamdera) - when a user wants to see the article, we just have to render it with a
List Block->Htmlrenderer. - the next time an admin wants to edit the article, we could the string thanks to the
toStringfunction and we'd put this in a textarea.
We could just storing the string as it is entered by the admin but:
- this asks an extra parsing step for the user to view it. It of course seems an inefficient process but what mostly bothers me is that we could have an
Errduring the process... What do we display to the user in this case? - directly storing the
List Blockvalue automatically provides a formater, so all the contents are eventually uniformly displayed to the admin. - this feature could be a good spot for property testing (the property being:
forall blocks : List Block, blocks |> toString |> parse == Ok blocks. And it is always cool writing property tests :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels