Repository navigation
Releases
Releases · veyga/funstruct
v2.0.0a2
funstruct v2.0.0a2 — Pure Typeclass Architecture
Major architectural overhaul. Data types are pure data; all behavior lives on typeclass instances.
Architecture
- HKTMeta metaclass — class-level typeclass dispatch (
Option.pure,Result.do,Option.empty) - DotNotation — instance-level dispatch (
Some(10).bind(f),Ok(10).map(f)) @finalsealed variants —Ok,Err,Some,Nothing, etc. can't be subclassed@dataclass(frozen=True, eq=False, repr=False)— no auto-generated dunders
Typeclasses (15)
Functor, Applicative, Monad, MonadError, Alternative, Bifunctor, Foldable, Traversable, Semigroup, Monoid, Eq, Representable, Stringable, Truthable
Do-notation
- AST-based do (experimental) — compiles yield to bind/map chains, works for CList
- Generator-based do (default) — works for all monads except CList
Breaking Changes
- Imports moved:
funstruct.monad.*→funstruct.types.* pure,raise_error,emptyremoved from data types — use HKTMeta dispatchbind,handle_error_with,bimap,left_mapremoved from data type variants — on instances__eq__,__repr__,__bool__,__hash__removed from variants — via Eq/Representable/Truthable- Semigroup/Monoid changed from dataclasses to ABCs
from_result/from_eitherremoved from AsyncResult
v2.0.0-alpha1
v2.0.0-alpha1
Architecture (breaking change from v1)
- Separated data types from typeclass instances — data types extend
DataType, not typeclasses summon(Monad, Option)— typeclass instance resolution via registryDotNotationmixin —Some(10).map(f)delegates to summon internallyfor_type=auto-registration —class _OptionMonad(Monad, for_type=Option)BaseTypeclass— root of all typeclasses with AutoRegisterTypeConstructor— auto_type_constructordetectiontc_of(value)— Haskell-style automatic type constructor resolution
New typeclasses
Bifunctor,Alternative,MonadError,Foldable,Traversable
New features
- Optics (lenses):
at('key') >> at('nested') frozendict.to_dict()+ JSON round-tripfrozendictdeep-freeze by defaultWriter.for_monoid()factory- Auto-generated typeclass hierarchy SVG
- Browser playground (PyScript/Pyodide)
- 11 guides, 18 demo scripts, 57 benchmarks
v1.0.2
Fix Result type preservation for downstream clients.
Resultis now abstract withmap,bind,alt,or_elsereturningResultOk/Erroverride all methods to stay inResultland (no degradation toEither)TryAsyncoverloads for correct async function inferenceValidated.__add__returnsValidated(notApplicative)- Abstract
to_result/to_result_oronValidatedbase
Downstream clients no longer need any ty suppressions.