    {-# LANGUAGE CPP #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE LambdaCase #-}
    {-# LANGUAGE TemplateHaskell #-}

    module Text.Heterocephalus.Parse.Control where

    #if MIN_VERSION_base(4,9,0)
    #else
    import Control.Applicative ((<$>), (*>), (<*), pure)
    #endif
    import Control.Monad (guard, void)
    import Control.Monad.Reader (Reader, runReaderT)
    import Data.Char (isUpper)
    import Data.Data (Data)
    import Data.Functor (($>))
    import Data.Functor.Identity (runIdentity)
    import Data.Typeable (Typeable)
    import Text.Parsec
           (Parsec, ParsecT, (<?>), (<|>), alphaNum, between, char, choice,
            eof, many, many1, manyTill, mkPT, noneOf, oneOf, option, optional,
            runParsecT, runParserT, sepBy, skipMany, spaces, string,
            try)
    import Text.Shakespeare.Base
           (Ident(Ident), Deref, parseDeref, parseVar)

    import Text.Hamlet.Parse
    import Text.Heterocephalus.Parse.Option
           (ParseOptions, getControlPrefix, getVariablePrefix)

    data Control
      = ControlForall Deref Binding
      | ControlEndForall
      | ControlIf Deref
      | ControlElse
      | ControlElseIf Deref
      | ControlEndIf
      | ControlCase Deref
      | ControlCaseOf Binding
      | ControlEndCase
      | NoControl Content
      deriving (Typeable Control
    Typeable Control =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Control -> c Control)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Control)
    -> (Control -> Constr)
    -> (Control -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Control))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Control))
    -> ((forall b. Data b => b -> b) -> Control -> Control)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Control -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Control -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Control -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Control -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Control -> m Control)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Control -> m Control)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Control -> m Control)
    -> Data Control
    Control -> Constr
    Control -> DataType
    (forall b. Data b => b -> b) -> Control -> Control
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Control -> u
    forall u. (forall d. Data d => d -> u) -> Control -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Control
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Control -> c Control
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Control)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Control)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Control -> c Control
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Control -> c Control
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Control
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Control
    $ctoConstr :: Control -> Constr
    toConstr :: Control -> Constr
    $cdataTypeOf :: Control -> DataType
    dataTypeOf :: Control -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Control)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Control)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Control)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Control)
    $cgmapT :: (forall b. Data b => b -> b) -> Control -> Control
    gmapT :: (forall b. Data b => b -> b) -> Control -> Control
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Control -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Control -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Control -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Control -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Control -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Control -> m Control
    Data, Control -> Control -> Bool
    (Control -> Control -> Bool)
    -> (Control -> Control -> Bool) -> Eq Control
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Control -> Control -> Bool
    == :: Control -> Control -> Bool
    $c/= :: Control -> Control -> Bool
    /= :: Control -> Control -> Bool
    Eq, ReadPrec [Control]
    ReadPrec Control
    Int -> ReadS Control
    ReadS [Control]
    (Int -> ReadS Control)
    -> ReadS [Control]
    -> ReadPrec Control
    -> ReadPrec [Control]
    -> Read Control
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Control
    readsPrec :: Int -> ReadS Control
    $creadList :: ReadS [Control]
    readList :: ReadS [Control]
    $creadPrec :: ReadPrec Control
    readPrec :: ReadPrec Control
    $creadListPrec :: ReadPrec [Control]
    readListPrec :: ReadPrec [Control]
    Read, Int -> Control -> ShowS
    [Control] -> ShowS
    Control -> String
    (Int -> Control -> ShowS)
    -> (Control -> String) -> ([Control] -> ShowS) -> Show Control
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Control -> ShowS
    showsPrec :: Int -> Control -> ShowS
    $cshow :: Control -> String
    show :: Control -> String
    $cshowList :: [Control] -> ShowS
    showList :: [Control] -> ShowS
    Show, Typeable)

    data Content = ContentRaw String
                 | ContentVar Deref
        deriving (Typeable Content
    Typeable Content =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Content -> c Content)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Content)
    -> (Content -> Constr)
    -> (Content -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Content))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content))
    -> ((forall b. Data b => b -> b) -> Content -> Content)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Content -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Content -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Content -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Content -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Content -> m Content)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Content -> m Content)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Content -> m Content)
    -> Data Content
    Content -> Constr
    Content -> DataType
    (forall b. Data b => b -> b) -> Content -> Content
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
    forall u. (forall d. Data d => d -> u) -> Content -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Content
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Content -> c Content
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Content)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Content -> c Content
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Content -> c Content
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Content
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Content
    $ctoConstr :: Content -> Constr
    toConstr :: Content -> Constr
    $cdataTypeOf :: Content -> DataType
    dataTypeOf :: Content -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Content)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Content)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
    $cgmapT :: (forall b. Data b => b -> b) -> Content -> Content
    gmapT :: (forall b. Data b => b -> b) -> Content -> Content
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Content -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Content -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content
    Data, Content -> Content -> Bool
    (Content -> Content -> Bool)
    -> (Content -> Content -> Bool) -> Eq Content
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Content -> Content -> Bool
    == :: Content -> Content -> Bool
    $c/= :: Content -> Content -> Bool
    /= :: Content -> Content -> Bool
    Eq, ReadPrec [Content]
    ReadPrec Content
    Int -> ReadS Content
    ReadS [Content]
    (Int -> ReadS Content)
    -> ReadS [Content]
    -> ReadPrec Content
    -> ReadPrec [Content]
    -> Read Content
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Content
    readsPrec :: Int -> ReadS Content
    $creadList :: ReadS [Content]
    readList :: ReadS [Content]
    $creadPrec :: ReadPrec Content
    readPrec :: ReadPrec Content
    $creadListPrec :: ReadPrec [Content]
    readListPrec :: ReadPrec [Content]
    Read, Int -> Content -> ShowS
    [Content] -> ShowS
    Content -> String
    (Int -> Content -> ShowS)
    -> (Content -> String) -> ([Content] -> ShowS) -> Show Content
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Content -> ShowS
    showsPrec :: Int -> Content -> ShowS
    $cshow :: Content -> String
    show :: Content -> String
    $cshowList :: [Content] -> ShowS
    showList :: [Content] -> ShowS
    Show, Typeable)

    type UserParser = ParsecT String () (Reader ParseOptions)

    parseLineControl :: ParseOptions -> String -> Either String [Control]
    parseLineControl :: ParseOptions -> String -> Either String [Control]
    parseLineControl ParseOptions
    opts String
    s =
      let readerT :: Reader ParseOptions (Either ParseError [Control])
    readerT = ParsecT String () (Reader ParseOptions) [Control]
    -> ()
    -> String
    -> String
    -> Reader ParseOptions (Either ParseError [Control])
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> u -> String -> s -> m (Either ParseError a)
    runParserT ParsecT String () (Reader ParseOptions) [Control]
    lineControl () String
    "" String
    s
          res :: Either ParseError [Control]
    res = Identity (Either ParseError [Control])
    -> Either ParseError [Control]
    forall a. Identity a -> a
    runIdentity (Identity (Either ParseError [Control])
     -> Either ParseError [Control])
    -> Identity (Either ParseError [Control])
    -> Either ParseError [Control]
    forall a b. (a -> b) -> a -> b
    $ Reader ParseOptions (Either ParseError [Control])
    -> ParseOptions -> Identity (Either ParseError [Control])
    forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
    runReaderT Reader ParseOptions (Either ParseError [Control])
    readerT ParseOptions
    opts
      in case Either ParseError [Control]
    res of
           Left ParseError
    e -> String -> Either String [Control]
    forall a b. a -> Either a b
    Left (String -> Either String [Control])
    -> String -> Either String [Control]
    forall a b. (a -> b) -> a -> b
    $ ParseError -> String
    forall a. Show a => a -> String
    show ParseError
    e
           Right [Control]
    x -> [Control] -> Either String [Control]
    forall a b. b -> Either a b
    Right [Control]
    x

    lineControl :: UserParser [Control]
    lineControl :: ParsecT String () (Reader ParseOptions) [Control]
    lineControl = ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) [Control]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT String () (Reader ParseOptions) Control
    control (ParsecT String () (Reader ParseOptions) ()
     -> ParsecT String () (Reader ParseOptions) [Control])
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) [Control]
    forall a b. (a -> b) -> a -> b
    $ ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () -> ParsecT String () (Reader ParseOptions) ()
    forall a. a -> ParsecT String () (Reader ParseOptions) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    control :: UserParser Control
    control :: ParsecT String () (Reader ParseOptions) Control
    control = ParsecT String () (Reader ParseOptions) Control
    noControlVariable ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Control
    controlStatement ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Control
    noControlRaw
      where
        controlStatement :: UserParser Control
        controlStatement :: ParsecT String () (Reader ParseOptions) Control
    controlStatement = do
          x <- UserParser (Either String Control)
    parseControlStatement
          case x of
            Left String
    str -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall a. a -> ParsecT String () (Reader ParseOptions) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Content -> Control
    NoControl (Content -> Control) -> Content -> Control
    forall a b. (a -> b) -> a -> b
    $ String -> Content
    ContentRaw String
    str)
            Right Control
    ctrl -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall a. a -> ParsecT String () (Reader ParseOptions) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Control
    ctrl

        noControlVariable :: UserParser Control
        noControlVariable :: ParsecT String () (Reader ParseOptions) Control
    noControlVariable = do
          variablePrefix <- ParsecT String () (Reader ParseOptions) Char
    forall (m :: * -> *). MonadReader ParseOptions m => m Char
    getVariablePrefix
          x <- identityToReader $ parseVar variablePrefix
          return . NoControl $
            case x of
              Left String
    str -> String -> Content
    ContentRaw String
    str
              Right Deref
    deref -> Deref -> Content
    ContentVar Deref
    deref

        noControlRaw :: UserParser Control
        noControlRaw :: ParsecT String () (Reader ParseOptions) Control
    noControlRaw = do
          controlPrefix <- ParsecT String () (Reader ParseOptions) Char
    forall (m :: * -> *). MonadReader ParseOptions m => m Char
    getControlPrefix
          variablePrefix <- getVariablePrefix
          (NoControl . ContentRaw) <$>
            many (noneOf [controlPrefix, variablePrefix])

    parseControlStatement :: UserParser (Either String Control)
    parseControlStatement :: UserParser (Either String Control)
    parseControlStatement = do
      a <- UserParser (Either String Control)
    parseControl
      optional eol
      return a
     where
      eol :: UserParser ()
      eol :: ParsecT String () (Reader ParseOptions) ()
    eol = ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\n') ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "\r\n")

    parseControl :: UserParser (Either String Control)
    parseControl :: UserParser (Either String Control)
    parseControl = do
      controlPrefix <- ParsecT String () (Reader ParseOptions) Char
    forall (m :: * -> *). MonadReader ParseOptions m => m Char
    getControlPrefix
      void $ char controlPrefix
      let escape = Char -> ParsecT String u (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\\' ParsecT String u (Reader ParseOptions) Char
    -> Either String b
    -> ParsecT String u (Reader ParseOptions) (Either String b)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> String -> Either String b
    forall a b. a -> Either a b
    Left [Char
    controlPrefix]
      escape <|>
        (Right <$> parseControlBetweenBrackets) <|>
        return (Left [controlPrefix])

    parseControlBetweenBrackets :: UserParser Control
    parseControlBetweenBrackets :: ParsecT String () (Reader ParseOptions) Control
    parseControlBetweenBrackets =
      ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s (m :: * -> *) t u open close a.
    Stream s m t =>
    ParsecT s u m open
    -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
    between (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '{') (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '}') (ParsecT String () (Reader ParseOptions) Control
     -> ParsecT String () (Reader ParseOptions) Control)
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b. (a -> b) -> a -> b
    $ ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT String () (Reader ParseOptions) Control
    parseControl' ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces

    parseControl' :: UserParser Control
    parseControl' :: ParsecT String () (Reader ParseOptions) Control
    parseControl' =
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseForall ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseEndForall ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseIf ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseElseIf ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseElse ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseEndIf ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseCase ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseCaseOf ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) Control
    parseEndCase
      where
        parseForall :: UserParser Control
        parseForall :: ParsecT String () (Reader ParseOptions) Control
    parseForall = do
          String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "forall" ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces
          (x, y) <- UserParser (Deref, Binding)
    binding
          pure $ ControlForall x y

        parseEndForall :: UserParser Control
        parseEndForall :: ParsecT String () (Reader ParseOptions) Control
    parseEndForall = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "endforall" ParsecT String () (Reader ParseOptions) String
    -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Control
    ControlEndForall

        parseIf :: UserParser Control
        parseIf :: ParsecT String () (Reader ParseOptions) Control
    parseIf =
          String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "if" ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (Deref -> Control)
    -> ParsecT String () (Reader ParseOptions) Deref
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    (a -> b)
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Deref -> Control
    ControlIf (Parsec String () Deref
    -> ParsecT String () (Reader ParseOptions) Deref
    forall a. Parsec String () a -> UserParser a
    identityToReader Parsec String () Deref
    forall a. UserParser a Deref
    parseDeref)

        parseElseIf :: UserParser Control
        parseElseIf :: ParsecT String () (Reader ParseOptions) Control
    parseElseIf =
          String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "elseif" ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *>
          ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *>
          (Deref -> Control)
    -> ParsecT String () (Reader ParseOptions) Deref
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    (a -> b)
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Deref -> Control
    ControlElseIf (Parsec String () Deref
    -> ParsecT String () (Reader ParseOptions) Deref
    forall a. Parsec String () a -> UserParser a
    identityToReader Parsec String () Deref
    forall a. UserParser a Deref
    parseDeref)

        parseElse :: UserParser Control
        parseElse :: ParsecT String () (Reader ParseOptions) Control
    parseElse = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "else" ParsecT String () (Reader ParseOptions) String
    -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Control
    ControlElse

        parseEndIf :: UserParser Control
        parseEndIf :: ParsecT String () (Reader ParseOptions) Control
    parseEndIf = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "endif" ParsecT String () (Reader ParseOptions) String
    -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Control
    ControlEndIf

        parseCase :: UserParser Control
        parseCase :: ParsecT String () (Reader ParseOptions) Control
    parseCase =
          String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "case" ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *>
          ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *>
          (Deref -> Control)
    -> ParsecT String () (Reader ParseOptions) Deref
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    (a -> b)
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Deref -> Control
    ControlCase (Parsec String () Deref
    -> ParsecT String () (Reader ParseOptions) Deref
    forall a. Parsec String () a -> UserParser a
    identityToReader Parsec String () Deref
    forall a. UserParser a Deref
    parseDeref)

        parseCaseOf :: UserParser Control
        parseCaseOf :: ParsecT String () (Reader ParseOptions) Control
    parseCaseOf = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "of" ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT String () (Reader ParseOptions) ()
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
    spaces ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) Control
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (Binding -> Control)
    -> ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Control
    forall a b.
    (a -> b)
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Binding -> Control
    ControlCaseOf ParsecT String () (Reader ParseOptions) Binding
    identPattern

        parseEndCase :: UserParser Control
        parseEndCase :: ParsecT String () (Reader ParseOptions) Control
    parseEndCase = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    "endcase" ParsecT String () (Reader ParseOptions) String
    -> Control -> ParsecT String () (Reader ParseOptions) Control
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Control
    ControlEndCase

        binding :: UserParser (Deref, Binding)
        binding :: UserParser (Deref, Binding)
    binding = do
          y <- ParsecT String () (Reader ParseOptions) Binding
    identPattern
          spaces
          _ <- string "<-"
          spaces
          x <- identityToReader parseDeref
          _ <- spaceTabs
          return (x, y)

        spaceTabs :: UserParser String
        spaceTabs :: ParsecT String () (Reader ParseOptions) String
    spaceTabs = ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT String () (Reader ParseOptions) Char
     -> ParsecT String () (Reader ParseOptions) String)
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall a b. (a -> b) -> a -> b
    $ String -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    oneOf String
    " \t"

        -- | Parse an indentifier.  This is an sequence of alphanumeric characters,
        -- or an operator.
        ident :: UserParser Ident
        ident :: UserParser Ident
    ident = do
          i <- (ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '_' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '\'')) ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) String
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) String
    operator
          white
          return (Ident i) <?> "identifier"

        -- | Parse an operator.  An operator is a sequence of characters in
        -- 'operatorList' in between parenthesis.
        operator :: UserParser String
        operator :: ParsecT String () (Reader ParseOptions) String
    operator = do
          oper <- ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) t u open close a.
    Stream s m t =>
    ParsecT s u m open
    -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
    between (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '(') (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ')') (ParsecT String () (Reader ParseOptions) String
     -> ParsecT String () (Reader ParseOptions) String)
    -> (ParsecT String () (Reader ParseOptions) Char
        -> ParsecT String () (Reader ParseOptions) String)
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT String () (Reader ParseOptions) Char
     -> ParsecT String () (Reader ParseOptions) String)
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) String
    forall a b. (a -> b) -> a -> b
    $ String -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    oneOf String
    operatorList
          pure $ oper

        operatorList :: String
        operatorList :: String
    operatorList = String
    "!#$%&*+./<=>?@\\^|-~:"

        parens :: UserParser a -> UserParser a
        parens :: forall a. UserParser a -> UserParser a
    parens = ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) a
    forall s (m :: * -> *) t u open close a.
    Stream s m t =>
    ParsecT s u m open
    -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
    between (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '(' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white) (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ')' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white)

        brackets :: UserParser a -> UserParser a
        brackets :: forall a. UserParser a -> UserParser a
    brackets = ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) a
    forall s (m :: * -> *) t u open close a.
    Stream s m t =>
    ParsecT s u m open
    -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
    between (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '[' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white) (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ']' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white)

        braces :: UserParser a -> UserParser a
        braces :: forall a. UserParser a -> UserParser a
    braces = ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) a
    forall s (m :: * -> *) t u open close a.
    Stream s m t =>
    ParsecT s u m open
    -> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
    between (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '{' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white) (Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '}' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white)

        comma :: UserParser ()
        comma :: ParsecT String () (Reader ParseOptions) ()
    comma = Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ',' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white

        atsign :: UserParser ()
        atsign :: ParsecT String () (Reader ParseOptions) ()
    atsign = Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '@' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white

        equals :: UserParser ()
        equals :: ParsecT String () (Reader ParseOptions) ()
    equals = Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '=' ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white

        white :: UserParser ()
        white :: ParsecT String () (Reader ParseOptions) ()
    white = ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (ParsecT String () (Reader ParseOptions) Char
     -> ParsecT String () (Reader ParseOptions) ())
    -> ParsecT String () (Reader ParseOptions) Char
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ' '

        wildDots :: UserParser ()
        wildDots :: ParsecT String () (Reader ParseOptions) ()
    wildDots = String -> ParsecT String () (Reader ParseOptions) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string String
    ".." ParsecT String () (Reader ParseOptions) String
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) ()
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT String () (Reader ParseOptions) ()
    white

        -- | Return 'True' if 'Ident' is a variable.  Variables are defined as
        -- starting with a lowercase letter.
        isVariable :: Ident -> Bool
        isVariable :: Ident -> Bool
    isVariable (Ident (Char
    x:String
    _)) = Bool -> Bool
    not (Char -> Bool
    isUpper Char
    x)
        isVariable (Ident []) = String -> Bool
    forall a. HasCallStack => String -> a
    error String
    "isVariable: bad identifier"

        -- | Return 'True' if an 'Ident' is a constructor.  Constructors are
        -- defined as either starting with an uppercase letter, or being an
        -- operator.
        isConstructor :: Ident -> Bool
        isConstructor :: Ident -> Bool
    isConstructor (Ident (Char
    x:String
    _)) = Char -> Bool
    isUpper Char
    x Bool -> Bool -> Bool
    || Char -> String -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    elem Char
    x String
    operatorList
        isConstructor (Ident []) = String -> Bool
    forall a. HasCallStack => String -> a
    error String
    "isConstructor: bad identifier"

        -- | This function tries to parse an entire pattern binding with either
        -- @'gcon' True@ or 'apat'.  For instance, in the pattern
        -- @let Foo a b = ...@, this function tries to parse @Foo a b@ with 'gcon'.
        -- In the pattern @let n = ...@, this function tries to parse @n@ with
        -- 'apat'.
        identPattern :: UserParser Binding
        identPattern :: ParsecT String () (Reader ParseOptions) Binding
    identPattern = Bool -> ParsecT String () (Reader ParseOptions) Binding
    gcon Bool
    True ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT String () (Reader ParseOptions) Binding
    apat
          where
            apat :: UserParser Binding
            apat :: ParsecT String () (Reader ParseOptions) Binding
    apat = [ParsecT String () (Reader ParseOptions) Binding]
    -> ParsecT String () (Reader ParseOptions) Binding
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ParsecT String () (Reader ParseOptions) Binding
    varpat, Bool -> ParsecT String () (Reader ParseOptions) Binding
    gcon Bool
    False, ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    forall a. UserParser a -> UserParser a
    parens ParsecT String () (Reader ParseOptions) Binding
    tuplepat, ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    forall a. UserParser a -> UserParser a
    brackets ParsecT String () (Reader ParseOptions) Binding
    listpat]

            -- | Parse a variable in a pattern.  For instance in, in a pattern like
            -- @let Just n = ...@, this function would be what is used to parse the
            -- @n@.  This function also handles aliases with @\@@.
            varpat :: UserParser Binding
            varpat :: ParsecT String () (Reader ParseOptions) Binding
    varpat = do
              v <-
                UserParser Ident -> UserParser Ident
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (UserParser Ident -> UserParser Ident)
    -> UserParser Ident -> UserParser Ident
    forall a b. (a -> b) -> a -> b
    $ do
                  v <- UserParser Ident
    ident
                  guard (isVariable v)
                  return v
              option (BindVar v) $ do
                atsign
                b <- apat
                return (BindAs v b) <?> "variable"

            -- | This function tries to parse an entire pattern binding.  For
            -- instance, in the pattern @let Foo a b = ...@, this function tries to
            -- parse @Foo a b@.
            --
            -- This function first tries to parse a data contructor (using
            -- 'dataConstr').  In the example above, that would be like parsing
            -- @Foo@.
            --
            -- Then, the function tries to do two different things.
            --
            -- 1. It tries to parse record syntax with 'record'.  In a pattern like
            -- @let Foo{foo1 = 3, foo2 = "hello"} = ...@, it would parse the
            -- @{foo1 = 3, foo2 = "hello"}@ part.
            --
            -- 2. If parsing the record syntax fails, it then tries to parse
            -- many normal patterns with 'apat'.  In a pattern like
            -- @let Foo a b = ...@, it would be like parsing the @a b@ part.
            --
            -- If that fails, then it just returns the original data contructor
            -- with no arguments.
            --
            -- The 'Bool' argument determines whether or not it tries to parse
            -- normal patterns in 2.  If the boolean argument is 'True', then it
            -- tries parsing normal patterns in 2.  If the boolean argument is
            -- 'False', then 2 is skipped altogether.
            gcon :: Bool -> UserParser Binding
            gcon :: Bool -> ParsecT String () (Reader ParseOptions) Binding
    gcon Bool
    allowArgs = do
              c <- ParsecT String () (Reader ParseOptions) DataConstr
    -> ParsecT String () (Reader ParseOptions) DataConstr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT String () (Reader ParseOptions) DataConstr
    dataConstr
              choice
                [ record c
                , fmap (BindConstr c) (guard allowArgs >> many apat)
                , return (BindConstr c [])
                ] <?>
                "constructor"

            -- | Parse a possibly qualified identifier using 'ident'.
            dataConstr :: UserParser DataConstr
            dataConstr :: ParsecT String () (Reader ParseOptions) DataConstr
    dataConstr = do
              p <- ParsecT String () (Reader ParseOptions) String
    dcPiece
              ps <- many dcPieces
              return $ toDataConstr p ps

            dcPiece :: UserParser String
            dcPiece :: ParsecT String () (Reader ParseOptions) String
    dcPiece = do
              x@(Ident y) <- UserParser Ident
    ident
              guard $ isConstructor x
              return y

            dcPieces :: UserParser String
            dcPieces :: ParsecT String () (Reader ParseOptions) String
    dcPieces = do
              _ <- Char -> ParsecT String () (Reader ParseOptions) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    '.'
              dcPiece

            toDataConstr :: String -> [String] -> DataConstr
            toDataConstr :: String -> [String] -> DataConstr
    toDataConstr String
    x [] = Ident -> DataConstr
    DCUnqualified (Ident -> DataConstr) -> Ident -> DataConstr
    forall a b. (a -> b) -> a -> b
    $ String -> Ident
    Ident String
    x
            toDataConstr String
    x (String
    y:[String]
    ys) = ([String] -> [String]) -> String -> [String] -> DataConstr
    go (String
    x String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :) String
    y [String]
    ys
              where
                go :: ([String] -> [String]) -> String -> [String] -> DataConstr
                go :: ([String] -> [String]) -> String -> [String] -> DataConstr
    go [String] -> [String]
    front String
    next [] = Module -> Ident -> DataConstr
    DCQualified ([String] -> Module
    Module ([String] -> Module) -> [String] -> Module
    forall a b. (a -> b) -> a -> b
    $ [String] -> [String]
    front []) (String -> Ident
    Ident String
    next)
                go [String] -> [String]
    front String
    next (String
    rest:[String]
    rests) = ([String] -> [String]) -> String -> [String] -> DataConstr
    go ([String] -> [String]
    front ([String] -> [String])
    -> ([String] -> [String]) -> [String] -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String
    next String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)) String
    rest [String]
    rests

            record :: DataConstr -> UserParser Binding
            record :: DataConstr -> ParsecT String () (Reader ParseOptions) Binding
    record DataConstr
    c =
              ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    forall a. UserParser a -> UserParser a
    braces (ParsecT String () (Reader ParseOptions) Binding
     -> ParsecT String () (Reader ParseOptions) Binding)
    -> ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) Binding
    forall a b. (a -> b) -> a -> b
    $ do
                (fields, wild) <- ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ([], Bool
    False) ParsecT String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    go
                return (BindRecord c fields wild)
              where
                go :: UserParser ([(Ident, Binding)], Bool)
                go :: ParsecT String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    go =
                  (ParsecT String () (Reader ParseOptions) ()
    wildDots ParsecT String () (Reader ParseOptions) ()
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    forall a b.
    ParsecT String () (Reader ParseOptions) a
    -> ParsecT String () (Reader ParseOptions) b
    -> ParsecT String () (Reader ParseOptions) b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    forall a. a -> ParsecT String () (Reader ParseOptions) a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([], Bool
    True)) ParsecT String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    -> ParsecT
         String () (Reader ParseOptions) ([(Ident, Binding)], Bool)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
                  (do x <- UserParser (Ident, Binding)
    recordField
                      (xs, wild) <- option ([], False) (comma >> go)
                      return (x : xs, wild))

            recordField :: UserParser (Ident, Binding)
            recordField :: UserParser (Ident, Binding)
    recordField = do
              field <- UserParser Ident
    ident
              p <-
                option
                  (BindVar field) -- support punning
                  (equals >> identPattern)
              return (field, p)

            tuplepat :: UserParser Binding
            tuplepat :: ParsecT String () (Reader ParseOptions) Binding
    tuplepat = do
              xs <- ParsecT String () (Reader ParseOptions) Binding
    identPattern ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) [Binding]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    `sepBy` ParsecT String () (Reader ParseOptions) ()
    comma
              return $
                case xs of
                  [Binding
    x] -> Binding
    x
                  [Binding]
    _ -> [Binding] -> Binding
    BindTuple [Binding]
    xs

            listpat :: UserParser Binding
            listpat :: ParsecT String () (Reader ParseOptions) Binding
    listpat = [Binding] -> Binding
    BindList ([Binding] -> Binding)
    -> ParsecT String () (Reader ParseOptions) [Binding]
    -> ParsecT String () (Reader ParseOptions) Binding
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT String () (Reader ParseOptions) Binding
    identPattern ParsecT String () (Reader ParseOptions) Binding
    -> ParsecT String () (Reader ParseOptions) ()
    -> ParsecT String () (Reader ParseOptions) [Binding]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    `sepBy` ParsecT String () (Reader ParseOptions) ()
    comma

    identityToReader :: Parsec String () a -> UserParser a
    identityToReader :: forall a. Parsec String () a -> UserParser a
    identityToReader Parsec String () a
    p =
      (State String ()
     -> Reader
          ParseOptions (Consumed (Reader ParseOptions (Reply String () a))))
    -> ParsecT String () (Reader ParseOptions) a
    forall (m :: * -> *) s u a.
    Monad m =>
    (State s u -> m (Consumed (m (Reply s u a)))) -> ParsecT s u m a
    mkPT ((State String ()
      -> Reader
           ParseOptions (Consumed (Reader ParseOptions (Reply String () a))))
     -> ParsecT String () (Reader ParseOptions) a)
    -> (State String ()
        -> Reader
             ParseOptions (Consumed (Reader ParseOptions (Reply String () a))))
    -> ParsecT String () (Reader ParseOptions) a
    forall a b. (a -> b) -> a -> b
    $ Consumed (Reader ParseOptions (Reply String () a))
    -> Reader
         ParseOptions (Consumed (Reader ParseOptions (Reply String () a)))
    forall a. a -> ReaderT ParseOptions Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Consumed (Reader ParseOptions (Reply String () a))
     -> Reader
          ParseOptions (Consumed (Reader ParseOptions (Reply String () a))))
    -> (State String ()
        -> Consumed (Reader ParseOptions (Reply String () a)))
    -> State String ()
    -> Reader
         ParseOptions (Consumed (Reader ParseOptions (Reply String () a)))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Identity (Reply String () a)
     -> Reader ParseOptions (Reply String () a))
    -> Consumed (Identity (Reply String () a))
    -> Consumed (Reader ParseOptions (Reply String () a))
    forall a b. (a -> b) -> Consumed a -> Consumed b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Reply String () a -> Reader ParseOptions (Reply String () a)
    forall a. a -> ReaderT ParseOptions Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Reply String () a -> Reader ParseOptions (Reply String () a))
    -> (Identity (Reply String () a) -> Reply String () a)
    -> Identity (Reply String () a)
    -> Reader ParseOptions (Reply String () a)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Identity (Reply String () a) -> Reply String () a
    forall a. Identity a -> a
    runIdentity) (Consumed (Identity (Reply String () a))
     -> Consumed (Reader ParseOptions (Reply String () a)))
    -> (State String () -> Consumed (Identity (Reply String () a)))
    -> State String ()
    -> Consumed (Reader ParseOptions (Reply String () a))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Identity (Consumed (Identity (Reply String () a)))
    -> Consumed (Identity (Reply String () a))
    forall a. Identity a -> a
    runIdentity (Identity (Consumed (Identity (Reply String () a)))
     -> Consumed (Identity (Reply String () a)))
    -> (State String ()
        -> Identity (Consumed (Identity (Reply String () a))))
    -> State String ()
    -> Consumed (Identity (Reply String () a))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Parsec String () a
    -> State String ()
    -> Identity (Consumed (Identity (Reply String () a)))
    forall (m :: * -> *) s u a.
    Monad m =>
    ParsecT s u m a -> State s u -> m (Consumed (m (Reply s u a)))
    runParsecT Parsec String () a
    p