Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
wallymathieu committed Oct 15, 2023
2 parents 71c323a + 1a5e595 commit 52467f7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#### 1.5.0 - October 15 2023
- Support for Fable 4 (some functions had to be removed from Fable in order to it)
- More IList and IReadOnlyList functions
- Bug fixes in parse, tryParse, seq's TryFinally and (=>>) for ValueTask
- Add Free.hoist
- Add distinct for NonEmptySeq and NonEmptyList
- Add ValueOption.ofOption and Task.result for Task and ValueTask

#### 1.4.0 - February 22 2023
- Additional Alternatives available (functions, error monads)
- More IReadOnlyDictionary functions
Expand Down
13 changes: 7 additions & 6 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Release Notes for FSharpPlus 1.4.0 - February 22 2023
Release Notes for FSharpPlus 1.5.0 - October 15 2023
------------------------------------------------------

Additional Alternatives available (functions, error monads)
More IReadOnlyDictionary functions
Bug fixes in Map as FoldIndexable and missing <*> for IDictionary and IReadOnlyDictionary
Deprecate IReadOnlyDictionary.map
Guid to/from bytes conversion
Support for Fable 4 (some functions had to be removed from Fable in order to it)
More IList and IReadOnlyList functions
Bug fixes in parse, tryParse, seq's TryFinally and (=>>) for ValueTask
Add Free.hoist
Add distinct for NonEmptySeq and NonEmptyList
Add ValueOption.ofOption and Task.result for Task and ValueTask
4 changes: 2 additions & 2 deletions src/FSharpPlus/Control/Converter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ type TryParse =
match DateTime.TryParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"|], null, DateTimeStyles.RoundtripKind) with
| true, x -> Some x
| _ ->
match DateTime.TryParse (x, CultureInfo.InvariantCulture, DateTimeStyles.None) with
match DateTime.TryParse (x, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal) with
| true, x -> Some x
| _ -> None

Expand Down Expand Up @@ -164,7 +164,7 @@ type Parse =
static member Parse (_: DateTime , _: Parse) = fun (x:string) ->
match DateTime.TryParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"|], null, DateTimeStyles.RoundtripKind) with
| true, x -> x
| _ -> DateTime.Parse (x, CultureInfo.InvariantCulture)
| _ -> DateTime.Parse (x, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)

static member Parse (_: DateTimeOffset, _: Parse) = fun (x:string) ->
try DateTimeOffset.ParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffK"; "yyyy-MM-ddTHH:mm:ssK"|], null, DateTimeStyles.AssumeUniversal)
Expand Down
9 changes: 8 additions & 1 deletion src/FSharpPlus/Extensions/IList.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace FSharpPlus

#if !FABLE_COMPILER

/// Additional operations IList<'T>
[<RequireQualifiedAccess>]
Expand All @@ -9,9 +8,17 @@ module IList =
open System.Collections.ObjectModel
open System.Collections.Generic

#if !FABLE_COMPILER
/// <summary>Converts an IList to an IReadOnlyList (from System.Collections.Generic).</summary>
/// <param name="source">The System.Collections.Generic.IList</param>
/// <returns>The list converted to a System.Collections.Generic.IReadOnlyList</returns>
let toIReadOnlyList (source: IList<_>) = ReadOnlyCollection source :> IReadOnlyList<_>

#endif

let ofArray (source: 'T[] ) = source :> IList<'T>
let ofList (source: 'T list) = source |> Array.ofList :> IList<'T>
let ofSeq (source: seq<'T>) = source |> Array.ofSeq :> IList<'T>
let map mapping (source: IList<'T>) = Seq.map mapping source |> Seq.toArray :> IList<'U>
let iter mapping (source: IList<'T>) = Seq.iter mapping source

11 changes: 10 additions & 1 deletion src/FSharpPlus/Extensions/IReadOnlyList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ module IReadOnlyList =
#if !FABLE_COMPILER

let ofArray (source: 'T array) = IList.toIReadOnlyList source
let ofList (source: 'T list) = source |> Array.ofList |> IList.toIReadOnlyList
let ofSeq (source: seq<'T>) = source |> Array.ofSeq |> IList.toIReadOnlyList

#endif

let toArray (source: IReadOnlyList<'T>) = Array.ofSeq source

#if !FABLE_COMPILER
Expand All @@ -19,8 +23,13 @@ module IReadOnlyList =
if 0 <= i && i < source.Count then
source |> Array.ofSeq |> setNth i value |> ofArray |> Some
else None

let map mapping (source: IReadOnlyList<'T>) : IReadOnlyList<'U> = Seq.map mapping source |> Seq.toArray |> IList.toIReadOnlyList

#endif

let tryItem i (source: IReadOnlyList<_>) =
if 0 <= i && i < source.Count then Some source.[i]
else None
else None

let iter mapping (source: IReadOnlyList<'T>) = Seq.iter mapping source
3 changes: 0 additions & 3 deletions src/FSharpPlus/Operators.fs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ module Operators =
let inline lift2 (f: 'T->'U->'V) (x: '``Applicative<'T>``) (y: '``Applicative<'U>``) : '``Applicative<'V>`` = Lift2.Invoke f x y

[<System.Obsolete("Use lift2 instead.")>]
/// <category index="2">Applicative</category>
let inline liftA2 (f: 'T->'U->'V) (x: '``Applicative<'T>``) (y: '``Applicative<'U>``) : '``Applicative<'V>`` = lift2 f x y

/// <summary>
Expand All @@ -208,11 +207,9 @@ module Operators =
let inline (<* ) (x: '``Applicative<'U>``) (y: '``Applicative<'T>``) : '``Applicative<'U>`` = ((fun (k: 'U) (_: 'T) -> k ) <!> x : '``Applicative<'T->'U>``) <*> y

[<System.Obsolete("Use flip (<*>) instead.")>]
/// <category index="2">Applicative</category>
let inline (<**>) (x: '``Applicative<'T>``) : '``Applicative<'T -> 'U>``->'``Applicative<'U>`` = flip (<*>) x

[<System.Obsolete("Use opt instead.")>]
/// <category index="2">Applicative</category>
let inline optional v = Some <!> v </Append.Invoke/> result None

/// <summary>
Expand Down

0 comments on commit 52467f7

Please sign in to comment.