When importing numbers from a csv file, I need to convert them to floats with unit.
Currently I do this with an inline function:
data |> List.map float |> List.map (fun n -> n * 1.0<m>)
But I'm wondering if there is a more elegant way to do this - or do I have to create my own 'units' module with conversion functions?
What would be really nice would be something like this, but I doubt it's possible...
data |> List.map float |> List.map lift<m>
This is the opposite of my previous question (How to generically remove F# Units of measure).
UPDATE: For homemade units, I've tried this, which works ok:
[<Measure>]
type km =
static member lift (v:float) = v * 1.0<km>
data |> List.map float |> List.map km.lift
or, following the question in this answer
data |> List.map (float >> km.lift)