How do I declare a generic parameter in F#?
-
29-10-2019 - |
Question
Given the following code:
let DisplayImpl logger data =
data |> Seq.iter logger
printfn ""
let Working =
DisplayImpl (printfn "%O") [1;2;3]
DisplayImpl (printfn "%O") ["a";"b";"c"]
let NotWorking display =
display (printfn "%O") [1;2;3]
display (printfn "%O") ["a";"b";"c"]
~~~ ~~~ ~~~
The last line gives the error: This expression was expected to have type int but here has type string
I thought the following might work, but it doesn't:
let StillNotWorking (display: ('a -> unit) -> seq<'a> -> unit) =
My question is, how do I define the NotWorking function so that the display parameter stays generic within the function?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow