let trace = (x:'a, b: string) => {
Js.logMany([String.make(x), b])
x
}
let main = (): unit => {
Console.log("Hi")
let trace_err = trace(_, "err")
trace("ADaS", "FD")->ignore
trace(23, "FD")->ignore
trace_err("DSDA")->ignore
trace_err(314)->ignore
}
main()
So the code above works if I define trace function in global scope.
But if I put it inside the main like this, it will complains.
let main = (): unit => {
Console.log("Hi")
let trace = (x:'a, b: string) => {
Js.logMany([String.make(x), b])
x
}
trace("ADaS", "FD")->ignore
trace(23, "FD")->ignore
}
main()
And if I remove the type notation of x here, it will also work inside of main scope
let main = (): unit => {
Console.log("Hi")
let trace = (x, b: string) => {
Js.logMany([String.make(x), b])
x
}
trace("ADaS", "FD")->ignore
trace(23, "FD")->ignore
}
main()