私は OCaml にこの単純なコードを持っています:
type int_pair = int * int;;
type a = A of int_pair;;
let extract (A x) = x;;
extract
私の機能をテストすると、うまくいくようです:
# extract (A (1,2));;
- : int_pair = (1, 2)
単純化して、必要なタイプは 1 つだけです。
type a' = A' of int * int;;
let extract' (A' x) = x;;
しかし、私はエラーが発生します:
Error: The constructor A' expects 2 argument(s),
but is applied here to 1 argument(s)
面白いことに、次の値を構築できますa'
...
# A' (1,2);;
- : a' = A' (1, 2)
...私はそれらを解体することはできません。なんで?