Skip to content

Commit bf8c221

Browse files
committed
Use catch in <??> definition
1 parent f5d8b19 commit bf8c221

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ZMidi/Internal/ParserMonad.fs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,8 @@ module ParserMonad =
167167
fmapM modify parser
168168

169169
/// Run the parser, if it fails swap the error message.
170-
let inline ( <??> ) (parser : ParserMonad<'a>) (genMessage : Pos -> string) : ParserMonad<'a> =
171-
StateT <| fun st ->
172-
match apply1 parser st with
173-
| Ok result -> Ok result
174-
| Error e ->
175-
logf "oops <??>: e:%A" e
176-
Error(mkOtherParseError st genMessage)
170+
let inline ( <??> ) (parser : ParserMonad<'a>) (genMessage : Pos -> string) : ParserMonad<'a> =
171+
parser </catch/> fun (ParseError (pos, _)) -> throw <| ParseError (pos, Other (genMessage pos))
177172

178173
///
179174
let fmap (f: 'a -> 'b) (p: ParserMonad<'a>) : ParserMonad<'b> = map f p

0 commit comments

Comments
 (0)