~pepe/eleanor

Data manager
Fix return from if
Add add/remove cases

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~pepe/eleanor
read/write
git@git.sr.ht:~pepe/eleanor

You can also use your local clone with git send-email.

#Eleanor

Data structures querying tool. The basic concept is the function created from the path with guide function from the library code, which can be called with data structure to query. There is also the tour convenience function that created the quite and calls it in one go.

#General overview

#Data types

Eleanor is specialy designed for the mutable Janet types, eg. tables and arrays. Or better, we did not have any motivation for working with immutable types.

#Path

Path could be considered a Janet DSL akin to the peg definition, but simpler both in definition - no structs just tuples, and workings - only couple of the operations are available.

Any path must be a tuple, bracketed by tradition, and contain steps needed to traverse or transform the datastructure. Inside the tuple you need to list the steps along the way. Each step operates on the current base, which is usualy result of the traversing or transforming previous base. The first base is the provided datastructure.

There are three main kinds of steps:

  • literals
    • keyword, string or number are called with get on the base
    • functions that are not parameters of other operarors filter the current base for the members that the function returns truthy value.
  • symbols
    • all gets all values from the base if it is a table. If the base is array values of all of its members are mapped and flattened to new array.
    • vals gets all the values of the base
    • keys get all the keys of the base
    • exists only truthy members of the base are filtered
    • drop drops all collected results, more about collecting later
    • trace tracev the current base
    • not negates the next function, be it filter or parameter
  • tuples are matched on first member and the tuple parameter which is again tuple
    • if walks the subpath parameter, but the last function is not filtering the current base, but the base just before the if tuple
    • collect walks the subpath parameter and adds the final base to the result. Then it rewinds the base to just before collect tuple. The result of the whole path will be always last item of the resulting array
    • transform walks the subpath tuple and applies the last function of it to the base. You are mutating the memebers of the datastructure with it.
    • view similar to the transform but clones or splices the base before walking the subpath.
    • view-collected is similar to the view, but the function will receive not only the base but also all the collected values as arguments.
    • not negates the function in the subpath
#Anatomy example

So lets say we have path:

'[:clients all
  :projects all
  :task all :name]

That can be read as:

  • get all clients from the root and flatten them to one array
    • get all projects from all the members of the base and flatten them
      • get all tasks from all projects, flatten them and get name of all of them

#Cases

In the /cases directory are Judge Gen cases describing the usage. Please feel free to refer to these for more detailed examples.

#Status

Consolidation phase of the development. All the bits and pieces are in place, we just need to polish and document them all. Stay tuned.