@@ -6,6 +6,7 @@ module ParserMonad =
6
6
open System.IO
7
7
open FSharpPlus
8
8
open FSharpPlus.Data
9
+ open FSharpPlus.Math .Generic
9
10
10
11
/// Status is either OFF or the previous VoiceEvent * Channel.
11
12
type VoiceEvent =
@@ -68,6 +69,8 @@ module ParserMonad =
68
69
#if DEBUG_ LASTPARSE
69
70
* lastToken : obj // need top level type, picking System.Object for now
70
71
#endif
72
+ with
73
+ static member (+) ( _ : ParseError , y : ParseError ) = y
71
74
72
75
let inline mkOtherParseError st ( genMessage : Pos -> string ) =
73
76
ParseError(
@@ -134,11 +137,7 @@ module ParserMonad =
134
137
let mzero () : ParserMonad < 'a > =
135
138
StateT <| fun state -> Error ( mkParseError state ( EOF " mzero" ))
136
139
137
- let inline mplus ( parser1 : ParserMonad < 'a >) ( parser2 : ParserMonad < 'a >) : ParserMonad < 'a > =
138
- StateT <| fun state ->
139
- match apply1 parser1 state with
140
- | Error _ -> apply1 parser2 state
141
- | Ok res -> Ok res
140
+ let inline mplus ( parser1 : ParserMonad < 'a >) ( parser2 : ParserMonad < 'a >) : ParserMonad < 'a > = parser1 <|> parser2
142
141
143
142
let inline mfor ( items : #seq<'a> ) ( fn : 'a -> ParserMonad < 'b >) : ParserMonad < seq < 'b >> = failwithf " "
144
143
@@ -253,13 +252,13 @@ module ParserMonad =
253
252
( st : State )
254
253
( fk : ParseError -> Result < 'a list * State , ParseError >)
255
254
( sk : State -> 'a list -> Result < 'a list * State , ParseError >) =
256
- if i <= LanguagePrimitives.GenericZero then
255
+ if i <= 0 G then
257
256
sk st []
258
257
else
259
258
match apply1 parser st with
260
259
| Error msg -> fk msg
261
260
| Ok ( a1, st1) ->
262
- work ( i - LanguagePrimitives.GenericOne ) st1 fk ( fun st2 ac ->
261
+ work ( i - 1 G ) st1 fk ( fun st2 ac ->
263
262
sk st2 ( a1 :: ac))
264
263
work length state ( fun msg -> Error msg) ( fun st ac -> Ok ( ac, st))
265
264
|> Result.map ( fun ( ans , st ) -> ( List.toArray ans, st))
0 commit comments