Skip to content

Commit

Permalink
Type-level literals and Nat-dependent vector/matrix (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin authored Apr 27, 2020
1 parent fdc10e4 commit 8fdd0a5
Show file tree
Hide file tree
Showing 28 changed files with 1,702 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.108
dotnet-version: 3.1.101
- name: Restore
run: git submodule update --init --recursive
- name: Build with dotnet
run: dotnet build build.proj --configuration Release
- name: Test with dotnet
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/FSharp.TypeProvider.SDK"]
path = external/FSharp.TypeProviders.SDK
url = https://github.com/fsprojects/FSharp.TypeProviders.SDK.git
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ script:
- dotnet run -c Release --project ./docsrc/tools

env:
FSHARP_FORMATTING_LOG=NONE
FSHARP_FORMATTING_LOG=NONE
37 changes: 36 additions & 1 deletion FSharpPlus.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -63,6 +63,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
docsrc\content\type-kleisli.fsx = docsrc\content\type-kleisli.fsx
docsrc\content\type-last.fsx = docsrc\content\type-last.fsx
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.fsx = docsrc\content\type-nonempty.fsx
docsrc\content\type-optiont.fsx = docsrc\content\type-optiont.fsx
Expand All @@ -74,6 +75,7 @@ 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-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
Expand All @@ -88,6 +90,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{81F5F559-FD2
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpPlus.Docs", "src\FSharpPlus.Docs\FSharpPlus.Docs.fsproj", "{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.TypeLevel", "src\FSharpPlus\TypeLevel\FSharpPlus.TypeLevel.fsproj", "{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlus.Providers", "src\FSharpPlus\Providers\FSharpPlus.Providers.fsproj", "{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -130,10 +136,38 @@ Global
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Debug|x86.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}.Release|x64.ActiveCfg = Release|x64
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x64.Build.0 = Release|x64
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x86.ActiveCfg = Release|x86
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x86.Build.0 = Release|x86
{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}.Debug|x64.ActiveCfg = Debug|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Debug|x64.Build.0 = Debug|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Debug|x86.ActiveCfg = Debug|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Debug|x86.Build.0 = Debug|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|x64.ActiveCfg = Release|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|x64.Build.0 = Release|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|x86.ActiveCfg = Release|Any CPU
{AFB80E42-3D22-4C38-B51E-27E9FA4D8111}.Release|x86.Build.0 = Release|Any CPU
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x64.ActiveCfg = Release|Any CPU
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x64.Build.0 = Release|Any CPU
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x86.ActiveCfg = Release|Any CPU
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF}.Release|x86.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}.Debug|x64.ActiveCfg = Debug|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Debug|x64.Build.0 = Debug|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Debug|x86.ActiveCfg = Debug|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Debug|x86.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}.Release|x64.ActiveCfg = Release|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|x64.Build.0 = Release|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|x86.ActiveCfg = Release|Any CPU
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -143,6 +177,7 @@ Global
{8E6D5255-776D-4B61-85F9-73C37AA1FB9A} = {A6A6AF7D-D6E3-442D-9B1E-58CC91879BE1}
{FED64B0A-3FD7-4357-98B6-0B01A3A26EC7} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{B725BEFA-524E-4FD8-BFFF-4AEBCD03D8CF} = {81F5F559-FD23-4E90-9EE6-3E2A2C1A7F96}
{9B93F5E5-3D53-42F1-96E2-06E6A7B496A0} = {81F5F559-FD23-4E90-9EE6-3E2A2C1A7F96}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {789B5FFA-7891-4F60-831E-42C3C5ED2C51}
Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
image: Visual Studio 2019
init:
- git config --global core.autocrlf input
install:
- git submodule update --init --recursive
build_script:
- cmd: dotnet restore ./FSharpPlus.sln
- cmd: dotnet build -c Release ./FSharpPlus.sln
Expand All @@ -11,4 +13,4 @@ build_script:
test: off
artifacts:
- path: bin
name: bin
name: bin
4 changes: 3 additions & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
</Target>

<Target Name="Pack">
<Exec Command='dotnet build src/FSharpPlus/Providers -c Release --version-suffix "$(VersionSuffix)" ' WorkingDirectory="$(RepoRootDir)" IgnoreStandardErrorWarningFormat="true" />
<Exec Command='dotnet pack src/FSharpPlus -c Release -o "$(NupkgsDir)" --version-suffix "$(VersionSuffix)" ' WorkingDirectory="$(RepoRootDir)" IgnoreStandardErrorWarningFormat="true" />
</Target>

<Target Name="Test">
<Exec Command='dotnet build src/FSharpPlus/TypeLevel' WorkingDirectory="$(RepoRootDir)" IgnoreStandardErrorWarningFormat="true" />
<Exec Command='dotnet test tests/FSharpPlus.Tests -c Release --logger:trx' WorkingDirectory="$(RepoRootDir)" IgnoreStandardErrorWarningFormat="true" />
</Target>

<Target Name="VSTest" DependsOnTargets="Test" />

</Project>
</Project>
3 changes: 3 additions & 0 deletions docsrc/content/abstraction-applicative.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ From F#+
- ``Const<'C,'T>``
- ``Compose<'F<'G<'T>>>``
- ``DList<'T>``
- [``Vector<'T,'Dimension>``](type-vector.html)
- [``Matrix<'T,'Rows,'Columns>``](type-matrix.html)
Restricted:
- ``string``
- ``StringBuilder``
- ``Set<'T>``
- ``IEnumerator<'T>``
[Suggest another](https://github.com/fsprojects/FSharpPlus/issues/new) concrete implementation
Examples
Expand Down
2 changes: 2 additions & 0 deletions docsrc/content/abstraction-functor.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ From F#+
- ``Compose<'F<'G<'T>>>``
- ``Coproduct<'FunctorL<'T>,'FunctorR<'T>>``
- ``DList<'T>``
- [``Vector<'T,'Dimension>``](type-vector.html)
- [``Matrix<'T,'Rows,'Columns>``](type-matrix.html)
Restricted:
- ``string``
Expand Down
3 changes: 3 additions & 0 deletions docsrc/content/abstraction-monoid.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ From F#+
- [``First<'T>``](type-first.html)
- [``Last<'T>``](type-last.html)
- [``DList<'T>``](type-dlist.html)
- [``Vector<'T,'Dimension>``](type-vector.html)
- [``Matrix<'T,'Rows,'Columns>``](type-matrix.html)
[Suggest another](https://github.com/fsprojects/FSharpPlus/issues/new) concrete implementation
Expand Down
2 changes: 2 additions & 0 deletions docsrc/content/abstraction-semigroup.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ From F#+
- ``First<'T>``
- ``Last<'T>``
- ``DList<'T>``
- [``Vector<'T,'Dimension>``](type-vector.html)
- [``Matrix<'T,'Rows,'Columns>``](type-matrix.html)
[Suggest another](https://github.com/fsprojects/FSharpPlus/issues/new) concrete implementation
*)
69 changes: 69 additions & 0 deletions docsrc/content/type-matrix.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(*** hide ***)
// This block of code is omitted in the generated HTML documentation. Use
// it to define helpers that you do not want to show in the documentation.
#I "../../bin"

(**
Matrix<'NumType,'Rows,'Cols>
========================================
This is a fixed size matrix of a (typically) numeric type.
Related Tyes
------------
- [Vector](type-vector.html): Similar but for vectors
Abstractions
------------
- [Semigroup](abstraction-semigroup.html)
- [Monoid](abstraction-monoid.html)
- [Functor](abstraction-functor.html)
- [Applicative](abstraction-applicative.html)
Examples
--------
*)


#r @"../../src/FSharpPlus/bin/Release/net45/FSharpPlus.dll"

open FSharpPlus
open FSharpPlus.Data

let matrix3x4_1 =
matrix (
(1, 0, 0, 0),
(0, 1, 0, 0),
(0, 0, 0, 0)
)

let matrix3x4_2 =
matrix (
(10, 0, 100, 0),
(30, 1, 100, 0),
(60, 0, 100, 0)
)


// Add two matrices

let matrix3x4_sum = matrix3x4_1 + matrix3x4_2


// Add a scalar

let matrix3x4_3 = matrix3x4_1 + result 5


// Another way

open FSharpPlus.Math.Generic

let vector3d_4 = matrix3x4_1 + 5G
62 changes: 62 additions & 0 deletions docsrc/content/type-vector.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
(*** hide ***)
// This block of code is omitted in the generated HTML documentation. Use
// it to define helpers that you do not want to show in the documentation.
#I "../../bin"

(**
Vector<'NumType,'Dimension>
===========================
This is a fixed size vector of a (typically) numeric type.
Related Tyes
------------
- [Matrix](type-matrix.html): Similar but for matrices
Abstractions
------------
- [Semigroup](abstraction-semigroup.html)
- [Monoid](abstraction-monoid.html)
- [Functor](abstraction-functor.html)
- [ZipFunctor](abstraction-misc.html)
- [Applicative](abstraction-applicative.html)
- [Foldable](abstraction-foldable.html)
- [Reducible](abstraction-misc.html)
Examples
--------
*)


#r @"../../src/FSharpPlus/bin/Release/net45/FSharpPlus.dll"

open FSharpPlus
open FSharpPlus.Data


let vector3d_1 = vector (1, 2, 3)
let vector3d_2 = vector (10, 20, 30)


// Add two vectors

let vector3d_sum = vector3d_1 + vector3d_2


// Add a scalar

let vector3d_3 = vector (1, 2, 3) + result 5


// Another way

open FSharpPlus.Math.Generic

let vector3d_4 = vector (1, 2, 3) + 5G
1 change: 1 addition & 0 deletions external/FSharp.TypeProviders.SDK
Loading

0 comments on commit 8fdd0a5

Please sign in to comment.