Registry / serialization / sumtypes

sumtypes

JSON →
library0.1a6pypypi✓ verified 83d ago

Provides algebraic data types (sum types / tagged unions) for Python, with pattern matching support, inspired by Rust and Haskell. Current version is 0.1a6 (alpha); no release cadence established.

pip install sumtypes
INSTALL
IMPORT
SIG · SUMTYPES
S
sumtypes
serializationpythonv0.1a6
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1a6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sumtype
from sumtypes import sumtype
from sumtypes import SumType
match
from sumtypes import match
constructor
from sumtypes import constructor

Define a sum type with three variants; pattern match using isinstance.

from sumtypes import SumType, Case, Enum class Status(SumType): Active = Case() Inactive = Case() Pending = Case(str) statuses = [Status.Active(), Status.Inactive(), Status.Pending("waiting")] for s in statuses: if isinstance(s, Status.Active): print("active") elif isinstance(s, Status.Inactive): print("inactive") else: print(f"pending: {s.value}")
Debug
Known issues
deprecatedLibrary is in alpha (0.1a6) and appears unmaintained; last updated in 2015. Consider alternatives like 'union' or 'adt' for production use.
fix
Migrate to 'adt' or 'union' library for actively maintained sum types.
affects: all
gotchaAvoid Python 3.10+ pattern matching (match/case) as it conflicts with sumtypes.Case naming. Use isinstance instead.
fix
Always check variant type via isinstance, not structural pattern matching.
affects: all
gotchasumtypes.Enum is not iterable and cannot be used like stdlib Enum. Do not call list() on it.
fix
If you need iteration, maintain a separate list of variants.
affects: all
Upgrade
Version history
0.1a6latest on PyPI · released Nov 30, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
sumtypes — pip install sumtypes · libregistry