vendrinc/elm-flow-layout/1.0.0

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/vendrinc/elm-flow-layout is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 1.0.0 found (1 same-name repos checked); no cached copy. Use another version.

Details

Flow

Workflow

type Flow node
= Node node
| Sequential (List (Flow node))
| Parallel (List (Flow node))
| Condition
node
{ trueSeq : List (Flow node)
, falseSeq : List (Flow node)
}

Note that Sequential [] is our designated "empty" node. Parallel [] could fit the same purpose technically but we prefer Sequential. We coerce Parallel [] into Sequential [] when running optimize.

DESIGN NOTE: Another option would be to have non-empty lists in Sequential and Parallel and have an explicit Empty constructor.

Query

getNode : Flow node -> Maybe node
isSequential : Flow node -> Bool
isParallel : Flow node -> Bool
isCondition : Flow node -> Bool
isEmpty : Flow node -> Bool
descendants : Flow node -> List (Flow node)

Returns all recursive children of the Flow (including the input Flow itself), in a depth-first traversal.

Sequential
    [ Node 1
    , Parallel
        [ Node 2
        , Node 3
        ]
    , Condition 4
        { trueSeq = [ Node 5 ]
        , falseSeq = [ Node 6 ]
        }
    ]
    |> descendants
    == [ Sequential [ Node 1, Parallel [ Node 2, Node 3 ], Condition 4 { trueSeq = [ Node 5 ], falseSeq = [ Node 6 ] } ]
       , Node 1
       , Parallel [ Node 2, Node 3 ]
       , Node 2
       , Node 3
       , Condition 4 { trueSeq = [ Node 5 ], falseSeq = [ Node 6 ] }
       , Node 5
       , Node 6
       ]
nodes : Flow node -> List ( node, List Step )
Flow node
-> List
{ path : List Step
, node : node
}
rightEdgeNodes : Flow node -> List node

Collect the right-most nodes.

List Step
-> Flow node
-> List
{ node : node
, branch : Int
}
List Step
-> Flow node
-> List
{ path : List Step
, node : node
, branch : Int
}
findNode : (a -> Maybe b) -> Flow a -> Maybe b
{ nodeToId : node -> String }
-> Flow node
-> List
{ before : String
, after : String
, branch : Int
}

The before and after record fields are meant in the workflow sense: you need to first complete the before step, then you can complete the after step.

 edges (Seq [ Node 0, Node 1 ])
 -->
 [ { before = 0, after = 1, branch = 0 } ]
toDot : { nodeToId : node -> String } -> Flow node -> String
type alias DependencyChange =
{ task : String
, newDeps :
List
{ branch : Int
, id : String
}
, removeDeps :
List
{ branch : Int
, id : String
}
}
{ before : Flow node
, after : Flow node
, nodeToId : node -> String
}
-> List DependencyChange
breadthFirstFold : (a -> b -> b) -> b -> Flow a -> b

Fold by visiting nodes in the same order they would get unblocked.

0 ──╮── 1 ─── 3 ── 6 ──╭─ 3
    ╰── 2 ─╮─ 4 ──╭────╯
           ╰─ 5 ──╯

Unlike parallel tracks, condition branches are visited entirely before the next one.

           ᴛʀᴜᴇ
0 ──╮──╮── 1 ─── 3 ── 6 ──╭──╭─── 10
    │  ╰── 2 ─╮─ 4 ─╭─────╯  │
    │         ╰─ 5 ─╯        │
    │      ғᴀʟsᴇ             │
    ╰──╮── 7 ─── 9 ─╭────────╯
       ╰── 8 ───────╯
findMap : (Flow node -> Maybe a) -> Flow node -> Maybe ( a, List Step )

Update

optimize : Flow node -> Flow node

OPTIMIZE: apply simplifications until you reach a fixpoint. This uses a library Janiczek/transform that handles that fixpoint boilerplate.

sortParallel : { toPosition : node -> comparable } -> Flow node -> Flow node
map : (a -> b) -> Flow a -> Flow b

Apply a function to every node.

mapWithNode : (Flow a -> a -> b) -> Flow a -> Flow b

Apply a function to every node, having acces to the Flow value itself.

filter : (a -> Bool) -> Flow a -> Flow a

Keeping nodes satisfying a predicate

type Step
= InSequential Int
| InParallel Int
| InConditionTrue Int
| InConditionFalse Int
mapAt : List Step -> (Flow node -> Flow node) -> Flow node -> Flow node
previousPath : List Step -> Maybe (List Step)
nextPath : List Step -> Flow node -> Maybe (List Step)
find : (Flow node -> Bool) -> Flow node -> Maybe ( Flow node, List Step )