impl: move `liftTypedString` to `Language.Haskell.TH.Show`
[haskell/symantic-parser.git] / tests / Golden / Splice / G16.expected.txt
index 7e6ea076de38798c88d4a72bd030e1a0c7ab9de0..ab835bd0c59f97c2804214063fd8351bbf95778a 100644 (file)
 \(input :: inp) ->
   let !(#
-         init,
+         initBuffer,
+         initPos,
          readMore,
-         readNext
+         readNext,
+         append
          #) =
-          let _ = "cursorOf"
-           in let next
-                    ( t@( Data.Text.Internal.Text
-                            arr
-                            off
-                            unconsumed
-                          )
-                      ) =
-                      let !( Data.Text.Unsafe.Iter
-                               c
-                               d
-                             ) = Data.Text.Unsafe.iter t 0
-                       in (#
-                            c,
-                            Data.Text.Internal.Text arr (off GHC.Num.+ d) (unconsumed GHC.Num.- d)
-                          #)
-                  more
-                    ( Data.Text.Internal.Text
-                        _
-                        _
-                        unconsumed
-                      ) = unconsumed GHC.Classes.> 0
-               in (# input, more, next #)
-      finalRet = \_farInp _farExp v _inp -> Symantic.Parser.Machine.Generate.returnST GHC.Base.$ Data.Either.Right v
-      finalRaise ::
-        forall st b.
-        Symantic.Parser.Machine.Generate.OnException
-          st
-          inp
-          b = \(!exn) _failInp (!farInp) (!farExp) ->
-          Symantic.Parser.Machine.Generate.returnST GHC.Base.$
-            Data.Either.Left
-              Symantic.Parser.Machine.Generate.ParsingError
-                { Symantic.Parser.Machine.Generate.parsingErrorOffset = Symantic.Parser.Machine.Input.offset farInp,
-                  Symantic.Parser.Machine.Generate.parsingErrorException = exn,
-                  Symantic.Parser.Machine.Generate.parsingErrorUnexpected =
-                    if readMore farInp
-                      then
-                        GHC.Maybe.Just
-                          ( let (#
-                                  c,
-                                  _
-                                  #) = readNext farInp
-                             in c
-                          )
-                      else GHC.Maybe.Nothing,
-                  Symantic.Parser.Machine.Generate.parsingErrorExpecting =
-                    let ( minHoriz,
-                          res
-                          ) =
-                            Data.Set.Internal.foldr
-                              ( \f
-                                 ( minH,
-                                   acc
-                                   ) -> case Symantic.Parser.Grammar.Combinators.unSomeFailure f of
-                                    GHC.Maybe.Just (Symantic.Parser.Grammar.Combinators.FailureHorizon h :: Symantic.Parser.Grammar.Combinators.Failure (Symantic.Parser.Grammar.Combinators.CombSatisfiable (Symantic.Parser.Machine.Input.InputToken inp)))
-                                      | GHC.Maybe.Just old <- minH ->
-                                        ( GHC.Maybe.Just (GHC.Classes.min old h),
-                                          acc
-                                        )
-                                      | GHC.Base.otherwise ->
-                                        ( GHC.Maybe.Just h,
-                                          acc
-                                        )
-                                    _ ->
-                                      ( minH,
-                                        f GHC.Types.: acc
-                                      )
+          let next buf pos =
+                let !( Data.Text.Unsafe.Iter
+                         c
+                         d
+                       ) = Symantic.Parser.Machine.Input.Text.Buffer.iter buf pos
+                 in (# c, pos GHC.Num.+ d #)
+              more buf pos = pos GHC.Classes.< Symantic.Parser.Machine.Input.Text.Buffer.length buf
+              append = Symantic.Parser.Machine.Input.Text.Buffer.pappend
+           in (#
+                Symantic.Parser.Machine.Input.Text.Buffer.buffer input,
+                0,
+                more,
+                next,
+                append
+              #)
+      finalRet = \_farInp _farExp v _inp _buf _end -> Symantic.Parser.Machine.Generate.returnST GHC.Base.$ Symantic.Parser.Machine.Generate.ResultDone v
+      finalRaise :: Symantic.Parser.Machine.Generate.ForallOnException inp =
+        Symantic.Parser.Machine.Generate.ForallOnException GHC.Base.$
+          ( \(!exn) _failInp (!farInp) (!farExp) buf end ->
+              Symantic.Parser.Machine.Generate.returnST GHC.Base.$
+                Symantic.Parser.Machine.Generate.ResultError
+                  Symantic.Parser.Machine.Generate.ParsingError
+                    { Symantic.Parser.Machine.Generate.parsingErrorOffset = Symantic.Parser.Machine.Input.position farInp,
+                      Symantic.Parser.Machine.Generate.parsingErrorException = exn,
+                      Symantic.Parser.Machine.Generate.parsingErrorUnexpected =
+                        if readMore buf farInp
+                          then
+                            GHC.Maybe.Just
+                              ( let (#
+                                      c,
+                                      _
+                                      #) = readNext buf farInp
+                                 in c
                               )
-                              ( GHC.Maybe.Nothing,
-                                GHC.Types . []
+                          else GHC.Maybe.Nothing,
+                      Symantic.Parser.Machine.Generate.parsingErrorExpecting =
+                        let ( minHoriz,
+                              res
+                              ) =
+                                Data.Set.Internal.foldr
+                                  ( \f
+                                     ( minH,
+                                       acc
+                                       ) -> case Symantic.Parser.Grammar.Combinators.unSomeFailure f of
+                                        GHC.Maybe.Just (Symantic.Parser.Grammar.Combinators.FailureHorizon h :: Symantic.Parser.Grammar.Combinators.Failure (Symantic.Parser.Grammar.Combinators.CombSatisfiable (Symantic.Parser.Machine.Input.InputToken inp)))
+                                          | GHC.Maybe.Just old <- minH ->
+                                              ( GHC.Maybe.Just (GHC.Classes.min old h),
+                                                acc
+                                              )
+                                          | GHC.Base.otherwise ->
+                                              ( GHC.Maybe.Just h,
+                                                acc
+                                              )
+                                        _ ->
+                                          ( minH,
+                                            f GHC.Types.: acc
+                                          )
+                                  )
+                                  ( GHC.Maybe.Nothing,
+                                    GHC.Types . []
+                                  )
+                                  farExp
+                         in Data.Set.Internal.fromList GHC.Base.$
+                              ( case minHoriz of
+                                  GHC.Maybe.Just h -> Symantic.Parser.Grammar.Combinators.SomeFailure (Symantic.Parser.Grammar.Combinators.FailureHorizon @(Symantic.Parser.Machine.Input.InputToken inp) h) GHC.Types.: res
+                                  GHC.Maybe.Nothing -> res
                               )
-                              farExp
-                     in Data.Set.Internal.fromList GHC.Base.$
-                          ( case minHoriz of
-                              GHC.Maybe.Just h -> Symantic.Parser.Grammar.Combinators.SomeFailure (Symantic.Parser.Grammar.Combinators.FailureHorizon @(Symantic.Parser.Machine.Input.InputToken inp) h) GHC.Types.: res
-                              GHC.Maybe.Nothing -> res
-                          )
-                }
-   in GHC.ST.runST
-        ( let inputToken = Data.Proxy.Proxy :: Data.Proxy.Proxy (Symantic.Parser.Machine.Input.InputToken inp)
-           in let inp = init
-               in let readFail = finalRaise
-                   in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=2"
-                       in if readMore (Symantic.Parser.Machine.Input.shiftRightText 1 inp)
-                            then
-                              let
-                               in let _ = "pushValue"
-                                   in let join = \farInp farExp v (!inp) ->
-                                            let _ = "lift2Value checkedHorizon=0"
-                                             in let _ = "comment: satisfy ((GHC.Classes.==) 'd')"
-                                                 in let inp = inp
-                                                     in let readFail = finalRaise
+                    }
+          )
+   in let inputToken = Data.Proxy.Proxy :: Data.Proxy.Proxy (Symantic.Parser.Machine.Input.InputToken inp)
+       in let partialCont buf =
+                let readFail = Symantic.Parser.Machine.Generate.unForallOnException finalRaise
+                 in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=2"
+                     in if readMore buf ((GHC.Num.+) @GHC.Types.Int 1 initPos)
+                          then
+                            let
+                             in let _ = "pushValue"
+                                 in let join = \farInp farExp v (!inp) buf end ->
+                                          let _ = "lift2Value checkedHorizon=0"
+                                           in let _ = "comment: satisfy ((GHC.Classes.==) 'd')"
+                                               in let partialCont buf =
+                                                        let readFail = Symantic.Parser.Machine.Generate.unForallOnException finalRaise
                                                          in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=1"
-                                                             in if readMore inp
+                                                             in if readMore buf inp
                                                                   then
                                                                     let _ = "checkToken"
                                                                      in let !(#
                                                                                c,
                                                                                cs
-                                                                               #) = readNext inp
+                                                                               #) = readNext buf inp
                                                                          in if (GHC.Classes.==) 'd' c
                                                                               then
                                                                                 let _ = "lift2Value checkedHorizon=1"
                                                                                              in GHC.Show.show v
                                                                                           )
                                                                                           cs
+                                                                                          buf
+                                                                                          end
                                                                               else
                                                                                 let _ = "checkToken.fail"
                                                                                  in let failExp =
                                                                                      in let (#
                                                                                               farInp,
                                                                                               farExp
-                                                                                              #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
+                                                                                              #) = case GHC.Classes.compare @GHC.Types.Int farInp inp of
                                                                                                 GHC.Types.LT ->
                                                                                                   (#
                                                                                                     inp,
                                                                                                     farInp,
                                                                                                     farExp
                                                                                                   #)
-                                                                                         in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
+                                                                                         in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp buf end
                                                                   else
                                                                     let _ = "checkHorizon.newCheck.fail"
-                                                                     in let failExp =
-                                                                              Data.Set.Internal.Bin
-                                                                                1
-                                                                                ( Symantic.Parser.Grammar.Combinators.SomeFailure
-                                                                                    ( case inputToken of
-                                                                                        (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 1
-                                                                                    )
-                                                                                )
-                                                                                Data.Set.Internal.Tip
-                                                                                Data.Set.Internal.Tip
-                                                                         in let (#
-                                                                                  farInp,
-                                                                                  farExp
-                                                                                  #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
-                                                                                    GHC.Types.LT ->
-                                                                                      (#
-                                                                                        inp,
-                                                                                        failExp
-                                                                                      #)
-                                                                                    GHC.Types.EQ ->
-                                                                                      (#
-                                                                                        farInp,
-                                                                                        failExp GHC.Base.<> farExp
-                                                                                      #)
-                                                                                    GHC.Types.GT ->
-                                                                                      (#
+                                                                     in let noMoreInput =
+                                                                              let failExp =
+                                                                                    Data.Set.Internal.Bin
+                                                                                      1
+                                                                                      ( Symantic.Parser.Grammar.Combinators.SomeFailure
+                                                                                          ( case inputToken of
+                                                                                              (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 1
+                                                                                          )
+                                                                                      )
+                                                                                      Data.Set.Internal.Tip
+                                                                                      Data.Set.Internal.Tip
+                                                                               in let (#
                                                                                         farInp,
                                                                                         farExp
-                                                                                      #)
-                                                                             in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
-                                       in let _ = "catch ExceptionFailure checkedHorizon=2"
-                                           in let onException =
-                                                    let _ = "onException"
-                                                     in \(!_exn) (!failInp) (!farInp) (!farExp) ->
-                                                          let _ = "comment: raiseAgainIfConsumed"
-                                                           in let _ = "saveInput checkedHorizon=0"
-                                                               in let _ = "lift2Value checkedHorizon=0"
-                                                                   in if ( \( Data.Text.Internal.Text
-                                                                                _
-                                                                                i
-                                                                                _
-                                                                              )
-                                                                            ( Data.Text.Internal.Text
-                                                                                _
-                                                                                j
-                                                                                _
-                                                                              ) -> i GHC.Classes.== j
-                                                                         )
-                                                                        inp
-                                                                        failInp
-                                                                        then
-                                                                          let _ = "choicesBranch checkedHorizon=0"
-                                                                           in let _ = "catch ExceptionFailure checkedHorizon=0"
-                                                                               in let onException =
-                                                                                        let _ = "onException"
-                                                                                         in \(!_exn) (!failInp) (!farInp) (!farExp) ->
-                                                                                              let _ = "comment: raiseAgainIfConsumed"
-                                                                                               in let _ = "saveInput checkedHorizon=0"
-                                                                                                   in let _ = "lift2Value checkedHorizon=0"
-                                                                                                       in if ( \( Data.Text.Internal.Text
-                                                                                                                    _
-                                                                                                                    i
-                                                                                                                    _
-                                                                                                                  )
-                                                                                                                ( Data.Text.Internal.Text
-                                                                                                                    _
-                                                                                                                    j
-                                                                                                                    _
-                                                                                                                  ) -> i GHC.Classes.== j
-                                                                                                             )
-                                                                                                            failInp
-                                                                                                            failInp
-                                                                                                            then
-                                                                                                              let _ = "choicesBranch checkedHorizon=0"
-                                                                                                               in let _ = "pushValue"
-                                                                                                                   in let _ = "comment: satisfy ((GHC.Classes.==) 'c')"
-                                                                                                                       in let inp = failInp
-                                                                                                                           in let readFail = finalRaise
+                                                                                        #) = case GHC.Classes.compare @GHC.Types.Int farInp inp of
+                                                                                          GHC.Types.LT ->
+                                                                                            (#
+                                                                                              inp,
+                                                                                              failExp
+                                                                                            #)
+                                                                                          GHC.Types.EQ ->
+                                                                                            (#
+                                                                                              farInp,
+                                                                                              failExp GHC.Base.<> farExp
+                                                                                            #)
+                                                                                          GHC.Types.GT ->
+                                                                                            (#
+                                                                                              farInp,
+                                                                                              farExp
+                                                                                            #)
+                                                                                   in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp buf GHC.Types.True
+                                                                         in if end
+                                                                              then noMoreInput
+                                                                              else
+                                                                                Symantic.Parser.Machine.Generate.returnST GHC.Base.$
+                                                                                  ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
+                                                                                      ( \newInput ->
+                                                                                          if Symantic.Parser.Machine.Input.nullInput newInput
+                                                                                            then noMoreInput
+                                                                                            else partialCont (append buf newInput)
+                                                                                      )
+                                                                                  )
+                                                   in partialCont buf
+                                     in let _ = "catch ExceptionFailure checkedHorizon=2"
+                                         in let onException =
+                                                  let _ = "onException"
+                                                   in \(!_exn) (!failInp) (!farInp) (!farExp) buf end ->
+                                                        let _ = "comment: raiseAgainIfConsumed"
+                                                         in let _ = "saveInput checkedHorizon=0"
+                                                             in let _ = "lift2Value checkedHorizon=0"
+                                                                 in if (GHC.Classes.==) @GHC.Types.Int initPos failInp
+                                                                      then
+                                                                        let _ = "choicesBranch checkedHorizon=0"
+                                                                         in let _ = "catch ExceptionFailure checkedHorizon=0"
+                                                                             in let onException =
+                                                                                      let _ = "onException"
+                                                                                       in \(!_exn) (!failInp) (!farInp) (!farExp) buf end ->
+                                                                                            let _ = "comment: raiseAgainIfConsumed"
+                                                                                             in let _ = "saveInput checkedHorizon=0"
+                                                                                                 in let _ = "lift2Value checkedHorizon=0"
+                                                                                                     in if (GHC.Classes.==) @GHC.Types.Int failInp failInp
+                                                                                                          then
+                                                                                                            let _ = "choicesBranch checkedHorizon=0"
+                                                                                                             in let _ = "pushValue"
+                                                                                                                 in let _ = "comment: satisfy ((GHC.Classes.==) 'c')"
+                                                                                                                     in let partialCont buf =
+                                                                                                                              let readFail = Symantic.Parser.Machine.Generate.unForallOnException finalRaise
                                                                                                                                in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=2"
-                                                                                                                                   in if readMore (Symantic.Parser.Machine.Input.shiftRightText 1 inp)
+                                                                                                                                   in if readMore buf ((GHC.Num.+) @GHC.Types.Int 1 failInp)
                                                                                                                                         then
                                                                                                                                           let _ = "checkToken"
                                                                                                                                            in let !(#
                                                                                                                                                      c,
                                                                                                                                                      cs
-                                                                                                                                                     #) = readNext inp
+                                                                                                                                                     #) = readNext buf failInp
                                                                                                                                                in if (GHC.Classes.==) 'c' c
                                                                                                                                                     then
                                                                                                                                                       let _ = "lift2Value checkedHorizon=2"
                                                                                                                                                                    in 'c'
                                                                                                                                                                 )
                                                                                                                                                                 cs
+                                                                                                                                                                buf
+                                                                                                                                                                end
                                                                                                                                                     else
                                                                                                                                                       let _ = "checkToken.fail"
                                                                                                                                                        in let failExp =
                                                                                                                                                            in let (#
                                                                                                                                                                     farInp,
                                                                                                                                                                     farExp
-                                                                                                                                                                    #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
+                                                                                                                                                                    #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
                                                                                                                                                                       GHC.Types.LT ->
                                                                                                                                                                         (#
-                                                                                                                                                                          inp,
+                                                                                                                                                                          failInp,
                                                                                                                                                                           failExp
                                                                                                                                                                         #)
                                                                                                                                                                       GHC.Types.EQ ->
                                                                                                                                                                           farInp,
                                                                                                                                                                           farExp
                                                                                                                                                                         #)
-                                                                                                                                                               in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
+                                                                                                                                                               in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
                                                                                                                                         else
                                                                                                                                           let _ = "checkHorizon.newCheck.fail"
-                                                                                                                                           in let failExp =
-                                                                                                                                                    Data.Set.Internal.Bin
-                                                                                                                                                      1
-                                                                                                                                                      ( Symantic.Parser.Grammar.Combinators.SomeFailure
-                                                                                                                                                          ( case inputToken of
-                                                                                                                                                              (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
-                                                                                                                                                          )
-                                                                                                                                                      )
-                                                                                                                                                      Data.Set.Internal.Tip
-                                                                                                                                                      Data.Set.Internal.Tip
-                                                                                                                                               in let (#
-                                                                                                                                                        farInp,
-                                                                                                                                                        farExp
-                                                                                                                                                        #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
-                                                                                                                                                          GHC.Types.LT ->
-                                                                                                                                                            (#
-                                                                                                                                                              inp,
-                                                                                                                                                              failExp
-                                                                                                                                                            #)
-                                                                                                                                                          GHC.Types.EQ ->
-                                                                                                                                                            (#
-                                                                                                                                                              farInp,
-                                                                                                                                                              failExp GHC.Base.<> farExp
-                                                                                                                                                            #)
-                                                                                                                                                          GHC.Types.GT ->
-                                                                                                                                                            (#
+                                                                                                                                           in let noMoreInput =
+                                                                                                                                                    let failExp =
+                                                                                                                                                          Data.Set.Internal.Bin
+                                                                                                                                                            1
+                                                                                                                                                            ( Symantic.Parser.Grammar.Combinators.SomeFailure
+                                                                                                                                                                ( case inputToken of
+                                                                                                                                                                    (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
+                                                                                                                                                                )
+                                                                                                                                                            )
+                                                                                                                                                            Data.Set.Internal.Tip
+                                                                                                                                                            Data.Set.Internal.Tip
+                                                                                                                                                     in let (#
                                                                                                                                                               farInp,
                                                                                                                                                               farExp
-                                                                                                                                                            #)
-                                                                                                                                                   in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
-                                                                                                            else
-                                                                                                              let _ = "choicesBranch.else"
-                                                                                                               in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp
-                                                                                   in let _ = "pushValue"
-                                                                                       in let _ = "comment: satisfy ((GHC.Classes.==) 'b')"
-                                                                                           in let inp = failInp
-                                                                                               in let readFail = onException
+                                                                                                                                                              #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
+                                                                                                                                                                GHC.Types.LT ->
+                                                                                                                                                                  (#
+                                                                                                                                                                    failInp,
+                                                                                                                                                                    failExp
+                                                                                                                                                                  #)
+                                                                                                                                                                GHC.Types.EQ ->
+                                                                                                                                                                  (#
+                                                                                                                                                                    farInp,
+                                                                                                                                                                    failExp GHC.Base.<> farExp
+                                                                                                                                                                  #)
+                                                                                                                                                                GHC.Types.GT ->
+                                                                                                                                                                  (#
+                                                                                                                                                                    farInp,
+                                                                                                                                                                    farExp
+                                                                                                                                                                  #)
+                                                                                                                                                         in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf GHC.Types.True
+                                                                                                                                               in if end
+                                                                                                                                                    then noMoreInput
+                                                                                                                                                    else
+                                                                                                                                                      Symantic.Parser.Machine.Generate.returnST GHC.Base.$
+                                                                                                                                                        ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
+                                                                                                                                                            ( \newInput ->
+                                                                                                                                                                if Symantic.Parser.Machine.Input.nullInput newInput
+                                                                                                                                                                  then noMoreInput
+                                                                                                                                                                  else partialCont (append buf newInput)
+                                                                                                                                                            )
+                                                                                                                                                        )
+                                                                                                                         in partialCont buf
+                                                                                                          else
+                                                                                                            let _ = "choicesBranch.else"
+                                                                                                             in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
+                                                                                 in let _ = "pushValue"
+                                                                                     in let _ = "comment: satisfy ((GHC.Classes.==) 'b')"
+                                                                                         in let partialCont buf =
+                                                                                                  let readFail = onException
                                                                                                    in let _ = "checkHorizon.newCheck: checkedHorizon=0 minHoriz=2"
-                                                                                                       in if readMore (Symantic.Parser.Machine.Input.shiftRightText 1 inp)
+                                                                                                       in if readMore buf ((GHC.Num.+) @GHC.Types.Int 1 failInp)
                                                                                                             then
                                                                                                               let _ = "checkToken"
                                                                                                                in let !(#
                                                                                                                          c,
                                                                                                                          cs
-                                                                                                                         #) = readNext inp
+                                                                                                                         #) = readNext buf failInp
                                                                                                                    in if (GHC.Classes.==) 'b' c
                                                                                                                         then
                                                                                                                           let _ = "lift2Value checkedHorizon=2"
                                                                                                                                            in 'b'
                                                                                                                                         )
                                                                                                                                         cs
+                                                                                                                                        buf
+                                                                                                                                        end
                                                                                                                         else
                                                                                                                           let _ = "checkToken.fail"
                                                                                                                            in let failExp =
                                                                                                                                in let (#
                                                                                                                                         farInp,
                                                                                                                                         farExp
-                                                                                                                                        #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
+                                                                                                                                        #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
                                                                                                                                           GHC.Types.LT ->
                                                                                                                                             (#
-                                                                                                                                              inp,
+                                                                                                                                              failInp,
                                                                                                                                               failExp
                                                                                                                                             #)
                                                                                                                                           GHC.Types.EQ ->
                                                                                                                                               farInp,
                                                                                                                                               farExp
                                                                                                                                             #)
-                                                                                                                                   in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
+                                                                                                                                   in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
                                                                                                             else
                                                                                                               let _ = "checkHorizon.newCheck.fail"
-                                                                                                               in let failExp =
-                                                                                                                        Data.Set.Internal.Bin
-                                                                                                                          1
-                                                                                                                          ( Symantic.Parser.Grammar.Combinators.SomeFailure
-                                                                                                                              ( case inputToken of
-                                                                                                                                  (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
-                                                                                                                              )
-                                                                                                                          )
-                                                                                                                          Data.Set.Internal.Tip
-                                                                                                                          Data.Set.Internal.Tip
-                                                                                                                   in let (#
-                                                                                                                            farInp,
-                                                                                                                            farExp
-                                                                                                                            #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) farInp inp of
-                                                                                                                              GHC.Types.LT ->
-                                                                                                                                (#
-                                                                                                                                  inp,
-                                                                                                                                  failExp
-                                                                                                                                #)
-                                                                                                                              GHC.Types.EQ ->
-                                                                                                                                (#
-                                                                                                                                  farInp,
-                                                                                                                                  failExp GHC.Base.<> farExp
-                                                                                                                                #)
-                                                                                                                              GHC.Types.GT ->
-                                                                                                                                (#
+                                                                                                               in let noMoreInput =
+                                                                                                                        let failExp =
+                                                                                                                              Data.Set.Internal.Bin
+                                                                                                                                1
+                                                                                                                                ( Symantic.Parser.Grammar.Combinators.SomeFailure
+                                                                                                                                    ( case inputToken of
+                                                                                                                                        (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
+                                                                                                                                    )
+                                                                                                                                )
+                                                                                                                                Data.Set.Internal.Tip
+                                                                                                                                Data.Set.Internal.Tip
+                                                                                                                         in let (#
                                                                                                                                   farInp,
                                                                                                                                   farExp
-                                                                                                                                #)
-                                                                                                                       in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
-                                                                        else
-                                                                          let _ = "choicesBranch.else"
-                                                                           in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp
-                                               in let _ = "pushValue"
-                                                   in let _ = "comment: satisfy ((GHC.Classes.==) 'a')"
-                                                       in let _ = "checkHorizon.oldCheck: checkedHorizon=2"
-                                                           in let _ = "checkToken"
-                                                               in let !(#
-                                                                         c,
-                                                                         cs
-                                                                         #) = readNext inp
-                                                                   in if (GHC.Classes.==) 'a' c
-                                                                        then
-                                                                          let _ = "lift2Value checkedHorizon=1"
-                                                                           in let _ = "commit"
-                                                                               in let _ = "resume"
-                                                                                   in join
-                                                                                        init
-                                                                                        Data.Set.Internal.empty
-                                                                                        ( let _ = "resume.genCode"
-                                                                                           in 'a'
-                                                                                        )
-                                                                                        cs
-                                                                        else
-                                                                          let _ = "checkToken.fail"
-                                                                           in let failExp =
-                                                                                    Data.Set.Internal.Bin
-                                                                                      1
-                                                                                      ( Symantic.Parser.Grammar.Combinators.SomeFailure
-                                                                                          ( case inputToken of
-                                                                                              (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'a'
-                                                                                          )
+                                                                                                                                  #) = case GHC.Classes.compare @GHC.Types.Int farInp failInp of
+                                                                                                                                    GHC.Types.LT ->
+                                                                                                                                      (#
+                                                                                                                                        failInp,
+                                                                                                                                        failExp
+                                                                                                                                      #)
+                                                                                                                                    GHC.Types.EQ ->
+                                                                                                                                      (#
+                                                                                                                                        farInp,
+                                                                                                                                        failExp GHC.Base.<> farExp
+                                                                                                                                      #)
+                                                                                                                                    GHC.Types.GT ->
+                                                                                                                                      (#
+                                                                                                                                        farInp,
+                                                                                                                                        farExp
+                                                                                                                                      #)
+                                                                                                                             in readFail Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf GHC.Types.True
+                                                                                                                   in if end
+                                                                                                                        then noMoreInput
+                                                                                                                        else
+                                                                                                                          Symantic.Parser.Machine.Generate.returnST GHC.Base.$
+                                                                                                                            ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
+                                                                                                                                ( \newInput ->
+                                                                                                                                    if Symantic.Parser.Machine.Input.nullInput newInput
+                                                                                                                                      then noMoreInput
+                                                                                                                                      else partialCont (append buf newInput)
+                                                                                                                                )
+                                                                                                                            )
+                                                                                             in partialCont buf
+                                                                      else
+                                                                        let _ = "choicesBranch.else"
+                                                                         in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure failInp farInp farExp buf end
+                                             in let _ = "pushValue"
+                                                 in let _ = "comment: satisfy ((GHC.Classes.==) 'a')"
+                                                     in let _ = "checkHorizon.oldCheck: checkedHorizon=2"
+                                                         in let _ = "checkToken"
+                                                             in let !(#
+                                                                       c,
+                                                                       cs
+                                                                       #) = readNext buf initPos
+                                                                 in if (GHC.Classes.==) 'a' c
+                                                                      then
+                                                                        let _ = "lift2Value checkedHorizon=1"
+                                                                         in let _ = "commit"
+                                                                             in let _ = "resume"
+                                                                                 in join
+                                                                                      initPos
+                                                                                      Data.Set.Internal.empty
+                                                                                      ( let _ = "resume.genCode"
+                                                                                         in 'a'
                                                                                       )
-                                                                                      Data.Set.Internal.Tip
-                                                                                      Data.Set.Internal.Tip
-                                                                               in let (#
-                                                                                        farInp,
-                                                                                        farExp
-                                                                                        #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) init inp of
-                                                                                          GHC.Types.LT ->
-                                                                                            (#
-                                                                                              inp,
-                                                                                              failExp
-                                                                                            #)
-                                                                                          GHC.Types.EQ ->
-                                                                                            (#
-                                                                                              init,
-                                                                                              failExp GHC.Base.<> Data.Set.Internal.empty
-                                                                                            #)
-                                                                                          GHC.Types.GT ->
-                                                                                            (#
-                                                                                              init,
-                                                                                              Data.Set.Internal.empty
-                                                                                            #)
-                                                                                   in onException Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
-                            else
-                              let _ = "checkHorizon.newCheck.fail"
-                               in let failExp =
-                                        Data.Set.Internal.Bin
-                                          1
-                                          ( Symantic.Parser.Grammar.Combinators.SomeFailure
-                                              ( case inputToken of
-                                                  (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
+                                                                                      cs
+                                                                                      buf
+                                                                                      GHC.Types.False
+                                                                      else
+                                                                        let _ = "checkToken.fail"
+                                                                         in let failExp =
+                                                                                  Data.Set.Internal.Bin
+                                                                                    1
+                                                                                    ( Symantic.Parser.Grammar.Combinators.SomeFailure
+                                                                                        ( case inputToken of
+                                                                                            (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureToken 'a'
+                                                                                        )
+                                                                                    )
+                                                                                    Data.Set.Internal.Tip
+                                                                                    Data.Set.Internal.Tip
+                                                                             in let (#
+                                                                                      farInp,
+                                                                                      farExp
+                                                                                      #) = case GHC.Classes.compare @GHC.Types.Int initPos initPos of
+                                                                                        GHC.Types.LT ->
+                                                                                          (#
+                                                                                            initPos,
+                                                                                            failExp
+                                                                                          #)
+                                                                                        GHC.Types.EQ ->
+                                                                                          (#
+                                                                                            initPos,
+                                                                                            failExp GHC.Base.<> Data.Set.Internal.empty
+                                                                                          #)
+                                                                                        GHC.Types.GT ->
+                                                                                          (#
+                                                                                            initPos,
+                                                                                            Data.Set.Internal.empty
+                                                                                          #)
+                                                                                 in onException Symantic.Parser.Grammar.Combinators.ExceptionFailure initPos farInp farExp buf GHC.Types.False
+                          else
+                            let _ = "checkHorizon.newCheck.fail"
+                             in let noMoreInput =
+                                      let failExp =
+                                            Data.Set.Internal.Bin
+                                              1
+                                              ( Symantic.Parser.Grammar.Combinators.SomeFailure
+                                                  ( case inputToken of
+                                                      (Data.Proxy.Proxy :: Data.Proxy.Proxy tok') -> Symantic.Parser.Grammar.Combinators.FailureHorizon @tok' 2
+                                                  )
+                                              )
+                                              Data.Set.Internal.Tip
+                                              Data.Set.Internal.Tip
+                                       in let (#
+                                                farInp,
+                                                farExp
+                                                #) = case GHC.Classes.compare @GHC.Types.Int initPos initPos of
+                                                  GHC.Types.LT ->
+                                                    (#
+                                                      initPos,
+                                                      failExp
+                                                    #)
+                                                  GHC.Types.EQ ->
+                                                    (#
+                                                      initPos,
+                                                      failExp GHC.Base.<> Data.Set.Internal.empty
+                                                    #)
+                                                  GHC.Types.GT ->
+                                                    (#
+                                                      initPos,
+                                                      Data.Set.Internal.empty
+                                                    #)
+                                           in Symantic.Parser.Machine.Generate.unForallOnException finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure initPos farInp farExp buf GHC.Types.True
+                                 in if GHC.Types.False
+                                      then noMoreInput
+                                      else
+                                        Symantic.Parser.Machine.Generate.returnST GHC.Base.$
+                                          ( Symantic.Parser.Machine.Generate.ResultPartial GHC.Base.$
+                                              ( \newInput ->
+                                                  if Symantic.Parser.Machine.Input.nullInput newInput
+                                                    then noMoreInput
+                                                    else partialCont (append buf newInput)
                                               )
                                           )
-                                          Data.Set.Internal.Tip
-                                          Data.Set.Internal.Tip
-                                   in let (#
-                                            farInp,
-                                            farExp
-                                            #) = case (GHC.Classes.compare `Data.Function.on` Symantic.Parser.Machine.Input.offset) init inp of
-                                              GHC.Types.LT ->
-                                                (#
-                                                  inp,
-                                                  failExp
-                                                #)
-                                              GHC.Types.EQ ->
-                                                (#
-                                                  init,
-                                                  failExp GHC.Base.<> Data.Set.Internal.empty
-                                                #)
-                                              GHC.Types.GT ->
-                                                (#
-                                                  init,
-                                                  Data.Set.Internal.empty
-                                                #)
-                                       in finalRaise Symantic.Parser.Grammar.Combinators.ExceptionFailure inp farInp farExp
-        )
+           in partialCont initBuffer