F# Partial Active Pattern Matching "Rule Will Never Be Matched" -
given following active pattern:
let (| hasmatch |) (x:string) = if x.contains("0") some() else none;;
and following pattern matching func:
let testfn x = function | hasmatch -> printfn "%a" | _ -> printf "nope";;
the last line's wildcard pattern says warning fs0026: rule never matched
all of examples see seem infer partial active patterns must return some('a)
match, , ones return none
captured wildcard. error seems differently.
what missing?
i think should add none
case active pattern declaration follows:
let (| hasmatch | _ |) (x:string) = if x.contains("0") some() else none;;
in orignal example, compiler infers want return option
type. when run printf
in example, see print some null
when there match.
also, bad return some()
, should return some(x)
or similar
Comments
Post a Comment