gcanti / gcanti/parser-ts

P.either should fail with fatal error, if second parser failed with fatal, or should it?

Open
#47 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
196
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Take a look at the following test (which currently fails):
```typescript
const fatalParser: P.Parser = i => error(i, ['expected'], true)
const parser5 = P.either(C.char('a'), () => fatalParser)
assert.deepStrictEqual(S.run('c')(parser5), error(stream(['c']), ['"a"', 'expected'], true))
```

I believe that the semigroup of ParserResult should use `getLastSemigroup` on the fatal property, and not `getFirstSemigroup`. I guess it is kind of a philosophical question as one can argue that I'm mistaken....

@gcanti thoughts?

If you think this should indeed be fixed, I have a PR ready to go

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.