Skip to content

Commit 098e36e

Browse files
Rename to FSharp.UMX
1 parent 3c5e4ac commit 098e36e

7 files changed

Lines changed: 26 additions & 25 deletions

File tree

Build.fsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#load "node_modules/fable-publish-utils/PublishUtils.fs"
22
open PublishUtils
33

4-
// run "npm test"
4+
run "dotnet test"
5+
56
match args with
67
| IgnoreCase "publish"::_ ->
7-
pushNuget "src/UnitsOfMeasure.Extra.fsproj"
8+
pushNuget "src/FSharp.UMX.fsproj"
89
| _ -> ()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26124.0
55
MinimumVisualStudioVersion = 15.0.26124.0
6-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UnitsOfMeasure.Extra", "src\UnitsOfMeasure.Extra.fsproj", "{194B07ED-714F-48CD-A1E3-E09862D58F60}"
6+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.UMX", "src\FSharp.UMX.fsproj", "{194B07ED-714F-48CD-A1E3-E09862D58F60}"
77
EndProject
8-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UnitsOfMeasure.Extra.Tests", "tests\UnitsOfMeasure.Extra.Tests.fsproj", "{431B9BEF-AC69-43FF-8CB8-7900E8E0FB83}"
8+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.UMX.Tests", "tests\FSharp.UMX.Tests.fsproj", "{431B9BEF-AC69-43FF-8CB8-7900E8E0FB83}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# UnitsOfMeasure.Extra
1+
# FSharp.UMX
22

33
F# Units of Measure for non-numeric types by Eirik Tsarpalis. Compatible with Fable.
44

55
## Installing
66

7-
Add the `UnitsOfMeasure.Extra` package from Nuget or just copy the `src/UnitsOfMeasure.Extra.fs` file.
7+
Add the `FSharp.UMX` package from Nuget or just copy the `src/FSharp.UMX.fs` file.
88

99
## Publishing to Nuget
1010

@@ -13,7 +13,7 @@ Run `npm i && npm run build publish`.
1313
## Usage
1414

1515
```fsharp
16-
open UnitsOfMeasure.Extra
16+
open FSharp.UMX
1717
1818
[<Measure>] type customerId
1919
[<Measure>] type orderId
@@ -39,11 +39,11 @@ let printOrder (order : Order) =
3939
let lookupById (orders : Order list) (id : string<orderId>) = orders |> List.tryFind (fun o -> o.id = id)
4040
4141
lookupById [] order.id // compiles
42-
lookupById [] order.customer // compiler error
42+
lookupById [] order.customer // compiler error
4343
// stdin(94,15): error FS0001: Type mismatch. Expecting a
44-
// 'string<orderId>'
44+
// 'string<orderId>'
4545
// but given a
46-
// 'string<customerId>'
46+
// 'string<customerId>'
4747
// The unit of measure 'orderId' does not match the unit of measure 'customerId'
4848
```
4949

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace UnitsOfMeasure.Extra
1+
namespace FSharp.UMX
22

33
// Units of Measure extensions
44
// Provides a mechanism for extending units of measure to non-numeric primitives
@@ -16,14 +16,14 @@ open System
1616
[<MeasureAnnotatedAbbreviation>] type DateTimeOffset<[<Measure>] 'm> = DateTimeOffset
1717

1818
module private Unsafe =
19-
let inline cast<'a, 'b> (a : 'a) : 'b =
19+
let inline cast<'a, 'b> (a : 'a) : 'b =
2020
#if !FABLE_COMPILER
2121
(# "" a : 'b #)
2222
#else
2323
unbox<'b> a
2424
#endif
2525

26-
type UoM =
26+
type UMX =
2727

2828
static member inline tag<[<Measure>]'m> (x : bool) : bool<'m> = Unsafe.cast x
2929
static member inline tag<[<Measure>]'m> (x : int) : int<'m> = Unsafe.cast x
@@ -70,4 +70,4 @@ module Operators =
7070

7171
// NB the particular infix operator shadows the rarely used quotation splicing operator
7272
/// Infix operator used for tagging, untagging, or casting units of measure
73-
let inline (~%) (x : ^xm) : ^xn = _cast<UoM, ^xm, ^xn> x
73+
let inline (~%) (x : ^xm) : ^xn = _cast<UMX, ^xm, ^xn> x
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<Version>1.0.0</Version>
6-
<PackageVersion>1.0.0-beta-006</PackageVersion>
6+
<PackageVersion>1.0.0-beta-005</PackageVersion>
77
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
88
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
99
<WarningLevel>5</WarningLevel>
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<Compile Include="UnitsOfMeasure.Extra.fs" />
15+
<Compile Include="FSharp.UMX.fs" />
1616
</ItemGroup>
1717

1818
<ItemGroup>
@@ -23,4 +23,4 @@
2323
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' == 'net45' " />
2424
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
2525
</ItemGroup>
26-
</Project>
26+
</Project>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
module UnitsOfMeasure.Extra.Tests
1+
module FSharp.UMX.Tests
22

33
open System
44
open Xunit
5-
open UnitsOfMeasure.Extra
5+
open FSharp.UMX
66

77
[<Measure>] type skuId
88
[<Measure>] type km
@@ -19,10 +19,10 @@ type Record =
1919

2020
[<Fact>]
2121
let ``Simple unit of measure conversions``() =
22-
let x = Guid.NewGuid() |> UoM.tag<skuId>
23-
let y = (UoM.untag x).ToString("N") |> UoM.tag<skuId>
24-
let z = UoM.tag<km> 42
25-
let w = sprintf "%O %s %d" (UoM.untag x) (UoM.untag y) z
22+
let x = Guid.NewGuid() |> UMX.tag<skuId>
23+
let y = (UMX.untag x).ToString("N") |> UMX.tag<skuId>
24+
let z = UMX.tag<km> 42
25+
let w = sprintf "%O %s %d" (UMX.untag x) (UMX.untag y) z
2626
()
2727

2828
[<Fact>]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Compile Include="UnitsOfMeasure.fs" />
9+
<Compile Include="FSharp.UMX.Tests.fs" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<ProjectReference Include="../src/UnitsOfMeasure.Extra.fsproj" />
13+
<ProjectReference Include="../src/FSharp.UMX.fsproj" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

0 commit comments

Comments
 (0)