monad-maybe
Installation
SKILL.md
Maybe Monad
Installation: If not already installed, add the package with pnpm add @efesto-cloud/maybe.
Use this skill to keep Maybe<T> usage simple and predictable.
Core Rules
- Wrap optional value with
Maybe.maybe(value). - Build explicit presence with
Maybe.some(value). - Build explicit absence with
Maybe.none(). - Check state with
isSome()/isNone(). - Provide fallback with
else(() => defaultValue). - Convert to
Resultwhen needed withtoResult()— returnsResult<T, NoneError>. - Pattern match with
fold(onNone, onSome)when both branches need to return the same type. - Execute side effects with
run(fn => {...})— Some runs the function, None does nothing. - Serialize to plain object with
toObject()— returnsISome<T> | INone. - Deserialize with
Maybe.fromObject(obj)— reconstructs from{ some: boolean, data: T | null }. - Combine two Maybes with
Maybe.combine(m1, m2)— returnsMaybe<[T1, T2]>.
Related skills
More from efesto-cloud/lib
usecase
>
3observer
Use when writing or reviewing Observable code from the @efesto-cloud/observable package.
3entity
Create or modify domain entities using the @efesto-cloud/entity package. Use this skill whenever the user asks to add a new entity, update an existing entity, add properties or methods to an entity, or work on the entity/dto layer. Trigger when the user says things like "create a Foo entity", "add a field to Bar", "I need a new domain object", or "add entity X". Also trigger for DTO creation or modification.
3persistence
>
3type-enum-dict
|
3value-object
|
3