JeffreyBenjaminBrown / hode

rslt, take five-ish
GNU General Public License v3.0
147 stars 4 forks source link

Permit other UIs #4

Open JeffreyBenjaminBrown opened 5 years ago

JeffreyBenjaminBrown commented 5 years ago

Some of the discussion on this earlier issue regards permitting other applications, say Vim, to access Hode without having to go through ncurses. It's possible. @adaszko suggests a REPL with autocomplete. I haven't got autocomplete, but GHCI itself is a REPL that lets you do everything you'd want to do in the GUI. I'll write this up further later, but here's a sketch:

The module Hode.UI.NoUI provides all the needed functions. It's not very many -- all there is to do, after all, is add statements and search for them. For instance, if you have defined this code:

r = either (error "bad parse") id $ nInserts (mkRslt mempty) [ "0 #is mystical" , "0 #is a number" , "1 #is mystical" , "1 #is a number" , "the sun #is mystical" , "the sun #is a great flaming ball of gas" , "5000 #is a number" ] you'll have defined a graph that describes some properties of some numbers and the sun. You can then run the following in GHCI to find all mystical numbers:

nFindStringsIO r "/eval (/it= /eval /it #is a number) #is mystical" 3: 0 6: 1 (Before each colon appears the address of the expression after the colon.) You could then add a few more statements to the graph interactively:

Right r <- return $ nInsert' r "birds #eat fish" Right r <- return $ nInsert' r "bears #eat fish" Right r <- return $ nInsert' r "fish #eat bugs" Right r <- return $ nInsert' r "bugs #eat glyphosate" and search for everything that eats glyphosate:

nFindStringsIO r "/tr /it #eat glyphosate" 19: birds 20: fish 22: bears 24: bugs 26: glyphosate (Transitive relationships are a new feature. Currently the system assumes any transitive relationship is reflexive, which is why glyphosate appears in the results for things that eat glyphosate. If you don't want it there, for now you'll have to do the subtraction manually, like the following.)

nFindStringsIO r "(/tr /it #eat glyphosate) \ glyphosate" 19: birds 20: fish 22: bears 24: bugs

no-identd commented 4 years ago

http://leoeditor.com/ seems like a good candidate for some grafting?

JeffreyBenjaminBrown commented 4 years ago

That's pretty! Will bear in mind ...