Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Practical async patterns using TaskEither - clean pipelines instead of try/catch hell, with real API examples
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-16 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✓→✓ | = Same ✓ | — | — |
| case-04 | ✓→✓ | = Same ✓ | — | — |
| case-01 | ✓→✓ | = Same ✓ | — | — |
| case-19 | ✗→✗ | = Same ✗ | — | — |
Stop writing nested try/catch blocks. Stop losing error context. Start building clean async pipelines that handle errors properly.
TaskEither is simply an async operation that tracks success or failure. That's it. No fancy terminology needed.
Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.
TaskEither.try/catch flows.typescript// TaskEither<Error, User> means: // "An async operation that either fails with Error or succeeds with User"
typescript// types.ts interface ApiError { code: string message: string status: number details?: unknown } // api.ts const createApiError = ( code: string, message: string, status: number, details?: unknown ): ApiError => ({ code, message, status, details }) const request = <T>( url: string, options: RequestInit = {} ): TE.TaskEither<ApiError, T> => TE.tryCatch( async () => { const response = await fetch(url, { headers: { 'Content-Type': 'application/json', ...options.headers, }, ...options, }) if (!response.ok) { const body = await response.json().catch(() => ({})) throw createApiError( body.code || 'HTTP_ERROR', body.message || response.statusText, response.status, body ) } // Handle 204 No Content if (response.status === 204) { return undefined as T } return response.json() }, (error): ApiError => { if (typeof error === 'object' && error !== null && 'code' in error) { return error as ApiError } return createApiError( 'NETWORK_ERROR', error instanceof Error ? error.message : 'Request failed', 0 ) } ) // API client const api = { get: <T>(url: string) => request<T>(url), post: <T>(url: string, body: unknown) => request<T>(url, { method: 'POST', body: JSON.stringify(body) }), put: <T>(url: string, body: unknown) => request<T>(url, { method: 'PUT', body: JSON.stringify(body) }), delete: (url: string) => request<void>(url, { method: 'DELETE' }), } // Usage const getUser = (id: string) => api.get<User>(`/api/users/${id}`) const createUser = (data: CreateUserDto) => api.post<User>('/api/users', data) const updateUser = (id: string, data: UpdateUserDto) => api.put<User>(`/api/users/${id}`, data) const deleteUser = (id: string) => api.delete(`/api/users/${id}`)
typescriptimport { PrismaClient, Prisma } from '@prisma/client' type DbError = | { _tag: 'NotFound'; entity: string; id: string } | { _tag: 'UniqueViolation'; field: string } | { _tag: 'ConnectionError'; cause: unknown } const prisma = new PrismaClient() const wrapPrisma = <T>( operation: () => Promise<T> ): TE.TaskEither<DbError, T> => TE.tryCatch( operation, (error): DbError => { if (error instanceof Prisma.PrismaClientKnownRequestError) { if (error.code === 'P2002') { const field = (error.meta?.target as string[])?.join(', ') || 'unknown' return { _tag: 'UniqueViolation', field } } if (error.code === 'P2025') { return { _tag: 'NotFound', entity: 'Record', id: 'unknown' } } } return { _tag: 'ConnectionError', cause: error } } ) // Repository pattern const userRepository = { findById: (id: string): TE.TaskEither<DbError, User> => pipe( wrapPrisma(() => prisma.user.findUnique({ where: { id } })), TE.chain(user => user ? TE.right(user) : TE.left({ _tag: 'NotFound', entity: 'User', id }) ) ), findByEmail: (email: string): TE.TaskEither<DbError, User | null> => wrapPrisma(() => prisma.user.findUnique({ where: { email } })), create: (data: CreateUserInput): TE.TaskEither<DbError, User> => wrapPrisma(() => prisma.user.create({ data })), update: (id: string, data: UpdateUserInput): TE.TaskEither<DbError, User> => wrapPrisma(() => prisma.user.update({ where: { id }, data })), delete: (id: string): TE.TaskEither<DbError, void> => pipe( wrapPrisma(() => prisma.user.delete({ where: { id } })), TE.map(() => undefined) ), } // Service using repository const createUserService = (input: CreateUserInput) => pipe( // Check email doesn't exist userRepository.findByEmail(input.email), TE.chain(existing => existing ? TE.left({ _tag: 'UniqueViolation' as const, field: 'email' }) : TE.right(undefined) ), // Create user TE.chain(() => userRepository.create(input)) )
typescriptimport * as fs from 'fs/promises' import * as path from 'path' type FileError = | { _tag: 'NotFound'; path: string } | { _tag: 'PermissionDenied'; path: string } | { _tag: 'IoError'; cause: unknown } const toFileError = (error: unknown, filePath: string): FileError => { if (error instanceof Error) { if ('code' in error) { if (error.code === 'ENOENT') return { _tag: 'NotFound', path: filePath } if (error.code === 'EACCES') return { _tag: 'PermissionDenied', path: filePath } } } return { _tag: 'IoError', cause: error } } const readFile = (filePath: string): TE.TaskEither<FileError, string> => TE.tryCatch( () => fs.readFile(filePath, 'utf-8'), (e) => toFileError(e, filePath) ) const writeFile = (filePath: string, content: string): TE.TaskEither<FileError, void> => TE.tryCatch( () => fs.writeFile(filePath, content, 'utf-8'), (e) => toFileError(e, filePath) ) const readJson = <T>(filePath: string): TE.TaskEither<FileError | { _tag: 'ParseError'; cause: unknown }, T> => pipe( readFile(filePath), TE.chain(content => TE.tryCatch( () => Promise.resolve(JSON.parse(content)), (e): { _tag: 'ParseError'; cause: unknown } => ({ _tag: 'ParseError', cause: e }) ) ) ) // Usage: Load config with fallback const loadConfig = () => pipe( readJson<Config>('./config.json'), TE.orElse(() => readJson<Config>('./config.default.json')), TE.getOrElse(() => T.of(defaultConfig)) )
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
The publisher has shipped newer versions since this run, so these numbers describe v1, not the version currently listed.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.