Validated
funstruct.applicative.validated
Validated: applicative error-accumulating functor.
Examples:
>>> from funstruct.applicative.validated import Validated, Valid, Invalid
>>> Validated.cond(True, 42, "err")
Valid(value=42)
>>> Validated.cond(False, 42, "err")
Invalid(errors=Cons('err', Nil()))
>>> Valid(1) * Valid(2)
Valid(value=(1, 2))
>>> Invalid("a:") * Invalid("b")
Invalid(errors='a:b')
Validated
Bases: DataType, Generic[_E, _A]
Base class for Valid/Invalid. Bifunctor over error and value types.
Source code in funstruct/applicative/validated/__init__.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
Valid
dataclass
Bases: Validated, Generic[_A]
Success case.
Source code in funstruct/applicative/validated/__init__.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
Invalid
dataclass
Bases: Validated, Generic[_E]
Failure case — accumulated errors.
Source code in funstruct/applicative/validated/__init__.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |