import { Effect, pipe } from "effect" import { z } from "zod" /** * Parses a value using a ZodType schema wrapped in an Effect monad. * * @param schema - The ZodType schema to use for parsing. * @param args - The arguments to pass to the `safeParseAsync` method of the schema. * @returns An Effect monad representing the parsing result. */ export const parseZodTypeEffect = < Output, Input, >( schema: z.ZodType, ...args: Parameters ) => pipe( Effect.promise(() => schema.safeParseAsync(...args)), Effect.flatMap(response => response.success ? Effect.succeed(response.data) : Effect.fail(response.error) ), )