<div dir="ltr"><div>This is a demonstration of DWT, a data structure built from and more flexible than graphs. It is powered by the *wonderful* Functional Graph Library.</div><div><br></div><div>We beseech your involvement! DWT is open-source and actively seeking co-developers. I would happily trade any and all the privilege of determining tasks, teaching haskell or math, learning anything, and receiving obligations. We surely have much knowledge to trade! Even just a "hey why don't you do [this]!" could be precious to me.</div><div><br></div><div>This transcript makes tiny digressions about what monads make possible.</div><div><br></div><div>> let g = empty :: Mindmap -- g is now an empty mindmap (which is a kind of graph).</div><div>> g <- pure $ insStr "frog" g -- This inserts a string into g.</div><div>>   -- "g <- pure $" because we use the IO monad to redefine g.</div><div>> -- Now g has one thing, the word frog:</div><div>> v g $ nodes g -- This views every expression in g.</div><div>(0,"0: frog")</div><div>>   -- The 0 before the comma is a count of how many expressions refer to that expression. None do, because none yet exist. Such contexts offer many possibilities for tracking where you are (the data) and how you got there (also kind of the data, and perhaps enabling a desirable kind of removal of self|redaction).</div><div>>   -- The second 0 is an FGL Node, the address of the string "frog".</div><div>> -- Let's add more words:</div><div>> g <- pure $ insStr "moist" g</div><div>> g <- pure $ insStr "springy" g</div><div>> -- Now g has three words:</div><div>> v g $ nodes g</div><div>(0,"0: frog")</div><div>(0,"1: moist")</div><div>(0,"2: springy")</div><div>> -- Let's indicate that moist and springy are both qualities of frogs:</div><div>> -- First, we'll create a template for relationships about qualities.</div><div>> g <- pure $ insTplt "_ is a quality of _" g</div><div>> v g $ nodes g</div><div>(0,"0: frog")</div><div>(0,"1: moist")</div><div>(0,"2: springy")</div><div>(0,":3 _ #(is a quality of) _")</div><div>>   -- The template has been inserted at node 3. Its address is preceded by a : to indicate that it is a template, as opposed to the string "_ is a quality of _". (That will seem more natural in the context of how relationships are displayed.)</div><div>> -- Now we'll use the template at 3 to insert two relationships among the other nodes:</div><div>> -- We could have added them in a single stage:</div><div>> g <- pure $ fromRight $ insRel 3 [2,0] g >>= insRel 3 [1,0]</div><div>>   -- insRel 3 [1,0] inserts "moist is a quality of frog".</div><div>>   -- insRel 3 [2,0] inserts "springy is a quality of frog".</div><div>>   -- Both relationships use the template at node 3, and in both the second member is frog, at node 0.</div><div>>   -- Since the template at 3 relates 2 expressions, each list has length two. Templates can have any arity -- for instance, "_ does _ to _" has arity 3.</div><div>>   -- I used the monadic bind operator (>>=) because that way I only need to escape one Either monad (using fromRight) rather than two of them, one containing the other.</div><div>> -- Inserting those two relationships worked:</div><div>> v g $ nodes g</div><div>(2,"0: frog")</div><div>(1,"1: moist")</div><div>(1,"2: springy")</div><div>(2,":3 _ #(is a quality of) _")</div><div>(0,"4:3 2: springy ##(is a quality of) 0: frog")</div><div>(0,"5:3 1: moist ##(is a quality of) 0: frog")</div><div>>   -- When showing a relationship, the node (integer) listed first, before the :, is it's address, and the node listed after the : is the address of its template.</div><div>>   -- After the first two, any other node in a relationship is the address of the symbol(s) it appears just left of.</div><div>>   -- Notice that now the frog is in two relationships. One of those relationships involves springy, the other involves moist.</div><div>>   -- The # symbols are better explained later.</div><div>> -- DWT can encode meta-statements, statements about other statements. As an example, next let's encode that maybe frogs are springy because they use rubber bands. </div><div>> -- First we should insert a new string and a couple new templates for relationships.</div><div>> g <- pure $ insTplt "maybe _ because _" g</div><div>> g <- pure $ insStr "rubber bands" g</div><div>> g <- pure $ insTplt "_ uses _" g</div><div>> v g $ nodes g</div><div>(2,"0: frog")</div><div>(1,"1: moist")</div><div>(1,"2: springy")</div><div>(2,":3 _ #(is a quality of) _")</div><div>(0,"4:3 2: springy ##(is a quality of) 0: frog")</div><div>(0,"5:3 1: moist ##(is a quality of) 0: frog")</div><div>(0,":6 #maybe _ #because _")</div><div>(0,"7: rubber bands")</div><div>(0,":8 _ #uses _")</div><div>> -- Now we can encode the subexpression that frog uses rubber bands.</div><div>> g <- pure $ fr $ insRel 8 [0,7] g</div><div>> v g $ nodes g</div><div>(3,"0: frog")</div><div>(1,"1: moist")</div><div>(1,"2: springy")</div><div>(2,":3 _ #(is a quality of) _")</div><div>(0,"4:3 2: springy ##(is a quality of) 0: frog")</div><div>(0,"5:3 1: moist ##(is a quality of) 0: frog")</div><div>(0,":6 #maybe _ #because _")</div><div>(1,"7: rubber bands")</div><div>(1,":8 _ #uses _")</div><div>(0,"9:8 0: frog ##uses 7: rubber bands")</div><div>> -- From those elements, we can encode that maybe frogs are springy because they use rubber bands.</div><div>> g <- pure $ fr $ insRel 6 [4,9] g</div><div>> v g $ nodes g</div><div>(3,"0: frog")</div><div>(1,"1: moist")</div><div>(1,"2: springy")</div><div>(2,":3 _ #(is a quality of) _")</div><div>(1,"4:3 2: springy ##(is a quality of) 0: frog")</div><div>(0,"5:3 1: moist ##(is a quality of) 0: frog")</div><div>(1,":6 #maybe _ #because _")</div><div>(1,"7: rubber bands")</div><div>(1,":8 _ #uses _")</div><div>(1,"9:8 0: frog ##uses 7: rubber bands")</div><div>(0,"10:6 ####maybe 4:3 2: springy ##(is a quality of) 0: frog ####because 9:8 0: frog ##uses 7: rubber bands")</div><div><br></div><div>At last I can explain the # symbols: They indicate how fast an expression binds. In the last, at node 10, the highest-level|slowest-binding relationship is "maybe _ because _". In the first _ of the maybe-because relationship is another relationship, one that binds faster and hence has fewer # symbols, between springy and frog. The strings "springy", "frog" and "rubber bands" can be thought of as atomic, "binding" even before the first-level relationships bind.</div><div><br></div><div>This illustrates one of DWT's advantages over graphs. In a graph, an edge cannot be a member of another edge. By contrast, in DWT a relationship can involve other relationships.</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Jeffrey Benjamin Brown</div></div>
</div>