Do Notation
Do
import { OptionAsync } from 'funkcia';
declare function findUserById(id: string): OptionAsync<User>;
declare function calculateUserScore(user: User): OptionAsync<UserScore>;
declare function rankUserLevel(user: User, score: UserScore): OptionAsync<UserLevel>;
// ββββ OptionAsync<UserLevel>
// βΌ
const userLevel = OptionAsync.Do
.bind('user', () => findUserById('user_123'))
.bind('score', (ctx) => calculateUserScore(ctx.user))
.andThen((ctx) => rankUserLevel(ctx.user, ctx.score));
// β²
// ββββ { user: User; score: UserScore }bindTo
bind
let
Understanding the do notation
Last updated
Was this helpful?