Closed buzzerpuzzle closed 1 year ago
I fee like I would need to add something like below but still not work
Execution Command
dhall-to-yaml-ng <<< './testFunction.dhall testParameter::{test=True}'
testFunction.dhall
let testParameter = {
Type = { test: Bool, test2: Bool},
default = { test = False, test2 = False}
}
let testFunction = \(args : {test: Bool, test2: Bool}) ->
{ a = "123", b = args.test }
in testFunction
Hi Len! Regarding your first post: This doesn't work because { test = True }
is of type { test : Bool }
whereas the expected args
argument is of type { test : Bool, test2 : Bool }
}. Dhall will note the missing test2
field and complain accordingly.
Regarding your second post: The content of the testFunction.dhall is equivalent to
let testParameter = { Type = { test: Bool, test2: Bool}, default = { test = False, test2 = False} }
in \(args : {test: Bool, test2: Bool}) -> { a = "123", b = args.test }
as the testFunction
at the right-hand-side of the in
will be substituted by its definition. This in turn is equivalent to
\(args : {test: Bool, test2: Bool}) -> { a = "123", b = args.test }
since testParameter
is never used at the right-hand side of the in
.
So what you can do for example is something like:
-- testFunction.dhall
\(args : {test: Bool, test2: Bool}) -> { a = "123", b = args.test }
-- testSchema.dhall
{ Type = { test: Bool, test2: Bool}, default = { test = False, test2 = False} }
-- myTest.dhall
./testFunction.dhall ( ./testSchema.dhall )::{ test2 = Bool }
Besides: The testFunction.dhall in your second post looks like you wanted to "export " both testParameter
and testFunction
from that file. You can do this like
-- testFunction.dhall
let testParameter = {
Type = { test: Bool, test2: Bool},
default = { test = False, test2 = False}
}
let testFunction = \(args : {test: Bool, test2: Bool}) ->
{ a = "123", b = args.test }
in { testParameter, testFunction }
and evaluate it like dhall <<< "( ./testFunction.dhall ).testFunction ( ./testFunction.dhall ).testParameter::{ test2 = Bool }"
Thanks for your input and it is totally match what I need!
Hi!
I am wondering how I could set up with default parameter for this testFunction.
I am trying to use below command without test2 parameter and like to have default value test2 as false but do not sure whether dhall could support this kind of intent.
Execution Comand
dhall-to-yaml-ng <<< './testFunction.dhall { test = True}'
testFunction.dhall
Thanks, Len