https://github.com/noxecane/pyfunk
An exploration of functional programming in python
https://github.com/noxecane/pyfunk
functional-programming monads
Last synced: about 1 month ago
JSON representation
An exploration of functional programming in python
- Host: GitHub
- URL: https://github.com/noxecane/pyfunk
- Owner: noxecane
- License: gpl-3.0
- Created: 2016-07-21T01:15:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-24T15:57:14.000Z (almost 9 years ago)
- Last Synced: 2025-03-27T20:45:29.398Z (8 months ago)
- Topics: functional-programming, monads
- Language: Python
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gakp-pyfunk
A set of functional tools for python. It is supposed to have the same interface as Gakp-jsfunk and Gakp-lispfunk
## Example
```python
from pyfunk.combinators import compose
from pyfunk.collections import fmap
from pyfunk.functors.io import IO
def get_file(filename):
"""@sig get_file :: String -> IO String """
def open_file():
with open(filename) as f:
return f.read()
return IO(open_file)
def get_tokens(str):
return str.split()
def get_lenght_of_tokens(tokens):
return len(tokens)
tokenLength = compose(fmap(get_lenght_of_tokens), fmap(get_tokens), get_file)
print(tokenLength('.gitignore').unsafeIO())
```
## Contributing
Anyone can contribute using the fork and pull model.