-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67e56ce
commit d6c90a4
Showing
11 changed files
with
201 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
package monads | ||
package monads_test | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
func TestMonadInterface(t *testing.T) { | ||
"github.com/rushsteve1/fp" | ||
. "github.com/rushsteve1/fp/fun" | ||
. "github.com/rushsteve1/fp/monads" | ||
. "github.com/rushsteve1/fp/reducers" | ||
. "github.com/rushsteve1/fp/transducers" | ||
) | ||
|
||
func TestOptionMonadInterface(t *testing.T) { | ||
v := Some(1) | ||
// If this cast succedes the test does | ||
m := Monad[int](v) | ||
t.Log(m) | ||
} | ||
|
||
func TestResultMonadInterface(t *testing.T) { | ||
v := Wrap(1, nil) | ||
// If this cast succedes the test does | ||
m := Monad[int](v) | ||
t.Log(m) | ||
} | ||
|
||
func TestMonadTransducer(t *testing.T) { | ||
a := Transduce( | ||
Some(10), | ||
Curry2(Map, func(x int) int { return x * 2 }), | ||
Chain2(First[int], Some), | ||
) | ||
|
||
fp.AssertEq(t, a, Some(20)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.