1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open Ast

(*
--# List Node Dependencies
--#
--# Returns a dictionary mapping node names to their dependencies.
--#
--# @name pipeline_deps
--# @param p :: Pipeline The pipeline.
--# @return :: Dict The dependency graph.
--# @family pipeline
--# @seealso pipeline_nodes
--# @export
*)
let register env =
  Env.add "pipeline_deps"
    (make_builtin ~name:"pipeline_deps" 1 (fun args _env ->
      match args with
      | [VPipeline { p_deps; _ }] ->
          VDict (List.map (fun (name, deps) ->
            (name, VList (List.map (fun d -> (None, VString d)) deps))
          ) p_deps)
      | [_] -> Error.type_error "Function `pipeline_deps` expects a Pipeline."
      | _ -> Error.arity_error_named "pipeline_deps" 1 (List.length args)
    ))
    env