You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A number of things in the final environment are lists, and lists don't compose well (they don't compose at all currently in Nickel, and that's arguably the less bad solution). As a consequence, we'll likely want to internally represent them as DAGs. Defining a DAG is easy (see below), but fairly verbose to use.
With a smart contract (no pun intended), we could probably make this much lighter by just normalizing the fields that we pass in.
let
DagElement = fun Data => {
before : Array Str | default = [],
after : Array Str | default = [],
value : Data
}
in let
Dag = fun Data => {
_: DagElement Data
}
in
let
# FIXME: This isn't sorting anything, would have to
topo_sort | Dag Str -> Array Str = fun dag => array.map (fun elt => elt.value) (record.values dag)
in
let StructuredEnvVar = { sep : Str | default = ":", elems : Dag Str } in
let StructuredEnv = { _ : StructuredEnvVar } in
let Env = { _ : Str } in
let destructure_env_elt | Str -> StructuredEnvVar -> Str = fun name { sep, elems } => string.join sep (topo_sort elems) in
let destructure_env | StructuredEnv -> Env = fun env => record.map destructure_env_elt env in
{
env | Env = destructure_env structured_env,
# Building the DAG in client code. This is so nice because it composes well,
# but it's also quite heavy to write
structured_env | StructuredEnv = {
PATH.elems = {
bash.value = "$bash/bin",
gcc.value = "$gcc/bin",
clang.value = "$clang/bin",
clang.before = ["gcc"],
},
},
# Would be nice to be able to just write (for the simple cases)
# something like
# ```
# structured_env.PATH = [ "$bash/bin", "$clang/bin", "$gcc/bin" ],
# ```
# which would expand to
# ```
# Structured_env.PATH.elems = {
# "$bash/bin" = { value = "$bash/bin", before = ["$clang/bin"], },
# "$clang/bin" = { value = "$clang/bin", before = ["$gcc/bin"], },
# "$gcc/bin" = { value = "$gcc/bin", },
# },
}
The text was updated successfully, but these errors were encountered:
A number of things in the final environment are lists, and lists don't compose well (they don't compose at all currently in Nickel, and that's arguably the less bad solution). As a consequence, we'll likely want to internally represent them as DAGs. Defining a DAG is easy (see below), but fairly verbose to use.
With a smart contract (no pun intended), we could probably make this much lighter by just normalizing the fields that we pass in.
The text was updated successfully, but these errors were encountered: