%dw 2.0

type Callbacks = (String) -> Any

fun test(a: String, tests: Array<Callbacks>) = do {
    tests map $(a)
}

fun test(a: String, tests: Callbacks) = do {
    tests(a)
}


fun test2(a: String, tests: Array<(String) -> Any>) = do {
    tests map $(a)
}

fun test2(a: String, tests: (String) -> Any) = do {
    tests(a)
}

fun test3(a: String, tests: Array<(String) -> Any>) = do {
    tests map $(a)
}

fun test3(a: String, tests: (String) -> Any) = do {
    tests(a)
}

fun test3(a: String, tests: String) = do {
    a ++ tests
}

---
{
  a: "foo" test [$ ++ "bar", (s) -> s ++ "test"],
  b: "test" test $ ++ "bar",
  c: "foo" test2 [$ ++ "bar", (s) -> s ++ "test"],
  d: "test" test2 $ ++ "bar",
  e: "test" test3 [$ ++ "bar"],
  f: "test" test3 "bar",
  g: "foo" test2  do {
    var payload = "bar"
    ---
    [$ ++ payload, (s) -> s ++ "test$(payload)"]
  },
  h: "foo" test2  using(
        payload = "bar"
      )
      [$ ++ payload, (s) -> s ++ "test$(payload)"]

}