-
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
Showing
23 changed files
with
216 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ pymonet.egg-info | |
dist | ||
docs/dist | ||
monet | ||
_build | ||
_build | ||
build |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Semigroups | ||
********* | ||
|
||
.. code-block:: python | ||
:caption: example_semigroup.py | ||
:name: example_semigroup-py | ||
from pymonet.semigroups import All, First, Map, Sum | ||
All(True).concat(All(False)) # All<False> | ||
All(True).concat(All(True)) # All<True> | ||
All(True) == All(True) # True | ||
All(True) == All(False) # False | ||
ingredient1 = Map({'score': Sum(1), 'won': All(True), 'captain': First('captain america')}) | ||
ingredient2 = Map({'score': Sum(2), 'won': All(True), 'captain': First('iron man')}) | ||
ingredient1.concat(ingredient2) # Map<{'score': Sum(3), 'won': All(True), 'captain': First('captain america')}> | ||
.. autoclass:: pymonet.semigroups.All | ||
:members: __init__, concat, fold | ||
|
||
.. autoclass:: pymonet.semigroups.One | ||
:members: __init__, concat, fold | ||
|
||
.. autoclass:: pymonet.semigroups.First | ||
:members: __init__, concat, fold | ||
|
||
.. autoclass:: pymonet.semigroups.Map | ||
:members: __init__, concat, fold | ||
|
||
|
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 |
---|---|---|
|
@@ -4,12 +4,12 @@ | |
setup( | ||
name='pymonet', | ||
packages=['pymonet'], | ||
version='0.9.0', | ||
version='0.9.1', | ||
description='High abstract python library for functional programming. Contains algebraic data structures known from Haskell or Scala.', | ||
author='Przemyslaw Jan Pietrzak', | ||
author_email='[email protected]', | ||
url='https://github.com/przemyslawjanpietrzak/pyMonet', | ||
download_url='https://github.com/przemyslawjanpietrzak/pyMonet/archive/0.9.0.tar.gz', | ||
download_url='https://github.com/przemyslawjanpietrzak/pyMonet/archive/0.9.1.tar.gz', | ||
keywords=['functional-programming', 'monads', 'functors', 'semigroups'], | ||
classifiers=[], | ||
) |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class MonoidLawTester: | ||
|
||
def __init__(self, monoid, value): | ||
self.monoid = monoid | ||
self.value = value | ||
|
||
def left_identity_test(self): | ||
monoid = self.monoid(self.value) | ||
assert monoid.concat(monoid.neutral()) == monoid | ||
|
||
def right_identity_test(self): | ||
monoid = self.monoid(self.value) | ||
assert monoid.neutral().concat(monoid) == monoid | ||
|
||
def test(self): | ||
self.left_identity_test() | ||
self.right_identity_test() |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class SemigroupLawTester: | ||
|
||
def __init__(self, semigroup, value1, value2, value3, result): | ||
self.semigroup = semigroup | ||
self.value1 = value1 | ||
self.value2 = value2 | ||
self.value3 = value3 | ||
self.result = result | ||
|
||
def associativity_test(self): | ||
|
||
x = self.semigroup(self.value1)\ | ||
.concat(self.semigroup(self.value2))\ | ||
.concat(self.semigroup(self.value3)) | ||
|
||
y = self.semigroup(self.value1).concat( | ||
self.semigroup(self.value2).concat(self.semigroup(self.value3)) | ||
) | ||
|
||
assert x == y == self.result | ||
|
||
def test(self): | ||
self.associativity_test() |
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
Oops, something went wrong.