From 098e36ea01024d2cf9c9a4335f3eb4efce925d3f Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Tue, 5 Feb 2019 19:01:38 +0100 Subject: [PATCH] Rename to FSharp.UMX --- Build.fsx | 5 +++-- UnitsOfMeasure.Extra.sln => FSharp.UMX.sln | 4 ++-- README.md | 12 ++++++------ src/{UnitsOfMeasure.Extra.fs => FSharp.UMX.fs} | 8 ++++---- ...UnitsOfMeasure.Extra.fsproj => FSharp.UMX.fsproj} | 6 +++--- tests/{UnitsOfMeasure.fs => FSharp.UMX.Tests.fs} | 12 ++++++------ ...re.Extra.Tests.fsproj => FSharp.UMX.Tests.fsproj} | 4 ++-- 7 files changed, 26 insertions(+), 25 deletions(-) rename UnitsOfMeasure.Extra.sln => FSharp.UMX.sln (88%) rename src/{UnitsOfMeasure.Extra.fs => FSharp.UMX.fs} (96%) rename src/{UnitsOfMeasure.Extra.fsproj => FSharp.UMX.fsproj} (88%) rename tests/{UnitsOfMeasure.fs => FSharp.UMX.Tests.fs} (75%) rename tests/{UnitsOfMeasure.Extra.Tests.fsproj => FSharp.UMX.Tests.fsproj} (80%) diff --git a/Build.fsx b/Build.fsx index 1baab97..4a77723 100644 --- a/Build.fsx +++ b/Build.fsx @@ -1,8 +1,9 @@ #load "node_modules/fable-publish-utils/PublishUtils.fs" open PublishUtils -// run "npm test" +run "dotnet test" + match args with | IgnoreCase "publish"::_ -> - pushNuget "src/UnitsOfMeasure.Extra.fsproj" + pushNuget "src/FSharp.UMX.fsproj" | _ -> () diff --git a/UnitsOfMeasure.Extra.sln b/FSharp.UMX.sln similarity index 88% rename from UnitsOfMeasure.Extra.sln rename to FSharp.UMX.sln index 9d79acf..e53249f 100644 --- a/UnitsOfMeasure.Extra.sln +++ b/FSharp.UMX.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26124.0 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UnitsOfMeasure.Extra", "src\UnitsOfMeasure.Extra.fsproj", "{194B07ED-714F-48CD-A1E3-E09862D58F60}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.UMX", "src\FSharp.UMX.fsproj", "{194B07ED-714F-48CD-A1E3-E09862D58F60}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UnitsOfMeasure.Extra.Tests", "tests\UnitsOfMeasure.Extra.Tests.fsproj", "{431B9BEF-AC69-43FF-8CB8-7900E8E0FB83}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.UMX.Tests", "tests\FSharp.UMX.Tests.fsproj", "{431B9BEF-AC69-43FF-8CB8-7900E8E0FB83}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/README.md b/README.md index d522694..0e4ff3a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# UnitsOfMeasure.Extra +# FSharp.UMX F# Units of Measure for non-numeric types by Eirik Tsarpalis. Compatible with Fable. ## Installing -Add the `UnitsOfMeasure.Extra` package from Nuget or just copy the `src/UnitsOfMeasure.Extra.fs` file. +Add the `FSharp.UMX` package from Nuget or just copy the `src/FSharp.UMX.fs` file. ## Publishing to Nuget @@ -13,7 +13,7 @@ Run `npm i && npm run build publish`. ## Usage ```fsharp -open UnitsOfMeasure.Extra +open FSharp.UMX [] type customerId [] type orderId @@ -39,11 +39,11 @@ let printOrder (order : Order) = let lookupById (orders : Order list) (id : string) = orders |> List.tryFind (fun o -> o.id = id) lookupById [] order.id // compiles -lookupById [] order.customer // compiler error +lookupById [] order.customer // compiler error // stdin(94,15): error FS0001: Type mismatch. Expecting a -// 'string' +// 'string' // but given a -// 'string' +// 'string' // The unit of measure 'orderId' does not match the unit of measure 'customerId' ``` diff --git a/src/UnitsOfMeasure.Extra.fs b/src/FSharp.UMX.fs similarity index 96% rename from src/UnitsOfMeasure.Extra.fs rename to src/FSharp.UMX.fs index 2c4894b..ddcec4b 100644 --- a/src/UnitsOfMeasure.Extra.fs +++ b/src/FSharp.UMX.fs @@ -1,4 +1,4 @@ -namespace UnitsOfMeasure.Extra +namespace FSharp.UMX // Units of Measure extensions // Provides a mechanism for extending units of measure to non-numeric primitives @@ -16,14 +16,14 @@ open System [] type DateTimeOffset<[] 'm> = DateTimeOffset module private Unsafe = - let inline cast<'a, 'b> (a : 'a) : 'b = + let inline cast<'a, 'b> (a : 'a) : 'b = #if !FABLE_COMPILER (# "" a : 'b #) #else unbox<'b> a #endif -type UoM = +type UMX = static member inline tag<[]'m> (x : bool) : bool<'m> = Unsafe.cast x static member inline tag<[]'m> (x : int) : int<'m> = Unsafe.cast x @@ -70,4 +70,4 @@ module Operators = // NB the particular infix operator shadows the rarely used quotation splicing operator /// Infix operator used for tagging, untagging, or casting units of measure - let inline (~%) (x : ^xm) : ^xn = _cast x + let inline (~%) (x : ^xm) : ^xn = _cast x diff --git a/src/UnitsOfMeasure.Extra.fsproj b/src/FSharp.UMX.fsproj similarity index 88% rename from src/UnitsOfMeasure.Extra.fsproj rename to src/FSharp.UMX.fsproj index f71aac6..5c3e383 100644 --- a/src/UnitsOfMeasure.Extra.fsproj +++ b/src/FSharp.UMX.fsproj @@ -3,7 +3,7 @@ 1.0.0 - 1.0.0-beta-006 + 1.0.0-beta-005 net45;netstandard2.0 true 5 @@ -12,7 +12,7 @@ - + @@ -23,4 +23,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/UnitsOfMeasure.fs b/tests/FSharp.UMX.Tests.fs similarity index 75% rename from tests/UnitsOfMeasure.fs rename to tests/FSharp.UMX.Tests.fs index 64fc232..08d1961 100644 --- a/tests/UnitsOfMeasure.fs +++ b/tests/FSharp.UMX.Tests.fs @@ -1,8 +1,8 @@ -module UnitsOfMeasure.Extra.Tests +module FSharp.UMX.Tests open System open Xunit -open UnitsOfMeasure.Extra +open FSharp.UMX [] type skuId [] type km @@ -19,10 +19,10 @@ type Record = [] let ``Simple unit of measure conversions``() = - let x = Guid.NewGuid() |> UoM.tag - let y = (UoM.untag x).ToString("N") |> UoM.tag - let z = UoM.tag 42 - let w = sprintf "%O %s %d" (UoM.untag x) (UoM.untag y) z + let x = Guid.NewGuid() |> UMX.tag + let y = (UMX.untag x).ToString("N") |> UMX.tag + let z = UMX.tag 42 + let w = sprintf "%O %s %d" (UMX.untag x) (UMX.untag y) z () [] diff --git a/tests/UnitsOfMeasure.Extra.Tests.fsproj b/tests/FSharp.UMX.Tests.fsproj similarity index 80% rename from tests/UnitsOfMeasure.Extra.Tests.fsproj rename to tests/FSharp.UMX.Tests.fsproj index ca6b701..6d784af 100644 --- a/tests/UnitsOfMeasure.Extra.Tests.fsproj +++ b/tests/FSharp.UMX.Tests.fsproj @@ -6,11 +6,11 @@ - + - +