From c1ebe7495b65f3a89dd26cc4b709647e839e9313 Mon Sep 17 00:00:00 2001 From: Oskar Gewalli <88096+wallymathieu@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:39:47 +0300 Subject: [PATCH] + Trace for testing overloads (#557) --- FSharpPlus.sln | 99 ++++++++---- appveyor.yml | 2 +- build.proj | 2 +- src/FSharpPlus/Control/Traversable.fs | 152 ++++++++++++------ src/FSharpPlus/FSharpPlus.fsproj | 3 +- src/FSharpPlus/Internals.fs | 8 + .../FSharpPlus.Tests/FSharpPlus.Tests.fsproj | 3 +- tests/FSharpPlus.Tests/Traversals.fs | 21 +++ 8 files changed, 205 insertions(+), 85 deletions(-) diff --git a/FSharpPlus.sln b/FSharpPlus.sln index eb9285cfd..d29d962dc 100644 --- a/FSharpPlus.sln +++ b/FSharpPlus.sln @@ -1,10 +1,11 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29709.97 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus", "src\FSharpPlus\FSharpPlus.fsproj", "{1368368E-D2F4-4FEF-BB2F-492E05156E0F}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus", "src\FSharpPlus\FSharpPlus.fsproj", "{1368368E-D2F4-4FEF-BB2F-492E05156E0F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{BF60BC93-E09B-4E5F-9D85-95A519479D54}" ProjectSection(SolutionItems) = preProject @@ -34,15 +35,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D docsrc\content\abstraction-semigroup.fsx = docsrc\content\abstraction-semigroup.fsx docsrc\content\abstraction-traversable.fsx = docsrc\content\abstraction-traversable.fsx docsrc\content\abstractions.fsx = docsrc\content\abstractions.fsx - docsrc\content\abstractions.plantuml = docsrc\tools\templates\abstractions.plantuml - docsrc\content\_template.html = docsrc\content\_template.html docsrc\content\applicative-functors.fsx = docsrc\content\applicative-functors.fsx docsrc\content\computation-expressions.fsx = docsrc\content\computation-expressions.fsx docsrc\content\extension-methods.fsx = docsrc\content\extension-methods.fsx + docsrc\content\extensions.fsx = docsrc\content\extensions.fsx + docsrc\content\favicon.ico = docsrc\content\favicon.ico docsrc\content\generic-doc.fsx = docsrc\content\generic-doc.fsx docsrc\content\index.fsx = docsrc\content\index.fsx docsrc\content\lens.fsx = docsrc\content\lens.fsx docsrc\content\numerics.fsx = docsrc\content\numerics.fsx + docsrc\content\operators-common.fsx = docsrc\content\operators-common.fsx + docsrc\content\parsing.fsx = docsrc\content\parsing.fsx docsrc\content\tutorial.fsx = docsrc\content\tutorial.fsx docsrc\content\type-all.fsx = docsrc\content\type-all.fsx docsrc\content\type-any.fsx = docsrc\content\type-any.fsx @@ -63,9 +66,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D docsrc\content\type-listt.fsx = docsrc\content\type-listt.fsx docsrc\content\type-matrix.fsx = docsrc\content\type-matrix.fsx docsrc\content\type-mult.fsx = docsrc\content\type-mult.fsx + docsrc\content\type-nonempty-map.fsx = docsrc\content\type-nonempty-map.fsx + docsrc\content\type-nonempty-set.fsx = docsrc\content\type-nonempty-set.fsx docsrc\content\type-nonempty.fsx = docsrc\content\type-nonempty.fsx docsrc\content\type-optiont.fsx = docsrc\content\type-optiont.fsx - docsrc\content\type-valueoptiont.fsx = docsrc\content\type-valueoptiont.fsx docsrc\content\type-parallelarray.fsx = docsrc\content\type-parallelarray.fsx docsrc\content\type-reader.fsx = docsrc\content\type-reader.fsx docsrc\content\type-readert.fsx = docsrc\content\type-readert.fsx @@ -74,112 +78,138 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D docsrc\content\type-state.fsx = docsrc\content\type-state.fsx docsrc\content\type-statet.fsx = docsrc\content\type-statet.fsx docsrc\content\type-validation.fsx = docsrc\content\type-validation.fsx + docsrc\content\type-valueoptiont.fsx = docsrc\content\type-valueoptiont.fsx docsrc\content\type-vector.fsx = docsrc\content\type-vector.fsx docsrc\content\type-writer.fsx = docsrc\content\type-writer.fsx docsrc\content\type-writert.fsx = docsrc\content\type-writert.fsx docsrc\content\type-ziplist.fsx = docsrc\content\type-ziplist.fsx docsrc\content\types.fsx = docsrc\content\types.fsx + docsrc\content\_template.html = docsrc\content\_template.html EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD-2B06-4030-9F0F-DC548F98E1C4}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.Tests", "tests\FSharpPlus.Tests\FSharpPlus.Tests.fsproj", "{FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus.Tests", "tests\FSharpPlus.Tests\FSharpPlus.Tests.fsproj", "{FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{81F5F559-FD23-4E90-9EE6-3E2A2C1A7F96}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.Docs", "src\FSharpPlus.Docs\FSharpPlus.Docs.fsproj", "{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus.Docs", "src\FSharpPlus.Docs\FSharpPlus.Docs.fsproj", "{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus.TypeLevel", "src\FSharpPlus.TypeLevel\FSharpPlus.TypeLevel.fsproj", "{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.TypeLevel", "src\FSharpPlus.TypeLevel\FSharpPlus.TypeLevel.fsproj", "{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus.Providers", "src\FSharpPlus.TypeLevel\Providers\FSharpPlus.Providers.fsproj", "{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.Providers", "src\FSharpPlus.TypeLevel\Providers\FSharpPlus.Providers.fsproj", "{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpLib", "tests\CSharpLib\CSharpLib.csproj", "{7A5B766E-8141-4D8A-B3EB-91422FDBDF71}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpLib", "tests\CSharpLib\CSharpLib.csproj", "{7A5B766E-8141-4D8A-B3EB-91422FDBDF71}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlusFable.Tests", "tests\FSharpPlusFable.Tests\FSharpPlusFable.Tests.fsproj", "{1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlusFable.Tests", "tests\FSharpPlusFable.Tests\FSharpPlusFable.Tests.fsproj", "{1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Benchmarks", "tests\benchmarks\Benchmarks.fsproj", "{EEFF08EB-8B0C-4F63-9425-4281EFF12087}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Benchmarks", "tests\benchmarks\Benchmarks.fsproj", "{EEFF08EB-8B0C-4F63-9425-4281EFF12087}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "docsTool", "docsrc\tools\docsTool.fsproj", "{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "docsTool", "docsrc\tools\docsTool.fsproj", "{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{F4D5D32F-D47A-4727-8965-80A4BB7A29DD}" + ProjectSection(SolutionItems) = preProject + docsrc\tools\templates\abstractions.plantuml = docsrc\tools\templates\abstractions.plantuml + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU Fable|Any CPU = Fable|Any CPU Fable3|Any CPU = Fable3|Any CPU + Release|Any CPU = Release|Any CPU + Test|Any CPU = Test|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Release|Any CPU.Build.0 = Release|Any CPU {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Fable|Any CPU.Build.0 = Fable|Any CPU {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Release|Any CPU.Build.0 = Release|Any CPU + {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Test|Any CPU.ActiveCfg = Test|Any CPU + {1368368E-D2F4-4FEF-BB2F-492E05156E0F}.Test|Any CPU.Build.0 = Test|Any CPU {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Release|Any CPU.Build.0 = Release|Any CPU {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Fable|Any CPU.Build.0 = Fable|Any CPU {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU + {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Release|Any CPU.Build.0 = Release|Any CPU + {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Test|Any CPU.ActiveCfg = Test|Any CPU + {FED64B0A-3FD7-4357-98B6-0B01A3A26EC7}.Test|Any CPU.Build.0 = Test|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|Any CPU.Build.0 = Release|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Fable|Any CPU.Build.0 = Fable|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|Any CPU.Build.0 = Release|Any CPU + {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Test|Any CPU.ActiveCfg = Release|Any CPU + {B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Test|Any CPU.Build.0 = Release|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|Any CPU.Build.0 = Release|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Fable|Any CPU.Build.0 = Fable|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|Any CPU.Build.0 = Release|Any CPU + {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Test|Any CPU.ActiveCfg = Release|Any CPU + {AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Test|Any CPU.Build.0 = Release|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|Any CPU.Build.0 = Release|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Fable|Any CPU.Build.0 = Fable|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|Any CPU.Build.0 = Release|Any CPU + {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Test|Any CPU.ActiveCfg = Release|Any CPU + {9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Test|Any CPU.Build.0 = Release|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Release|Any CPU.Build.0 = Release|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Fable|Any CPU.Build.0 = Fable|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Release|Any CPU.Build.0 = Release|Any CPU + {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Test|Any CPU.ActiveCfg = Release|Any CPU + {7A5B766E-8141-4D8A-B3EB-91422FDBDF71}.Test|Any CPU.Build.0 = Release|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Release|Any CPU.Build.0 = Release|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Fable|Any CPU.ActiveCfg = Fable|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Fable|Any CPU.Build.0 = Fable|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Fable3|Any CPU.ActiveCfg = Fable3|Any CPU {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Fable3|Any CPU.Build.0 = Fable3|Any CPU + {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Release|Any CPU.Build.0 = Release|Any CPU + {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Test|Any CPU.ActiveCfg = Release|Any CPU + {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83}.Test|Any CPU.Build.0 = Release|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Release|Any CPU.Build.0 = Release|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable|Any CPU.ActiveCfg = Debug|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable|Any CPU.Build.0 = Debug|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable3|Any CPU.ActiveCfg = Debug|Any CPU {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable3|Any CPU.Build.0 = Debug|Any CPU + {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Release|Any CPU.Build.0 = Release|Any CPU + {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Test|Any CPU.ActiveCfg = Release|Any CPU + {EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Test|Any CPU.Build.0 = Release|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.Build.0 = Release|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable|Any CPU.ActiveCfg = Debug|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable|Any CPU.Build.0 = Debug|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable3|Any CPU.ActiveCfg = Debug|Any CPU {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable3|Any CPU.Build.0 = Debug|Any CPU + {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.Build.0 = Release|Any CPU + {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Test|Any CPU.ActiveCfg = Release|Any CPU + {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Test|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -194,6 +224,7 @@ Global {1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4} {EEFF08EB-8B0C-4F63-9425-4281EFF12087} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4} {ACBBD11E-0746-4B9D-9CED-A90FE5824CE2} = {83F16175-43B1-4C90-A1EE-8E351C33435D} + {F4D5D32F-D47A-4727-8965-80A4BB7A29DD} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {789B5FFA-7891-4F60-831E-42C3C5ED2C51} diff --git a/appveyor.yml b/appveyor.yml index a5f63ab1d..64e4ab6a7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ install: build_script: - cmd: dotnet restore ./FSharpPlus.sln - cmd: dotnet build -c Release ./FSharpPlus.sln - - cmd: dotnet test -c Release tests/FSharpPlus.Tests + - cmd: dotnet test -c Test tests/FSharpPlus.Tests - ps: if ($env:VersionSuffix) { dotnet pack build.proj --version-suffix $env:VersionSuffix } else { dotnet pack build.proj } test: off artifacts: diff --git a/build.proj b/build.proj index 20cff49e0..02ae75484 100644 --- a/build.proj +++ b/build.proj @@ -15,7 +15,7 @@ - + diff --git a/src/FSharpPlus/Control/Traversable.fs b/src/FSharpPlus/Control/Traversable.fs index f977aad99..40e276cf1 100644 --- a/src/FSharpPlus/Control/Traversable.fs +++ b/src/FSharpPlus/Control/Traversable.fs @@ -33,87 +33,145 @@ type Traverse = static member inline InvokeOnInstance f (t: ^a) = (^a : (static member Traverse : _*_ -> 'R) t, f) static member inline Traverse (t: '``Traversable<'T>`` , f: 'T->'``Functor<'U>``, []_output: '``Functor<'Traversable<'U>>``, []_impl: Default4) = - let mapped = Map.Invoke f t : '``Traversable<'Functor<'U>>`` - (^``Traversable<'T>`` : (static member Sequence : _ -> _) mapped) : '``Functor<'Traversable<'U>>`` - - static member inline Traverse (t: Id<_>, f, []_output: 'R, []_impl: Default3) = Map.Invoke Id.create (f (Id.run t)) + #if TEST_TRACE + Traces.add "Traverse 'Traversable, 'T->Functor<'U>" + #endif + let mapped = Map.Invoke f t : '``Traversable<'Functor<'U>>`` + (^``Traversable<'T>`` : (static member Sequence : _ -> _) mapped) : '``Functor<'Traversable<'U>>`` + + static member inline Traverse (t: Id<_>, f, []_output: 'R, []_impl: Default3) = + #if TEST_TRACE + Traces.add "Traverse Id" + #endif + Map.Invoke Id.create (f (Id.run t)) static member inline Traverse (t: _ seq, f, []_output: 'R, []_impl: Default3) = + #if TEST_TRACE + Traces.add "Traverse seq" + #endif let cons x y = seq {yield x; yield! y} let cons_f x ys = Map.Invoke (cons: 'a->seq<_>->seq<_>) (f x) <*> ys Seq.foldBack cons_f t (result Seq.empty) static member inline Traverse (t: _ NonEmptySeq, f, []_output: 'R, []_impl: Default3) = + #if TEST_TRACE + Traces.add "Traverse NonEmptySeq" + #endif let cons x y = seq {yield x; yield! y} let cons_f x ys = Map.Invoke (cons: 'a->seq<_>->seq<_>) (f x) <*> ys Map.Invoke NonEmptySeq.ofSeq (Seq.foldBack cons_f t (result Seq.empty)) static member inline Traverse (t: seq<'T>, f: 'T->'``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = - let mapped = Seq.map f t - Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, List.toSeq) : '``Functor>`` + #if TEST_TRACE + Traces.add "Traverse seq, 'T->Functor<'U>" + #endif + let mapped = Seq.map f t + Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, List.toSeq) : '``Functor>`` static member inline Traverse (t: NonEmptySeq<'T>, f: 'T->'``Functor<'U>``, []_output: '``Functor>``, []_impl: Default2) = - let mapped = NonEmptySeq.map f t - Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq.ofList) : '``Functor>`` - - static member inline Traverse (t: ^a , f, []_output: 'R, []_impl: Default1) = Traverse.InvokeOnInstance f t : 'R + #if TEST_TRACE + Traces.add "Traverse NonEmptySeq, 'T->Functor<'U>" + #endif + let mapped = NonEmptySeq.map f t + Sequence.ForInfiniteSequences (mapped, IsLeftZero.Invoke, NonEmptySeq.ofList) : '``Functor>`` + + static member inline Traverse (t: ^a , f, []_output: 'R, []_impl: Default1) = + #if TEST_TRACE + Traces.add "Traverse ^a" + #endif + Traverse.InvokeOnInstance f t : 'R static member inline Traverse (_: ^a when ^a : null and ^a :struct, _, _: 'R , _impl: Default1) = id #if !FABLE_COMPILER static member Traverse (t: 't seq, f: 't->Async<'u>, []_output: Async>, []_impl: Traverse) : Async> = async { - let! ct = Async.CancellationToken - return seq { - use enum = t.GetEnumerator () - while enum.MoveNext() do - yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) }} + #if TEST_TRACE + Traces.add "Traverse 't seq, 't->Async<'u>" + #endif + + let! ct = Async.CancellationToken + return seq { + use enum = t.GetEnumerator () + while enum.MoveNext() do + yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) }} #endif #if !FABLE_COMPILER static member Traverse (t: 't NonEmptySeq, f: 't->Async<'u>, []_output: Async>, []_impl: Traverse) : Async> = async { - let! ct = Async.CancellationToken - return seq { - use enum = t.GetEnumerator () - while enum.MoveNext() do - yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq.unsafeOfSeq } + #if TEST_TRACE + Traces.add "Traverse 't NonEmptySeq, 't->Async<'u>" + #endif + + let! ct = Async.CancellationToken + return seq { + use enum = t.GetEnumerator () + while enum.MoveNext() do + yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq.unsafeOfSeq } #endif - static member Traverse (t: Id<'t> , f: 't->option<'u>, []_output: option>, []_impl: Traverse) = Option.map Id.create (f (Id.run t)) - static member inline Traverse (t: option<_>, f, []_output: 'R, []_impl: Traverse) : 'R = match t with Some x -> Map.Invoke Some (f x) | _ -> result None - static member inline Traverse (t: voption<_>, f, []_output: 'R, []_impl: Traverse) : 'R = match t with ValueSome x -> Map.Invoke ValueSome (f x) | _ -> result ValueNone + static member Traverse (t: Id<'t> , f: 't->option<'u>, []_output: option>, []_impl: Traverse) = + #if TEST_TRACE + Traces.add "Traverse Id, 't->option<'u>" + #endif + Option.map Id.create (f (Id.run t)) + static member inline Traverse (t: option<_>, f, []_output: 'R, []_impl: Traverse) : 'R = + #if TEST_TRACE + Traces.add "Traverse option" + #endif + match t with Some x -> Map.Invoke Some (f x) | _ -> result None + static member inline Traverse (t: voption<_>, f, []_output: 'R, []_impl: Traverse) : 'R = + #if TEST_TRACE + Traces.add "Traverse voption" + #endif + match t with ValueSome x -> Map.Invoke ValueSome (f x) | _ -> result ValueNone static member inline Traverse (t:Map<_,_> , f, []_output: 'R, []_impl: Traverse) : 'R = - let insert_f m k v = Map.Invoke (Map.add k) v <*> m - Map.fold insert_f (result Map.empty) (Map.mapValues f t) + #if TEST_TRACE + Traces.add "Traverse Map" + #endif + let insert_f m k v = Map.Invoke (Map.add k) v <*> m + Map.fold insert_f (result Map.empty) (Map.mapValues f t) static member inline Traverse (t: Result<'T,'Error>, f: 'T->'``Functor<'U>``, []_output: '``Functor>``, []_impl: Traverse) : '``Functor>`` = - match t with - | Ok a -> Map.Invoke Result<'U,'Error>.Ok (f a) - | Error e -> Return.Invoke (Result<'U,'Error>.Error e) + #if TEST_TRACE + Traces.add "Traverse Result, 'T->Functor<'U>" + #endif + match t with + | Ok a -> Map.Invoke Result<'U,'Error>.Ok (f a) + | Error e -> Return.Invoke (Result<'U,'Error>.Error e) static member inline Traverse (t: Choice<'T,'Error>, f: 'T->'``Functor<'U>``, []_output: '``Functor>``, []_impl: Traverse) : '``Functor>`` = - match t with - | Choice1Of2 a -> Map.Invoke Choice<'U,'Error>.Choice1Of2 (f a) - | Choice2Of2 e -> Return.Invoke (Choice<'U,'Error>.Choice2Of2 e) + #if TEST_TRACE + Traces.add "Traverse Choice, 'T->Functor<'U>" + #endif + match t with + | Choice1Of2 a -> Map.Invoke Choice<'U,'Error>.Choice1Of2 (f a) + | Choice2Of2 e -> Return.Invoke (Choice<'U,'Error>.Choice2Of2 e) static member inline Traverse (t:list<_> ,f , []_output: 'R, []_impl: Traverse) : 'R = - let rec loop acc = function - | [] -> acc - | x::xs -> - let v = f x - loop (v::acc) xs - let cons_f x xs = Map.Invoke List.cons xs <*> x - List.fold cons_f (result []) (loop [] t) + #if TEST_TRACE + Traces.add "Traverse list" + #endif + let rec loop acc = function + | [] -> acc + | x::xs -> + let v = f x + loop (v::acc) xs + let cons_f x xs = Map.Invoke List.cons xs <*> x + List.fold cons_f (result []) (loop [] t) static member inline Traverse (t:_ [] ,f , []_output: 'R, []_impl: Traverse) : 'R = - let cons x y = Array.append [|x|] y - let rec loop acc = function - | [||] -> acc - | xxs -> - let x, xs = Array.head xxs, Array.tail xxs - let v = f x - loop (cons v acc) xs - let cons_f x xs = Map.Invoke cons xs <*> x - Array.fold cons_f (result [||]) (loop [||] t) + #if TEST_TRACE + Traces.add "Traverse []" + #endif + let cons x y = Array.append [|x|] y + let rec loop acc = function + | [||] -> acc + | xxs -> + let x, xs = Array.head xxs, Array.tail xxs + let v = f x + loop (cons v acc) xs + let cons_f x xs = Map.Invoke cons xs <*> x + Array.fold cons_f (result [||]) (loop [||] t) static member inline Invoke (f: 'T->'``Functor<'U>``) (t: '``Traversable<'T>``) : '``Functor<'Traversable<'U>>`` = let inline call_3 (a: ^a, b: ^b, c: ^c, f) = ((^a or ^b or ^c) : (static member Traverse : _*_*_*_ -> _) b, f, c, a) diff --git a/src/FSharpPlus/FSharpPlus.fsproj b/src/FSharpPlus/FSharpPlus.fsproj index 9202db334..c113e81ba 100644 --- a/src/FSharpPlus/FSharpPlus.fsproj +++ b/src/FSharpPlus/FSharpPlus.fsproj @@ -19,9 +19,10 @@ false false true - Debug;Release;Fable;Fable3 + Debug;Release;Fable;Fable3;Test AnyCPU 6.0 + $(DefineConstants);TEST_TRACE $(DefineConstants);FABLE_COMPILER $(DefineConstants);FABLE_COMPILER;FABLE_COMPILER_3 $(DefineConstants);FABLE_COMPILER;FABLE_COMPILER_4 diff --git a/src/FSharpPlus/Internals.fs b/src/FSharpPlus/Internals.fs index 5f0a7a90b..2329828ff 100644 --- a/src/FSharpPlus/Internals.fs +++ b/src/FSharpPlus/Internals.fs @@ -1,5 +1,13 @@ namespace FSharpPlus.Internals +#if TEST_TRACE +module Traces = + let private effects = ResizeArray [] + let reset () = effects.Clear () + let add x = effects.Add (x) + let get () = effects |> Seq.toList +#endif + /// /// /// Internal to the library - please ignore diff --git a/tests/FSharpPlus.Tests/FSharpPlus.Tests.fsproj b/tests/FSharpPlus.Tests/FSharpPlus.Tests.fsproj index 46ee59d92..767e2ee10 100644 --- a/tests/FSharpPlus.Tests/FSharpPlus.Tests.fsproj +++ b/tests/FSharpPlus.Tests/FSharpPlus.Tests.fsproj @@ -8,8 +8,9 @@ true 6.0 false - Debug;Release;Fable + Debug;Release;Fable;Test AnyCPU + $(DefineConstants);TEST_TRACE $(DefineConstants);FABLE_COMPILER net7.0 diff --git a/tests/FSharpPlus.Tests/Traversals.fs b/tests/FSharpPlus.Tests/Traversals.fs index 6f0265226..7cbf800bd 100644 --- a/tests/FSharpPlus.Tests/Traversals.fs +++ b/tests/FSharpPlus.Tests/Traversals.fs @@ -12,6 +12,9 @@ open Helpers open FSharpPlus.Math.Applicative open CSharpLib open System.Threading.Tasks +#if TEST_TRACE +open FSharpPlus.Internals +#endif module Traversable = @@ -251,9 +254,15 @@ module Traversable = [] let traverseTask () = + #if TEST_TRACE + Traces.reset() + #endif let a = traverse Task.FromResult [1;2] CollectionAssert.AreEqual ([1;2], a.Result) Assert.IsInstanceOf>> (Some a.Result) + #if TEST_TRACE + CollectionAssert.AreEqual (["Traverse list"], Traces.get()) + #endif let b = map Task.FromResult [1;2] |> sequence CollectionAssert.AreEqual ([1;2], b.Result) Assert.IsInstanceOf>> (Some b.Result) @@ -266,6 +275,9 @@ module Traversable = [] let traverseMap () = + #if TEST_TRACE + Traces.reset() + #endif let m = Map.ofList [("a", 1); ("b", 2); ("c", 3)] let r1 = traverse (fun i -> if i = 2 then None else Some i) m let r2 = traverse Some m @@ -278,14 +290,23 @@ module Traversable = Map.ofList [(1, 1); (2, 2)]; Map.ofList [(1, 1); (2, 2)]; Map.ofList [(1, 1); (2, 2)]] let actual = sequence m1 CollectionAssert.AreEqual (expected, actual) + #if TEST_TRACE + CollectionAssert.AreEqual (["Traverse Map";"Traverse Map"], Traces.get()) + #endif [] let traverseResults () = + #if TEST_TRACE + Traces.reset() + #endif let a = sequence (if true then Ok [1] else Error "no") let b = traverse id (if true then Ok [1] else Error "no") let expected: Result list = [Ok 1] CollectionAssert.AreEqual (expected, a) CollectionAssert.AreEqual (expected, b) + #if TEST_TRACE + CollectionAssert.AreEqual (["Traverse Result, 'T->Functor<'U>"], Traces.get()) + #endif module Bitraversable =