Skip to content

Commit

Permalink
Add Monoid CE example.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdziadkiewicz committed Oct 30, 2022
1 parent 88b2c45 commit 3957ba3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion FSharpx.Extras.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A6A6AF7D-D
ProjectSection(SolutionItems) = preProject
docs\DiningPhilosophers.fsx = docs\DiningPhilosophers.fsx
docs\index.fsx = docs\index.fsx
docs\MonoidCESample.fsx = docs\MonoidCESample.fsx
docs\Santa.fsx = docs\Santa.fsx
docs\StmSample.fsx = docs\StmSample.fsx
docs\StateSample.fsx = docs\StateSample.fsx
docs\StmSample.fsx = docs\StmSample.fsx
docs\StructuredFormatSample.fsx = docs\StructuredFormatSample.fsx
docs\UndoSample.fsx = docs\UndoSample.fsx
docs\WebProxy.fsx = docs\WebProxy.fsx
Expand Down
21 changes: 21 additions & 0 deletions docs/MonoidCESample.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#r @"../bin/FSharpx.Extras.dll"
#r @"../bin/FSharpx.Collections.dll"

open FSharpx

// Sample monoid implementation
let addition = Monoid.sum()

// Using monoids computation expression capabilities
let x : float =
addition {
yield 1.0
yield 5.0
yield 6.0
}

// Getting the zero
let zero : float =
addition {
()
}

0 comments on commit 3957ba3

Please sign in to comment.