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