Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SliceMap.Tests/SliceMap.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
<DefineConstants>$(DefineConstants);USE_LEGACY_NAMESPACE</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 16 additions & 2 deletions SliceMap.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ module Types =

[<Properties(Arbitrary = [| typeof<Types> |] )>]
module SlicetSetTests =
#if USE_LEGACY_NAMESPACE
open Flips.SliceMap
#else
open SliceMap

#endif

[<Property>]
let ``SliceSet has only distinct values`` (v:List<NonEmptyString>) =
Expand Down Expand Up @@ -204,7 +207,11 @@ module Types =

[<Properties(Arbitrary = [| typeof<Types> |] )>]
module SliceMapTests =
#if USE_LEGACY_NAMESPACE
open Flips.SliceMap
#else
open SliceMap
#endif

[<Property>]
let ``SliceMap addition is commutative`` (v1:List<(NonEmptyString * Scalar)>) (v2:List<(NonEmptyString * Scalar)>) =
Expand Down Expand Up @@ -293,8 +300,15 @@ module Types =
(x1:NonEmptyString) =

let sm = d |> SMap
#if USE_LEGACY_NAMESPACE
// todo: see https://github.com/dotnet/fsharp/issues/10544
// maybe there is a workaround?
let r = sm.[Flips.SliceMap.SliceType.GreaterOrEqual x1]
// original code was:
// let r = sm.[GreaterOrEqual x1]
#else
let r = sm.[GreaterOrEqual x1]

#endif
for (k1) in r.Keys do
Assert.True(k1 >= x1)

Expand Down
22 changes: 22 additions & 0 deletions SliceMap/SMap.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,25 @@ module SMap =

let containsKey k (m:SMap<_,_>) =
m.ContainsKey k

#if USE_LEGACY_NAMESPACE
namespace Flips.SliceMap
open System
[<Obsolete("Use types in SliceMap namespace instead of Flips.SliceMap")>]
type SMap<'Key, 'Value when 'Key : comparison and 'Value : equality> = SliceMap.SMap<'Key,'Value>

[<Obsolete("Use modules in SliceMap namespace instead of Flips.SliceMap")>]
[<RequireQualifiedAccess>]
module SMap =

let ofSeq = SliceMap.SMap.ofSeq
let toSeq = SliceMap.SMap.toSeq

let ofMap = SliceMap.SMap.ofMap
let toMap = SliceMap.SMap.toMap
let ofList = SliceMap.SMap.ofList
let toList = SliceMap.SMap.toList
let ofArray = SliceMap.SMap.ofArray
let toArray = SliceMap.SMap.toArray
let containsKey = SliceMap.SMap.containsKey
#endif
1 change: 1 addition & 0 deletions SliceMap/SliceMap.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<RepositoryUrl>https://github.com/matthewcrews/SliceMap</RepositoryUrl>
<PackageLicenseFile></PackageLicenseFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<DefineConstants>$(DefineConstants);USE_LEGACY_NAMESPACE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
22 changes: 21 additions & 1 deletion SliceMap/SliceSet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,24 @@ module SliceSet =
| Between (lowerBound, upperBound) -> keys.Between lowerBound upperBound
| In set -> keys.Intersect (SliceSet set)
| NotIn set -> keys.Minus (SliceSet set)
| Where f -> keys.Filter f
| Where f -> keys.Filter f

#if USE_LEGACY_NAMESPACE
namespace Flips.SliceMap
open System
[<Obsolete("Use types in SliceMap namespace instead of Flips.SliceMap")>]
type SliceType<'a when 'a : comparison> = SliceMap.SliceType<'a>
[<Obsolete("Use types in SliceMap namespace instead of Flips.SliceMap");RequireQualifiedAccess>]
type RankResult = SliceMap.RankResult
[<Obsolete("Use types in SliceMap namespace instead of Flips.SliceMap")>]
type SliceSet<'T when 'T : comparison> = SliceMap.SliceSet<'T>

[<Obsolete("Use modules in SliceMap namespace instead of Flips.SliceMap")>]
[<RequireQualifiedAccess>]
module SliceSet =
let intersect = SliceMap.SliceSet.intersect
let toSeq = SliceMap.SliceSet.toSeq
let toList = SliceMap.SliceSet.toList
let union = SliceMap.SliceSet.union
let slice = SliceMap.SliceSet.slice
#endif