Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @since 0.4.0
*/
export const constructor: P.Parser = pipe(
recordConstructor,
P.alt(() => positionalConstructor)
)
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'
)