The error you encountered is related to the fact that things like #1 are special and their type depends on what it is used for. For example, in #1 (1,2) type #1 is 'a * 'b -> 'a ; whereas in #1 (1,2,3) type #1 is equal to 'a * 'b * 'c -> 'a . There is no type like 'a * ... -> 'a that will work for everything, so the compiler must be able to determine the type in which it will be used (basically, how many elements are in the tuple).
So this does not work:
fun f lst = case lst of x::xs =>
because he just knows that it is "some kind of list", and x - "some value of some type". But he does not know what kind of motorcade this is.
Just adding a type guard or some other context that allows the compiler to tell you what type of tuple it will work:
fun f (lst : (string * 'a) list) = case lst of x::xs =>
source share