Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case 0:
return M.unit
case 1:
return types[0]
default:
return M.tuple(types)
}
})
)
),
P.apFirst(rightParens)
),
'a tuple'
)
const arrow = S.fold([S.spaces, S.string('->'), S.spaces])
/**
* @since 0.4.0
*/
export const fun: P.Parser = P.expected(
pipe(
S.spaces,
P.chain(() =>
pipe(
ref,
P.alt(() => tuple),
P.chain(domain =>
pipe(
arrow,
P.apSecond(type),
P.map(codomain => M.fun(domain, codomain))
export const parameterDeclaration = P.expected(
pipe(
unconstrainedParameterDeclaration,
P.alt(() => constrainedParameterDeclaration)
),
'a parameter'
)
const pipeParser = S.fold([S.spaces, C.char('|'), S.spaces])
/**
* @since 0.4.0
*/
export const data: P.Parser = P.expected(
pipe(
S.string('data'),
P.chain(() =>
pipe(
S.spaces,
P.apSecond(
pipe(
identifier,
P.chain(name =>
pipe(
S.spaces,
P.apSecond(P.sepBy(S.spaces, parameterDeclaration)),
P.apFirst(equal),
P.chain(typeParameters =>
pipe(
P.sepBy1(pipeParser, constructor),
P.map(constructors => M.data(name, typeParameters, constructors)),
P.apFirst(S.spaces),
P.chain(name =>
pipe(
S.fold([S.spaces, S.string('::'), S.spaces]),
P.apSecond(type),
P.map(type => ({ name, type }))
)
)