Hello guys,
I'm trying to make a function array, which I'm using inside a List.reduce HOF. I used to have a
let minimax = [| (min : int->int->int); max |]
which was working great, but now I want to get the max value of a list, so I thought:
let minimax = [|List.min; List.max|]
This, however, throws the following error:
Minimax.fs(175,5): error FS0030: Value restriction. The value 'minimax' has been inferred to have generic type
val minimax : ('_a list -> '_a) [] when '_a : comparison
Either define 'minimax' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation.
I added a type annotation like this:
let minimax = [|(List.min:TreeOfPosition list -> TreeOfPosition); List.max|]
and it compiled. The problem now is with the List.reduce,
| BranchP(position, children) -> List.reduce (minimax.[minOrmax]) (List.map (loop (1 - minOrmax)) children)
Type mismatch. Expecting a TreeOfPosition -> TreeOfPosition -> TreeOfPosition but given a TreeOfPosition list -> TreeOfPosition The type 'TreeOfPosition' does not match the type 'TreeOfPosition list'
Thanks for any tip,
Pedro Dusso