Skip to content

An exploration of functional programming in python

License

Notifications You must be signed in to change notification settings

noxecane/pyfunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gakp-pyfunk

A set of functional tools for python. It is supposed to have the same interface as Gakp-jsfunk and Gakp-lispfunk

Example

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.

About

An exploration of functional programming in python

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages