Skip to content

Commit 735a8bc

Browse files
committed
Use catch in <??> definition
1 parent 64c1106 commit 735a8bc

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ZMidi/Internal/ParserMonad.fs

+2-7
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,8 @@ module ParserMonad =
157157
StateT <| fun st -> Error (mkOtherParseError st genMessage)
158158

159159
/// Run the parser, if it fails swap the error message.
160-
let inline ( <??> ) (parser : ParserMonad<'a>) (genMessage : Pos -> string) : ParserMonad<'a> =
161-
StateT <| fun st ->
162-
match apply1 parser st with
163-
| Ok result -> Ok result
164-
| Error e ->
165-
logf "oops <??>: e:%A" e
166-
Error(mkOtherParseError st genMessage)
160+
let inline ( <??> ) (parser : ParserMonad<'a>) (genMessage : Pos -> string) : ParserMonad<'a> =
161+
parser </catch/> fun (ParseError (pos, _)) -> throw <| ParseError (pos, Other (genMessage pos))
167162

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

0 commit comments

Comments
 (0)