Активный шаблон сломан в F # 3.0
Этот активный шаблон компилируется с F # 2.0:
let (|Value|_|) value = // 'a -> 'T option
match box value with
| :? 'T as x -> Some x
| _ -> None
но в F # 3.0 выдает ошибку:
Active pattern '|Value|_|' has a result type containing type variables that are not determined by the input. The common cause is a [sic] when a result case is not mentioned, e.g. 'let (|A|B|) (x:int) = A x'. This can be fixed with a type constraint, e.g. 'let (|A|B|) (x:int) : Choice = A x'
Я старался:
let (|Value|_|) value : 'T option = ...
а также:
let (|Value|_|) (value: 'U) = ...
Как это можно исправить?
Среды: Visual Studio 2012 (RTM) и FSI v11.0.50727.1
РЕДАКТИРОВАТЬ: Вот более простое воспроизведение:
let (|X|) x = unbox x