Fork me on GitHub
#specter
<
2018-10-31
>
npetryk14:10:57

Hey @nathanmarz, in a few of your blog posts you mention using specter for some pretty interesting graph stuff. I was interested in making specialized navigators for https://jsonapi.org/ and thought some examples of defining navigators for "specialized" domains might be helpful. Do you have any more information / examples about your graph implementation?

npetryk14:10:13

IDK if ur familiar with the spec but the most kludgey thing it requires me to do is to hold onto the top level document, or some kind of id -> entity index, while I'm navigating through the tree structure w/ specter

npetryk14:10:47

I'm handling that by attaching metadata onto the things I'm navigating into, but like I said, its a little kludgy

nathanmarz14:10:55

@npetryk my graph navigators are specifically for dag's

nathanmarz14:10:11

TOPSORT is like ALL but visits nodes in topological order

jsa-aerial15:10:59

Wow. This looks to be exactly what I will be needing in rewriting a DAG transformer! Specter is awesome! 💯

nathanmarz14:10:46

REVERSE-TOPSORT is the same but opposite order

nathanmarz14:10:59

CHILDREN goes from node to all children

nathanmarz14:10:07

likewise PARENTS, DESCENDANTS

nathanmarz14:10:31

NODE goes from a pointer to a node (which the aforementioned ones navigate you to) to the value for that node

nathanmarz14:10:56

node-nav navigates to a specific node

nathanmarz14:10:58

and then a couple navigators for navigating to sub-dag's, with metadata and ids on nodes used to determine how to attach the transformed sub-dag into the parent dag

nathanmarz14:10:49

there's a few more but those are the main ones

nathanmarz14:10:30

for navigating a tree you probably don't need custom navigator implementations, just a few composite navigators using recursive-path

nathanmarz14:10:35

if you have some examples I can walk you through it

npetryk15:10:12

Thanks! https://github.com/nathanmarz/specter/issues/241 also gave me some insight. It looks like that instead of passing [graph node-id] around I can just pass my tree "context" as metadata on individual nodes. The bit about reducing in the transform is also helpful for when I need to make updates to my tree

jsa-aerial15:10:59

Wow. This looks to be exactly what I will be needing in rewriting a DAG transformer! Specter is awesome! 💯