JeffreyBenjaminBrown / digraphs-with-text

BSD 3-Clause "New" or "Revised" License
65 stars 5 forks source link

Saving configuration data #7

Open JeffreyBenjaminBrown opened 6 years ago

JeffreyBenjaminBrown commented 6 years ago

Since RSLT is an instance of Read and Show, it can already be saved as plain text:

>>> g <- ui empty -- after executing this, I added the expression "a # b" and then exited the ui
>>> s = show g -- s is g represented as a String
>>> s
"mkGraph [(0,Word \"a\"),(1,Word \"b\"),(2,Tplt [\"\",\"\",\"\"]),(3,Rel)] [(3,0,RelEdge (Mbr 1)),(3,1,RelEdge (Mbr 2)),(3,2,RelEdge TpltRole)]"
>>> writeFile "data.rslt" s
>>> s' <- readFile "data.rslt"
>>> g' = read h :: RSLT
>>> g'
mkGraph [(0,Word "a"),(1,Word "b"),(2,Tplt ["","",""]),(3,Rel)] [(3,0,RelEdge (Mbr 1)),(3,1,RelEdge (Mbr 2)),(3,2,RelEdge TpltRole)]

However, the user cannot yet save configuration details like "decorate tasks by prepending the symbol TODO", "Order expressions by priority", or "Hide anything marked 'boring'."

The configuration data will need to refer to the graph. It would be most naturally encoded as part of the graph. That will require expanding the data model (the number of Expr constructors).

A less elegant but easier alternative would be to store the configuration data as QNodes that match on text. This has the drawback, though, that if the text of the graph changes, the QNodes can become invalid.