Skip to content

Commit cba9eba

Browse files
committed
Conflicts: src/FSharpx.Extras/ComputationExpressions/Monad.fs
2 parents 8812e1e + 006949c commit cba9eba

File tree

18 files changed

+190
-169
lines changed

18 files changed

+190
-169
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,6 @@ docs/content/release-notes.md
191191
.fake
192192
docs/tools/FSharp.Formatting.svclog
193193
TestResult.xml
194+
195+
tmp.*
196+

build.fsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ open System.IO
1414
#else
1515
#load "packages/build/SourceLink.Fake/tools/Fake.fsx"
1616
open SourceLink
17-
1817
#endif
1918

2019
// --------------------------------------------------------------------------------------
@@ -120,11 +119,8 @@ Target "CopyBinaries" (fun _ ->
120119
// Clean build results
121120

122121
Target "Clean" (fun _ ->
123-
CleanDirs ["bin"; "temp"]
124-
)
125-
126-
Target "CleanDocs" (fun _ ->
127-
CleanDirs ["docs/output"]
122+
!! solutionFile |> MSBuildRelease "" "Clean" |> ignore
123+
CleanDirs ["bin"; "temp"; "docs/output"]
128124
)
129125

130126
// --------------------------------------------------------------------------------------
@@ -133,9 +129,9 @@ Target "CleanDocs" (fun _ ->
133129
Target "Build" (fun _ ->
134130
!! solutionFile
135131
#if MONO
136-
|> MSBuildReleaseExt "" [ ("DefineConstants","MONO") ] "Rebuild"
132+
|> MSBuildReleaseExt "" [ ("DefineConstants","MONO") ] "Build"
137133
#else
138-
|> MSBuildRelease "" "Rebuild"
134+
|> MSBuildRelease "" "Build"
139135
#endif
140136
|> ignore
141137
)
@@ -371,40 +367,36 @@ Target "BuildPackage" DoNothing
371367

372368
Target "All" DoNothing
373369

374-
"Clean"
375-
==> "AssemblyInfo"
370+
"AssemblyInfo"
376371
==> "Build"
377372
==> "CopyBinaries"
378373
==> "RunTests"
379374
==> "GenerateReferenceDocs"
380375
==> "GenerateDocs"
381-
==> "All"
382-
=?> ("ReleaseDocs",isLocalBuild)
383-
384-
"All"
385376
#if MONO
386377
#else
387378
=?> ("SourceLink", Pdbstr.tryFind().IsSome )
388379
#endif
389380
==> "NuGet"
390381
==> "BuildPackage"
382+
==> "All"
383+
=?> ("ReleaseDocs",isLocalBuild)
391384

392-
"CleanDocs"
393-
==> "GenerateHelp"
385+
"GenerateHelp"
394386
==> "GenerateReferenceDocs"
395387
==> "GenerateDocs"
396388

397-
"CleanDocs"
398-
==> "GenerateHelpDebug"
399-
400389
"GenerateHelpDebug"
401390
==> "KeepRunning"
402391

392+
"Clean"
393+
==> "Release"
394+
403395
"BuildPackage"
404396
==> "PublishNuget"
405397
==> "Release"
406398

407399
"ReleaseDocs"
408400
==> "Release"
409-
401+
410402
RunTargetOrDefault "All"

paket.lock

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ NUGET
22
remote: https://www.nuget.org/api/v2
33
FSharp.Control.AsyncSeq (2.0.9)
44
FSharp.Core (4.0.0.1) - redirects: force
5-
FSharpx.Async (1.12)
5+
FSharpx.Async (1.13)
66
FSharp.Control.AsyncSeq
7+
FSharp.Core
78
FSharpx.Collections (1.15.2)
89
FSharp.Core
910

1011
GROUP Build
1112
NUGET
1213
remote: https://www.nuget.org/api/v2
13-
FAKE (4.39.1)
14+
FAKE (4.41.6)
1415
FSharp.Compiler.Service (2.0.0.6)
1516
FSharp.Formatting (2.14.4)
1617
FSharp.Compiler.Service (2.0.0.6)
@@ -23,40 +24,40 @@ NUGET
2324
Microsoft.Net.Http (2.2.29) - framework: net10, net11, net20, net30, net35, net40, net40-full
2425
Microsoft.Bcl (>= 1.1.10)
2526
Microsoft.Bcl.Build (>= 1.0.14)
26-
Octokit (0.22)
27+
Octokit (0.23)
2728
Microsoft.Net.Http - framework: net10, net11, net20, net30, net35, net40, net40-full
2829
SourceLink.Fake (1.1)
2930
GITHUB
3031
remote: fsharp/FAKE
31-
modules/Octokit/Octokit.fsx (73589a85a5e30a2c78d61efccdd3446a99483142)
32+
modules/Octokit/Octokit.fsx (889bda9367dfb24f9abb524165a0dbe2cdd86252)
3233
Octokit (>= 0.20)
3334
GROUP Test
3435
NUGET
3536
remote: https://www.nuget.org/api/v2
36-
FsCheck (2.6)
37+
FsCheck (2.6.2)
3738
FSharp.Core (>= 3.1.2.5)
3839
FSharp.Core (4.0.0.1)
39-
FsUnit (2.3.1)
40+
FsUnit (2.3.2)
4041
FSharp.Core (>= 3.1.2.5)
41-
NUnit (3.4.1)
42-
NUnit (3.4.1)
43-
NUnit.Console (3.4.1)
44-
NUnit.ConsoleRunner (>= 3.4.1)
45-
NUnit.Extension.NUnitProjectLoader (>= 3.4.1)
46-
NUnit.Extension.NUnitV2Driver (>= 3.4.1)
47-
NUnit.Extension.NUnitV2ResultWriter (>= 3.4.1)
48-
NUnit.Extension.TeamCityEventListener (>= 1.0.1)
49-
NUnit.Extension.VSProjectLoader (>= 3.4.1)
50-
NUnit.ConsoleRunner (3.4.1)
51-
NUnit.Extension.NUnitProjectLoader (3.4.1)
52-
NUnit.Extension.NUnitV2Driver (3.4.1)
53-
NUnit.Extension.NUnitV2ResultWriter (3.4.1)
54-
NUnit.Extension.TeamCityEventListener (1.0.1)
55-
NUnit.Extension.VSProjectLoader (3.4.1)
56-
NUnit.Runners (3.4.1)
57-
NUnit.ConsoleRunner (>= 3.4.1)
58-
NUnit.Extension.NUnitProjectLoader (>= 3.4.1)
59-
NUnit.Extension.NUnitV2Driver (>= 3.4.1)
60-
NUnit.Extension.NUnitV2ResultWriter (>= 3.4.1)
61-
NUnit.Extension.TeamCityEventListener (>= 1.0.1)
62-
NUnit.Extension.VSProjectLoader (>= 3.4.1)
42+
NUnit (3.5)
43+
NUnit (3.5)
44+
NUnit.Console (3.5)
45+
NUnit.ConsoleRunner (>= 3.5)
46+
NUnit.Extension.NUnitProjectLoader (>= 3.5)
47+
NUnit.Extension.NUnitV2Driver (>= 3.5)
48+
NUnit.Extension.NUnitV2ResultWriter (>= 3.5)
49+
NUnit.Extension.TeamCityEventListener (>= 1.0.2)
50+
NUnit.Extension.VSProjectLoader (>= 3.5)
51+
NUnit.ConsoleRunner (3.5)
52+
NUnit.Extension.NUnitProjectLoader (3.5)
53+
NUnit.Extension.NUnitV2Driver (3.5)
54+
NUnit.Extension.NUnitV2ResultWriter (3.5)
55+
NUnit.Extension.TeamCityEventListener (1.0.2)
56+
NUnit.Extension.VSProjectLoader (3.5)
57+
NUnit.Runners (3.5)
58+
NUnit.ConsoleRunner (>= 3.5)
59+
NUnit.Extension.NUnitProjectLoader (>= 3.5)
60+
NUnit.Extension.NUnitV2Driver (>= 3.5)
61+
NUnit.Extension.NUnitV2ResultWriter (>= 3.5)
62+
NUnit.Extension.TeamCityEventListener (>= 1.0.2)
63+
NUnit.Extension.VSProjectLoader (>= 3.5)

src/FSharpx.Extras/AssemblyInfo.fs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/FSharpx.Extras/ComputationExpressions/Monad.fs

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,13 @@ module Choice =
747747
| Choice1Of2 a -> a
748748
| Choice2Of2 e -> invalidArg "choice" (sprintf "The choice value was Choice2Of2 '%A'" e)
749749
750+
/// If Choice is 1Of2, return its value.
751+
/// Otherwise throw the exception in 2Of2.
752+
let getOrRaise<'a, 'exn when 'exn :> exn> (c:Choice<'a, 'exn>) =
753+
match c with
754+
| Choice1Of2 r -> r
755+
| Choice2Of2 e -> raise e
756+
750757
/// Wraps a function, encapsulates any exception thrown within to a Choice
751758
let inline protect f x =
752759
try
@@ -1172,37 +1179,66 @@ module Task =
11721179
/// Creates a task that runs the given task and ignores its result.
11731180
let inline Ignore t = bind (fun _ -> returnM ()) t
11741181

1182+
/// Active pattern that matches on flattened inner exceptions in an AggregateException
1183+
let (|AggregateExn|_|) (e:exn) =
1184+
match e with
1185+
| :? AggregateException as ae ->
1186+
ae.Flatten().InnerExceptions
1187+
|> List.ofSeq
1188+
|> Some
1189+
| _ -> None
1190+
11751191
/// Creates a task that executes a specified task.
11761192
/// If this task completes successfully, then this function returns Choice1Of2 with the returned value.
11771193
/// If this task raises an exception before it completes then return Choice2Of2 with the raised exception.
1178-
let Catch (t:Task<'a>) =
1194+
let Catch (t:Task<'a>) : Task<Choice<'a, exn>> =
11791195
task {
11801196
try let! r = t
11811197
return Choice1Of2 r
11821198
with e ->
1183-
return Choice2Of2 e
1199+
let e' = match e with
1200+
| AggregateExn [inner] -> inner
1201+
| x -> x
1202+
return Choice2Of2 e'
11841203
}
11851204

11861205
/// Creates a task that executes all the given tasks.
1187-
let Parallel (tasks : seq<unit -> Task<'a>>) =
1206+
let Parallel (tasks : seq<unit -> Task<'a>>) : (Task<'a[]>) =
11881207
tasks
11891208
|> Seq.map (fun t -> t())
11901209
|> Array.ofSeq
11911210
|> Task.WhenAll
11921211

11931212
/// Creates a task that executes all the given tasks.
1194-
/// The paralelism is throttled, so that at most `throttle` tasks run at one time.
1195-
let ParallelWithTrottle throttle (tasks : seq<unit -> Task<'a>>) : (Task<'a[]>) =
1196-
let semaphore = new SemaphoreSlim(throttle)
1197-
let throttleTask (t:unit->Task<'a>) () : Task<'a> =
1213+
/// This function doesn't throw exceptions, but instead returns an array of Choices.
1214+
let ParallelCatch (tasks : seq<unit -> Task<'a>>) : (Task<Choice<'a, exn>[]>) =
1215+
let catch t () =
1216+
Catch <| t()
1217+
tasks
1218+
|> Seq.map catch
1219+
|> Parallel
1220+
1221+
/// common code for ParallelCatchWithTrottle and ParallelWithTrottle
1222+
let private ParallelWithTrottleCustom transformResult throttle (tasks : seq<unit -> Task<'a>>) : (Task<'b[]>) =
1223+
use semaphore = new SemaphoreSlim(throttle)
1224+
let throttleTask (t:unit->Task<'a>) () : Task<'b> =
11981225
task {
11991226
do! semaphore.WaitAsync() |> ToTaskUnit
12001227
let! result = Catch <| t()
12011228
semaphore.Release() |> ignore
1202-
return match result with
1203-
| Choice1Of2 r -> r
1204-
| Choice2Of2 e -> raise e
1229+
return transformResult result
12051230
}
12061231
tasks
12071232
|> Seq.map throttleTask
12081233
|> Parallel
1234+
1235+
/// Creates a task that executes all the given tasks.
1236+
/// This function doesn't throw exceptions, but instead returns an array of Choices.
1237+
/// The paralelism is throttled, so that at most `throttle` tasks run at one time.
1238+
let ParallelCatchWithTrottle throttle (tasks : seq<unit -> Task<'a>>) : (Task<Choice<'a, exn>[]>) =
1239+
ParallelWithTrottleCustom id throttle tasks
1240+
1241+
/// Creates a task that executes all the given tasks.
1242+
/// The paralelism is throttled, so that at most `throttle` tasks run at one time.
1243+
let ParallelWithTrottle throttle (tasks : seq<unit -> Task<'a>>) : (Task<'a[]>) =
1244+
ParallelWithTrottleCustom Choice.getOrRaise throttle tasks

src/FSharpx.Extras/FSharpx.Extras.fsproj

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
32
<PropertyGroup>
43
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -21,10 +20,10 @@
2120
<DebugType>full</DebugType>
2221
<Optimize>false</Optimize>
2322
<Tailcalls>false</Tailcalls>
24-
<OutputPath>..\..\bin\Debug\</OutputPath>
23+
<OutputPath>bin\Debug\</OutputPath>
2524
<DefineConstants>TRACE;DEBUG</DefineConstants>
2625
<WarningLevel>3</WarningLevel>
27-
<DocumentationFile>..\..\bin\Debug\FSharpx.Extras.xml</DocumentationFile>
26+
<DocumentationFile>bin\Debug\FSharpx.Extras.xml</DocumentationFile>
2827
</PropertyGroup>
2928
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3029
<DebugType>pdbonly</DebugType>
@@ -41,23 +40,29 @@
4140
<PropertyGroup Condition="$(TargetFrameworkVersion) == 'v4.0'">
4241
<DefineConstants>NET40</DefineConstants>
4342
</PropertyGroup>
44-
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets') And '$(TargetFrameworkProfile)' == ''">
45-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
43+
<PropertyGroup Condition="$(TargetFrameworkVersion) == 'v4.5'">
44+
<DefineConstants>NET45</DefineConstants>
4645
</PropertyGroup>
47-
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets') And '$(TargetFrameworkProfile)' == ''">
48-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
49-
</PropertyGroup>
50-
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets') And '$(TargetFrameworkProfile)' != ''">
51-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
52-
</PropertyGroup>
53-
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.Portable.FSharp.Targets') And '$(TargetFrameworkProfile)' != ''">
54-
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.Portable.FSharp.Targets</FSharpTargetsPath>
46+
<PropertyGroup>
47+
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
5548
</PropertyGroup>
49+
<Choose>
50+
<When Condition="'$(VisualStudioVersion)' == '11.0'">
51+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
52+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
53+
</PropertyGroup>
54+
</When>
55+
<Otherwise>
56+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
57+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
58+
</PropertyGroup>
59+
</Otherwise>
60+
</Choose>
5661
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
5762
<ItemGroup>
5863
<Content Include="paket.references" />
64+
<None Include="paket.template" />
5965
<Content Include="app.config" />
60-
<Compile Include="AssemblyInfo.fs" />
6166
<Compile Include="Prelude.fs" />
6267
<Compile Include="Pluralizer.fs" />
6368
<Compile Include="String.fs" />
@@ -79,7 +84,6 @@
7984
<Compile Include="Net.fs" />
8085
<Compile Include="Conneg.fs" />
8186
<Compile Include="Enum.fs" />
82-
<None Include="paket.template" />
8387
</ItemGroup>
8488
<ItemGroup>
8589
<Reference Include="mscorlib" />
@@ -174,10 +178,10 @@
174178
</When>
175179
</Choose>
176180
<Choose>
177-
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
181+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
178182
<ItemGroup>
179183
<Reference Include="FSharpx.Async">
180-
<HintPath>..\..\packages\FSharpx.Async\lib\net40\FSharpx.Async.dll</HintPath>
184+
<HintPath>..\..\packages\FSharpx.Async\lib\net45\FSharpx.Async.dll</HintPath>
181185
<Private>True</Private>
182186
<Paket>True</Paket>
183187
</Reference>

0 commit comments

Comments
 (0)