I think you should add the None
case to the active pattern declaration as follows:
let (| HasMatch | _ |) (x:string) =
if x.Contains("0") then Some()
else None;;
In your orignal example, the compiler infers that you actually want to return the Option
type. When you run the printf
in your example, you would see it print Some Null
when there is a match.
Also, it is bad to return Some()
, you should return say Some(x)
or similar