So I was looking at the following bit of code
let rec zip list list' =
match list, list' with
| [], _ -> []
| _, [] -> []
| h::t, h'::t' -> (h, h')::(zip t t')
when I noticed that it is not a syntactic error to replace
match list, list' with
by
match list list' with
being the only error shown
This expression was expected to have type
'a -> 'b list * 'c list
but here has type
'b list
on zip t t' (over t).
My question is if makes any sense, at all, to have match list list' with instead of match list list' with. Shouldn’t the targets of pattern matching be always comma separated?
Yes, but if you write
match list list' withthere is only a single target, said target being what you get from applying the functionlistto the argumentlist'. Sincelistisn’t actually a function, you get the type error you quote.