I usually have an βoh yesβ moment writing F # when I realize that I need an extra value somewhere. This is usually easy to do by adding a different value to the transferred tuple. However, this means that the various maps are / sorts / collects / etc. an update is required, and in particular, the fst / snd functions only work with tuples of length 2.
This is not a huge problem, but it is annoying enough during the search development, which, although I would write an assistant to ease the annoyance:
let inline get2 (t:^a) = (^a : (member get_Item2 : unit -> string) (t, ())) let inline get2a (t:^a) = (^a : (member Item2 : string) t)
However, both versions do not work. The first, get2 , will not compile, with "Expected 1 expressions received 2". The second, get2a , will be compiled, but subsequently cannot be used in tuples: "Type (int * string)" does not support operators named "get_Item2".
Is there a way to do this so that there are not many overloads? with noisy annotations OverloadID (annotations not required in F # 2.0)
source share