Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
const equal = S.fold([S.spaces, C.char('='), S.spaces])
const unconstrainedParameterDeclaration: P.Parser = pipe(
identifier,
P.map(name => M.parameterDeclaration(name))
)
const constrainedParameterDeclaration: P.Parser = pipe(
S.fold([C.char('('), S.spaces]),
P.apSecond(
pipe(
pair,
P.map(({ name, type }) => M.parameterDeclaration(name, some(type))),
P.apFirst(S.fold([S.spaces, C.char(')')]))
)
)
)
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
const withParens = <a>(parser: P.Parser): P.Parser => {
return pipe(
leftParens,
P.apSecond(parser),
P.apFirst(rightParens)
)
}
</a>
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.apFirst(P.eof())
)
)
)
)
P.chain(typeParameters =>
pipe(
P.sepBy1(pipeParser, constructor),
P.map(constructors => M.data(name, typeParameters, constructors)),
P.apFirst(S.spaces),
P.apFirst(P.eof())
)
)