F# Units of Measure for non-numeric types by Eirik Tsarpalis. Compatible with Fable.
Add the UnitsOfMeasure.Extra
package from Nuget or just copy the src/UnitsOfMeasure.Extra.fs
file.
Run npm i && npm run build publish
.
open UnitsOfMeasure.Extra
[<Measure>] type dir
[<Measure>] type file
let inline mkDir x: string<dir> = %% x
let inline mkFile x: string<file> = %% x
let test (dirPath: string<dir>) (fileName: string<file>): unit =
printfn "FULL PATH: %s/%s" %%dirPath %%fileName
let myDir = mkDir "/my/path"
let myFile = mkFile "file.txt"
// let myDir = mkDir 5 // This doesn't compile
test myDir myFile
// test myFile myDir // This doesn't compile