Releases: lubieowoce/sumtype
Constant variants
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.
Added typechecking
Fixed code-block indentation in the README, because it looked bad on PyPI
Added typechecking
Fixed typo in README
Added Typechecking
Added missing typeguard
dependency to setup.py
Added Typechecking
Added field typechecking based on annotations (see README)