    {-# LANGUAGE OverloadedStrings #-}
    {-# OPTIONS_HADDOCK show-extensions #-}

    -- |
    -- Module      :  Yi.Mode.Latex
    -- License     :  GPL-2
    -- Maintainer  :  yi-devel@googlegroups.com
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Collection of 'Mode's for working with LaTeX.

    module Yi.Mode.Latex (latexMode3, latexMode2, fastMode) where

    import           Data.Text            ()
    import           Yi.Buffer
    import qualified Yi.IncrementalParse  as IncrParser (scanner)
    import           Yi.Lexer.Alex        (AlexState, CharScanner, Tok, commonLexer, lexScanner)
    import qualified Yi.Lexer.Latex       as Latex (HlState, Token, alexScanToken, initState)
    import           Yi.Mode.Common       (anyExtension, fundamentalMode)
    import           Yi.Syntax            (ExtHL (ExtHL), Scanner, mkHighlighter)
    import qualified Yi.Syntax.Driver     as Driver (mkHighlighter)
    import qualified Yi.Syntax.Latex      as Latex (TT, Tree, getStrokes, parse, tokenToStroke)
    import           Yi.Syntax.OnlineTree (Tree, manyToks)
    import           Yi.Syntax.Tree       (tokenBasedStrokes)

    abstract :: Mode syntax
    abstract :: forall syntax. Mode syntax
    abstract = Mode syntax
    forall syntax. Mode syntax
    fundamentalMode
     {
       modeApplies = anyExtension ["tex", "sty", "ltx"],
       modeToggleCommentSelection = Just (toggleCommentB "%")
     }

    fastMode :: Mode (Tree Latex.TT)
    fastMode :: Mode (Tree (Tok Token))
    fastMode = Mode (Tree (Tok Token))
    forall syntax. Mode syntax
    abstract
      {
        modeName = "fast latex",
        modeHL = ExtHL $ mkHighlighter (IncrParser.scanner manyToks . latexLexer),
        modeGetStrokes = tokenBasedStrokes Latex.tokenToStroke
      }

    -- | syntax-based latex mode
    latexMode2 :: Mode (Latex.Tree Latex.TT)
    latexMode2 :: Mode (Tree (Tok Token))
    latexMode2 = Mode (Tree (Tok Token))
    forall syntax. Mode syntax
    abstract
      {
        modeName = "latex",
        modeHL = ExtHL $
           mkHighlighter (IncrParser.scanner Latex.parse . latexLexer),
        modeGetStrokes = \Tree (Tok Token)
    t Point
    point Point
    begin Point
    end -> Point -> Point -> Point -> Tree (Tok Token) -> [Stroke]
    Latex.getStrokes Point
    point Point
    begin Point
    end Tree (Tok Token)
    t
      }

    -- | syntax-based latex mode
    latexMode3 :: Mode (Latex.Tree Latex.TT)
    latexMode3 :: Mode (Tree (Tok Token))
    latexMode3 = Mode (Tree (Tok Token))
    forall syntax. Mode syntax
    abstract
      {
        modeName = "latex",
        modeHL = ExtHL $
           Driver.mkHighlighter (IncrParser.scanner Latex.parse . latexLexer),
        modeGetStrokes = \Tree (Tok Token)
    t Point
    point Point
    begin Point
    end -> Point -> Point -> Point -> Tree (Tok Token) -> [Stroke]
    Latex.getStrokes Point
    point Point
    begin Point
    end Tree (Tok Token)
    t
      }

    latexLexer :: CharScanner -> Scanner (AlexState Latex.HlState) (Tok Latex.Token)
    latexLexer :: Scanner Point Char -> Scanner (AlexState HlState) (Tok Token)
    latexLexer = Lexer AlexState HlState (Tok Token) AlexInput
    -> Scanner Point Char -> Scanner (AlexState HlState) (Tok Token)
    forall (l :: * -> *) s t i.
    Lexer l s t i -> Scanner Point Char -> Scanner (l s) t
    lexScanner ((ASI HlState -> Maybe (Tok Token, ASI HlState))
    -> HlState -> Lexer AlexState HlState (Tok Token) AlexInput
    forall s t.
    (ASI s -> Maybe (Tok t, ASI s))
    -> s -> Lexer AlexState s (Tok t) AlexInput
    commonLexer ASI HlState -> Maybe (Tok Token, ASI HlState)
    Latex.alexScanToken HlState
    Latex.initState)