Sumtype Versions Save

A namedtuple-style library for defining immutable sum types in Python.

0.11.b0

5 years ago

We only ever need one None, (), etc. After this update, variants with no payload (i.e. Nothing from Maybe[A]) can behave that way: we do Maybe.Nothing (access the singleton immutable value) instead of Maybe.Nothing() (create a new instance). This is enabled with the new constants option:

class Maybe(sumtype, constants=True):
def Just(val): ... 
Nothing = … # new syntax

or by inheriting from sumtype.future.sumtype instead of sumtype.sumtype (This will be the default behavior after 1.0).

Note: it isn't currently guaranteed that there only ever exists one Maybe.Nothing - currently, _replace(), .__copy__() etc. will produce another instance, so you shouldn't rely on the is operator. This may or may not change in the future.

v0.10.0.post4

5 years ago

Fixed code-block indentation in the README, because it looked bad on PyPI

v0.10.0.post2

5 years ago

Fixed typo in README

v0.10.0.post1

5 years ago

Added missing typeguard dependency to setup.py

v0.10.0

5 years ago

Added field typechecking based on annotations (see README)