How to generically remove F# Units of measure

前端 未结 1 1711
遥遥无期
遥遥无期 2020-12-07 03:37

I\'ve got some data manipulation code which spits out csv at the end.

I started upgrading it to add units of measure everywhere, but I now have a problem with my csv

1条回答
  •  渐次进展
    2020-12-07 03:46

    If I got your Problem right, casting it to "pure" float removes the Unit. For Example:

    [] type m
    [] type km
    
    let removeUnit (x:float<_>) =
        float x
    
    let foo = removeUnit 2.6
    let foo2 = removeUnit 2.1
    

    val removeUnit : float<'u> -> float

    0 讨论(0)
提交回复
热议问题