getLexerReprs :: [BpRepr] -> IO (Seq LpRepr)
getLexerReprs tokens = extract <$> (runParse tokens >>= withSuccess) where

  -- drops the trailing new line for each result
  extract = fmap (\(Lp repr _) -> repr)
          . (\items -> Seq.take ((Seq.length items) - 2) items)

  withSuccess :: FileDebug -> IO (Seq LexerPass)
  withSuccess (FileDebug { output = PDebugLexer p, error = Nothing }) = pure p
  withSuccess (FileDebug {                         error = Just er }) = failMessage (ppShow er)
  withSuccess (FileDebug { output = _____________, error = Nothing }) =
    failMessage "unexpected pass debug target"

  failMessage m = assertFailure m >> undefined

  runParse :: [BpRepr] -> IO FileDebug
  runParse ts = runFileBuildM config (runConduitRes conduit) where
    conduit = source .| runLexerPass .| consumeLexerPass
    config = FileBC "test"
    source = sourceList (fmap (\x -> Right (Bp x Position.init)) (ts <> [BpEnd]))
getLexerReprs :: [BpRepr] -> IO (Seq LpRepr)
getLexerReprs tokens = extract <$> (runParse tokens >>= withSuccess) where

  -- drops the trailing new line for each result
  extract = fmap (\(Lp repr _) -> repr)
          . (\items -> Seq.take ((Seq.length items) - 2) items)

  withSuccess :: FileDebug -> IO (Seq LexerPass)
  withSuccess (FileDebug { output = PDebugLexer p, error = Nothing }) = pure p
  withSuccess (FileDebug {                         error = Just er }) = failMessage (ppShow er)
  withSuccess (FileDebug { output = _____________, error = Nothing }) =
    failMessage "unexpected pass debug target"

  failMessage m = assertFailure m >> undefined

  runParse :: [BpRepr] -> IO FileDebug
  runParse ts = runFileBuildM config (runConduitRes conduit) where
    conduit = source .| runLexerPass .| consumeLexerPass
    config = FileBC "test"
    source = sourceList (fmap (\x -> Right (Bp x Position.init)) (ts <> [BpEnd]))
getLexerReprs tokens = extract <$> (runParse tokens >>= withSuccess) where

  -- drops the trailing new line for each result
  extract = fmap (\(Lp repr _) -> repr)
          . (\items -> Seq.take ((Seq.length items) - 2) items)

  withSuccess :: FileDebug -> IO (Seq LexerPass)
  withSuccess (FileDebug { output = PDebugLexer p, error = Nothing }) = pure p
  withSuccess (FileDebug {                         error = Just er }) = failMessage (ppShow er)
  withSuccess (FileDebug { output = _____________, error = Nothing }) =
    failMessage "unexpected pass debug target"

  failMessage m = assertFailure m >> undefined

  runParse :: [BpRepr] -> IO FileDebug
  runParse ts = runFileBuildM config (runConduitRes conduit) where
    conduit = source .| runLexerPass .| consumeLexerPass
    config = FileBC "test"
    source = sourceList (fmap (\x -> Right (Bp x Position.init)) (ts <> [BpEnd]))