Repository navigation
v2.0.0a2
Pre-release
Pre-release
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