How to generically remove F# Units of measure

前端 未结 1 1703
遥遥无期
遥遥无期 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:

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

    val removeUnit : float<'u> -> float

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