sfermigier / awesome-functional-python

A curated list of awesome things related to functional programming in Python.
2.33k stars 136 forks source link

Include Pampy? #16

Closed danostrowski closed 5 years ago

danostrowski commented 5 years ago

One of the most useful things in functional programming I've come across is pattern matching, and Pampy seems to do a good job of it.

https://github.com/santinic/pampy

Consider adding this? I'm in a time crunch or I'd make a PR, but I just wanted to get this mentioned somewhere.

Technologicat commented 5 years ago

Wow, nice indeed. Seconded.

As a side note, also MacroPy3 provides pattern matching. Granted, there are many attempts at pattern matching for Python - see e.g. the links in the README of the recently resurrected pypatt - but I think MacroPy does it differently enough to merit a mention.

In Pampy, the action must be an expression, which limits what is conveniently doable, but it's built on pure Python and (at least at a quick glance in the source) the implementation looks very pythonic.

MacroPy's with switch, on the other hand, locally makes if into a binding construct. It's convenient for inlining lots of short actions that use the full power of Python (including features only available as statements). But a complete syntactic macro system can be a hard sell.

Both solutions have their advantages. It's nice to see an easily approachable and documented pattern matcher built on pure Python!

sfermigier commented 5 years ago

Done.