Skip to content

JohannesMessner/pyskell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Stuck with Python but you actually want to use Haskell?

This is a silly package that (ab)uses Python operator overloading to reproduce beloved features from functional programming.

You can do:

Currying

@curry
def f(a, b, c):
  return a + b + c
  
f(1, 2, 3)
Out[0]: 6

g = f << 1
g << 2 << 3
Out[1]:  6

f << 1 << 2 <<< 3
Out[2]: 6

Infix Notation

@infix
def plus(a, b):
  return a + b
  
1 |plus| 2
Out[0]: 3

Functional Programming!

@curry
def foldl(fn, x, xs):
    return x if not xs else foldl << fn << (x |fn| xs[0]) << xs[1:]
    
sum = foldl << plus << 0

sum([1, 2, 3])
Out[0]: 6

Installation

pip install pyskell

Credit

Big credit goes to these guys:

About

Abusing Python to make it feel like Haskell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages