MCPcopy Create free account
hub / github.com/Effect-TS/effect / allTupled

Function allTupled

packages/effect/src/unstable/cli/Prompt.ts:1329–1346  ·  view source on GitHub ↗
(arg: T)

Source from the content-addressed store, hash-verified

1327{}
1328
1329const allTupled = <const T extends ArrayLike<Prompt<any>>>(arg: T): Prompt<
1330 {
1331 [K in keyof T]: [T[K]] extends [Prompt<infer A>] ? A : never
1332 }
1333> => {
1334 if (arg.length === 0) {
1335 return succeed([]) as any
1336 }
1337 if (arg.length === 1) {
1338 return map(arg[0], (x) => [x]) as any
1339 }
1340 let result = map(arg[0], (x) => [x])
1341 for (let i = 1; i < arg.length; i++) {
1342 const curr = arg[i]
1343 result = flatMap(result, (tuple) => map(curr, (a) => [...tuple, a]))
1344 }
1345 return result as any
1346}
1347
1348const runWithInput = <Output>(
1349 prompt: Prompt<Output>,

Callers 1

allFunction · 0.85

Calls 2

mapFunction · 0.85
succeedFunction · 0.70

Tested by

no test coverage detected