Pattern Matching of Units of Measure in F#
Posted
by Oldrich Svec
on Stack Overflow
See other posts from Stack Overflow
or by Oldrich Svec
Published on 2010-04-19T09:06:54Z
Indexed on
2010/04/19
9:13 UTC
Read the original article
Hit count: 187
This function:
let convert (v: float<_>) =
match v with
| :? float<m> -> v / 0.1<m>
| :? float<m/s> -> v / 0.2<m/s>
| _ -> failwith "unknown"
produces an error
The type 'float<'u>' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion.
Is there any way how to pattern match units of measure?
© Stack Overflow or respective owner