    -- | Parser for the Futhark core language.
    module Futhark.IR.Parse
      ( -- * Programs
        parseSOACS,
        parseGPU,
        parseGPUMem,
        parseMC,
        parseMCMem,
        parseSeq,
        parseSeqMem,

        -- * Fragments
        parseType,
        parseDeclExtType,
        parseDeclType,
        parseVName,
        parseSubExp,
        parseSubExpRes,
        parseBodyGPU,
        parseBodyMC,
        parseStmGPU,
        parseStmMC,
      )
    where

    import Data.Char (isAlpha)
    import Data.Functor
    import Data.List (singleton)
    import Data.List.NonEmpty (NonEmpty (..))
    import Data.Maybe
    import Data.Set qualified as S
    import Data.Text qualified as T
    import Data.Void
    import Futhark.Analysis.PrimExp.Parse
    import Futhark.IR
    import Futhark.IR.GPU (GPU)
    import Futhark.IR.GPU.Op qualified as GPU
    import Futhark.IR.GPUMem (GPUMem)
    import Futhark.IR.MC (MC)
    import Futhark.IR.MC.Op qualified as MC
    import Futhark.IR.MCMem (MCMem)
    import Futhark.IR.Mem
    import Futhark.IR.Mem.LMAD qualified as LMAD
    import Futhark.IR.SOACS (SOACS)
    import Futhark.IR.SOACS.SOAC qualified as SOAC
    import Futhark.IR.SegOp qualified as SegOp
    import Futhark.IR.Seq (Seq)
    import Futhark.IR.SeqMem (SeqMem)
    import Language.Futhark.Primitive.Parse
    import Text.Megaparsec
    import Text.Megaparsec.Char hiding (space)
    import Text.Megaparsec.Char.Lexer qualified as L

    type Parser = Parsec Void T.Text

    pStringLiteral :: Parser T.Text
    pStringLiteral :: Parsec Void Text Text
    pStringLiteral =
      Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme (Parsec Void Text Text -> Parsec Void Text Text)
    -> (ParsecT Void Text Identity String -> Parsec Void Text Text)
    -> ParsecT Void Text Identity String
    -> Parsec Void Text Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> Text)
    -> ParsecT Void Text Identity String -> Parsec Void Text Text
    forall a b.
    (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap String -> Text
    T.pack (ParsecT Void Text Identity String -> Parsec Void Text Text)
    -> ParsecT Void Text Identity String -> Parsec Void Text Text
    forall a b. (a -> b) -> a -> b
    $ Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '"' ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity String
    -> ParsecT Void Text Identity String
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity String
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    manyTill ParsecT Void Text Identity Char
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m Char
    L.charLiteral (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '"')

    pName :: Parser Name
    pName :: Parser Name
    pName =
      Parser Name -> Parser Name
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme (Parser Name -> Parser Name)
    -> (ParsecT Void Text Identity String -> Parser Name)
    -> ParsecT Void Text Identity String
    -> Parser Name
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (String -> Name)
    -> ParsecT Void Text Identity String -> Parser Name
    forall a b.
    (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap String -> Name
    nameFromString (ParsecT Void Text Identity String -> Parser Name)
    -> ParsecT Void Text Identity String -> Parser Name
    forall a b. (a -> b) -> a -> b
    $
        (:) (Char -> String -> String)
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (String -> String)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Token Text -> Bool) -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    (Token s -> Bool) -> m (Token s)
    satisfy Char -> Bool
    Token Text -> Bool
    leading ParsecT Void Text Identity (String -> String)
    -> ParsecT Void Text Identity String
    -> ParsecT Void Text Identity String
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity String
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ((Token Text -> Bool) -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    (Token s -> Bool) -> m (Token s)
    satisfy Char -> Bool
    Token Text -> Bool
    constituent)
      where
        leading :: Char -> Bool
    leading Char
    c = Char -> Bool
    isAlpha Char
    c Bool -> Bool -> Bool
    || Char
    c Char -> String -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` (String
    "_+-*/%=!<>|&^.#" :: String)

    pVName :: Parser VName
    pVName :: Parser VName
    pVName = Parser VName -> Parser VName
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme (Parser VName -> Parser VName) -> Parser VName -> Parser VName
    forall a b. (a -> b) -> a -> b
    $ do
      ([String]
    s, Int
    tag) <-
        [ParsecT Void Text Identity String]
    -> ParsecT Void Text Identity String
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity String
    ParsecT Void Text Identity [Token Text]
    exprBox, Char -> String
    forall a. a -> [a]
    singleton (Char -> String)
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Token Text -> Bool) -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    (Token s -> Bool) -> m (Token s)
    satisfy Char -> Bool
    Token Text -> Bool
    constituent]
          ParsecT Void Text Identity String
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ([String], Int)
    forall (m :: * -> *) a end.
    MonadPlus m =>
    m a -> m end -> m ([a], end)
    `manyTill_` ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity Int
    pTag
          ParsecT Void Text Identity ([String], Int)
    -> String -> ParsecT Void Text Identity ([String], Int)
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "variable name"
      VName -> Parser VName
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (VName -> Parser VName) -> VName -> Parser VName
    forall a b. (a -> b) -> a -> b
    $ Name -> Int -> VName
    VName (String -> Name
    nameFromString (String -> Name) -> String -> Name
    forall a b. (a -> b) -> a -> b
    $ [String] -> String
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [String]
    s) Int
    tag
      where
        pTag :: ParsecT Void Text Identity Int
    pTag = Parsec Void Text Text
    "_" Parsec Void Text Text
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity (Token Text)
    -> ParsecT Void Text Identity ()
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity ()
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
    notFollowedBy ((Token Text -> Bool) -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    (Token s -> Bool) -> m (Token s)
    satisfy Char -> Bool
    Token Text -> Bool
    constituent)
        exprBox :: ParsecT Void Text Identity [Token Text]
    exprBox = ([Token Text]
    "<{" <>) ([Token Text] -> [Token Text])
    -> ([Token Text] -> [Token Text]) -> [Token Text] -> [Token Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Token Text] -> [Token Text] -> [Token Text]
    forall a. Semigroup a => a -> a -> a
    <> [Token Text]
    "}>") ([Token Text] -> [Token Text])
    -> ParsecT Void Text Identity [Token Text]
    -> ParsecT Void Text Identity [Token Text]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    chunk Tokens Text
    "<{" ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity [Token Text]
    -> ParsecT Void Text Identity [Token Text]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (Token Text)
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity [Token Text]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    manyTill ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *). MonadParsec e s m => m (Token s)
    anySingle (Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    chunk Tokens Text
    "}>"))

    pInt :: Parser Int
    pInt :: ParsecT Void Text Identity Int
    pInt = ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal

    pInt64 :: Parser Int64
    pInt64 :: Parser Int64
    pInt64 = Parser Int64 -> Parser Int64
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parser Int64
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal

    braces, brackets, parens :: Parser a -> Parser a
    braces :: forall a. Parsec Void Text a -> Parsec Void Text a
    braces = Parsec Void Text Text
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a
    forall (m :: * -> *) open close a.
    Applicative m =>
    m open -> m close -> m a -> m a
    between (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "{") (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "}")
    brackets :: forall a. Parsec Void Text a -> Parsec Void Text a
    brackets = Parsec Void Text Text
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a
    forall (m :: * -> *) open close a.
    Applicative m =>
    m open -> m close -> m a -> m a
    between (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "[") (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "]")
    parens :: forall a. Parsec Void Text a -> Parsec Void Text a
    parens = Parsec Void Text Text
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a
    forall (m :: * -> *) open close a.
    Applicative m =>
    m open -> m close -> m a -> m a
    between (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "(") (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ")")

    pComma, pColon, pSemi, pEqual, pSlash, pAsterisk, pArrow :: Parser ()
    pComma :: ParsecT Void Text Identity ()
    pComma = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ","
    pColon :: ParsecT Void Text Identity ()
    pColon = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":"
    pSemi :: ParsecT Void Text Identity ()
    pSemi = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ";"
    pEqual :: ParsecT Void Text Identity ()
    pEqual = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "="
    pSlash :: ParsecT Void Text Identity ()
    pSlash = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "/"
    pAsterisk :: ParsecT Void Text Identity ()
    pAsterisk = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "*"
    pArrow :: ParsecT Void Text Identity ()
    pArrow = Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->"

    pNonArray :: Parser (TypeBase shape NoUniqueness)
    pNonArray :: forall shape. Parser (TypeBase shape NoUniqueness)
    pNonArray =
      [ParsecT Void Text Identity (TypeBase shape NoUniqueness)]
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ PrimType -> TypeBase shape NoUniqueness
    forall shape u. PrimType -> TypeBase shape u
    Prim (PrimType -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimType
    pPrimType,
          Parsec Void Text Text
    "acc"
            Parsec Void Text Text
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( VName
    -> Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness
    forall shape u. VName -> Shape -> [Type] -> u -> TypeBase shape u
    Acc
                  (VName
     -> Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    -> Parser VName
    -> ParsecT
         Void
         Text
         Identity
         (Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName
                  ParsecT
      Void
      Text
      Identity
      (Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         (Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void
      Text
      Identity
      (Shape -> [Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity Shape
    -> ParsecT
         Void
         Text
         Identity
         ([Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Shape
    pShape
                  ParsecT
      Void
      Text
      Identity
      ([Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void
      Text
      Identity
      ([Type] -> NoUniqueness -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT
         Void Text Identity (NoUniqueness -> TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Type]
    pTypes
                  ParsecT
      Void Text Identity (NoUniqueness -> TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity NoUniqueness
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness
              )
        ]

    pTypeBase ::
      (ArrayShape shape) =>
      Parser shape ->
      Parser u ->
      Parser (TypeBase shape u)
    pTypeBase :: forall shape u.
    ArrayShape shape =>
    Parser shape -> Parser u -> Parser (TypeBase shape u)
    pTypeBase Parser shape
    ps Parser u
    pu = do
      u
    u <- Parser u
    pu
      shape
    shape <- Parser shape
    ps
      TypeBase shape NoUniqueness -> shape -> u -> TypeBase shape u
    forall shape u_unused u.
    ArrayShape shape =>
    TypeBase shape u_unused -> shape -> u -> TypeBase shape u
    arrayOf (TypeBase shape NoUniqueness -> shape -> u -> TypeBase shape u)
    -> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity (shape -> u -> TypeBase shape u)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (TypeBase shape NoUniqueness)
    forall shape. Parser (TypeBase shape NoUniqueness)
    pNonArray ParsecT Void Text Identity (shape -> u -> TypeBase shape u)
    -> Parser shape
    -> ParsecT Void Text Identity (u -> TypeBase shape u)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> shape -> Parser shape
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure shape
    shape ParsecT Void Text Identity (u -> TypeBase shape u)
    -> Parser u -> Parser (TypeBase shape u)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> u -> Parser u
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure u
    u

    pShape :: Parser Shape
    pShape :: ParsecT Void Text Identity Shape
    pShape = [SubExp] -> Shape
    forall d. [d] -> ShapeBase d
    Shape ([SubExp] -> Shape)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity Shape
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets ParsecT Void Text Identity SubExp
    pSubExp)

    pExt :: Parser a -> Parser (Ext a)
    pExt :: forall a. Parser a -> Parser (Ext a)
    pExt Parser a
    p =
      [ParsecT Void Text Identity (Ext a)]
    -> ParsecT Void Text Identity (Ext a)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ ParsecT Void Text Identity (Ext a)
    -> ParsecT Void Text Identity (Ext a)
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme (ParsecT Void Text Identity (Ext a)
     -> ParsecT Void Text Identity (Ext a))
    -> ParsecT Void Text Identity (Ext a)
    -> ParsecT Void Text Identity (Ext a)
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text
    "?" Parsec Void Text Text
    -> (Int -> Ext a) -> ParsecT Void Text Identity (Int -> Ext a)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Int -> Ext a
    forall a. Int -> Ext a
    Ext ParsecT Void Text Identity (Int -> Ext a)
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Ext a)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal,
          a -> Ext a
    forall a. a -> Ext a
    Free (a -> Ext a) -> Parser a -> ParsecT Void Text Identity (Ext a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser a
    p
        ]

    pExtSize :: Parser ExtSize
    pExtSize :: Parser ExtSize
    pExtSize = ParsecT Void Text Identity SubExp -> Parser ExtSize
    forall a. Parser a -> Parser (Ext a)
    pExt ParsecT Void Text Identity SubExp
    pSubExp

    pExtShape :: Parser ExtShape
    pExtShape :: Parser ExtShape
    pExtShape = [ExtSize] -> ExtShape
    forall d. [d] -> ShapeBase d
    Shape ([ExtSize] -> ExtShape)
    -> ParsecT Void Text Identity [ExtSize] -> Parser ExtShape
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser ExtSize -> ParsecT Void Text Identity [ExtSize]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (Parser ExtSize -> Parser ExtSize
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets Parser ExtSize
    pExtSize)

    pType :: Parser Type
    pType :: Parser Type
    pType = ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity NoUniqueness -> Parser Type
    forall shape u.
    ArrayShape shape =>
    Parser shape -> Parser u -> Parser (TypeBase shape u)
    pTypeBase ParsecT Void Text Identity Shape
    pShape (NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness)

    pTypes :: Parser [Type]
    pTypes :: ParsecT Void Text Identity [Type]
    pTypes = ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity [Type]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity [Type]
     -> ParsecT Void Text Identity [Type])
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity [Type]
    forall a b. (a -> b) -> a -> b
    $ Parser Type
    pType Parser Type
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Type]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pExtType :: Parser ExtType
    pExtType :: Parser ExtType
    pExtType = Parser ExtShape
    -> ParsecT Void Text Identity NoUniqueness -> Parser ExtType
    forall shape u.
    ArrayShape shape =>
    Parser shape -> Parser u -> Parser (TypeBase shape u)
    pTypeBase Parser ExtShape
    pExtShape (NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness)

    pRank :: Parser Rank
    pRank :: Parser Rank
    pRank = Int -> Rank
    Rank (Int -> Rank) -> ([Text] -> Int) -> [Text] -> Rank
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length ([Text] -> Rank)
    -> ParsecT Void Text Identity [Text] -> Parser Rank
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text -> ParsecT Void Text Identity [Text]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "[" Parsec Void Text Text
    -> Parsec Void Text Text -> Parsec Void Text Text
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "]")

    pUniqueness :: Parser Uniqueness
    pUniqueness :: Parser Uniqueness
    pUniqueness = [Parser Uniqueness] -> Parser Uniqueness
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity ()
    pAsterisk ParsecT Void Text Identity () -> Uniqueness -> Parser Uniqueness
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Uniqueness
    Unique, Uniqueness -> Parser Uniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Uniqueness
    Nonunique]

    pDeclBase ::
      Parser (TypeBase shape NoUniqueness) ->
      Parser (TypeBase shape Uniqueness)
    pDeclBase :: forall shape.
    Parser (TypeBase shape NoUniqueness)
    -> Parser (TypeBase shape Uniqueness)
    pDeclBase Parser (TypeBase shape NoUniqueness)
    p = (TypeBase shape NoUniqueness
     -> Uniqueness -> TypeBase shape Uniqueness)
    -> Uniqueness
    -> TypeBase shape NoUniqueness
    -> TypeBase shape Uniqueness
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip TypeBase shape NoUniqueness
    -> Uniqueness -> TypeBase shape Uniqueness
    forall shape.
    TypeBase shape NoUniqueness
    -> Uniqueness -> TypeBase shape Uniqueness
    toDecl (Uniqueness
     -> TypeBase shape NoUniqueness -> TypeBase shape Uniqueness)
    -> Parser Uniqueness
    -> ParsecT
         Void
         Text
         Identity
         (TypeBase shape NoUniqueness -> TypeBase shape Uniqueness)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Uniqueness
    pUniqueness ParsecT
      Void
      Text
      Identity
      (TypeBase shape NoUniqueness -> TypeBase shape Uniqueness)
    -> Parser (TypeBase shape NoUniqueness)
    -> ParsecT Void Text Identity (TypeBase shape Uniqueness)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (TypeBase shape NoUniqueness)
    p

    pDeclType :: Parser DeclType
    pDeclType :: Parser DeclType
    pDeclType = Parser Type -> Parser DeclType
    forall shape.
    Parser (TypeBase shape NoUniqueness)
    -> Parser (TypeBase shape Uniqueness)
    pDeclBase Parser Type
    pType

    pDeclExtType :: Parser DeclExtType
    pDeclExtType :: Parser DeclExtType
    pDeclExtType = Parser ExtType -> Parser DeclExtType
    forall shape.
    Parser (TypeBase shape NoUniqueness)
    -> Parser (TypeBase shape Uniqueness)
    pDeclBase Parser ExtType
    pExtType

    pSubExp :: Parser SubExp
    pSubExp :: ParsecT Void Text Identity SubExp
    pSubExp = VName -> SubExp
    Var (VName -> SubExp)
    -> Parser VName -> ParsecT Void Text Identity SubExp
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> PrimValue -> SubExp
    Constant (PrimValue -> SubExp)
    -> ParsecT Void Text Identity PrimValue
    -> ParsecT Void Text Identity SubExp
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimValue
    pPrimValue

    pSubExps :: Parser [SubExp]
    pSubExps :: ParsecT Void Text Identity [SubExp]
    pSubExps = ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pVNames :: Parser [VName]
    pVNames :: Parser [VName]
    pVNames = Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pConvOp ::
      T.Text -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp :: forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    s t1 -> t2 -> ConvOp
    op Parser t1
    t1 Parser t2
    t2 =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    s ParsecT Void Text Identity ()
    -> (t1 -> SubExp -> t2 -> BasicOp)
    -> ParsecT Void Text Identity (t1 -> SubExp -> t2 -> BasicOp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> t1 -> SubExp -> t2 -> BasicOp
    op' ParsecT Void Text Identity (t1 -> SubExp -> t2 -> BasicOp)
    -> Parser t1
    -> ParsecT Void Text Identity (SubExp -> t2 -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser t1
    t1 ParsecT Void Text Identity (SubExp -> t2 -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (t2 -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (t2 -> BasicOp)
    -> Parser t2 -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "to" ParsecT Void Text Identity () -> Parser t2 -> Parser t2
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser t2
    t2)
      where
        op' :: t1 -> SubExp -> t2 -> BasicOp
    op' t1
    f SubExp
    se t2
    t = ConvOp -> SubExp -> BasicOp
    ConvOp (t1 -> t2 -> ConvOp
    op t1
    f t2
    t) SubExp
    se

    pBinOp :: Parser BasicOp
    pBinOp :: Parser BasicOp
    pBinOp = [Parser BasicOp] -> Parser BasicOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice ((BinOp -> Parser BasicOp) -> [BinOp] -> [Parser BasicOp]
    forall a b. (a -> b) -> [a] -> [b]
    map BinOp -> Parser BasicOp
    p [BinOp]
    allBinOps) Parser BasicOp -> String -> Parser BasicOp
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "binary op"
      where
        p :: BinOp -> Parser BasicOp
    p BinOp
    bop =
          Text -> ParsecT Void Text Identity ()
    keyword (BinOp -> Text
    forall a. Pretty a => a -> Text
    prettyText BinOp
    bop)
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (BinOp -> SubExp -> SubExp -> BasicOp
    BinOp BinOp
    bop (SubExp -> SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp)

    pCmpOp :: Parser BasicOp
    pCmpOp :: Parser BasicOp
    pCmpOp = [Parser BasicOp] -> Parser BasicOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice ((CmpOp -> Parser BasicOp) -> [CmpOp] -> [Parser BasicOp]
    forall a b. (a -> b) -> [a] -> [b]
    map CmpOp -> Parser BasicOp
    p [CmpOp]
    allCmpOps) Parser BasicOp -> String -> Parser BasicOp
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "comparison op"
      where
        p :: CmpOp -> Parser BasicOp
    p CmpOp
    op =
          Text -> ParsecT Void Text Identity ()
    keyword (CmpOp -> Text
    forall a. Pretty a => a -> Text
    prettyText CmpOp
    op)
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (CmpOp -> SubExp -> SubExp -> BasicOp
    CmpOp CmpOp
    op (SubExp -> SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp)

    pUnOp :: Parser BasicOp
    pUnOp :: Parser BasicOp
    pUnOp = [Parser BasicOp] -> Parser BasicOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice ((UnOp -> Parser BasicOp) -> [UnOp] -> [Parser BasicOp]
    forall a b. (a -> b) -> [a] -> [b]
    map UnOp -> Parser BasicOp
    p [UnOp]
    allUnOps) Parser BasicOp -> String -> Parser BasicOp
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "unary op"
      where
        p :: UnOp -> Parser BasicOp
    p UnOp
    bop = Text -> ParsecT Void Text Identity ()
    keyword (UnOp -> Text
    forall a. Pretty a => a -> Text
    prettyText UnOp
    bop) ParsecT Void Text Identity ()
    -> (SubExp -> BasicOp)
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> UnOp -> SubExp -> BasicOp
    UnOp UnOp
    bop ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp

    pDimIndex :: Parser (DimIndex SubExp)
    pDimIndex :: Parser (DimIndex SubExp)
    pDimIndex =
      [Parser (DimIndex SubExp)] -> Parser (DimIndex SubExp)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Parser (DimIndex SubExp) -> Parser (DimIndex SubExp)
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser (DimIndex SubExp) -> Parser (DimIndex SubExp))
    -> Parser (DimIndex SubExp) -> Parser (DimIndex SubExp)
    forall a b. (a -> b) -> a -> b
    $
            SubExp -> SubExp -> SubExp -> DimIndex SubExp
    forall d. d -> d -> d -> DimIndex d
    DimSlice
              (SubExp -> SubExp -> SubExp -> DimIndex SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> SubExp -> DimIndex SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
              ParsecT Void Text Identity (SubExp -> SubExp -> DimIndex SubExp)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> SubExp -> DimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":+"
              ParsecT Void Text Identity (SubExp -> SubExp -> DimIndex SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> DimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
              ParsecT Void Text Identity (SubExp -> DimIndex SubExp)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> DimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "*"
              ParsecT Void Text Identity (SubExp -> DimIndex SubExp)
    -> ParsecT Void Text Identity SubExp -> Parser (DimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp,
          SubExp -> DimIndex SubExp
    forall d. d -> DimIndex d
    DimFix (SubExp -> DimIndex SubExp)
    -> ParsecT Void Text Identity SubExp -> Parser (DimIndex SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
        ]

    pSlice :: Parser (Slice SubExp)
    pSlice :: Parser (Slice SubExp)
    pSlice = [DimIndex SubExp] -> Slice SubExp
    forall d. [DimIndex d] -> Slice d
    Slice ([DimIndex SubExp] -> Slice SubExp)
    -> ParsecT Void Text Identity [DimIndex SubExp]
    -> Parser (Slice SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [DimIndex SubExp]
    -> ParsecT Void Text Identity [DimIndex SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (Parser (DimIndex SubExp)
    pDimIndex Parser (DimIndex SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [DimIndex SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pIndex :: Parser BasicOp
    pIndex :: Parser BasicOp
    pIndex = Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $ VName -> Slice SubExp -> BasicOp
    Index (VName -> Slice SubExp -> BasicOp)
    -> Parser VName
    -> ParsecT Void Text Identity (Slice SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (Slice SubExp -> BasicOp)
    -> Parser (Slice SubExp) -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (Slice SubExp)
    pSlice

    pFlatDimIndex :: Parser (FlatDimIndex SubExp)
    pFlatDimIndex :: Parser (FlatDimIndex SubExp)
    pFlatDimIndex =
      SubExp -> SubExp -> FlatDimIndex SubExp
    forall d. d -> d -> FlatDimIndex d
    FlatDimIndex (SubExp -> SubExp -> FlatDimIndex SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> FlatDimIndex SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (SubExp -> FlatDimIndex SubExp)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> FlatDimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":" ParsecT Void Text Identity (SubExp -> FlatDimIndex SubExp)
    -> ParsecT Void Text Identity SubExp
    -> Parser (FlatDimIndex SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp

    pFlatSlice :: Parser (FlatSlice SubExp)
    pFlatSlice :: Parser (FlatSlice SubExp)
    pFlatSlice =
      Parser (FlatSlice SubExp) -> Parser (FlatSlice SubExp)
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (Parser (FlatSlice SubExp) -> Parser (FlatSlice SubExp))
    -> Parser (FlatSlice SubExp) -> Parser (FlatSlice SubExp)
    forall a b. (a -> b) -> a -> b
    $ SubExp -> [FlatDimIndex SubExp] -> FlatSlice SubExp
    forall d. d -> [FlatDimIndex d] -> FlatSlice d
    FlatSlice (SubExp -> [FlatDimIndex SubExp] -> FlatSlice SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void Text Identity ([FlatDimIndex SubExp] -> FlatSlice SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT
      Void Text Identity ([FlatDimIndex SubExp] -> FlatSlice SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([FlatDimIndex SubExp] -> FlatSlice SubExp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi ParsecT
      Void Text Identity ([FlatDimIndex SubExp] -> FlatSlice SubExp)
    -> ParsecT Void Text Identity [FlatDimIndex SubExp]
    -> Parser (FlatSlice SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parser (FlatDimIndex SubExp)
    pFlatDimIndex Parser (FlatDimIndex SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [FlatDimIndex SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pFlatIndex :: Parser BasicOp
    pFlatIndex :: Parser BasicOp
    pFlatIndex = Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $ VName -> FlatSlice SubExp -> BasicOp
    FlatIndex (VName -> FlatSlice SubExp -> BasicOp)
    -> Parser VName
    -> ParsecT Void Text Identity (FlatSlice SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (FlatSlice SubExp -> BasicOp)
    -> Parser (FlatSlice SubExp) -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (FlatSlice SubExp)
    pFlatSlice

    pErrorMsgPart :: Parser (ErrorMsgPart SubExp)
    pErrorMsgPart :: Parser (ErrorMsgPart SubExp)
    pErrorMsgPart =
      [Parser (ErrorMsgPart SubExp)] -> Parser (ErrorMsgPart SubExp)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ErrorMsgPart SubExp
    forall a. Text -> ErrorMsgPart a
    ErrorString (Text -> ErrorMsgPart SubExp)
    -> Parsec Void Text Text -> Parser (ErrorMsgPart SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral,
          (PrimType -> SubExp -> ErrorMsgPart SubExp)
    -> SubExp -> PrimType -> ErrorMsgPart SubExp
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip PrimType -> SubExp -> ErrorMsgPart SubExp
    forall a. PrimType -> a -> ErrorMsgPart a
    ErrorVal (SubExp -> PrimType -> ErrorMsgPart SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (PrimType -> ErrorMsgPart SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon) ParsecT Void Text Identity (PrimType -> ErrorMsgPart SubExp)
    -> ParsecT Void Text Identity PrimType
    -> Parser (ErrorMsgPart SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity PrimType
    pPrimType
        ]

    pErrorMsg :: Parser (ErrorMsg SubExp)
    pErrorMsg :: Parser (ErrorMsg SubExp)
    pErrorMsg = [ErrorMsgPart SubExp] -> ErrorMsg SubExp
    forall a. [ErrorMsgPart a] -> ErrorMsg a
    ErrorMsg ([ErrorMsgPart SubExp] -> ErrorMsg SubExp)
    -> ParsecT Void Text Identity [ErrorMsgPart SubExp]
    -> Parser (ErrorMsg SubExp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [ErrorMsgPart SubExp]
    -> ParsecT Void Text Identity [ErrorMsgPart SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser (ErrorMsgPart SubExp)
    pErrorMsgPart Parser (ErrorMsgPart SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [ErrorMsgPart SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pSrcLoc :: Parser SrcLoc
    pSrcLoc :: Parser SrcLoc
    pSrcLoc = Parsec Void Text Text
    pStringLiteral Parsec Void Text Text -> SrcLoc -> Parser SrcLoc
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SrcLoc
    forall a. Monoid a => a
    mempty -- FIXME

    pErrorLoc :: Parser (SrcLoc, [SrcLoc])
    pErrorLoc :: Parser (SrcLoc, [SrcLoc])
    pErrorLoc = (,[SrcLoc]
    forall a. Monoid a => a
    mempty) (SrcLoc -> (SrcLoc, [SrcLoc]))
    -> Parser SrcLoc -> Parser (SrcLoc, [SrcLoc])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser SrcLoc
    pSrcLoc

    pIota :: Parser BasicOp
    pIota :: Parser BasicOp
    pIota =
      [Parser BasicOp] -> Parser BasicOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice ([Parser BasicOp] -> Parser BasicOp)
    -> [Parser BasicOp] -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $ (IntType -> Parser BasicOp) -> [IntType] -> [Parser BasicOp]
    forall a b. (a -> b) -> [a] -> [b]
    map IntType -> Parser BasicOp
    p [IntType]
    allIntTypes
      where
        p :: IntType -> Parser BasicOp
    p IntType
    t =
          Text -> ParsecT Void Text Identity ()
    keyword (Text
    "iota" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Int -> Text
    forall a. Pretty a => a -> Text
    prettyText (PrimType -> Int
    primBitSize (IntType -> PrimType
    IntType IntType
    t)))
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( SubExp -> SubExp -> SubExp -> IntType -> BasicOp
    Iota
                  (SubExp -> SubExp -> SubExp -> IntType -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void Text Identity (SubExp -> SubExp -> IntType -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT Void Text Identity (SubExp -> SubExp -> IntType -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (SubExp -> SubExp -> IntType -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity (SubExp -> SubExp -> IntType -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> IntType -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT Void Text Identity (SubExp -> IntType -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> IntType -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity (SubExp -> IntType -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (IntType -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT Void Text Identity (IntType -> BasicOp)
    -> ParsecT Void Text Identity IntType -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> IntType -> ParsecT Void Text Identity IntType
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure IntType
    t
              )

    pBasicOp :: Parser BasicOp
    pBasicOp :: Parser BasicOp
    pBasicOp =
      [Parser BasicOp] -> Parser BasicOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "opaque" ParsecT Void Text Identity ()
    -> (SubExp -> BasicOp)
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> OpaqueOp -> SubExp -> BasicOp
    Opaque OpaqueOp
    OpaqueNil ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens ParsecT Void Text Identity SubExp
    pSubExp,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "trace"
            ParsecT Void Text Identity ()
    -> ((Text, SubExp) -> BasicOp)
    -> ParsecT Void Text Identity ((Text, SubExp) -> BasicOp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (Text -> SubExp -> BasicOp) -> (Text, SubExp) -> BasicOp
    forall a b c. (a -> b -> c) -> (a, b) -> c
    uncurry (OpaqueOp -> SubExp -> BasicOp
    Opaque (OpaqueOp -> SubExp -> BasicOp)
    -> (Text -> OpaqueOp) -> Text -> SubExp -> BasicOp
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> OpaqueOp
    OpaqueTrace)
            ParsecT Void Text Identity ((Text, SubExp) -> BasicOp)
    -> ParsecT Void Text Identity (Text, SubExp) -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Text, SubExp)
    -> ParsecT Void Text Identity (Text, SubExp)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens ((,) (Text -> SubExp -> (Text, SubExp))
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> (Text, SubExp))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral ParsecT Void Text Identity (SubExp -> (Text, SubExp))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> (Text, SubExp))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SubExp -> (Text, SubExp))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Text, SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "copy" ParsecT Void Text Identity ()
    -> (VName -> BasicOp)
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Shape -> SubExp -> BasicOp
    Replicate Shape
    forall a. Monoid a => a
    mempty (SubExp -> BasicOp) -> (VName -> SubExp) -> VName -> BasicOp
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . VName -> SubExp
    Var ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName -> Parser VName
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens Parser VName
    pVName,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "assert"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( SubExp -> ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp
    Assert
                  (SubExp -> ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         (ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT
      Void
      Text
      Identity
      (ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         (ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void
      Text
      Identity
      (ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp)
    -> Parser (ErrorMsg SubExp)
    -> ParsecT Void Text Identity ((SrcLoc, [SrcLoc]) -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (ErrorMsg SubExp)
    pErrorMsg
                  ParsecT Void Text Identity ((SrcLoc, [SrcLoc]) -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ((SrcLoc, [SrcLoc]) -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity ((SrcLoc, [SrcLoc]) -> BasicOp)
    -> Parser (SrcLoc, [SrcLoc]) -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (SrcLoc, [SrcLoc])
    pErrorLoc
              ),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "replicate"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Shape -> SubExp -> BasicOp
    Replicate (Shape -> SubExp -> BasicOp)
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "reshape"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ReshapeKind -> Shape -> VName -> BasicOp
    Reshape ReshapeKind
    ReshapeArbitrary (Shape -> VName -> BasicOp)
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape ParsecT Void Text Identity (VName -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "coerce"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ReshapeKind -> Shape -> VName -> BasicOp
    Reshape ReshapeKind
    ReshapeCoerce (Shape -> VName -> BasicOp)
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape ParsecT Void Text Identity (VName -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "scratch"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (PrimType -> [SubExp] -> BasicOp
    Scratch (PrimType -> [SubExp] -> BasicOp)
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity ([SubExp] -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimType
    pPrimType ParsecT Void Text Identity ([SubExp] -> BasicOp)
    -> ParsecT Void Text Identity [SubExp] -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity SubExp
    pSubExp)),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "rearrange"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ([Int] -> VName -> BasicOp
    Rearrange ([Int] -> VName -> BasicOp)
    -> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Int]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma) ParsecT Void Text Identity (VName -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "manifest"
            ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ([Int] -> VName -> BasicOp
    Manifest ([Int] -> VName -> BasicOp)
    -> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Int]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma) ParsecT Void Text Identity (VName -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "concat" ParsecT Void Text Identity () -> Parser BasicOp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> do
            Int
    d <- Parsec Void Text Text
    "@" Parsec Void Text Text
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal
            Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $ do
              SubExp
    w <- ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              VName
    x <- Parser VName
    pVName
              [VName]
    ys <- Parser VName -> Parser [VName]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity () -> Parser VName -> Parser VName
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser VName
    pVName)
              BasicOp -> Parser BasicOp
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (BasicOp -> Parser BasicOp) -> BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $ Int -> NonEmpty VName -> SubExp -> BasicOp
    Concat Int
    d (VName
    x VName -> [VName] -> NonEmpty VName
    forall a. a -> [a] -> NonEmpty a
    :| [VName]
    ys) SubExp
    w,
          Parser BasicOp
    pIota,
          Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $
            (Safety -> VName -> Slice SubExp -> SubExp -> BasicOp)
    -> VName -> Safety -> Slice SubExp -> SubExp -> BasicOp
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Safety -> VName -> Slice SubExp -> SubExp -> BasicOp
    Update
              (VName -> Safety -> Slice SubExp -> SubExp -> BasicOp)
    -> Parser VName
    -> ParsecT
         Void Text Identity (Safety -> Slice SubExp -> SubExp -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName
              ParsecT
      Void Text Identity (Safety -> Slice SubExp -> SubExp -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (Safety -> Slice SubExp -> SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "with"
              ParsecT
      Void Text Identity (Safety -> Slice SubExp -> SubExp -> BasicOp)
    -> ParsecT Void Text Identity Safety
    -> ParsecT Void Text Identity (Slice SubExp -> SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [ParsecT Void Text Identity Safety]
    -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "?" Parsec Void Text Text
    -> Safety -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Safety
    Safe, Safety -> ParsecT Void Text Identity Safety
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Safety
    Unsafe]
              ParsecT Void Text Identity (Slice SubExp -> SubExp -> BasicOp)
    -> Parser (Slice SubExp)
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (Slice SubExp)
    pSlice
              ParsecT Void Text Identity (SubExp -> BasicOp)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "="
              ParsecT Void Text Identity (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp,
          Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $
            VName -> FlatSlice SubExp -> VName -> BasicOp
    FlatUpdate
              (VName -> FlatSlice SubExp -> VName -> BasicOp)
    -> Parser VName
    -> ParsecT
         Void Text Identity (FlatSlice SubExp -> VName -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName
              ParsecT Void Text Identity (FlatSlice SubExp -> VName -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (FlatSlice SubExp -> VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "with"
              ParsecT Void Text Identity (FlatSlice SubExp -> VName -> BasicOp)
    -> Parser (FlatSlice SubExp)
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (FlatSlice SubExp)
    pFlatSlice
              ParsecT Void Text Identity (VName -> BasicOp)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (VName -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "="
              ParsecT Void Text Identity (VName -> BasicOp)
    -> Parser VName -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName,
          Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser BasicOp -> Parser BasicOp)
    -> Parser BasicOp -> Parser BasicOp
    forall a b. (a -> b) -> a -> b
    $
            [PrimValue] -> PrimType -> BasicOp
    ArrayVal
              ([PrimValue] -> PrimType -> BasicOp)
    -> ParsecT Void Text Identity [PrimValue]
    -> ParsecT Void Text Identity (PrimType -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [PrimValue]
    -> ParsecT Void Text Identity [PrimValue]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (ParsecT Void Text Identity PrimValue
    pPrimValue ParsecT Void Text Identity PrimValue
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [PrimValue]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity (PrimType -> BasicOp)
    -> ParsecT Void Text Identity PrimType -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":" Parsec Void Text Text
    -> Parsec Void Text Text -> Parsec Void Text Text
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parsec Void Text Text
    "[]" Parsec Void Text Text
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity PrimType
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity PrimType
    pPrimType),
          [SubExp] -> Type -> BasicOp
    ArrayLit
            ([SubExp] -> Type -> BasicOp)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Type -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity (Type -> BasicOp)
    -> Parser Type -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":" Parsec Void Text Text
    -> Parsec Void Text Text -> Parsec Void Text Text
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parsec Void Text Text
    "[]" Parsec Void Text Text -> Parser Type -> Parser Type
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser Type
    pType),
          do
            Safety
    safety <-
              [ParsecT Void Text Identity Safety]
    -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Text -> ParsecT Void Text Identity ()
    keyword Text
    "update_acc_unsafe" ParsecT Void Text Identity ()
    -> Safety -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Safety
    Unsafe, Text -> ParsecT Void Text Identity ()
    keyword Text
    "update_acc" ParsecT Void Text Identity ()
    -> Safety -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Safety
    Safe]
            Parser BasicOp -> Parser BasicOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Safety -> VName -> [SubExp] -> [SubExp] -> BasicOp
    UpdateAcc Safety
    safety (VName -> [SubExp] -> [SubExp] -> BasicOp)
    -> Parser VName
    -> ParsecT Void Text Identity ([SubExp] -> [SubExp] -> BasicOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity ([SubExp] -> [SubExp] -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> [SubExp] -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ([SubExp] -> [SubExp] -> BasicOp)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity ([SubExp] -> BasicOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    pSubExps ParsecT Void Text Identity ([SubExp] -> BasicOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> BasicOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ([SubExp] -> BasicOp)
    -> ParsecT Void Text Identity [SubExp] -> Parser BasicOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    pSubExps),
          --
          Text
    -> (IntType -> IntType -> ConvOp)
    -> ParsecT Void Text Identity IntType
    -> ParsecT Void Text Identity IntType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "sext" IntType -> IntType -> ConvOp
    SExt ParsecT Void Text Identity IntType
    pIntType ParsecT Void Text Identity IntType
    pIntType,
          Text
    -> (IntType -> IntType -> ConvOp)
    -> ParsecT Void Text Identity IntType
    -> ParsecT Void Text Identity IntType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "zext" IntType -> IntType -> ConvOp
    ZExt ParsecT Void Text Identity IntType
    pIntType ParsecT Void Text Identity IntType
    pIntType,
          Text
    -> (FloatType -> FloatType -> ConvOp)
    -> Parser FloatType
    -> Parser FloatType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "fpconv" FloatType -> FloatType -> ConvOp
    FPConv Parser FloatType
    pFloatType Parser FloatType
    pFloatType,
          Text
    -> (FloatType -> IntType -> ConvOp)
    -> Parser FloatType
    -> ParsecT Void Text Identity IntType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "fptoui" FloatType -> IntType -> ConvOp
    FPToUI Parser FloatType
    pFloatType ParsecT Void Text Identity IntType
    pIntType,
          Text
    -> (FloatType -> IntType -> ConvOp)
    -> Parser FloatType
    -> ParsecT Void Text Identity IntType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "fptosi" FloatType -> IntType -> ConvOp
    FPToSI Parser FloatType
    pFloatType ParsecT Void Text Identity IntType
    pIntType,
          Text
    -> (IntType -> FloatType -> ConvOp)
    -> ParsecT Void Text Identity IntType
    -> Parser FloatType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "uitofp" IntType -> FloatType -> ConvOp
    UIToFP ParsecT Void Text Identity IntType
    pIntType Parser FloatType
    pFloatType,
          Text
    -> (IntType -> FloatType -> ConvOp)
    -> ParsecT Void Text Identity IntType
    -> Parser FloatType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "sitofp" IntType -> FloatType -> ConvOp
    SIToFP ParsecT Void Text Identity IntType
    pIntType Parser FloatType
    pFloatType,
          Text
    -> (IntType -> () -> ConvOp)
    -> ParsecT Void Text Identity IntType
    -> ParsecT Void Text Identity ()
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "itob" (ConvOp -> () -> ConvOp
    forall a b. a -> b -> a
    const (ConvOp -> () -> ConvOp)
    -> (IntType -> ConvOp) -> IntType -> () -> ConvOp
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . IntType -> ConvOp
    IToB) ParsecT Void Text Identity IntType
    pIntType (Text -> ParsecT Void Text Identity ()
    keyword Text
    "bool"),
          Text
    -> (() -> IntType -> ConvOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity IntType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "btoi" ((IntType -> ConvOp) -> () -> IntType -> ConvOp
    forall a b. a -> b -> a
    const IntType -> ConvOp
    BToI) (Text -> ParsecT Void Text Identity ()
    keyword Text
    "bool") ParsecT Void Text Identity IntType
    pIntType,
          Text
    -> (FloatType -> () -> ConvOp)
    -> Parser FloatType
    -> ParsecT Void Text Identity ()
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "ftob" (ConvOp -> () -> ConvOp
    forall a b. a -> b -> a
    const (ConvOp -> () -> ConvOp)
    -> (FloatType -> ConvOp) -> FloatType -> () -> ConvOp
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . FloatType -> ConvOp
    FToB) Parser FloatType
    pFloatType (Text -> ParsecT Void Text Identity ()
    keyword Text
    "bool"),
          Text
    -> (() -> FloatType -> ConvOp)
    -> ParsecT Void Text Identity ()
    -> Parser FloatType
    -> Parser BasicOp
    forall t1 t2.
    Text
    -> (t1 -> t2 -> ConvOp) -> Parser t1 -> Parser t2 -> Parser BasicOp
    pConvOp Text
    "btof" ((FloatType -> ConvOp) -> () -> FloatType -> ConvOp
    forall a b. a -> b -> a
    const FloatType -> ConvOp
    BToF) (Text -> ParsecT Void Text Identity ()
    keyword Text
    "bool") Parser FloatType
    pFloatType,
          --
          Parser BasicOp
    pIndex,
          Parser BasicOp
    pFlatIndex,
          Parser BasicOp
    pBinOp,
          Parser BasicOp
    pCmpOp,
          Parser BasicOp
    pUnOp,
          SubExp -> BasicOp
    SubExp (SubExp -> BasicOp)
    -> ParsecT Void Text Identity SubExp -> Parser BasicOp
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
        ]

    pAttr :: Parser Attr
    pAttr :: Parser Attr
    pAttr =
      [Parser Attr] -> Parser Attr
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Integer -> Attr
    AttrInt (Integer -> Attr) -> (Int -> Integer) -> Int -> Attr
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int -> Attr) -> ParsecT Void Text Identity Int -> Parser Attr
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Int
    pInt,
          do
            Name
    v <- Parser Name
    pName
            [Parser Attr] -> Parser Attr
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
              [ Name -> [Attr] -> Attr
    AttrComp Name
    v ([Attr] -> Attr)
    -> ParsecT Void Text Identity [Attr] -> Parser Attr
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [Attr]
    -> ParsecT Void Text Identity [Attr]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser Attr
    pAttr Parser Attr
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Attr]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma),
                Attr -> Parser Attr
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Attr -> Parser Attr) -> Attr -> Parser Attr
    forall a b. (a -> b) -> a -> b
    $ Name -> Attr
    AttrName Name
    v
              ]
        ]

    pAttrs :: Parser Attrs
    pAttrs :: Parser Attrs
    pAttrs = Set Attr -> Attrs
    Attrs (Set Attr -> Attrs) -> ([Attr] -> Set Attr) -> [Attr] -> Attrs
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Attr] -> Set Attr
    forall a. Ord a => [a] -> Set a
    S.fromList ([Attr] -> Attrs)
    -> ParsecT Void Text Identity [Attr] -> Parser Attrs
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Attr -> ParsecT Void Text Identity [Attr]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many Parser Attr
    pAttr'
      where
        pAttr' :: Parser Attr
    pAttr' = Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "#[" Parsec Void Text Text -> Parser Attr -> Parser Attr
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser Attr
    pAttr Parser Attr -> Parsec Void Text Text -> Parser Attr
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "]"

    pComm :: Parser Commutativity
    pComm :: Parser Commutativity
    pComm =
      [Parser Commutativity] -> Parser Commutativity
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "commutative" ParsecT Void Text Identity ()
    -> Commutativity -> Parser Commutativity
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Commutativity
    Commutative,
          Commutativity -> Parser Commutativity
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Commutativity
    Noncommutative
        ]

    -- | This record contains parser for all the representation-specific
    -- bits.  Essentially a manually passed-around type class dictionary,
    -- because ambiguities make it impossible to write this with actual
    -- type classes.
    data PR rep = PR
      { forall rep. PR rep -> Parser (RetType rep)
    pRetType :: Parser (RetType rep),
        forall rep. PR rep -> Parser (BranchType rep)
    pBranchType :: Parser (BranchType rep),
        forall rep. PR rep -> Parser (FParamInfo rep)
    pFParamInfo :: Parser (FParamInfo rep),
        forall rep. PR rep -> Parser (LParamInfo rep)
    pLParamInfo :: Parser (LParamInfo rep),
        forall rep. PR rep -> Parser (LetDec rep)
    pLetDec :: Parser (LetDec rep),
        forall rep. PR rep -> Parser (Op rep)
    pOp :: Parser (Op rep),
        forall rep. PR rep -> BodyDec rep
    pBodyDec :: BodyDec rep,
        forall rep. PR rep -> ExpDec rep
    pExpDec :: ExpDec rep
      }

    pRetAls :: Parser RetAls
    pRetAls :: Parser RetAls
    pRetAls = RetAls -> Maybe RetAls -> RetAls
    forall a. a -> Maybe a -> a
    fromMaybe ([Int] -> [Int] -> RetAls
    RetAls [Int]
    forall a. Monoid a => a
    mempty [Int]
    forall a. Monoid a => a
    mempty) (Maybe RetAls -> RetAls)
    -> ParsecT Void Text Identity (Maybe RetAls) -> Parser RetAls
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser RetAls -> ParsecT Void Text Identity (Maybe RetAls)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional Parser RetAls
    p
      where
        p :: Parser RetAls
    p = Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "#" Parsec Void Text Text -> Parser RetAls -> Parser RetAls
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser RetAls -> Parser RetAls
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens ([Int] -> [Int] -> RetAls
    RetAls ([Int] -> [Int] -> RetAls)
    -> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity ([Int] -> RetAls)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [Int]
    pInts ParsecT Void Text Identity ([Int] -> RetAls)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Int] -> RetAls)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ([Int] -> RetAls)
    -> ParsecT Void Text Identity [Int] -> Parser RetAls
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Int]
    pInts)
        pInts :: ParsecT Void Text Identity [Int]
    pInts = ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (ParsecT Void Text Identity [Int]
     -> ParsecT Void Text Identity [Int])
    -> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Int]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pRetTypes :: PR rep -> Parser [(RetType rep, RetAls)]
    pRetTypes :: forall rep. PR rep -> Parser [(RetType rep, RetAls)]
    pRetTypes PR rep
    pr = Parser [(RetType rep, RetAls)] -> Parser [(RetType rep, RetAls)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser [(RetType rep, RetAls)] -> Parser [(RetType rep, RetAls)])
    -> Parser [(RetType rep, RetAls)] -> Parser [(RetType rep, RetAls)]
    forall a b. (a -> b) -> a -> b
    $ ((,) (RetType rep -> RetAls -> (RetType rep, RetAls))
    -> ParsecT Void Text Identity (RetType rep)
    -> ParsecT Void Text Identity (RetAls -> (RetType rep, RetAls))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (RetType rep)
    forall rep. PR rep -> Parser (RetType rep)
    pRetType PR rep
    pr ParsecT Void Text Identity (RetAls -> (RetType rep, RetAls))
    -> Parser RetAls
    -> ParsecT Void Text Identity (RetType rep, RetAls)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser RetAls
    pRetAls) ParsecT Void Text Identity (RetType rep, RetAls)
    -> ParsecT Void Text Identity () -> Parser [(RetType rep, RetAls)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pBranchTypes :: PR rep -> Parser [BranchType rep]
    pBranchTypes :: forall rep. PR rep -> Parser [BranchType rep]
    pBranchTypes PR rep
    pr = Parser [BranchType rep] -> Parser [BranchType rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser [BranchType rep] -> Parser [BranchType rep])
    -> Parser [BranchType rep] -> Parser [BranchType rep]
    forall a b. (a -> b) -> a -> b
    $ PR rep -> ParsecT Void Text Identity (BranchType rep)
    forall rep. PR rep -> Parser (BranchType rep)
    pBranchType PR rep
    pr ParsecT Void Text Identity (BranchType rep)
    -> ParsecT Void Text Identity () -> Parser [BranchType rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pParam :: Parser t -> Parser (Param t)
    pParam :: forall t. Parser t -> Parser (Param t)
    pParam Parser t
    p = Attrs -> VName -> t -> Param t
    forall dec. Attrs -> VName -> dec -> Param dec
    Param (Attrs -> VName -> t -> Param t)
    -> Parser Attrs
    -> ParsecT Void Text Identity (VName -> t -> Param t)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Attrs
    pAttrs ParsecT Void Text Identity (VName -> t -> Param t)
    -> Parser VName -> ParsecT Void Text Identity (t -> Param t)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName ParsecT Void Text Identity (t -> Param t)
    -> Parser t -> ParsecT Void Text Identity (Param t)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Void Text Identity ()
    pColon ParsecT Void Text Identity () -> Parser t -> Parser t
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser t
    p)

    pFParam :: PR rep -> Parser (FParam rep)
    pFParam :: forall rep. PR rep -> Parser (FParam rep)
    pFParam = Parser (FParamInfo rep)
    -> ParsecT Void Text Identity (Param (FParamInfo rep))
    forall t. Parser t -> Parser (Param t)
    pParam (Parser (FParamInfo rep)
     -> ParsecT Void Text Identity (Param (FParamInfo rep)))
    -> (PR rep -> Parser (FParamInfo rep))
    -> PR rep
    -> ParsecT Void Text Identity (Param (FParamInfo rep))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PR rep -> Parser (FParamInfo rep)
    forall rep. PR rep -> Parser (FParamInfo rep)
    pFParamInfo

    pFParams :: PR rep -> Parser [FParam rep]
    pFParams :: forall rep. PR rep -> Parser [FParam rep]
    pFParams PR rep
    pr = Parser [FParam rep] -> Parser [FParam rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser [FParam rep] -> Parser [FParam rep])
    -> Parser [FParam rep] -> Parser [FParam rep]
    forall a b. (a -> b) -> a -> b
    $ PR rep -> ParsecT Void Text Identity (FParam rep)
    forall rep. PR rep -> Parser (FParam rep)
    pFParam PR rep
    pr ParsecT Void Text Identity (FParam rep)
    -> ParsecT Void Text Identity () -> Parser [FParam rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pLParam :: PR rep -> Parser (LParam rep)
    pLParam :: forall rep. PR rep -> Parser (LParam rep)
    pLParam = Parser (LParamInfo rep)
    -> ParsecT Void Text Identity (Param (LParamInfo rep))
    forall t. Parser t -> Parser (Param t)
    pParam (Parser (LParamInfo rep)
     -> ParsecT Void Text Identity (Param (LParamInfo rep)))
    -> (PR rep -> Parser (LParamInfo rep))
    -> PR rep
    -> ParsecT Void Text Identity (Param (LParamInfo rep))
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PR rep -> Parser (LParamInfo rep)
    forall rep. PR rep -> Parser (LParamInfo rep)
    pLParamInfo

    pLParams :: PR rep -> Parser [LParam rep]
    pLParams :: forall rep. PR rep -> Parser [LParam rep]
    pLParams PR rep
    pr = Parser [LParam rep] -> Parser [LParam rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser [LParam rep] -> Parser [LParam rep])
    -> Parser [LParam rep] -> Parser [LParam rep]
    forall a b. (a -> b) -> a -> b
    $ PR rep -> ParsecT Void Text Identity (LParam rep)
    forall rep. PR rep -> Parser (LParam rep)
    pLParam PR rep
    pr ParsecT Void Text Identity (LParam rep)
    -> ParsecT Void Text Identity () -> Parser [LParam rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pPatElem :: PR rep -> Parser (PatElem (LetDec rep))
    pPatElem :: forall rep. PR rep -> Parser (PatElem (LetDec rep))
    pPatElem PR rep
    pr =
      (VName -> LetDec rep -> PatElem (LetDec rep)
    forall dec. VName -> dec -> PatElem dec
    PatElem (VName -> LetDec rep -> PatElem (LetDec rep))
    -> Parser VName
    -> ParsecT Void Text Identity (LetDec rep -> PatElem (LetDec rep))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (LetDec rep -> PatElem (LetDec rep))
    -> ParsecT Void Text Identity (LetDec rep)
    -> ParsecT Void Text Identity (PatElem (LetDec rep))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Void Text Identity ()
    pColon ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (LetDec rep)
    -> ParsecT Void Text Identity (LetDec rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity (LetDec rep)
    forall rep. PR rep -> Parser (LetDec rep)
    pLetDec PR rep
    pr)) ParsecT Void Text Identity (PatElem (LetDec rep))
    -> String -> ParsecT Void Text Identity (PatElem (LetDec rep))
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "pattern element"

    pPat :: PR rep -> Parser (Pat (LetDec rep))
    pPat :: forall rep. PR rep -> Parser (Pat (LetDec rep))
    pPat PR rep
    pr = [PatElem (LetDec rep)] -> Pat (LetDec rep)
    forall dec. [PatElem dec] -> Pat dec
    Pat ([PatElem (LetDec rep)] -> Pat (LetDec rep))
    -> ParsecT Void Text Identity [PatElem (LetDec rep)]
    -> ParsecT Void Text Identity (Pat (LetDec rep))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [PatElem (LetDec rep)]
    -> ParsecT Void Text Identity [PatElem (LetDec rep)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (PatElem (LetDec rep))
    forall rep. PR rep -> Parser (PatElem (LetDec rep))
    pPatElem PR rep
    pr ParsecT Void Text Identity (PatElem (LetDec rep))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [PatElem (LetDec rep)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pResult :: Parser Result
    pResult :: Parser Result
    pResult = Parser Result -> Parser Result
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser Result -> Parser Result) -> Parser Result -> Parser Result
    forall a b. (a -> b) -> a -> b
    $ Parser SubExpRes
    pSubExpRes Parser SubExpRes -> ParsecT Void Text Identity () -> Parser Result
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma

    pMatchSort :: Parser MatchSort
    pMatchSort :: Parser MatchSort
    pMatchSort =
      [Parser MatchSort] -> Parser MatchSort
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<fallback>" Parsec Void Text Text -> MatchSort -> Parser MatchSort
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> MatchSort
    MatchFallback,
          Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<equiv>" Parsec Void Text Text -> MatchSort -> Parser MatchSort
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> MatchSort
    MatchEquiv,
          MatchSort -> Parser MatchSort
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure MatchSort
    MatchNormal
        ]

    pBranchBody :: PR rep -> Parser (Body rep)
    pBranchBody :: forall rep. PR rep -> Parser (Body rep)
    pBranchBody PR rep
    pr =
      [ParsecT Void Text Identity (Body rep)]
    -> ParsecT Void Text Identity (Body rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (ParsecT Void Text Identity (Body rep)
     -> ParsecT Void Text Identity (Body rep))
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a b. (a -> b) -> a -> b
    $ BodyDec rep -> Stms rep -> Result -> Body rep
    forall rep. BodyDec rep -> Stms rep -> Result -> Body rep
    Body (PR rep -> BodyDec rep
    forall rep. PR rep -> BodyDec rep
    pBodyDec PR rep
    pr) Stms rep
    forall a. Monoid a => a
    mempty (Result -> Body rep)
    -> Parser Result -> ParsecT Void Text Identity (Body rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Result
    pResult,
          ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr)
        ]

    pIf :: PR rep -> Parser (Exp rep)
    pIf :: forall rep. PR rep -> Parser (Exp rep)
    pIf PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "if"
        ParsecT Void Text Identity ()
    -> (MatchSort
        -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT
         Void
         Text
         Identity
         (MatchSort
          -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> MatchSort
    -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep
    forall {rep}.
    MatchSort
    -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep
    f
        ParsecT
      Void
      Text
      Identity
      (MatchSort
       -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    -> Parser MatchSort
    -> ParsecT
         Void
         Text
         Identity
         (SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser MatchSort
    pMatchSort
        ParsecT
      Void
      Text
      Identity
      (SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         (Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
        ParsecT
      Void
      Text
      Identity
      (Body rep -> Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT
         Void Text Identity (Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "then" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBranchBody PR rep
    pr)
        ParsecT
      Void Text Identity (Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity ([BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "else" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBranchBody PR rep
    pr)
        ParsecT Void Text Identity ([BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity [BranchType rep]
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":" Parsec Void Text Text
    -> ParsecT Void Text Identity [BranchType rep]
    -> ParsecT Void Text Identity [BranchType rep]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity [BranchType rep]
    forall rep. PR rep -> Parser [BranchType rep]
    pBranchTypes PR rep
    pr)
      where
        f :: MatchSort
    -> SubExp -> Body rep -> Body rep -> [BranchType rep] -> Exp rep
    f MatchSort
    sort SubExp
    cond Body rep
    tbranch Body rep
    fbranch [BranchType rep]
    t =
          [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> MatchDec (BranchType rep)
    -> Exp rep
    forall rep.
    [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> MatchDec (BranchType rep)
    -> Exp rep
    Match [SubExp
    cond] [[Maybe PrimValue] -> Body rep -> Case (Body rep)
    forall body. [Maybe PrimValue] -> body -> Case body
    Case [PrimValue -> Maybe PrimValue
    forall a. a -> Maybe a
    Just (PrimValue -> Maybe PrimValue) -> PrimValue -> Maybe PrimValue
    forall a b. (a -> b) -> a -> b
    $ Bool -> PrimValue
    BoolValue Bool
    True] Body rep
    tbranch] Body rep
    fbranch (MatchDec (BranchType rep) -> Exp rep)
    -> MatchDec (BranchType rep) -> Exp rep
    forall a b. (a -> b) -> a -> b
    $ [BranchType rep] -> MatchSort -> MatchDec (BranchType rep)
    forall rt. [rt] -> MatchSort -> MatchDec rt
    MatchDec [BranchType rep]
    t MatchSort
    sort

    pMatch :: PR rep -> Parser (Exp rep)
    pMatch :: forall rep. PR rep -> Parser (Exp rep)
    pMatch PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "match"
        ParsecT Void Text Identity ()
    -> (MatchSort
        -> [SubExp]
        -> [Case (Body rep)]
        -> Body rep
        -> [BranchType rep]
        -> Exp rep)
    -> ParsecT
         Void
         Text
         Identity
         (MatchSort
          -> [SubExp]
          -> [Case (Body rep)]
          -> Body rep
          -> [BranchType rep]
          -> Exp rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> MatchSort
    -> [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> [BranchType rep]
    -> Exp rep
    forall {rep}.
    MatchSort
    -> [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> [BranchType rep]
    -> Exp rep
    f
        ParsecT
      Void
      Text
      Identity
      (MatchSort
       -> [SubExp]
       -> [Case (Body rep)]
       -> Body rep
       -> [BranchType rep]
       -> Exp rep)
    -> Parser MatchSort
    -> ParsecT
         Void
         Text
         Identity
         ([SubExp]
          -> [Case (Body rep)] -> Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser MatchSort
    pMatchSort
        ParsecT
      Void
      Text
      Identity
      ([SubExp]
       -> [Case (Body rep)] -> Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT
         Void
         Text
         Identity
         ([Case (Body rep)] -> Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        ParsecT
      Void
      Text
      Identity
      ([Case (Body rep)] -> Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity [Case (Body rep)]
    -> ParsecT
         Void Text Identity (Body rep -> [BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Case (Body rep))
    -> ParsecT Void Text Identity [Case (Body rep)]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ParsecT Void Text Identity (Case (Body rep))
    pCase
        ParsecT
      Void Text Identity (Body rep -> [BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity ([BranchType rep] -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "default" ParsecT Void Text Identity ()
    -> Parsec Void Text Text -> Parsec Void Text Text
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->" Parsec Void Text Text
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBranchBody PR rep
    pr)
        ParsecT Void Text Identity ([BranchType rep] -> Exp rep)
    -> ParsecT Void Text Identity [BranchType rep]
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":" Parsec Void Text Text
    -> ParsecT Void Text Identity [BranchType rep]
    -> ParsecT Void Text Identity [BranchType rep]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> PR rep -> ParsecT Void Text Identity [BranchType rep]
    forall rep. PR rep -> Parser [BranchType rep]
    pBranchTypes PR rep
    pr)
      where
        f :: MatchSort
    -> [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> [BranchType rep]
    -> Exp rep
    f MatchSort
    sort [SubExp]
    cond [Case (Body rep)]
    cases Body rep
    defbody [BranchType rep]
    t =
          [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> MatchDec (BranchType rep)
    -> Exp rep
    forall rep.
    [SubExp]
    -> [Case (Body rep)]
    -> Body rep
    -> MatchDec (BranchType rep)
    -> Exp rep
    Match [SubExp]
    cond [Case (Body rep)]
    cases Body rep
    defbody (MatchDec (BranchType rep) -> Exp rep)
    -> MatchDec (BranchType rep) -> Exp rep
    forall a b. (a -> b) -> a -> b
    $ [BranchType rep] -> MatchSort -> MatchDec (BranchType rep)
    forall rt. [rt] -> MatchSort -> MatchDec rt
    MatchDec [BranchType rep]
    t MatchSort
    sort
        pCase :: ParsecT Void Text Identity (Case (Body rep))
    pCase =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "case"
            ParsecT Void Text Identity ()
    -> ([Maybe PrimValue] -> Body rep -> Case (Body rep))
    -> ParsecT
         Void
         Text
         Identity
         ([Maybe PrimValue] -> Body rep -> Case (Body rep))
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [Maybe PrimValue] -> Body rep -> Case (Body rep)
    forall body. [Maybe PrimValue] -> body -> Case body
    Case
            ParsecT
      Void
      Text
      Identity
      ([Maybe PrimValue] -> Body rep -> Case (Body rep))
    -> ParsecT Void Text Identity [Maybe PrimValue]
    -> ParsecT Void Text Identity (Body rep -> Case (Body rep))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Maybe PrimValue]
    -> ParsecT Void Text Identity [Maybe PrimValue]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity (Maybe PrimValue)
    pMaybeValue ParsecT Void Text Identity (Maybe PrimValue)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Maybe PrimValue]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity (Body rep -> Case (Body rep))
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (Body rep -> Case (Body rep))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->"
            ParsecT Void Text Identity (Body rep -> Case (Body rep))
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Case (Body rep))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBranchBody PR rep
    pr
        pMaybeValue :: ParsecT Void Text Identity (Maybe PrimValue)
    pMaybeValue =
          [ParsecT Void Text Identity (Maybe PrimValue)]
    -> ParsecT Void Text Identity (Maybe PrimValue)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "_" Parsec Void Text Text
    -> Maybe PrimValue -> ParsecT Void Text Identity (Maybe PrimValue)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Maybe PrimValue
    forall a. Maybe a
    Nothing, PrimValue -> Maybe PrimValue
    forall a. a -> Maybe a
    Just (PrimValue -> Maybe PrimValue)
    -> ParsecT Void Text Identity PrimValue
    -> ParsecT Void Text Identity (Maybe PrimValue)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimValue
    pPrimValue]

    pApply :: PR rep -> Parser (Exp rep)
    pApply :: forall rep. PR rep -> Parser (Exp rep)
    pApply PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "apply" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Exp rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (Safety -> ParsecT Void Text Identity (Exp rep)
    forall {rep}.
    (RetType rep ~ RetType rep) =>
    Safety -> ParsecT Void Text Identity (Exp rep)
    p (Safety -> ParsecT Void Text Identity (Exp rep))
    -> ParsecT Void Text Identity Safety
    -> ParsecT Void Text Identity (Exp rep)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< [ParsecT Void Text Identity Safety]
    -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<unsafe>" Parsec Void Text Text
    -> Safety -> ParsecT Void Text Identity Safety
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Safety
    Unsafe, Safety -> ParsecT Void Text Identity Safety
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Safety
    Safe])
      where
        p :: Safety -> ParsecT Void Text Identity (Exp rep)
    p Safety
    safety =
          Name
    -> [(SubExp, Diet)]
    -> [(RetType rep, RetAls)]
    -> (Safety, SrcLoc, [SrcLoc])
    -> Exp rep
    forall rep.
    Name
    -> [(SubExp, Diet)]
    -> [(RetType rep, RetAls)]
    -> (Safety, SrcLoc, [SrcLoc])
    -> Exp rep
    Apply
            (Name
     -> [(SubExp, Diet)]
     -> [(RetType rep, RetAls)]
     -> (Safety, SrcLoc, [SrcLoc])
     -> Exp rep)
    -> Parser Name
    -> ParsecT
         Void
         Text
         Identity
         ([(SubExp, Diet)]
          -> [(RetType rep, RetAls)]
          -> (Safety, SrcLoc, [SrcLoc])
          -> Exp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName
            ParsecT
      Void
      Text
      Identity
      ([(SubExp, Diet)]
       -> [(RetType rep, RetAls)]
       -> (Safety, SrcLoc, [SrcLoc])
       -> Exp rep)
    -> ParsecT Void Text Identity [(SubExp, Diet)]
    -> ParsecT
         Void
         Text
         Identity
         ([(RetType rep, RetAls)] -> (Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(SubExp, Diet)]
    -> ParsecT Void Text Identity [(SubExp, Diet)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (SubExp, Diet)
    pArg ParsecT Void Text Identity (SubExp, Diet)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [(SubExp, Diet)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT
      Void
      Text
      Identity
      ([(RetType rep, RetAls)] -> (Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([(RetType rep, RetAls)] -> (Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon
            ParsecT
      Void
      Text
      Identity
      ([(RetType rep, RetAls)] -> (Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    -> ParsecT Void Text Identity [(RetType rep, RetAls)]
    -> ParsecT
         Void Text Identity ((Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> Parser [(RetType rep, RetAls)]
    forall rep. PR rep -> Parser [(RetType rep, RetAls)]
    pRetTypes PR rep
    pr
            ParsecT Void Text Identity ((Safety, SrcLoc, [SrcLoc]) -> Exp rep)
    -> ParsecT Void Text Identity (Safety, SrcLoc, [SrcLoc])
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Safety, SrcLoc, [SrcLoc])
    -> ParsecT Void Text Identity (Safety, SrcLoc, [SrcLoc])
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Safety
    safety, SrcLoc
    forall a. Monoid a => a
    mempty, [SrcLoc]
    forall a. Monoid a => a
    mempty)

        pArg :: ParsecT Void Text Identity (SubExp, Diet)
    pArg =
          [ParsecT Void Text Identity (SubExp, Diet)]
    -> ParsecT Void Text Identity (SubExp, Diet)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
            [ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "*" Parsec Void Text Text
    -> (SubExp -> (SubExp, Diet))
    -> ParsecT Void Text Identity (SubExp -> (SubExp, Diet))
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (,Diet
    Consume) ParsecT Void Text Identity (SubExp -> (SubExp, Diet))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp, Diet)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp,
              (,Diet
    Observe) (SubExp -> (SubExp, Diet))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp, Diet)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
            ]

    pLoop :: PR rep -> Parser (Exp rep)
    pLoop :: forall rep. PR rep -> Parser (Exp rep)
    pLoop PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "loop"
        ParsecT Void Text Identity ()
    -> ([(Param (FParamInfo rep), SubExp)]
        -> LoopForm -> Body rep -> Exp rep)
    -> ParsecT
         Void
         Text
         Identity
         ([(Param (FParamInfo rep), SubExp)]
          -> LoopForm -> Body rep -> Exp rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [(Param (FParamInfo rep), SubExp)]
    -> LoopForm -> Body rep -> Exp rep
    forall rep.
    [(FParam rep, SubExp)] -> LoopForm -> Body rep -> Exp rep
    Loop
        ParsecT
      Void
      Text
      Identity
      ([(Param (FParamInfo rep), SubExp)]
       -> LoopForm -> Body rep -> Exp rep)
    -> ParsecT Void Text Identity [(Param (FParamInfo rep), SubExp)]
    -> ParsecT Void Text Identity (LoopForm -> Body rep -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(Param (FParamInfo rep), SubExp)]
    pLoopParams
        ParsecT Void Text Identity (LoopForm -> Body rep -> Exp rep)
    -> ParsecT Void Text Identity LoopForm
    -> ParsecT Void Text Identity (Body rep -> Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity LoopForm
    pLoopForm
        ParsecT Void Text Identity (Body rep -> Exp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Body rep -> Exp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "do"
        ParsecT Void Text Identity (Body rep -> Exp rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr)
      where
        pLoopParams :: ParsecT Void Text Identity [(Param (FParamInfo rep), SubExp)]
    pLoopParams = do
          [Param (FParamInfo rep)]
    params <- Parser [Param (FParamInfo rep)] -> Parser [Param (FParamInfo rep)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser [Param (FParamInfo rep)]
     -> Parser [Param (FParamInfo rep)])
    -> Parser [Param (FParamInfo rep)]
    -> Parser [Param (FParamInfo rep)]
    forall a b. (a -> b) -> a -> b
    $ PR rep -> ParsecT Void Text Identity (Param (FParamInfo rep))
    forall rep. PR rep -> Parser (FParam rep)
    pFParam PR rep
    pr ParsecT Void Text Identity (Param (FParamInfo rep))
    -> ParsecT Void Text Identity () -> Parser [Param (FParamInfo rep)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma
          Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "="
          [SubExp]
    args <- ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
          [(Param (FParamInfo rep), SubExp)]
    -> ParsecT Void Text Identity [(Param (FParamInfo rep), SubExp)]
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ([Param (FParamInfo rep)]
    -> [SubExp] -> [(Param (FParamInfo rep), SubExp)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [Param (FParamInfo rep)]
    params [SubExp]
    args)

        pLoopForm :: ParsecT Void Text Identity LoopForm
    pLoopForm =
          [ParsecT Void Text Identity LoopForm]
    -> ParsecT Void Text Identity LoopForm
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
            [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "for"
                ParsecT Void Text Identity ()
    -> (VName -> IntType -> SubExp -> LoopForm)
    -> ParsecT
         Void Text Identity (VName -> IntType -> SubExp -> LoopForm)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> VName -> IntType -> SubExp -> LoopForm
    ForLoop
                ParsecT Void Text Identity (VName -> IntType -> SubExp -> LoopForm)
    -> Parser VName
    -> ParsecT Void Text Identity (IntType -> SubExp -> LoopForm)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName
                ParsecT Void Text Identity (IntType -> SubExp -> LoopForm)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (IntType -> SubExp -> LoopForm)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    ":"
                ParsecT Void Text Identity (IntType -> SubExp -> LoopForm)
    -> ParsecT Void Text Identity IntType
    -> ParsecT Void Text Identity (SubExp -> LoopForm)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity IntType
    pIntType
                ParsecT Void Text Identity (SubExp -> LoopForm)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> LoopForm)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<"
                ParsecT Void Text Identity (SubExp -> LoopForm)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity LoopForm
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp,
              Text -> ParsecT Void Text Identity ()
    keyword Text
    "while" ParsecT Void Text Identity ()
    -> (VName -> LoopForm)
    -> ParsecT Void Text Identity (VName -> LoopForm)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> VName -> LoopForm
    WhileLoop ParsecT Void Text Identity (VName -> LoopForm)
    -> Parser VName -> ParsecT Void Text Identity LoopForm
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName
            ]

    pLambda :: PR rep -> Parser (Lambda rep)
    pLambda :: forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr =
      [ParsecT Void Text Identity (Lambda rep)]
    -> ParsecT Void Text Identity (Lambda rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "\\"
            Parsec Void Text Text
    -> ([Param (LParamInfo rep)] -> [Type] -> Body rep -> Lambda rep)
    -> ParsecT
         Void
         Text
         Identity
         ([Param (LParamInfo rep)] -> [Type] -> Body rep -> Lambda rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [Param (LParamInfo rep)] -> [Type] -> Body rep -> Lambda rep
    forall rep. [LParam rep] -> [Type] -> Body rep -> Lambda rep
    Lambda
            ParsecT
      Void
      Text
      Identity
      ([Param (LParamInfo rep)] -> [Type] -> Body rep -> Lambda rep)
    -> ParsecT Void Text Identity [Param (LParamInfo rep)]
    -> ParsecT Void Text Identity ([Type] -> Body rep -> Lambda rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity [Param (LParamInfo rep)]
    forall rep. PR rep -> Parser [LParam rep]
    pLParams PR rep
    pr
            ParsecT Void Text Identity ([Type] -> Body rep -> Lambda rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Type] -> Body rep -> Lambda rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon
            ParsecT Void Text Identity ([Type] -> Body rep -> Lambda rep)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity (Body rep -> Lambda rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Type]
    pTypes
            ParsecT Void Text Identity (Body rep -> Lambda rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Body rep -> Lambda rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pArrow
            ParsecT Void Text Identity (Body rep -> Lambda rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Lambda rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "nilFn" ParsecT Void Text Identity ()
    -> Lambda rep -> ParsecT Void Text Identity (Lambda rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [Param (LParamInfo rep)] -> [Type] -> Body rep -> Lambda rep
    forall rep. [LParam rep] -> [Type] -> Body rep -> Lambda rep
    Lambda [Param (LParamInfo rep)]
    forall a. Monoid a => a
    mempty [] (BodyDec rep -> Stms rep -> Result -> Body rep
    forall rep. BodyDec rep -> Stms rep -> Result -> Body rep
    Body (PR rep -> BodyDec rep
    forall rep. PR rep -> BodyDec rep
    pBodyDec PR rep
    pr) Stms rep
    forall a. Monoid a => a
    mempty [])
        ]

    pReduce :: PR rep -> Parser (SOAC.Reduce rep)
    pReduce :: forall rep. PR rep -> Parser (Reduce rep)
    pReduce PR rep
    pr =
      Commutativity -> Lambda rep -> [SubExp] -> Reduce rep
    forall rep. Commutativity -> Lambda rep -> [SubExp] -> Reduce rep
    SOAC.Reduce
        (Commutativity -> Lambda rep -> [SubExp] -> Reduce rep)
    -> Parser Commutativity
    -> ParsecT
         Void Text Identity (Lambda rep -> [SubExp] -> Reduce rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Commutativity
    pComm
        ParsecT Void Text Identity (Lambda rep -> [SubExp] -> Reduce rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity ([SubExp] -> Reduce rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        ParsecT Void Text Identity ([SubExp] -> Reduce rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> Reduce rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
        ParsecT Void Text Identity ([SubExp] -> Reduce rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Reduce rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pScan :: PR rep -> Parser (SOAC.Scan rep)
    pScan :: forall rep. PR rep -> Parser (Scan rep)
    pScan PR rep
    pr =
      Lambda rep -> [SubExp] -> Scan rep
    forall rep. Lambda rep -> [SubExp] -> Scan rep
    SOAC.Scan
        (Lambda rep -> [SubExp] -> Scan rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity ([SubExp] -> Scan rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        ParsecT Void Text Identity ([SubExp] -> Scan rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> Scan rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
        ParsecT Void Text Identity ([SubExp] -> Scan rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Scan rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pWithAcc :: PR rep -> Parser (Exp rep)
    pWithAcc :: forall rep. PR rep -> Parser (Exp rep)
    pWithAcc PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "with_acc"
        ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Exp rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (Exp rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens ([WithAccInput rep] -> Lambda rep -> Exp rep
    forall rep. [WithAccInput rep] -> Lambda rep -> Exp rep
    WithAcc ([WithAccInput rep] -> Lambda rep -> Exp rep)
    -> ParsecT Void Text Identity [WithAccInput rep]
    -> ParsecT Void Text Identity (Lambda rep -> Exp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [WithAccInput rep]
    -> ParsecT Void Text Identity [WithAccInput rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser (WithAccInput rep)
    pInput Parser (WithAccInput rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [WithAccInput rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma) ParsecT Void Text Identity (Lambda rep -> Exp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> Exp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (Lambda rep -> Exp rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr)
      where
        pInput :: Parser (WithAccInput rep)
    pInput =
          Parser (WithAccInput rep) -> Parser (WithAccInput rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
            ( (,,)
                (Shape
     -> [VName] -> Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    -> ParsecT Void Text Identity Shape
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape
                ParsecT
      Void
      Text
      Identity
      ([VName] -> Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                ParsecT
      Void
      Text
      Identity
      ([VName] -> Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    -> Parser [VName]
    -> ParsecT
         Void
         Text
         Identity
         (Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName]
    pVNames
                ParsecT
      Void
      Text
      Identity
      (Maybe (Lambda rep, [SubExp]) -> WithAccInput rep)
    -> ParsecT Void Text Identity (Maybe (Lambda rep, [SubExp]))
    -> Parser (WithAccInput rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Lambda rep, [SubExp])
    -> ParsecT Void Text Identity (Maybe (Lambda rep, [SubExp]))
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep, [SubExp])
    -> ParsecT Void Text Identity (Lambda rep, [SubExp])
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (Lambda rep, [SubExp])
    pCombFun)
            )
        pCombFun :: ParsecT Void Text Identity (Lambda rep, [SubExp])
    pCombFun = ParsecT Void Text Identity (Lambda rep, [SubExp])
    -> ParsecT Void Text Identity (Lambda rep, [SubExp])
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens ((,) (Lambda rep -> [SubExp] -> (Lambda rep, [SubExp]))
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity ([SubExp] -> (Lambda rep, [SubExp]))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr ParsecT Void Text Identity ([SubExp] -> (Lambda rep, [SubExp]))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> (Lambda rep, [SubExp]))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ([SubExp] -> (Lambda rep, [SubExp]))
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Lambda rep, [SubExp])
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    pSubExps)

    pExp :: PR rep -> Parser (Exp rep)
    pExp :: forall rep. PR rep -> Parser (Exp rep)
    pExp PR rep
    pr =
      [ParsecT Void Text Identity (Exp rep)]
    -> ParsecT Void Text Identity (Exp rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pIf PR rep
    pr,
          PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pMatch PR rep
    pr,
          PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pApply PR rep
    pr,
          PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pLoop PR rep
    pr,
          PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pWithAcc PR rep
    pr,
          Op rep -> Exp rep
    forall rep. Op rep -> Exp rep
    Op (Op rep -> Exp rep)
    -> ParsecT Void Text Identity (Op rep)
    -> ParsecT Void Text Identity (Exp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Op rep)
    forall rep. PR rep -> Parser (Op rep)
    pOp PR rep
    pr,
          BasicOp -> Exp rep
    forall rep. BasicOp -> Exp rep
    BasicOp (BasicOp -> Exp rep)
    -> Parser BasicOp -> ParsecT Void Text Identity (Exp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser BasicOp
    pBasicOp
        ]

    pCerts :: Parser Certs
    pCerts :: Parser Certs
    pCerts =
      [Parser Certs] -> Parser Certs
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "#"
            Parsec Void Text Text -> Parser Certs -> Parser Certs
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser Certs -> Parser Certs
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces ([VName] -> Certs
    Certs ([VName] -> Certs) -> Parser [VName] -> Parser Certs
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            Parser Certs -> String -> Parser Certs
    forall e s (m :: * -> *) a.
    MonadParsec e s m =>
    m a -> String -> m a
    <?> String
    "certificates",
          Certs -> Parser Certs
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Certs
    forall a. Monoid a => a
    mempty
        ]

    pSubExpRes :: Parser SubExpRes
    pSubExpRes :: Parser SubExpRes
    pSubExpRes = Certs -> SubExp -> SubExpRes
    SubExpRes (Certs -> SubExp -> SubExpRes)
    -> Parser Certs -> ParsecT Void Text Identity (SubExp -> SubExpRes)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Certs
    pCerts ParsecT Void Text Identity (SubExp -> SubExpRes)
    -> ParsecT Void Text Identity SubExp -> Parser SubExpRes
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp

    pStm :: PR rep -> Parser (Stm rep)
    pStm :: forall rep. PR rep -> Parser (Stm rep)
    pStm PR rep
    pr =
      Text -> ParsecT Void Text Identity ()
    keyword Text
    "let" ParsecT Void Text Identity ()
    -> (Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    -> ParsecT
         Void
         Text
         Identity
         (Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp rep -> Stm rep
    forall rep.
    Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp rep -> Stm rep
    Let ParsecT
      Void
      Text
      Identity
      (Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    -> ParsecT Void Text Identity (Pat (LetDec rep))
    -> ParsecT
         Void Text Identity (StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Pat (LetDec rep))
    forall rep. PR rep -> Parser (Pat (LetDec rep))
    pPat PR rep
    pr ParsecT
      Void Text Identity (StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pEqual ParsecT
      Void Text Identity (StmAux (ExpDec rep) -> Exp rep -> Stm rep)
    -> ParsecT Void Text Identity (StmAux (ExpDec rep))
    -> ParsecT Void Text Identity (Exp rep -> Stm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (StmAux (ExpDec rep))
    pStmAux ParsecT Void Text Identity (Exp rep -> Stm rep)
    -> ParsecT Void Text Identity (Exp rep)
    -> ParsecT Void Text Identity (Stm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Exp rep)
    forall rep. PR rep -> Parser (Exp rep)
    pExp PR rep
    pr
      where
        pStmAux :: ParsecT Void Text Identity (StmAux (ExpDec rep))
    pStmAux = (Certs -> Attrs -> ExpDec rep -> StmAux (ExpDec rep))
    -> Attrs -> Certs -> ExpDec rep -> StmAux (ExpDec rep)
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Certs -> Attrs -> ExpDec rep -> StmAux (ExpDec rep)
    forall dec. Certs -> Attrs -> dec -> StmAux dec
    StmAux (Attrs -> Certs -> ExpDec rep -> StmAux (ExpDec rep))
    -> Parser Attrs
    -> ParsecT
         Void Text Identity (Certs -> ExpDec rep -> StmAux (ExpDec rep))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Attrs
    pAttrs ParsecT
      Void Text Identity (Certs -> ExpDec rep -> StmAux (ExpDec rep))
    -> Parser Certs
    -> ParsecT Void Text Identity (ExpDec rep -> StmAux (ExpDec rep))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Certs
    pCerts ParsecT Void Text Identity (ExpDec rep -> StmAux (ExpDec rep))
    -> ParsecT Void Text Identity (ExpDec rep)
    -> ParsecT Void Text Identity (StmAux (ExpDec rep))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ExpDec rep -> ParsecT Void Text Identity (ExpDec rep)
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (PR rep -> ExpDec rep
    forall rep. PR rep -> ExpDec rep
    pExpDec PR rep
    pr)

    pStms :: PR rep -> Parser (Stms rep)
    pStms :: forall rep. PR rep -> Parser (Stms rep)
    pStms PR rep
    pr = [Stm rep] -> Stms rep
    forall rep. [Stm rep] -> Stms rep
    stmsFromList ([Stm rep] -> Stms rep)
    -> ParsecT Void Text Identity [Stm rep]
    -> ParsecT Void Text Identity (Stms rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (Stm rep)
    -> ParsecT Void Text Identity [Stm rep]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (PR rep -> ParsecT Void Text Identity (Stm rep)
    forall rep. PR rep -> Parser (Stm rep)
    pStm PR rep
    pr)

    pBody :: PR rep -> Parser (Body rep)
    pBody :: forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr =
      [ParsecT Void Text Identity (Body rep)]
    -> ParsecT Void Text Identity (Body rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ BodyDec rep -> Stms rep -> Result -> Body rep
    forall rep. BodyDec rep -> Stms rep -> Result -> Body rep
    Body (PR rep -> BodyDec rep
    forall rep. PR rep -> BodyDec rep
    pBodyDec PR rep
    pr) (Stms rep -> Result -> Body rep)
    -> ParsecT Void Text Identity (Stms rep)
    -> ParsecT Void Text Identity (Result -> Body rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Stms rep)
    forall rep. PR rep -> Parser (Stms rep)
    pStms PR rep
    pr ParsecT Void Text Identity (Result -> Body rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Result -> Body rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "in" ParsecT Void Text Identity (Result -> Body rep)
    -> Parser Result -> ParsecT Void Text Identity (Body rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Result
    pResult,
          BodyDec rep -> Stms rep -> Result -> Body rep
    forall rep. BodyDec rep -> Stms rep -> Result -> Body rep
    Body (PR rep -> BodyDec rep
    forall rep. PR rep -> BodyDec rep
    pBodyDec PR rep
    pr) Stms rep
    forall a. Monoid a => a
    mempty (Result -> Body rep)
    -> Parser Result -> ParsecT Void Text Identity (Body rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Result
    pResult
        ]

    pValueType :: Parser ValueType
    pValueType :: Parser ValueType
    pValueType = Rank -> (Signedness, PrimType) -> ValueType
    comb (Rank -> (Signedness, PrimType) -> ValueType)
    -> Parser Rank
    -> ParsecT Void Text Identity ((Signedness, PrimType) -> ValueType)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Rank
    pRank ParsecT Void Text Identity ((Signedness, PrimType) -> ValueType)
    -> ParsecT Void Text Identity (Signedness, PrimType)
    -> Parser ValueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Signedness, PrimType)
    pSignedType
      where
        comb :: Rank -> (Signedness, PrimType) -> ValueType
    comb Rank
    r (Signedness
    s, PrimType
    t) = Signedness -> Rank -> PrimType -> ValueType
    ValueType Signedness
    s Rank
    r PrimType
    t
        pSignedType :: ParsecT Void Text Identity (Signedness, PrimType)
    pSignedType =
          [ParsecT Void Text Identity (Signedness, PrimType)]
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
            [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "u8" ParsecT Void Text Identity ()
    -> (Signedness, PrimType)
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (Signedness
    Unsigned, IntType -> PrimType
    IntType IntType
    Int8),
              Text -> ParsecT Void Text Identity ()
    keyword Text
    "u16" ParsecT Void Text Identity ()
    -> (Signedness, PrimType)
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (Signedness
    Unsigned, IntType -> PrimType
    IntType IntType
    Int16),
              Text -> ParsecT Void Text Identity ()
    keyword Text
    "u32" ParsecT Void Text Identity ()
    -> (Signedness, PrimType)
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (Signedness
    Unsigned, IntType -> PrimType
    IntType IntType
    Int32),
              Text -> ParsecT Void Text Identity ()
    keyword Text
    "u64" ParsecT Void Text Identity ()
    -> (Signedness, PrimType)
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (Signedness
    Unsigned, IntType -> PrimType
    IntType IntType
    Int64),
              (Signedness
    Signed,) (PrimType -> (Signedness, PrimType))
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity (Signedness, PrimType)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimType
    pPrimType
            ]

    pEntryPointType :: Parser EntryPointType
    pEntryPointType :: Parser EntryPointType
    pEntryPointType =
      [Parser EntryPointType] -> Parser EntryPointType
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "opaque" ParsecT Void Text Identity ()
    -> (Text -> EntryPointType)
    -> ParsecT Void Text Identity (Text -> EntryPointType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Name -> EntryPointType
    TypeOpaque (Name -> EntryPointType)
    -> (Text -> Name) -> Text -> EntryPointType
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Name
    nameFromText ParsecT Void Text Identity (Text -> EntryPointType)
    -> Parsec Void Text Text -> Parser EntryPointType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parsec Void Text Text
    pStringLiteral,
          ValueType -> EntryPointType
    TypeTransparent (ValueType -> EntryPointType)
    -> Parser ValueType -> Parser EntryPointType
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser ValueType
    pValueType
        ]

    pEntry :: Parser EntryPoint
    pEntry :: Parser EntryPoint
    pEntry =
      Parser EntryPoint -> Parser EntryPoint
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser EntryPoint -> Parser EntryPoint)
    -> Parser EntryPoint -> Parser EntryPoint
    forall a b. (a -> b) -> a -> b
    $
        (,,)
          (Name -> [EntryParam] -> [EntryResult] -> EntryPoint)
    -> Parser Name
    -> ParsecT
         Void Text Identity ([EntryParam] -> [EntryResult] -> EntryPoint)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Text -> Name
    nameFromText (Text -> Name) -> Parsec Void Text Text -> Parser Name
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral)
          ParsecT
      Void Text Identity ([EntryParam] -> [EntryResult] -> EntryPoint)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([EntryParam] -> [EntryResult] -> EntryPoint)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
          ParsecT
      Void Text Identity ([EntryParam] -> [EntryResult] -> EntryPoint)
    -> ParsecT Void Text Identity [EntryParam]
    -> ParsecT Void Text Identity ([EntryResult] -> EntryPoint)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [EntryParam]
    pEntryPointInputs
          ParsecT Void Text Identity ([EntryResult] -> EntryPoint)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([EntryResult] -> EntryPoint)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
          ParsecT Void Text Identity ([EntryResult] -> EntryPoint)
    -> ParsecT Void Text Identity [EntryResult] -> Parser EntryPoint
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [EntryResult]
    pEntryPointResults
      where
        pEntryPointInputs :: ParsecT Void Text Identity [EntryParam]
    pEntryPointInputs = ParsecT Void Text Identity [EntryParam]
    -> ParsecT Void Text Identity [EntryParam]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity EntryParam
    pEntryPointInput ParsecT Void Text Identity EntryParam
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [EntryParam]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        pEntryPointResults :: ParsecT Void Text Identity [EntryResult]
    pEntryPointResults = ParsecT Void Text Identity [EntryResult]
    -> ParsecT Void Text Identity [EntryResult]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity EntryResult
    pEntryPointResult ParsecT Void Text Identity EntryResult
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [EntryResult]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        pEntryPointInput :: ParsecT Void Text Identity EntryParam
    pEntryPointInput =
          Name -> Uniqueness -> EntryPointType -> EntryParam
    EntryParam (Name -> Uniqueness -> EntryPointType -> EntryParam)
    -> Parser Name
    -> ParsecT
         Void Text Identity (Uniqueness -> EntryPointType -> EntryParam)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName ParsecT
      Void Text Identity (Uniqueness -> EntryPointType -> EntryParam)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (Uniqueness -> EntryPointType -> EntryParam)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon ParsecT
      Void Text Identity (Uniqueness -> EntryPointType -> EntryParam)
    -> Parser Uniqueness
    -> ParsecT Void Text Identity (EntryPointType -> EntryParam)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Uniqueness
    pUniqueness ParsecT Void Text Identity (EntryPointType -> EntryParam)
    -> Parser EntryPointType -> ParsecT Void Text Identity EntryParam
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser EntryPointType
    pEntryPointType
        pEntryPointResult :: ParsecT Void Text Identity EntryResult
    pEntryPointResult =
          Uniqueness -> EntryPointType -> EntryResult
    EntryResult (Uniqueness -> EntryPointType -> EntryResult)
    -> Parser Uniqueness
    -> ParsecT Void Text Identity (EntryPointType -> EntryResult)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Uniqueness
    pUniqueness ParsecT Void Text Identity (EntryPointType -> EntryResult)
    -> Parser EntryPointType -> ParsecT Void Text Identity EntryResult
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser EntryPointType
    pEntryPointType

    pFunDef :: PR rep -> Parser (FunDef rep)
    pFunDef :: forall rep. PR rep -> Parser (FunDef rep)
    pFunDef PR rep
    pr = do
      Attrs
    attrs <- Parser Attrs
    pAttrs
      Maybe EntryPoint
    entry <-
        [ParsecT Void Text Identity (Maybe EntryPoint)]
    -> ParsecT Void Text Identity (Maybe EntryPoint)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
          [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "entry" ParsecT Void Text Identity ()
    -> (EntryPoint -> Maybe EntryPoint)
    -> ParsecT Void Text Identity (EntryPoint -> Maybe EntryPoint)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> EntryPoint -> Maybe EntryPoint
    forall a. a -> Maybe a
    Just ParsecT Void Text Identity (EntryPoint -> Maybe EntryPoint)
    -> Parser EntryPoint
    -> ParsecT Void Text Identity (Maybe EntryPoint)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser EntryPoint
    pEntry,
            Text -> ParsecT Void Text Identity ()
    keyword Text
    "fun" ParsecT Void Text Identity ()
    -> Maybe EntryPoint
    -> ParsecT Void Text Identity (Maybe EntryPoint)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Maybe EntryPoint
    forall a. Maybe a
    Nothing
          ]
      Name
    fname <- Parser Name
    pName
      [Param (FParamInfo rep)]
    fparams <- PR rep -> ParsecT Void Text Identity [Param (FParamInfo rep)]
    forall rep. PR rep -> Parser [FParam rep]
    pFParams PR rep
    pr ParsecT Void Text Identity [Param (FParamInfo rep)]
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Param (FParamInfo rep)]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon
      [(RetType rep, RetAls)]
    ret <- PR rep -> ParsecT Void Text Identity [(RetType rep, RetAls)]
    forall rep. PR rep -> Parser [(RetType rep, RetAls)]
    pRetTypes PR rep
    pr
      Maybe EntryPoint
    -> Attrs
    -> Name
    -> [(RetType rep, RetAls)]
    -> [Param (FParamInfo rep)]
    -> Body rep
    -> FunDef rep
    forall rep.
    Maybe EntryPoint
    -> Attrs
    -> Name
    -> [(RetType rep, RetAls)]
    -> [FParam rep]
    -> Body rep
    -> FunDef rep
    FunDef Maybe EntryPoint
    entry Attrs
    attrs Name
    fname [(RetType rep, RetAls)]
    ret [Param (FParamInfo rep)]
    fparams
        (Body rep -> FunDef rep)
    -> ParsecT Void Text Identity (Body rep) -> Parser (FunDef rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Void Text Identity ()
    pEqual ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr))

    pOpaqueType :: Parser (Name, OpaqueType)
    pOpaqueType :: Parser (Name, OpaqueType)
    pOpaqueType =
      (,)
        (Name -> OpaqueType -> (Name, OpaqueType))
    -> Parser Name
    -> ParsecT Void Text Identity (OpaqueType -> (Name, OpaqueType))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "type" ParsecT Void Text Identity () -> Parser Name -> Parser Name
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (Text -> Name
    nameFromText (Text -> Name) -> Parsec Void Text Text -> Parser Name
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral) Parser Name -> ParsecT Void Text Identity () -> Parser Name
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pEqual)
        ParsecT Void Text Identity (OpaqueType -> (Name, OpaqueType))
    -> ParsecT Void Text Identity OpaqueType
    -> Parser (Name, OpaqueType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [ParsecT Void Text Identity OpaqueType]
    -> ParsecT Void Text Identity OpaqueType
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity OpaqueType
    pRecord, ParsecT Void Text Identity OpaqueType
    pSum, ParsecT Void Text Identity OpaqueType
    pOpaque, ParsecT Void Text Identity OpaqueType
    pRecordArray, ParsecT Void Text Identity OpaqueType
    pOpaqueArray]
      where
        pFieldName :: Parser Name
    pFieldName = [Parser Name] -> Parser Name
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Parser Name
    pName, String -> Name
    nameFromString (String -> Name) -> (Int -> String) -> Int -> Name
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String
    forall a. Show a => a -> String
    show (Int -> Name) -> ParsecT Void Text Identity Int -> Parser Name
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Int
    pInt]
        pField :: ParsecT Void Text Identity (Name, EntryPointType)
    pField = (,) (Name -> EntryPointType -> (Name, EntryPointType))
    -> Parser Name
    -> ParsecT
         Void Text Identity (EntryPointType -> (Name, EntryPointType))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pFieldName ParsecT
      Void Text Identity (EntryPointType -> (Name, EntryPointType))
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (EntryPointType -> (Name, EntryPointType))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon ParsecT
      Void Text Identity (EntryPointType -> (Name, EntryPointType))
    -> Parser EntryPointType
    -> ParsecT Void Text Identity (Name, EntryPointType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser EntryPointType
    pEntryPointType
        pRecord :: ParsecT Void Text Identity OpaqueType
    pRecord = Text -> ParsecT Void Text Identity ()
    keyword Text
    "record" ParsecT Void Text Identity ()
    -> ([(Name, EntryPointType)] -> OpaqueType)
    -> ParsecT
         Void Text Identity ([(Name, EntryPointType)] -> OpaqueType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [(Name, EntryPointType)] -> OpaqueType
    OpaqueRecord ParsecT Void Text Identity ([(Name, EntryPointType)] -> OpaqueType)
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(Name, EntryPointType)]
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity (Name, EntryPointType)
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ParsecT Void Text Identity (Name, EntryPointType)
    pField)

        pConstructor :: Parser Name
    pConstructor = Parsec Void Text Text
    "#" Parsec Void Text Text -> Parser Name -> Parser Name
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser Name
    pName
        pPayload :: Parser (EntryPointType, [Int])
    pPayload =
          Parser (EntryPointType, [Int]) -> Parser (EntryPointType, [Int])
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser (EntryPointType, [Int]) -> Parser (EntryPointType, [Int]))
    -> Parser (EntryPointType, [Int]) -> Parser (EntryPointType, [Int])
    forall a b. (a -> b) -> a -> b
    $
            (,)
              (EntryPointType -> [Int] -> (EntryPointType, [Int]))
    -> Parser EntryPointType
    -> ParsecT Void Text Identity ([Int] -> (EntryPointType, [Int]))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Parser EntryPointType
    pEntryPointType Parser EntryPointType
    -> ParsecT Void Text Identity () -> Parser EntryPointType
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity ([Int] -> (EntryPointType, [Int]))
    -> ParsecT Void Text Identity [Int]
    -> Parser (EntryPointType, [Int])
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Int]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        pVariant :: ParsecT Void Text Identity (Name, [(EntryPointType, [Int])])
    pVariant = (,) (Name
     -> [(EntryPointType, [Int])] -> (Name, [(EntryPointType, [Int])]))
    -> Parser Name
    -> ParsecT
         Void
         Text
         Identity
         ([(EntryPointType, [Int])] -> (Name, [(EntryPointType, [Int])]))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pConstructor ParsecT
      Void
      Text
      Identity
      ([(EntryPointType, [Int])] -> (Name, [(EntryPointType, [Int])]))
    -> ParsecT Void Text Identity [(EntryPointType, [Int])]
    -> ParsecT Void Text Identity (Name, [(EntryPointType, [Int])])
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (EntryPointType, [Int])
    -> ParsecT Void Text Identity [(EntryPointType, [Int])]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many Parser (EntryPointType, [Int])
    pPayload
        pSum :: ParsecT Void Text Identity OpaqueType
    pSum =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "sum"
            ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity OpaqueType
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity OpaqueType
    -> ParsecT Void Text Identity OpaqueType
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces
              ( [ValueType] -> [(Name, [(EntryPointType, [Int])])] -> OpaqueType
    OpaqueSum
                  ([ValueType] -> [(Name, [(EntryPointType, [Int])])] -> OpaqueType)
    -> ParsecT Void Text Identity [ValueType]
    -> ParsecT
         Void
         Text
         Identity
         ([(Name, [(EntryPointType, [Int])])] -> OpaqueType)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [ValueType]
    -> ParsecT Void Text Identity [ValueType]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (Parser ValueType
    pValueType Parser ValueType
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [ValueType]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                  ParsecT
      Void
      Text
      Identity
      ([(Name, [(EntryPointType, [Int])])] -> OpaqueType)
    -> ParsecT Void Text Identity [(Name, [(EntryPointType, [Int])])]
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Name, [(EntryPointType, [Int])])
    -> ParsecT Void Text Identity [(Name, [(EntryPointType, [Int])])]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ParsecT Void Text Identity (Name, [(EntryPointType, [Int])])
    pVariant
              )

        pOpaque :: ParsecT Void Text Identity OpaqueType
    pOpaque = Text -> ParsecT Void Text Identity ()
    keyword Text
    "opaque" ParsecT Void Text Identity ()
    -> ([ValueType] -> OpaqueType)
    -> ParsecT Void Text Identity ([ValueType] -> OpaqueType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [ValueType] -> OpaqueType
    OpaqueType ParsecT Void Text Identity ([ValueType] -> OpaqueType)
    -> ParsecT Void Text Identity [ValueType]
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [ValueType]
    -> ParsecT Void Text Identity [ValueType]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser ValueType -> ParsecT Void Text Identity [ValueType]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many Parser ValueType
    pValueType)

        pRecordArray :: ParsecT Void Text Identity OpaqueType
    pRecordArray =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "record_array"
            ParsecT Void Text Identity ()
    -> (Int -> Name -> [(Name, EntryPointType)] -> OpaqueType)
    -> ParsecT
         Void
         Text
         Identity
         (Int -> Name -> [(Name, EntryPointType)] -> OpaqueType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Int -> Name -> [(Name, EntryPointType)] -> OpaqueType
    OpaqueRecordArray
            ParsecT
      Void
      Text
      Identity
      (Int -> Name -> [(Name, EntryPointType)] -> OpaqueType)
    -> ParsecT Void Text Identity Int
    -> ParsecT
         Void Text Identity (Name -> [(Name, EntryPointType)] -> OpaqueType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> Parsec Void Text Text -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "d")
            ParsecT
      Void Text Identity (Name -> [(Name, EntryPointType)] -> OpaqueType)
    -> Parser Name
    -> ParsecT
         Void Text Identity ([(Name, EntryPointType)] -> OpaqueType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> Name
    nameFromText (Text -> Name) -> Parsec Void Text Text -> Parser Name
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral)
            ParsecT Void Text Identity ([(Name, EntryPointType)] -> OpaqueType)
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(Name, EntryPointType)]
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity (Name, EntryPointType)
    -> ParsecT Void Text Identity [(Name, EntryPointType)]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ParsecT Void Text Identity (Name, EntryPointType)
    pField)

        pOpaqueArray :: ParsecT Void Text Identity OpaqueType
    pOpaqueArray =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "array"
            ParsecT Void Text Identity ()
    -> (Int -> Name -> [ValueType] -> OpaqueType)
    -> ParsecT
         Void Text Identity (Int -> Name -> [ValueType] -> OpaqueType)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Int -> Name -> [ValueType] -> OpaqueType
    OpaqueArray
            ParsecT
      Void Text Identity (Int -> Name -> [ValueType] -> OpaqueType)
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Name -> [ValueType] -> OpaqueType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> Parsec Void Text Text -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "d")
            ParsecT Void Text Identity (Name -> [ValueType] -> OpaqueType)
    -> Parser Name
    -> ParsecT Void Text Identity ([ValueType] -> OpaqueType)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> Name
    nameFromText (Text -> Name) -> Parsec Void Text Text -> Parser Name
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parsec Void Text Text
    pStringLiteral)
            ParsecT Void Text Identity ([ValueType] -> OpaqueType)
    -> ParsecT Void Text Identity [ValueType]
    -> ParsecT Void Text Identity OpaqueType
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [ValueType]
    -> ParsecT Void Text Identity [ValueType]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser ValueType -> ParsecT Void Text Identity [ValueType]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many Parser ValueType
    pValueType)

    pOpaqueTypes :: Parser OpaqueTypes
    pOpaqueTypes :: Parser OpaqueTypes
    pOpaqueTypes = Text -> ParsecT Void Text Identity ()
    keyword Text
    "types" ParsecT Void Text Identity ()
    -> ([(Name, OpaqueType)] -> OpaqueTypes)
    -> ParsecT Void Text Identity ([(Name, OpaqueType)] -> OpaqueTypes)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [(Name, OpaqueType)] -> OpaqueTypes
    OpaqueTypes ParsecT Void Text Identity ([(Name, OpaqueType)] -> OpaqueTypes)
    -> ParsecT Void Text Identity [(Name, OpaqueType)]
    -> Parser OpaqueTypes
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(Name, OpaqueType)]
    -> ParsecT Void Text Identity [(Name, OpaqueType)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser (Name, OpaqueType)
    -> ParsecT Void Text Identity [(Name, OpaqueType)]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many Parser (Name, OpaqueType)
    pOpaqueType)

    pProg :: PR rep -> Parser (Prog rep)
    pProg :: forall rep. PR rep -> Parser (Prog rep)
    pProg PR rep
    pr =
      OpaqueTypes -> Stms rep -> [FunDef rep] -> Prog rep
    forall rep. OpaqueTypes -> Stms rep -> [FunDef rep] -> Prog rep
    Prog
        (OpaqueTypes -> Stms rep -> [FunDef rep] -> Prog rep)
    -> Parser OpaqueTypes
    -> ParsecT
         Void Text Identity (Stms rep -> [FunDef rep] -> Prog rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (OpaqueTypes -> Maybe OpaqueTypes -> OpaqueTypes
    forall a. a -> Maybe a -> a
    fromMaybe OpaqueTypes
    noTypes (Maybe OpaqueTypes -> OpaqueTypes)
    -> ParsecT Void Text Identity (Maybe OpaqueTypes)
    -> Parser OpaqueTypes
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser OpaqueTypes
    -> ParsecT Void Text Identity (Maybe OpaqueTypes)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional Parser OpaqueTypes
    pOpaqueTypes)
        ParsecT Void Text Identity (Stms rep -> [FunDef rep] -> Prog rep)
    -> ParsecT Void Text Identity (Stms rep)
    -> ParsecT Void Text Identity ([FunDef rep] -> Prog rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Stms rep)
    forall rep. PR rep -> Parser (Stms rep)
    pStms PR rep
    pr
        ParsecT Void Text Identity ([FunDef rep] -> Prog rep)
    -> ParsecT Void Text Identity [FunDef rep]
    -> ParsecT Void Text Identity (Prog rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (FunDef rep)
    -> ParsecT Void Text Identity [FunDef rep]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (PR rep -> ParsecT Void Text Identity (FunDef rep)
    forall rep. PR rep -> Parser (FunDef rep)
    pFunDef PR rep
    pr)
      where
        noTypes :: OpaqueTypes
    noTypes = [(Name, OpaqueType)] -> OpaqueTypes
    OpaqueTypes [(Name, OpaqueType)]
    forall a. Monoid a => a
    mempty

    pSOAC :: PR rep -> Parser (SOAC.SOAC rep)
    pSOAC :: forall rep. PR rep -> Parser (SOAC rep)
    pSOAC PR rep
    pr =
      [ParsecT Void Text Identity (SOAC rep)]
    -> ParsecT Void Text Identity (SOAC rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "map" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (ScremaForm rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall {rep}.
    ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    pScrema ParsecT Void Text Identity (ScremaForm rep)
    pMapForm,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "redomap" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (ScremaForm rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall {rep}.
    ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    pScrema ParsecT Void Text Identity (ScremaForm rep)
    pRedomapForm,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "scanomap" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (ScremaForm rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall {rep}.
    ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    pScrema ParsecT Void Text Identity (ScremaForm rep)
    pScanomapForm,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "screma" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (ScremaForm rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall {rep}.
    ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    pScrema ParsecT Void Text Identity (ScremaForm rep)
    pScremaForm,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "vjp" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SOAC rep)
    pVJP,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "jvp" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SOAC rep)
    pJVP,
          ParsecT Void Text Identity (SOAC rep)
    pScatter,
          ParsecT Void Text Identity (SOAC rep)
    pHist,
          ParsecT Void Text Identity (SOAC rep)
    pStream
        ]
      where
        pScrema :: ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    pScrema ParsecT Void Text Identity (ScremaForm rep)
    p =
          Parser (SOAC rep) -> Parser (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser (SOAC rep) -> Parser (SOAC rep))
    -> Parser (SOAC rep) -> Parser (SOAC rep)
    forall a b. (a -> b) -> a -> b
    $
            SubExp -> [VName] -> ScremaForm rep -> SOAC rep
    forall rep. SubExp -> [VName] -> ScremaForm rep -> SOAC rep
    SOAC.Screma
              (SubExp -> [VName] -> ScremaForm rep -> SOAC rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void Text Identity ([VName] -> ScremaForm rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
              ParsecT Void Text Identity ([VName] -> ScremaForm rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([VName] -> ScremaForm rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity ([VName] -> ScremaForm rep -> SOAC rep)
    -> Parser [VName]
    -> ParsecT Void Text Identity (ScremaForm rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity (ScremaForm rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (ScremaForm rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity (ScremaForm rep -> SOAC rep)
    -> ParsecT Void Text Identity (ScremaForm rep) -> Parser (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (ScremaForm rep)
    p
        pScremaForm :: ParsecT Void Text Identity (ScremaForm rep)
    pScremaForm =
          Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    forall rep.
    Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    SOAC.ScremaForm
            (Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
            ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity [Scan rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> Parser (Scan rep)
    forall rep. PR rep -> Parser (Scan rep)
    pScan PR rep
    pr Parser (Scan rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Scan rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity (ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity [Reduce rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> Parser (Reduce rep)
    forall rep. PR rep -> Parser (Reduce rep)
    pReduce PR rep
    pr Parser (Reduce rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Reduce rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        pRedomapForm :: ParsecT Void Text Identity (ScremaForm rep)
    pRedomapForm =
          Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    forall rep.
    Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    SOAC.ScremaForm
            (Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
            ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Scan rep] -> ParsecT Void Text Identity [Scan rep]
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure []
            ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity (ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity [Reduce rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> Parser (Reduce rep)
    forall rep. PR rep -> Parser (Reduce rep)
    pReduce PR rep
    pr Parser (Reduce rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Reduce rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        pScanomapForm :: ParsecT Void Text Identity (ScremaForm rep)
    pScanomapForm =
          Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    forall rep.
    Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    SOAC.ScremaForm
            (Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
            ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity [Scan rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> Parser (Scan rep)
    forall rep. PR rep -> Parser (Scan rep)
    pScan PR rep
    pr Parser (Scan rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Scan rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity (ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Reduce rep] -> ParsecT Void Text Identity [Reduce rep]
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure []
        pMapForm :: ParsecT Void Text Identity (ScremaForm rep)
    pMapForm =
          Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    forall rep.
    Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep
    SOAC.ScremaForm (Lambda rep -> [Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT
         Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr ParsecT
      Void Text Identity ([Scan rep] -> [Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Scan rep]
    -> ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Scan rep] -> ParsecT Void Text Identity [Scan rep]
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure [Scan rep]
    forall a. Monoid a => a
    mempty ParsecT Void Text Identity ([Reduce rep] -> ScremaForm rep)
    -> ParsecT Void Text Identity [Reduce rep]
    -> ParsecT Void Text Identity (ScremaForm rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [Reduce rep] -> ParsecT Void Text Identity [Reduce rep]
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure [Reduce rep]
    forall a. Monoid a => a
    mempty
        pScatter :: ParsecT Void Text Identity (SOAC rep)
    pScatter =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "scatter"
            ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( SubExp -> [VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep
    forall rep.
    SubExp -> [VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep
    SOAC.Scatter
                  (SubExp -> [VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT
      Void
      Text
      Identity
      ([VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void
      Text
      Identity
      ([VName] -> ScatterSpec VName -> Lambda rep -> SOAC rep)
    -> Parser [VName]
    -> ParsecT
         Void Text Identity (ScatterSpec VName -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                  ParsecT
      Void Text Identity (ScatterSpec VName -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (ScatterSpec VName -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void Text Identity (ScatterSpec VName -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (ScatterSpec VName)
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Shape, Int, VName)
    -> ParsecT Void Text Identity (ScatterSpec VName)
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (ParsecT Void Text Identity (Shape, Int, VName)
    pDest ParsecT Void Text Identity (Shape, Int, VName)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Shape, Int, VName)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma)
                  ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
              )
          where
            pDest :: ParsecT Void Text Identity (Shape, Int, VName)
    pDest =
              ParsecT Void Text Identity (Shape, Int, VName)
    -> ParsecT Void Text Identity (Shape, Int, VName)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (Shape, Int, VName)
     -> ParsecT Void Text Identity (Shape, Int, VName))
    -> ParsecT Void Text Identity (Shape, Int, VName)
    -> ParsecT Void Text Identity (Shape, Int, VName)
    forall a b. (a -> b) -> a -> b
    $ (,,) (Shape -> Int -> VName -> (Shape, Int, VName))
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity (Int -> VName -> (Shape, Int, VName))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape ParsecT Void Text Identity (Int -> VName -> (Shape, Int, VName))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Int -> VName -> (Shape, Int, VName))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (Int -> VName -> (Shape, Int, VName))
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (VName -> (Shape, Int, VName))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity (VName -> (Shape, Int, VName))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (VName -> (Shape, Int, VName))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (VName -> (Shape, Int, VName))
    -> Parser VName -> ParsecT Void Text Identity (Shape, Int, VName)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName
        pHist :: ParsecT Void Text Identity (SOAC rep)
    pHist =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "hist"
            ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( SubExp -> [VName] -> [HistOp rep] -> Lambda rep -> SOAC rep
    forall rep.
    SubExp -> [VName] -> [HistOp rep] -> Lambda rep -> SOAC rep
    SOAC.Hist
                  (SubExp -> [VName] -> [HistOp rep] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [HistOp rep] -> Lambda rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT
      Void
      Text
      Identity
      ([VName] -> [HistOp rep] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [HistOp rep] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void
      Text
      Identity
      ([VName] -> [HistOp rep] -> Lambda rep -> SOAC rep)
    -> Parser [VName]
    -> ParsecT
         Void Text Identity ([HistOp rep] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                  ParsecT Void Text Identity ([HistOp rep] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([HistOp rep] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity ([HistOp rep] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [HistOp rep]
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [HistOp rep]
    -> ParsecT Void Text Identity [HistOp rep]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity (HistOp rep)
    pHistOp ParsecT Void Text Identity (HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [HistOp rep]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                  ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
              )
          where
            pHistOp :: ParsecT Void Text Identity (HistOp rep)
    pHistOp =
              Shape -> SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep
    forall rep.
    Shape -> SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep
    SOAC.HistOp
                (Shape
     -> SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity Shape
    -> ParsecT
         Void
         Text
         Identity
         (SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape
                ParsecT
      Void
      Text
      Identity
      (SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         (SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                ParsecT
      Void
      Text
      Identity
      (SubExp -> [VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
                ParsecT
      Void
      Text
      Identity
      ([VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                ParsecT
      Void
      Text
      Identity
      ([VName] -> [SubExp] -> Lambda rep -> HistOp rep)
    -> Parser [VName]
    -> ParsecT
         Void Text Identity ([SubExp] -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                ParsecT Void Text Identity ([SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([SubExp] -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                ParsecT Void Text Identity ([SubExp] -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
                ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        pStream :: ParsecT Void Text Identity (SOAC rep)
    pStream = Text -> ParsecT Void Text Identity ()
    keyword Text
    "streamSeq" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SOAC rep)
    pStreamSeq
        pStreamSeq :: ParsecT Void Text Identity (SOAC rep)
    pStreamSeq =
          ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (SOAC rep)
     -> ParsecT Void Text Identity (SOAC rep))
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b. (a -> b) -> a -> b
    $
            SubExp -> [VName] -> [SubExp] -> Lambda rep -> SOAC rep
    forall rep. SubExp -> [VName] -> [SubExp] -> Lambda rep -> SOAC rep
    SOAC.Stream
              (SubExp -> [VName] -> [SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void Text Identity ([VName] -> [SubExp] -> Lambda rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
              ParsecT
      Void Text Identity ([VName] -> [SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([VName] -> [SubExp] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT
      Void Text Identity ([VName] -> [SubExp] -> Lambda rep -> SOAC rep)
    -> Parser [VName]
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        pVJP :: ParsecT Void Text Identity (SOAC rep)
    pVJP =
          ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (SOAC rep)
     -> ParsecT Void Text Identity (SOAC rep))
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b. (a -> b) -> a -> b
    $
            [SubExp] -> [SubExp] -> Lambda rep -> SOAC rep
    forall rep. [SubExp] -> [SubExp] -> Lambda rep -> SOAC rep
    SOAC.VJP
              ([SubExp] -> [SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        pJVP :: ParsecT Void Text Identity (SOAC rep)
    pJVP =
          ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (SOAC rep)
     -> ParsecT Void Text Identity (SOAC rep))
    -> ParsecT Void Text Identity (SOAC rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b. (a -> b) -> a -> b
    $
            [SubExp] -> [SubExp] -> Lambda rep -> SOAC rep
    forall rep. [SubExp] -> [SubExp] -> Lambda rep -> SOAC rep
    SOAC.JVP
              ([SubExp] -> [SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity ([SubExp] -> Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
              ParsecT Void Text Identity (Lambda rep -> SOAC rep)
    -> ParsecT Void Text Identity (Lambda rep)
    -> ParsecT Void Text Identity (SOAC rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> ParsecT Void Text Identity (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr

    pSizeClass :: Parser GPU.SizeClass
    pSizeClass :: Parser SizeClass
    pSizeClass =
      [Parser SizeClass] -> Parser SizeClass
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "thread_block_size" ParsecT Void Text Identity () -> SizeClass -> Parser SizeClass
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SizeClass
    GPU.SizeThreadBlock,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "grid_size" ParsecT Void Text Identity () -> SizeClass -> Parser SizeClass
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SizeClass
    GPU.SizeGrid,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "tile_size" ParsecT Void Text Identity () -> SizeClass -> Parser SizeClass
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SizeClass
    GPU.SizeTile,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "reg_tile_size" ParsecT Void Text Identity () -> SizeClass -> Parser SizeClass
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SizeClass
    GPU.SizeRegTile,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "shared_memory" ParsecT Void Text Identity () -> SizeClass -> Parser SizeClass
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SizeClass
    GPU.SizeSharedMemory,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "threshold"
            ParsecT Void Text Identity ()
    -> Parser SizeClass -> Parser SizeClass
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser SizeClass -> Parser SizeClass
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( (KernelPath -> Maybe Int64 -> SizeClass)
    -> Maybe Int64 -> KernelPath -> SizeClass
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip KernelPath -> Maybe Int64 -> SizeClass
    GPU.SizeThreshold
                  (Maybe Int64 -> KernelPath -> SizeClass)
    -> ParsecT Void Text Identity (Maybe Int64)
    -> ParsecT Void Text Identity (KernelPath -> SizeClass)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [ParsecT Void Text Identity (Maybe Int64)]
    -> ParsecT Void Text Identity (Maybe Int64)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [Int64 -> Maybe Int64
    forall a. a -> Maybe a
    Just (Int64 -> Maybe Int64)
    -> Parser Int64 -> ParsecT Void Text Identity (Maybe Int64)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Int64
    pInt64, Parsec Void Text Text
    "def" Parsec Void Text Text
    -> Maybe Int64 -> ParsecT Void Text Identity (Maybe Int64)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Maybe Int64
    forall a. Maybe a
    Nothing]
                  ParsecT Void Text Identity (KernelPath -> SizeClass)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (KernelPath -> SizeClass)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity (KernelPath -> SizeClass)
    -> ParsecT Void Text Identity KernelPath -> Parser SizeClass
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity KernelPath
    pKernelPath
              ),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "bespoke"
            ParsecT Void Text Identity ()
    -> Parser SizeClass -> Parser SizeClass
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser SizeClass -> Parser SizeClass
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Name -> Int64 -> SizeClass
    GPU.SizeBespoke (Name -> Int64 -> SizeClass)
    -> Parser Name -> ParsecT Void Text Identity (Int64 -> SizeClass)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName ParsecT Void Text Identity (Int64 -> SizeClass)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Int64 -> SizeClass)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (Int64 -> SizeClass)
    -> Parser Int64 -> Parser SizeClass
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Int64
    pInt64)
        ]
      where
        pKernelPath :: ParsecT Void Text Identity KernelPath
    pKernelPath = ParsecT Void Text Identity (Name, Bool)
    -> ParsecT Void Text Identity KernelPath
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many ParsecT Void Text Identity (Name, Bool)
    pStep
        pStep :: ParsecT Void Text Identity (Name, Bool)
    pStep =
          [ParsecT Void Text Identity (Name, Bool)]
    -> ParsecT Void Text Identity (Name, Bool)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
            [ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "!" Parsec Void Text Text
    -> (Name -> Bool -> (Name, Bool))
    -> ParsecT Void Text Identity (Name -> Bool -> (Name, Bool))
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> (,) ParsecT Void Text Identity (Name -> Bool -> (Name, Bool))
    -> Parser Name -> ParsecT Void Text Identity (Bool -> (Name, Bool))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Name
    pName ParsecT Void Text Identity (Bool -> (Name, Bool))
    -> ParsecT Void Text Identity Bool
    -> ParsecT Void Text Identity (Name, Bool)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Bool -> ParsecT Void Text Identity Bool
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Bool
    False,
              (,) (Name -> Bool -> (Name, Bool))
    -> Parser Name -> ParsecT Void Text Identity (Bool -> (Name, Bool))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName ParsecT Void Text Identity (Bool -> (Name, Bool))
    -> ParsecT Void Text Identity Bool
    -> ParsecT Void Text Identity (Name, Bool)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Bool -> ParsecT Void Text Identity Bool
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Bool
    True
            ]

    pSizeOp :: Parser GPU.SizeOp
    pSizeOp :: Parser SizeOp
    pSizeOp =
      [Parser SizeOp] -> Parser SizeOp
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "get_size"
            ParsecT Void Text Identity () -> Parser SizeOp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser SizeOp -> Parser SizeOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Name -> SizeClass -> SizeOp
    GPU.GetSize (Name -> SizeClass -> SizeOp)
    -> Parser Name -> ParsecT Void Text Identity (SizeClass -> SizeOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName ParsecT Void Text Identity (SizeClass -> SizeOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SizeClass -> SizeOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SizeClass -> SizeOp)
    -> Parser SizeClass -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser SizeClass
    pSizeClass),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "get_size_max"
            ParsecT Void Text Identity () -> Parser SizeOp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser SizeOp -> Parser SizeOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (SizeClass -> SizeOp
    GPU.GetSizeMax (SizeClass -> SizeOp) -> Parser SizeClass -> Parser SizeOp
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser SizeClass
    pSizeClass),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "cmp_size"
            ParsecT Void Text Identity () -> Parser SizeOp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ( Parser (SubExp -> SizeOp) -> Parser (SubExp -> SizeOp)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Name -> SizeClass -> SubExp -> SizeOp
    GPU.CmpSizeLe (Name -> SizeClass -> SubExp -> SizeOp)
    -> Parser Name
    -> ParsecT Void Text Identity (SizeClass -> SubExp -> SizeOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName ParsecT Void Text Identity (SizeClass -> SubExp -> SizeOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SizeClass -> SubExp -> SizeOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity (SizeClass -> SubExp -> SizeOp)
    -> Parser SizeClass -> Parser (SubExp -> SizeOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser SizeClass
    pSizeClass)
                   Parser (SubExp -> SizeOp)
    -> ParsecT Void Text Identity SubExp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<=" Parsec Void Text Text
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity SubExp
    pSubExp)
               ),
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "calc_num_tblocks"
            ParsecT Void Text Identity () -> Parser SizeOp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser SizeOp -> Parser SizeOp
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( SubExp -> Name -> SubExp -> SizeOp
    GPU.CalcNumBlocks
                  (SubExp -> Name -> SubExp -> SizeOp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Name -> SubExp -> SizeOp)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp
                  ParsecT Void Text Identity (Name -> SubExp -> SizeOp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Name -> SubExp -> SizeOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity (Name -> SubExp -> SizeOp)
    -> Parser Name -> Parser (SubExp -> SizeOp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Name
    pName
                  Parser (SubExp -> SizeOp)
    -> ParsecT Void Text Identity () -> Parser (SubExp -> SizeOp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  Parser (SubExp -> SizeOp)
    -> ParsecT Void Text Identity SubExp -> Parser SizeOp
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
              )
        ]

    pSegSpace :: Parser SegOp.SegSpace
    pSegSpace :: Parser SegSpace
    pSegSpace =
      (VName -> [(VName, SubExp)] -> SegSpace)
    -> [(VName, SubExp)] -> VName -> SegSpace
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip VName -> [(VName, SubExp)] -> SegSpace
    SegOp.SegSpace
        ([(VName, SubExp)] -> VName -> SegSpace)
    -> ParsecT Void Text Identity [(VName, SubExp)]
    -> ParsecT Void Text Identity (VName -> SegSpace)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [(VName, SubExp)]
    -> ParsecT Void Text Identity [(VName, SubExp)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (VName, SubExp)
    pDim ParsecT Void Text Identity (VName, SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [(VName, SubExp)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
        ParsecT Void Text Identity (VName -> SegSpace)
    -> Parser VName -> Parser SegSpace
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName -> Parser VName
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "~" Parsec Void Text Text -> Parser VName -> Parser VName
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser VName
    pVName)
      where
        pDim :: ParsecT Void Text Identity (VName, SubExp)
    pDim = (,) (VName -> SubExp -> (VName, SubExp))
    -> Parser VName
    -> ParsecT Void Text Identity (SubExp -> (VName, SubExp))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (SubExp -> (VName, SubExp))
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (SubExp -> (VName, SubExp))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "<" ParsecT Void Text Identity (SubExp -> (VName, SubExp))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (VName, SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp

    pKernelResult :: Parser SegOp.KernelResult
    pKernelResult :: Parser KernelResult
    pKernelResult = do
      Certs
    cs <- Parser Certs
    pCerts
      [Parser KernelResult] -> Parser KernelResult
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "returns"
            ParsecT Void Text Identity ()
    -> (ResultManifest -> Certs -> SubExp -> KernelResult)
    -> ParsecT
         Void
         Text
         Identity
         (ResultManifest -> Certs -> SubExp -> KernelResult)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> ResultManifest -> Certs -> SubExp -> KernelResult
    SegOp.Returns
            ParsecT
      Void
      Text
      Identity
      (ResultManifest -> Certs -> SubExp -> KernelResult)
    -> ParsecT Void Text Identity ResultManifest
    -> ParsecT Void Text Identity (Certs -> SubExp -> KernelResult)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [ParsecT Void Text Identity ResultManifest]
    -> ParsecT Void Text Identity ResultManifest
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
              [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "(manifest)" ParsecT Void Text Identity ()
    -> ResultManifest -> ParsecT Void Text Identity ResultManifest
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> ResultManifest
    SegOp.ResultNoSimplify,
                Text -> ParsecT Void Text Identity ()
    keyword Text
    "(private)" ParsecT Void Text Identity ()
    -> ResultManifest -> ParsecT Void Text Identity ResultManifest
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> ResultManifest
    SegOp.ResultPrivate,
                ResultManifest -> ParsecT Void Text Identity ResultManifest
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ResultManifest
    SegOp.ResultMaySimplify
              ]
            ParsecT Void Text Identity (Certs -> SubExp -> KernelResult)
    -> Parser Certs
    -> ParsecT Void Text Identity (SubExp -> KernelResult)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Certs -> Parser Certs
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Certs
    cs
            ParsecT Void Text Identity (SubExp -> KernelResult)
    -> ParsecT Void Text Identity SubExp -> Parser KernelResult
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp,
          Parser KernelResult -> Parser KernelResult
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser KernelResult -> Parser KernelResult)
    -> Parser KernelResult -> Parser KernelResult
    forall a b. (a -> b) -> a -> b
    $
            Certs -> VName -> [(Slice SubExp, SubExp)] -> KernelResult
    SegOp.WriteReturns Certs
    cs
              (VName -> [(Slice SubExp, SubExp)] -> KernelResult)
    -> Parser VName
    -> ParsecT
         Void Text Identity ([(Slice SubExp, SubExp)] -> KernelResult)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName
              ParsecT
      Void Text Identity ([(Slice SubExp, SubExp)] -> KernelResult)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([(Slice SubExp, SubExp)] -> KernelResult)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "with"
              ParsecT
      Void Text Identity ([(Slice SubExp, SubExp)] -> KernelResult)
    -> ParsecT Void Text Identity [(Slice SubExp, SubExp)]
    -> Parser KernelResult
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [(Slice SubExp, SubExp)]
    -> ParsecT Void Text Identity [(Slice SubExp, SubExp)]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (Slice SubExp, SubExp)
    pWrite ParsecT Void Text Identity (Slice SubExp, SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [(Slice SubExp, SubExp)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma),
          Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try Parsec Void Text Text
    "tile"
            Parsec Void Text Text
    -> ParsecT Void Text Identity (VName -> KernelResult)
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (VName -> KernelResult)
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Certs -> [(SubExp, SubExp)] -> VName -> KernelResult
    SegOp.TileReturns Certs
    cs ([(SubExp, SubExp)] -> VName -> KernelResult)
    -> ParsecT Void Text Identity [(SubExp, SubExp)]
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Void Text Identity (SubExp, SubExp)
    pTile ParsecT Void Text Identity (SubExp, SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [(SubExp, SubExp)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma))
            ParsecT Void Text Identity (VName -> KernelResult)
    -> Parser VName -> Parser KernelResult
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName,
          Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try Parsec Void Text Text
    "blkreg_tile"
            Parsec Void Text Text
    -> ParsecT Void Text Identity (VName -> KernelResult)
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (VName -> KernelResult)
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Certs -> [(SubExp, SubExp, SubExp)] -> VName -> KernelResult
    SegOp.RegTileReturns Certs
    cs ([(SubExp, SubExp, SubExp)] -> VName -> KernelResult)
    -> ParsecT Void Text Identity [(SubExp, SubExp, SubExp)]
    -> ParsecT Void Text Identity (VName -> KernelResult)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    pRegTile ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [(SubExp, SubExp, SubExp)]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma))
            ParsecT Void Text Identity (VName -> KernelResult)
    -> Parser VName -> Parser KernelResult
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VName
    pVName
        ]
      where
        pTile :: ParsecT Void Text Identity (SubExp, SubExp)
    pTile = (,) (SubExp -> SubExp -> (SubExp, SubExp))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp -> (SubExp, SubExp))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (SubExp -> (SubExp, SubExp))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> (SubExp, SubExp))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSlash ParsecT Void Text Identity (SubExp -> (SubExp, SubExp))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (SubExp, SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
        pRegTile :: ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    pRegTile = do
          SubExp
    dim <- ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSlash
          ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    -> ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity (SubExp, SubExp, SubExp)
     -> ParsecT Void Text Identity (SubExp, SubExp, SubExp))
    -> ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    -> ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    forall a b. (a -> b) -> a -> b
    $ do
            SubExp
    blk_tile <- ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity SubExp
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pAsterisk
            SubExp
    reg_tile <- ParsecT Void Text Identity SubExp
    pSubExp
            (SubExp, SubExp, SubExp)
    -> ParsecT Void Text Identity (SubExp, SubExp, SubExp)
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (SubExp
    dim, SubExp
    blk_tile, SubExp
    reg_tile)
        pWrite :: ParsecT Void Text Identity (Slice SubExp, SubExp)
    pWrite = (,) (Slice SubExp -> SubExp -> (Slice SubExp, SubExp))
    -> Parser (Slice SubExp)
    -> ParsecT Void Text Identity (SubExp -> (Slice SubExp, SubExp))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser (Slice SubExp)
    pSlice ParsecT Void Text Identity (SubExp -> (Slice SubExp, SubExp))
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SubExp -> (Slice SubExp, SubExp))
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pEqual ParsecT Void Text Identity (SubExp -> (Slice SubExp, SubExp))
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Slice SubExp, SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp

    pKernelBody :: PR rep -> Parser (SegOp.KernelBody rep)
    pKernelBody :: forall rep. PR rep -> Parser (KernelBody rep)
    pKernelBody PR rep
    pr =
      BodyDec rep -> Stms rep -> [KernelResult] -> KernelBody rep
    forall rep.
    BodyDec rep -> Stms rep -> [KernelResult] -> KernelBody rep
    SegOp.KernelBody (PR rep -> BodyDec rep
    forall rep. PR rep -> BodyDec rep
    pBodyDec PR rep
    pr)
        (Stms rep -> [KernelResult] -> KernelBody rep)
    -> ParsecT Void Text Identity (Stms rep)
    -> ParsecT Void Text Identity ([KernelResult] -> KernelBody rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep -> ParsecT Void Text Identity (Stms rep)
    forall rep. PR rep -> Parser (Stms rep)
    pStms PR rep
    pr
        ParsecT Void Text Identity ([KernelResult] -> KernelBody rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([KernelResult] -> KernelBody rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Text -> ParsecT Void Text Identity ()
    keyword Text
    "return"
        ParsecT Void Text Identity ([KernelResult] -> KernelBody rep)
    -> ParsecT Void Text Identity [KernelResult]
    -> ParsecT Void Text Identity (KernelBody rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [KernelResult]
    -> ParsecT Void Text Identity [KernelResult]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser KernelResult
    pKernelResult Parser KernelResult
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [KernelResult]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)

    pSegOp :: PR rep -> Parser lvl -> Parser (SegOp.SegOp lvl rep)
    pSegOp :: forall rep lvl. PR rep -> Parser lvl -> Parser (SegOp lvl rep)
    pSegOp PR rep
    pr Parser lvl
    pLvl =
      [ParsecT Void Text Identity (SegOp lvl rep)]
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "segmap" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp lvl rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp lvl rep)
    pSegMap,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "segred" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp lvl rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp lvl rep)
    pSegRed,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "segscan" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp lvl rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp lvl rep)
    pSegScan,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "seghist" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp lvl rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp lvl rep)
    pSegHist
        ]
      where
        pSegMap :: ParsecT Void Text Identity (SegOp lvl rep)
    pSegMap =
          lvl -> SegSpace -> [Type] -> KernelBody rep -> SegOp lvl rep
    forall lvl rep.
    lvl -> SegSpace -> [Type] -> KernelBody rep -> SegOp lvl rep
    SegOp.SegMap
            (lvl -> SegSpace -> [Type] -> KernelBody rep -> SegOp lvl rep)
    -> Parser lvl
    -> ParsecT
         Void
         Text
         Identity
         (SegSpace -> [Type] -> KernelBody rep -> SegOp lvl rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser lvl
    pLvl
            ParsecT
      Void
      Text
      Identity
      (SegSpace -> [Type] -> KernelBody rep -> SegOp lvl rep)
    -> Parser SegSpace
    -> ParsecT
         Void Text Identity ([Type] -> KernelBody rep -> SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser SegSpace
    pSegSpace
            ParsecT
      Void Text Identity ([Type] -> KernelBody rep -> SegOp lvl rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([Type] -> KernelBody rep -> SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon
            ParsecT
      Void Text Identity ([Type] -> KernelBody rep -> SegOp lvl rep)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity (KernelBody rep -> SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Type]
    pTypes
            ParsecT Void Text Identity (KernelBody rep -> SegOp lvl rep)
    -> ParsecT Void Text Identity (KernelBody rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (KernelBody rep)
    -> ParsecT Void Text Identity (KernelBody rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (KernelBody rep)
    forall rep. PR rep -> Parser (KernelBody rep)
    pKernelBody PR rep
    pr)
        pSegOp' :: (lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    pSegOp' lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b
    f ParsecT Void Text Identity a
    p =
          lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b
    f
            (lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> Parser lvl
    -> ParsecT
         Void
         Text
         Identity
         (SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser lvl
    pLvl
            ParsecT
      Void
      Text
      Identity
      (SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> Parser SegSpace
    -> ParsecT
         Void Text Identity ([a] -> [Type] -> KernelBody rep -> b)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser SegSpace
    pSegSpace
            ParsecT Void Text Identity ([a] -> [Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity [a]
    -> ParsecT Void Text Identity ([Type] -> KernelBody rep -> b)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (ParsecT Void Text Identity a
    p ParsecT Void Text Identity a
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity [a]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity ([Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Type] -> KernelBody rep -> b)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pColon
            ParsecT Void Text Identity ([Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity (KernelBody rep -> b)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Type]
    pTypes
            ParsecT Void Text Identity (KernelBody rep -> b)
    -> ParsecT Void Text Identity (KernelBody rep)
    -> ParsecT Void Text Identity b
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (KernelBody rep)
    -> ParsecT Void Text Identity (KernelBody rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (KernelBody rep)
    forall rep. PR rep -> Parser (KernelBody rep)
    pKernelBody PR rep
    pr)
        pSegBinOp :: ParsecT Void Text Identity (SegBinOp rep)
    pSegBinOp = do
          [SubExp]
    nes <- ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma) ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
          Shape
    shape <- ParsecT Void Text Identity Shape
    pShape ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Shape
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
          Commutativity
    comm <- Parser Commutativity
    pComm
          Lambda rep
    lam <- PR rep -> Parser (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
          SegBinOp rep -> ParsecT Void Text Identity (SegBinOp rep)
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (SegBinOp rep -> ParsecT Void Text Identity (SegBinOp rep))
    -> SegBinOp rep -> ParsecT Void Text Identity (SegBinOp rep)
    forall a b. (a -> b) -> a -> b
    $ Commutativity -> Lambda rep -> [SubExp] -> Shape -> SegBinOp rep
    forall rep.
    Commutativity -> Lambda rep -> [SubExp] -> Shape -> SegBinOp rep
    SegOp.SegBinOp Commutativity
    comm Lambda rep
    lam [SubExp]
    nes Shape
    shape
        pHistOp :: ParsecT Void Text Identity (HistOp rep)
    pHistOp =
          Shape
    -> SubExp
    -> [VName]
    -> [SubExp]
    -> Shape
    -> Lambda rep
    -> HistOp rep
    forall rep.
    Shape
    -> SubExp
    -> [VName]
    -> [SubExp]
    -> Shape
    -> Lambda rep
    -> HistOp rep
    SegOp.HistOp
            (Shape
     -> SubExp
     -> [VName]
     -> [SubExp]
     -> Shape
     -> Lambda rep
     -> HistOp rep)
    -> ParsecT Void Text Identity Shape
    -> ParsecT
         Void
         Text
         Identity
         (SubExp
          -> [VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape
            ParsecT
      Void
      Text
      Identity
      (SubExp
       -> [VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         (SubExp
          -> [VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT
      Void
      Text
      Identity
      (SubExp
       -> [VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp
            ParsecT
      Void
      Text
      Identity
      ([VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void
         Text
         Identity
         ([VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT
      Void
      Text
      Identity
      ([VName] -> [SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> Parser [VName]
    -> ParsecT
         Void Text Identity ([SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser [VName] -> Parser [VName]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser VName
    pVName Parser VName -> ParsecT Void Text Identity () -> Parser [VName]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT
      Void Text Identity ([SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity ([SubExp] -> Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT
      Void Text Identity ([SubExp] -> Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity [SubExp]
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [SubExp]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
            ParsecT Void Text Identity (Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Shape -> Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT Void Text Identity (Shape -> Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Shape
    pShape
            ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
            ParsecT Void Text Identity (Lambda rep -> HistOp rep)
    -> Parser (Lambda rep) -> ParsecT Void Text Identity (HistOp rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> PR rep -> Parser (Lambda rep)
    forall rep. PR rep -> Parser (Lambda rep)
    pLambda PR rep
    pr
        pSegRed :: ParsecT Void Text Identity (SegOp lvl rep)
    pSegRed = (lvl
     -> SegSpace
     -> [SegBinOp rep]
     -> [Type]
     -> KernelBody rep
     -> SegOp lvl rep)
    -> ParsecT Void Text Identity (SegBinOp rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall {a} {b}.
    (lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    pSegOp' lvl
    -> SegSpace
    -> [SegBinOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    forall lvl rep.
    lvl
    -> SegSpace
    -> [SegBinOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    SegOp.SegRed ParsecT Void Text Identity (SegBinOp rep)
    pSegBinOp
        pSegScan :: ParsecT Void Text Identity (SegOp lvl rep)
    pSegScan = (lvl
     -> SegSpace
     -> [SegBinOp rep]
     -> [Type]
     -> KernelBody rep
     -> SegOp lvl rep)
    -> ParsecT Void Text Identity (SegBinOp rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall {a} {b}.
    (lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    pSegOp' lvl
    -> SegSpace
    -> [SegBinOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    forall lvl rep.
    lvl
    -> SegSpace
    -> [SegBinOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    SegOp.SegScan ParsecT Void Text Identity (SegBinOp rep)
    pSegBinOp
        pSegHist :: ParsecT Void Text Identity (SegOp lvl rep)
    pSegHist = (lvl
     -> SegSpace
     -> [HistOp rep]
     -> [Type]
     -> KernelBody rep
     -> SegOp lvl rep)
    -> ParsecT Void Text Identity (HistOp rep)
    -> ParsecT Void Text Identity (SegOp lvl rep)
    forall {a} {b}.
    (lvl -> SegSpace -> [a] -> [Type] -> KernelBody rep -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    pSegOp' lvl
    -> SegSpace
    -> [HistOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    forall lvl rep.
    lvl
    -> SegSpace
    -> [HistOp rep]
    -> [Type]
    -> KernelBody rep
    -> SegOp lvl rep
    SegOp.SegHist ParsecT Void Text Identity (HistOp rep)
    pHistOp

    pSegLevel :: Parser GPU.SegLevel
    pSegLevel :: Parser SegLevel
    pSegLevel =
      Parser SegLevel -> Parser SegLevel
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens (Parser SegLevel -> Parser SegLevel)
    -> ([Parser SegLevel] -> Parser SegLevel)
    -> [Parser SegLevel]
    -> Parser SegLevel
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Parser SegLevel] -> Parser SegLevel
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice ([Parser SegLevel] -> Parser SegLevel)
    -> [Parser SegLevel] -> Parser SegLevel
    forall a b. (a -> b) -> a -> b
    $
        [ Parsec Void Text Text
    "thread"
            Parsec Void Text Text
    -> (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT
         Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SegVirt -> Maybe KernelGrid -> SegLevel
    GPU.SegThread
            ParsecT
      Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
            ParsecT
      Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity SegVirt
    -> ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SegVirt
    pSegVirt
            ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
            ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity (Maybe KernelGrid) -> Parser SegLevel
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity KernelGrid
    -> ParsecT Void Text Identity (Maybe KernelGrid)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional ParsecT Void Text Identity KernelGrid
    pKernelGrid,
          Parsec Void Text Text
    "block"
            Parsec Void Text Text
    -> (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT
         Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SegVirt -> Maybe KernelGrid -> SegLevel
    GPU.SegBlock
            ParsecT
      Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
            ParsecT
      Void Text Identity (SegVirt -> Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity SegVirt
    -> ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SegVirt
    pSegVirt
            ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
            ParsecT Void Text Identity (Maybe KernelGrid -> SegLevel)
    -> ParsecT Void Text Identity (Maybe KernelGrid) -> Parser SegLevel
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity KernelGrid
    -> ParsecT Void Text Identity (Maybe KernelGrid)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional ParsecT Void Text Identity KernelGrid
    pKernelGrid,
          Parsec Void Text Text
    "inblock" Parsec Void Text Text
    -> (SegVirt -> SegLevel)
    -> ParsecT Void Text Identity (SegVirt -> SegLevel)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SegVirt -> SegLevel
    GPU.SegThreadInBlock ParsecT Void Text Identity (SegVirt -> SegLevel)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegVirt -> SegLevel)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi ParsecT Void Text Identity (SegVirt -> SegLevel)
    -> ParsecT Void Text Identity SegVirt -> Parser SegLevel
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SegVirt
    pSegVirt
        ]
      where
        pSegVirt :: ParsecT Void Text Identity SegVirt
    pSegVirt =
          [ParsecT Void Text Identity SegVirt]
    -> ParsecT Void Text Identity SegVirt
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
            [ [ParsecT Void Text Identity SegVirt]
    -> ParsecT Void Text Identity SegVirt
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
                [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "full"
                    ParsecT Void Text Identity ()
    -> (SegSeqDims -> SegVirt)
    -> ParsecT Void Text Identity (SegSeqDims -> SegVirt)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SegSeqDims -> SegVirt
    GPU.SegNoVirtFull
                    ParsecT Void Text Identity (SegSeqDims -> SegVirt)
    -> ParsecT Void Text Identity SegSeqDims
    -> ParsecT Void Text Identity SegVirt
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ([Int] -> SegSeqDims
    GPU.SegSeqDims ([Int] -> SegSeqDims)
    -> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity SegSeqDims
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity [Int]
    -> ParsecT Void Text Identity [Int]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (ParsecT Void Text Identity Int
    pInt ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Int]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)),
                  Text -> ParsecT Void Text Identity ()
    keyword Text
    "virtualise" ParsecT Void Text Identity ()
    -> SegVirt -> ParsecT Void Text Identity SegVirt
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SegVirt
    GPU.SegVirt
                ],
              SegVirt -> ParsecT Void Text Identity SegVirt
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure SegVirt
    GPU.SegNoVirt
            ]
        pKernelGrid :: ParsecT Void Text Identity KernelGrid
    pKernelGrid =
          Count NumBlocks SubExp -> Count BlockSize SubExp -> KernelGrid
    GPU.KernelGrid
            (Count NumBlocks SubExp -> Count BlockSize SubExp -> KernelGrid)
    -> ParsecT Void Text Identity (Count NumBlocks SubExp)
    -> ParsecT
         Void Text Identity (Count BlockSize SubExp -> KernelGrid)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "grid=" Parsec Void Text Text
    -> (SubExp -> Count NumBlocks SubExp)
    -> ParsecT Void Text Identity (SubExp -> Count NumBlocks SubExp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SubExp -> Count NumBlocks SubExp
    forall {k} (u :: k) e. e -> Count u e
    GPU.Count ParsecT Void Text Identity (SubExp -> Count NumBlocks SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Count NumBlocks SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (Count NumBlocks SubExp)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (Count NumBlocks SubExp)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi)
            ParsecT Void Text Identity (Count BlockSize SubExp -> KernelGrid)
    -> ParsecT Void Text Identity (Count BlockSize SubExp)
    -> ParsecT Void Text Identity KernelGrid
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "blocksize=" Parsec Void Text Text
    -> (SubExp -> Count BlockSize SubExp)
    -> ParsecT Void Text Identity (SubExp -> Count BlockSize SubExp)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> SubExp -> Count BlockSize SubExp
    forall {k} (u :: k) e. e -> Count u e
    GPU.Count ParsecT Void Text Identity (SubExp -> Count BlockSize SubExp)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Count BlockSize SubExp)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SubExp
    pSubExp)

    pHostOp :: PR rep -> Parser (op rep) -> Parser (GPU.HostOp op rep)
    pHostOp :: forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (HostOp op rep)
    pHostOp PR rep
    pr Parser (op rep)
    pOther =
      [ParsecT Void Text Identity (HostOp op rep)]
    -> ParsecT Void Text Identity (HostOp op rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ SegOp SegLevel rep -> HostOp op rep
    forall (op :: * -> *) rep. SegOp SegLevel rep -> HostOp op rep
    GPU.SegOp (SegOp SegLevel rep -> HostOp op rep)
    -> ParsecT Void Text Identity (SegOp SegLevel rep)
    -> ParsecT Void Text Identity (HostOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PR rep
    -> Parser SegLevel
    -> ParsecT Void Text Identity (SegOp SegLevel rep)
    forall rep lvl. PR rep -> Parser lvl -> Parser (SegOp lvl rep)
    pSegOp PR rep
    pr Parser SegLevel
    pSegLevel,
          SizeOp -> HostOp op rep
    forall (op :: * -> *) rep. SizeOp -> HostOp op rep
    GPU.SizeOp (SizeOp -> HostOp op rep)
    -> Parser SizeOp -> ParsecT Void Text Identity (HostOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser SizeOp
    pSizeOp,
          op rep -> HostOp op rep
    forall (op :: * -> *) rep. op rep -> HostOp op rep
    GPU.OtherOp (op rep -> HostOp op rep)
    -> Parser (op rep) -> ParsecT Void Text Identity (HostOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser (op rep)
    pOther,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "gpu" ParsecT Void Text Identity ()
    -> ([Type] -> Body rep -> HostOp op rep)
    -> ParsecT Void Text Identity ([Type] -> Body rep -> HostOp op rep)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> [Type] -> Body rep -> HostOp op rep
    forall (op :: * -> *) rep. [Type] -> Body rep -> HostOp op rep
    GPU.GPUBody ParsecT Void Text Identity ([Type] -> Body rep -> HostOp op rep)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity (Body rep -> HostOp op rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Void Text Identity ()
    pColon ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity [Type]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity [Type]
    pTypes) ParsecT Void Text Identity (Body rep -> HostOp op rep)
    -> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (HostOp op rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Body rep)
    -> ParsecT Void Text Identity (Body rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (PR rep -> ParsecT Void Text Identity (Body rep)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR rep
    pr)
        ]

    pMCOp :: PR rep -> Parser (op rep) -> Parser (MC.MCOp op rep)
    pMCOp :: forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (MCOp op rep)
    pMCOp PR rep
    pr Parser (op rep)
    pOther =
      [ParsecT Void Text Identity (MCOp op rep)]
    -> ParsecT Void Text Identity (MCOp op rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Maybe (SegOp () rep) -> SegOp () rep -> MCOp op rep
    forall (op :: * -> *) rep.
    Maybe (SegOp () rep) -> SegOp () rep -> MCOp op rep
    MC.ParOp (Maybe (SegOp () rep) -> SegOp () rep -> MCOp op rep)
    -> (SegOp () rep -> Maybe (SegOp () rep))
    -> SegOp () rep
    -> SegOp () rep
    -> MCOp op rep
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SegOp () rep -> Maybe (SegOp () rep)
    forall a. a -> Maybe a
    Just
            (SegOp () rep -> SegOp () rep -> MCOp op rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (SegOp () rep -> MCOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "par" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces ParsecT Void Text Identity (SegOp () rep)
    pMCSegOp)
            ParsecT Void Text Identity (SegOp () rep -> MCOp op rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (MCOp op rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (Text -> ParsecT Void Text Identity ()
    keyword Text
    "seq" ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces ParsecT Void Text Identity (SegOp () rep)
    pMCSegOp),
          Maybe (SegOp () rep) -> SegOp () rep -> MCOp op rep
    forall (op :: * -> *) rep.
    Maybe (SegOp () rep) -> SegOp () rep -> MCOp op rep
    MC.ParOp Maybe (SegOp () rep)
    forall a. Maybe a
    Nothing (SegOp () rep -> MCOp op rep)
    -> ParsecT Void Text Identity (SegOp () rep)
    -> ParsecT Void Text Identity (MCOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (SegOp () rep)
    pMCSegOp,
          op rep -> MCOp op rep
    forall (op :: * -> *) rep. op rep -> MCOp op rep
    MC.OtherOp (op rep -> MCOp op rep)
    -> Parser (op rep) -> ParsecT Void Text Identity (MCOp op rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser (op rep)
    pOther
        ]
      where
        pMCSegOp :: ParsecT Void Text Identity (SegOp () rep)
    pMCSegOp = PR rep
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (SegOp () rep)
    forall rep lvl. PR rep -> Parser lvl -> Parser (SegOp lvl rep)
    pSegOp PR rep
    pr (Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Parsec Void Text Text -> ParsecT Void Text Identity ())
    -> Parsec Void Text Text -> ParsecT Void Text Identity ()
    forall a b. (a -> b) -> a -> b
    $ Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "()")

    pLMADBase :: Parser a -> Parser (LMAD.LMAD a)
    pLMADBase :: forall a. Parser a -> Parser (LMAD a)
    pLMADBase Parser a
    pNum = Parser (LMAD a) -> Parser (LMAD a)
    forall a. Parsec Void Text a -> Parsec Void Text a
    braces (Parser (LMAD a) -> Parser (LMAD a))
    -> Parser (LMAD a) -> Parser (LMAD a)
    forall a b. (a -> b) -> a -> b
    $ do
      a
    offset <- Text -> Parser a -> Parser a
    forall {b}.
    Text
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    pLab Text
    "offset" Parser a
    pNum Parser a -> ParsecT Void Text Identity () -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
      [a]
    strides <- Text
    -> ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall {b}.
    Text
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    pLab Text
    "strides" (ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a])
    -> ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (Parser a
    pNum Parser a
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity [a]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma) ParsecT Void Text Identity [a]
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity [a]
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pSemi
      [a]
    shape <- Text
    -> ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall {b}.
    Text
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    pLab Text
    "shape" (ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a])
    -> ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity [a] -> ParsecT Void Text Identity [a]
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets (Parser a
    pNum Parser a
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity [a]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    `sepBy` ParsecT Void Text Identity ()
    pComma)
      LMAD a -> Parser (LMAD a)
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (LMAD a -> Parser (LMAD a)) -> LMAD a -> Parser (LMAD a)
    forall a b. (a -> b) -> a -> b
    $ a -> [LMADDim a] -> LMAD a
    forall num. num -> [LMADDim num] -> LMAD num
    LMAD.LMAD a
    offset ([LMADDim a] -> LMAD a) -> [LMADDim a] -> LMAD a
    forall a b. (a -> b) -> a -> b
    $ (a -> a -> LMADDim a) -> [a] -> [a] -> [LMADDim a]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith a -> a -> LMADDim a
    forall num. num -> num -> LMADDim num
    LMAD.LMADDim [a]
    strides [a]
    shape
      where
        pLab :: Text
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    pLab Text
    s ParsecT Void Text Identity b
    m = Text -> ParsecT Void Text Identity ()
    keyword Text
    s ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity ()
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity ()
    pColon ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity b
    m

    pPrimExpLeaf :: Parser VName
    pPrimExpLeaf :: Parser VName
    pPrimExpLeaf = Parser VName
    pVName

    pExtPrimExpLeaf :: Parser (Ext VName)
    pExtPrimExpLeaf :: Parser (Ext VName)
    pExtPrimExpLeaf = Parser VName -> Parser (Ext VName)
    forall a. Parser a -> Parser (Ext a)
    pExt Parser VName
    pVName

    pLMAD :: Parser LMAD
    pLMAD :: Parser LMAD
    pLMAD = Parser (TPrimExp Int64 VName) -> Parser LMAD
    forall a. Parser a -> Parser (LMAD a)
    pLMADBase (Parser (TPrimExp Int64 VName) -> Parser LMAD)
    -> Parser (TPrimExp Int64 VName) -> Parser LMAD
    forall a b. (a -> b) -> a -> b
    $ PrimExp VName -> TPrimExp Int64 VName
    forall v. PrimExp v -> TPrimExp Int64 v
    isInt64 (PrimExp VName -> TPrimExp Int64 VName)
    -> ParsecT Void Text Identity (PrimExp VName)
    -> Parser (TPrimExp Int64 VName)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PrimType
    -> Parser VName -> ParsecT Void Text Identity (PrimExp VName)
    forall v.
    PrimType -> Parsec Void Text v -> Parsec Void Text (PrimExp v)
    pPrimExp PrimType
    int64 Parser VName
    pPrimExpLeaf

    pExtLMAD :: Parser ExtLMAD
    pExtLMAD :: Parser ExtLMAD
    pExtLMAD = Parser (TPrimExp Int64 (Ext VName)) -> Parser ExtLMAD
    forall a. Parser a -> Parser (LMAD a)
    pLMADBase (Parser (TPrimExp Int64 (Ext VName)) -> Parser ExtLMAD)
    -> Parser (TPrimExp Int64 (Ext VName)) -> Parser ExtLMAD
    forall a b. (a -> b) -> a -> b
    $ PrimExp (Ext VName) -> TPrimExp Int64 (Ext VName)
    forall v. PrimExp v -> TPrimExp Int64 v
    isInt64 (PrimExp (Ext VName) -> TPrimExp Int64 (Ext VName))
    -> ParsecT Void Text Identity (PrimExp (Ext VName))
    -> Parser (TPrimExp Int64 (Ext VName))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> PrimType
    -> Parser (Ext VName)
    -> ParsecT Void Text Identity (PrimExp (Ext VName))
    forall v.
    PrimType -> Parsec Void Text v -> Parsec Void Text (PrimExp v)
    pPrimExp PrimType
    int64 Parser (Ext VName)
    pExtPrimExpLeaf

    pMemInfo :: Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo :: forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo Parser d
    pd Parser u
    pu Parser ret
    pret =
      [ParsecT Void Text Identity (MemInfo d u ret)]
    -> ParsecT Void Text Identity (MemInfo d u ret)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ PrimType -> MemInfo d u ret
    forall d u ret. PrimType -> MemInfo d u ret
    MemPrim (PrimType -> MemInfo d u ret)
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity (MemInfo d u ret)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity PrimType
    pPrimType,
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "mem" ParsecT Void Text Identity ()
    -> (Space -> MemInfo d u ret)
    -> ParsecT Void Text Identity (Space -> MemInfo d u ret)
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Space -> MemInfo d u ret
    forall d u ret. Space -> MemInfo d u ret
    MemMem ParsecT Void Text Identity (Space -> MemInfo d u ret)
    -> ParsecT Void Text Identity Space
    -> ParsecT Void Text Identity (MemInfo d u ret)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [ParsecT Void Text Identity Space]
    -> ParsecT Void Text Identity Space
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity Space
    pSpace, Space -> ParsecT Void Text Identity Space
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Space
    DefaultSpace],
          ParsecT Void Text Identity (MemInfo d u ret)
    pArrayOrAcc
        ]
      where
        pArrayOrAcc :: ParsecT Void Text Identity (MemInfo d u ret)
    pArrayOrAcc = do
          u
    u <- Parser u
    pu
          ShapeBase d
    shape <- [d] -> ShapeBase d
    forall d. [d] -> ShapeBase d
    Shape ([d] -> ShapeBase d)
    -> ParsecT Void Text Identity [d]
    -> ParsecT Void Text Identity (ShapeBase d)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser d -> ParsecT Void Text Identity [d]
    forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
    many (Parser d -> Parser d
    forall a. Parsec Void Text a -> Parsec Void Text a
    brackets Parser d
    pd)
          [ParsecT Void Text Identity (MemInfo d u ret)]
    -> ParsecT Void Text Identity (MemInfo d u ret)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [u -> ShapeBase d -> ParsecT Void Text Identity (MemInfo d u ret)
    forall {u} {d}.
    u -> ShapeBase d -> ParsecT Void Text Identity (MemInfo d u ret)
    pArray u
    u ShapeBase d
    shape, u -> ParsecT Void Text Identity (MemInfo d u ret)
    forall {a} {d} {ret}.
    a -> ParsecT Void Text Identity (MemInfo d a ret)
    pAcc u
    u]
        pArray :: u -> ShapeBase d -> ParsecT Void Text Identity (MemInfo d u ret)
    pArray u
    u ShapeBase d
    shape = do
          PrimType
    pt <- ParsecT Void Text Identity PrimType
    pPrimType
          PrimType -> ShapeBase d -> u -> ret -> MemInfo d u ret
    forall d u ret.
    PrimType -> ShapeBase d -> u -> ret -> MemInfo d u ret
    MemArray PrimType
    pt ShapeBase d
    shape u
    u (ret -> MemInfo d u ret)
    -> Parser ret -> ParsecT Void Text Identity (MemInfo d u ret)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "@" Parsec Void Text Text -> Parser ret -> Parser ret
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser ret
    pret)
        pAcc :: a -> ParsecT Void Text Identity (MemInfo d a ret)
    pAcc a
    u =
          Text -> ParsecT Void Text Identity ()
    keyword Text
    "acc"
            ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (MemInfo d a ret)
    -> ParsecT Void Text Identity (MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (MemInfo d a ret)
    -> ParsecT Void Text Identity (MemInfo d a ret)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              ( VName -> Shape -> [Type] -> a -> MemInfo d a ret
    forall d u ret. VName -> Shape -> [Type] -> u -> MemInfo d u ret
    MemAcc
                  (VName -> Shape -> [Type] -> a -> MemInfo d a ret)
    -> Parser VName
    -> ParsecT
         Void Text Identity (Shape -> [Type] -> a -> MemInfo d a ret)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName
                  ParsecT
      Void Text Identity (Shape -> [Type] -> a -> MemInfo d a ret)
    -> ParsecT Void Text Identity ()
    -> ParsecT
         Void Text Identity (Shape -> [Type] -> a -> MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT
      Void Text Identity (Shape -> [Type] -> a -> MemInfo d a ret)
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity ([Type] -> a -> MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity Shape
    pShape
                  ParsecT Void Text Identity ([Type] -> a -> MemInfo d a ret)
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity ([Type] -> a -> MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    pComma
                  ParsecT Void Text Identity ([Type] -> a -> MemInfo d a ret)
    -> ParsecT Void Text Identity [Type]
    -> ParsecT Void Text Identity (a -> MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity [Type]
    pTypes
                  ParsecT Void Text Identity (a -> MemInfo d a ret)
    -> ParsecT Void Text Identity a
    -> ParsecT Void Text Identity (MemInfo d a ret)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> a -> ParsecT Void Text Identity a
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure a
    u
              )

    pSpace :: Parser Space
    pSpace :: ParsecT Void Text Identity Space
    pSpace =
      Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "@"
        Parsec Void Text Text
    -> ParsecT Void Text Identity Space
    -> ParsecT Void Text Identity Space
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> [ParsecT Void Text Identity Space]
    -> ParsecT Void Text Identity Space
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
          [ String -> Space
    Space (String -> Space) -> (Name -> String) -> Name -> Space
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Name -> String
    nameToString (Name -> Space) -> Parser Name -> ParsecT Void Text Identity Space
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Name
    pName,
            [SubExp] -> PrimType -> Space
    ScalarSpace ([SubExp] -> PrimType -> Space)
    -> ParsecT Void Text Identity [SubExp]
    -> ParsecT Void Text Identity (PrimType -> Space)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Shape -> [SubExp]
    forall d. ShapeBase d -> [d]
    shapeDims (Shape -> [SubExp])
    -> ParsecT Void Text Identity Shape
    -> ParsecT Void Text Identity [SubExp]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Shape
    pShape) ParsecT Void Text Identity (PrimType -> Space)
    -> ParsecT Void Text Identity PrimType
    -> ParsecT Void Text Identity Space
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity PrimType
    pPrimType
          ]

    pMemBind :: Parser MemBind
    pMemBind :: Parser MemBind
    pMemBind = VName -> LMAD -> MemBind
    ArrayIn (VName -> LMAD -> MemBind)
    -> Parser VName -> ParsecT Void Text Identity (LMAD -> MemBind)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (LMAD -> MemBind)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (LMAD -> MemBind)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->" ParsecT Void Text Identity (LMAD -> MemBind)
    -> Parser LMAD -> Parser MemBind
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser LMAD
    pLMAD

    pMemReturn :: Parser MemReturn
    pMemReturn :: Parser MemReturn
    pMemReturn =
      [Parser MemReturn] -> Parser MemReturn
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ VName -> ExtLMAD -> MemReturn
    ReturnsInBlock (VName -> ExtLMAD -> MemReturn)
    -> Parser VName
    -> ParsecT Void Text Identity (ExtLMAD -> MemReturn)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser VName
    pVName ParsecT Void Text Identity (ExtLMAD -> MemReturn)
    -> Parsec Void Text Text
    -> ParsecT Void Text Identity (ExtLMAD -> MemReturn)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->" ParsecT Void Text Identity (ExtLMAD -> MemReturn)
    -> Parser ExtLMAD -> Parser MemReturn
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser ExtLMAD
    pExtLMAD,
          do
            Int
    i <- Parsec Void Text Text
    "?" Parsec Void Text Text
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity Int
    pInt
            Space
    space <- [ParsecT Void Text Identity Space]
    -> ParsecT Void Text Identity Space
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity Space
    pSpace, Space -> ParsecT Void Text Identity Space
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Space
    DefaultSpace] ParsecT Void Text Identity Space
    -> Parsec Void Text Text -> ParsecT Void Text Identity Space
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Parsec Void Text Text -> Parsec Void Text Text
    forall a. Parsec Void Text a -> Parsec Void Text a
    lexeme Parsec Void Text Text
    "->"
            Space -> Int -> ExtLMAD -> MemReturn
    ReturnsNewBlock Space
    space Int
    i (ExtLMAD -> MemReturn) -> Parser ExtLMAD -> Parser MemReturn
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser ExtLMAD
    pExtLMAD
        ]

    pRetTypeMem :: Parser RetTypeMem
    pRetTypeMem :: Parser RetTypeMem
    pRetTypeMem = Parser ExtSize
    -> Parser Uniqueness -> Parser MemReturn -> Parser RetTypeMem
    forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo Parser ExtSize
    pExtSize Parser Uniqueness
    pUniqueness Parser MemReturn
    pMemReturn

    pBranchTypeMem :: Parser BranchTypeMem
    pBranchTypeMem :: Parser BranchTypeMem
    pBranchTypeMem = Parser ExtSize
    -> ParsecT Void Text Identity NoUniqueness
    -> Parser MemReturn
    -> Parser BranchTypeMem
    forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo Parser ExtSize
    pExtSize (NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness) Parser MemReturn
    pMemReturn

    pFParamMem :: Parser FParamMem
    pFParamMem :: Parser FParamMem
    pFParamMem = ParsecT Void Text Identity SubExp
    -> Parser Uniqueness -> Parser MemBind -> Parser FParamMem
    forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo ParsecT Void Text Identity SubExp
    pSubExp Parser Uniqueness
    pUniqueness Parser MemBind
    pMemBind

    pLParamMem :: Parser LParamMem
    pLParamMem :: Parser LParamMem
    pLParamMem = ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity NoUniqueness
    -> Parser MemBind
    -> Parser LParamMem
    forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo ParsecT Void Text Identity SubExp
    pSubExp (NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness) Parser MemBind
    pMemBind

    pLetDecMem :: Parser LetDecMem
    pLetDecMem :: Parser LParamMem
    pLetDecMem = ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity NoUniqueness
    -> Parser MemBind
    -> Parser LParamMem
    forall d u ret.
    Parser d -> Parser u -> Parser ret -> Parser (MemInfo d u ret)
    pMemInfo ParsecT Void Text Identity SubExp
    pSubExp (NoUniqueness -> ParsecT Void Text Identity NoUniqueness
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure NoUniqueness
    NoUniqueness) Parser MemBind
    pMemBind

    pMemOp :: Parser (inner rep) -> Parser (MemOp inner rep)
    pMemOp :: forall (inner :: * -> *) rep.
    Parser (inner rep) -> Parser (MemOp inner rep)
    pMemOp Parser (inner rep)
    pInner =
      [ParsecT Void Text Identity (MemOp inner rep)]
    -> ParsecT Void Text Identity (MemOp inner rep)
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice
        [ Text -> ParsecT Void Text Identity ()
    keyword Text
    "alloc"
            ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity (MemOp inner rep)
    -> ParsecT Void Text Identity (MemOp inner rep)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (MemOp inner rep)
    -> ParsecT Void Text Identity (MemOp inner rep)
    forall a. Parsec Void Text a -> Parsec Void Text a
    parens
              (SubExp -> Space -> MemOp inner rep
    forall (inner :: * -> *) rep. SubExp -> Space -> MemOp inner rep
    Alloc (SubExp -> Space -> MemOp inner rep)
    -> ParsecT Void Text Identity SubExp
    -> ParsecT Void Text Identity (Space -> MemOp inner rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity SubExp
    pSubExp ParsecT Void Text Identity (Space -> MemOp inner rep)
    -> ParsecT Void Text Identity Space
    -> ParsecT Void Text Identity (MemOp inner rep)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> [ParsecT Void Text Identity Space]
    -> ParsecT Void Text Identity Space
    forall (f :: * -> *) (m :: * -> *) a.
    (Foldable f, Alternative m) =>
    f (m a) -> m a
    choice [ParsecT Void Text Identity ()
    pComma ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Space
    -> ParsecT Void Text Identity Space
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity Space
    pSpace, Space -> ParsecT Void Text Identity Space
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Space
    DefaultSpace]),
          inner rep -> MemOp inner rep
    forall (inner :: * -> *) rep. inner rep -> MemOp inner rep
    Inner (inner rep -> MemOp inner rep)
    -> Parser (inner rep)
    -> ParsecT Void Text Identity (MemOp inner rep)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser (inner rep)
    pInner
        ]

    prSOACS :: PR SOACS
    prSOACS :: PR SOACS
    prSOACS =
      Parser (RetType SOACS)
    -> Parser (BranchType SOACS)
    -> Parser (FParamInfo SOACS)
    -> Parser (LParamInfo SOACS)
    -> Parser (LetDec SOACS)
    -> Parser (Op SOACS)
    -> BodyDec SOACS
    -> ExpDec SOACS
    -> PR SOACS
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser DeclExtType
    Parser (RetType SOACS)
    pDeclExtType Parser ExtType
    Parser (BranchType SOACS)
    pExtType Parser DeclType
    Parser (FParamInfo SOACS)
    pDeclType Parser Type
    Parser (LParamInfo SOACS)
    pType Parser Type
    Parser (LetDec SOACS)
    pType (PR SOACS -> Parser (SOAC SOACS)
    forall rep. PR rep -> Parser (SOAC rep)
    pSOAC PR SOACS
    prSOACS) () ()

    prSeq :: PR Seq
    prSeq :: PR Seq
    prSeq =
      Parser (RetType Seq)
    -> Parser (BranchType Seq)
    -> Parser (FParamInfo Seq)
    -> Parser (LParamInfo Seq)
    -> Parser (LetDec Seq)
    -> Parser (Op Seq)
    -> BodyDec Seq
    -> ExpDec Seq
    -> PR Seq
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser DeclExtType
    Parser (RetType Seq)
    pDeclExtType Parser ExtType
    Parser (BranchType Seq)
    pExtType Parser DeclType
    Parser (FParamInfo Seq)
    pDeclType Parser Type
    Parser (LParamInfo Seq)
    pType Parser Type
    Parser (LetDec Seq)
    pType Parser (Op Seq)
    ParsecT Void Text Identity (NoOp Seq)
    forall a. ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a
    empty () ()

    prSeqMem :: PR SeqMem
    prSeqMem :: PR SeqMem
    prSeqMem =
      Parser (RetType SeqMem)
    -> Parser (BranchType SeqMem)
    -> Parser (FParamInfo SeqMem)
    -> Parser (LParamInfo SeqMem)
    -> Parser (LetDec SeqMem)
    -> Parser (Op SeqMem)
    -> BodyDec SeqMem
    -> ExpDec SeqMem
    -> PR SeqMem
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser (RetType SeqMem)
    Parser RetTypeMem
    pRetTypeMem Parser (BranchType SeqMem)
    Parser BranchTypeMem
    pBranchTypeMem Parser (FParamInfo SeqMem)
    Parser FParamMem
    pFParamMem Parser (LParamInfo SeqMem)
    Parser LParamMem
    pLParamMem Parser (LetDec SeqMem)
    Parser LParamMem
    pLetDecMem Parser (Op SeqMem)
    Parser (MemOp NoOp SeqMem)
    forall {inner :: * -> *} {rep}. Parser (MemOp inner rep)
    op () ()
      where
        op :: Parser (MemOp inner rep)
    op = Parser (inner rep) -> Parser (MemOp inner rep)
    forall (inner :: * -> *) rep.
    Parser (inner rep) -> Parser (MemOp inner rep)
    pMemOp Parser (inner rep)
    forall a. ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a
    empty

    prGPU :: PR GPU
    prGPU :: PR GPU
    prGPU =
      Parser (RetType GPU)
    -> Parser (BranchType GPU)
    -> Parser (FParamInfo GPU)
    -> Parser (LParamInfo GPU)
    -> Parser (LetDec GPU)
    -> Parser (Op GPU)
    -> BodyDec GPU
    -> ExpDec GPU
    -> PR GPU
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser DeclExtType
    Parser (RetType GPU)
    pDeclExtType Parser ExtType
    Parser (BranchType GPU)
    pExtType Parser DeclType
    Parser (FParamInfo GPU)
    pDeclType Parser Type
    Parser (LParamInfo GPU)
    pType Parser Type
    Parser (LetDec GPU)
    pType Parser (Op GPU)
    Parser (HostOp SOAC GPU)
    op () ()
      where
        op :: Parser (HostOp SOAC GPU)
    op = PR GPU -> Parser (SOAC GPU) -> Parser (HostOp SOAC GPU)
    forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (HostOp op rep)
    pHostOp PR GPU
    prGPU (PR GPU -> Parser (SOAC GPU)
    forall rep. PR rep -> Parser (SOAC rep)
    pSOAC PR GPU
    prGPU)

    prGPUMem :: PR GPUMem
    prGPUMem :: PR GPUMem
    prGPUMem =
      Parser (RetType GPUMem)
    -> Parser (BranchType GPUMem)
    -> Parser (FParamInfo GPUMem)
    -> Parser (LParamInfo GPUMem)
    -> Parser (LetDec GPUMem)
    -> Parser (Op GPUMem)
    -> BodyDec GPUMem
    -> ExpDec GPUMem
    -> PR GPUMem
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser (RetType GPUMem)
    Parser RetTypeMem
    pRetTypeMem Parser (BranchType GPUMem)
    Parser BranchTypeMem
    pBranchTypeMem Parser (FParamInfo GPUMem)
    Parser FParamMem
    pFParamMem Parser (LParamInfo GPUMem)
    Parser LParamMem
    pLParamMem Parser (LetDec GPUMem)
    Parser LParamMem
    pLetDecMem Parser (Op GPUMem)
    Parser (MemOp (HostOp NoOp) GPUMem)
    forall {op :: * -> *}. Parser (MemOp (HostOp op) GPUMem)
    op () ()
      where
        op :: Parser (MemOp (HostOp op) GPUMem)
    op = Parser (HostOp op GPUMem) -> Parser (MemOp (HostOp op) GPUMem)
    forall (inner :: * -> *) rep.
    Parser (inner rep) -> Parser (MemOp inner rep)
    pMemOp (Parser (HostOp op GPUMem) -> Parser (MemOp (HostOp op) GPUMem))
    -> Parser (HostOp op GPUMem) -> Parser (MemOp (HostOp op) GPUMem)
    forall a b. (a -> b) -> a -> b
    $ PR GPUMem -> Parser (op GPUMem) -> Parser (HostOp op GPUMem)
    forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (HostOp op rep)
    pHostOp PR GPUMem
    prGPUMem Parser (op GPUMem)
    forall a. ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a
    empty

    prMC :: PR MC
    prMC :: PR MC
    prMC =
      Parser (RetType MC)
    -> Parser (BranchType MC)
    -> Parser (FParamInfo MC)
    -> Parser (LParamInfo MC)
    -> Parser (LetDec MC)
    -> Parser (Op MC)
    -> BodyDec MC
    -> ExpDec MC
    -> PR MC
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser DeclExtType
    Parser (RetType MC)
    pDeclExtType Parser ExtType
    Parser (BranchType MC)
    pExtType Parser DeclType
    Parser (FParamInfo MC)
    pDeclType Parser Type
    Parser (LParamInfo MC)
    pType Parser Type
    Parser (LetDec MC)
    pType Parser (Op MC)
    Parser (MCOp SOAC MC)
    op () ()
      where
        op :: Parser (MCOp SOAC MC)
    op = PR MC -> Parser (SOAC MC) -> Parser (MCOp SOAC MC)
    forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (MCOp op rep)
    pMCOp PR MC
    prMC (PR MC -> Parser (SOAC MC)
    forall rep. PR rep -> Parser (SOAC rep)
    pSOAC PR MC
    prMC)

    prMCMem :: PR MCMem
    prMCMem :: PR MCMem
    prMCMem =
      Parser (RetType MCMem)
    -> Parser (BranchType MCMem)
    -> Parser (FParamInfo MCMem)
    -> Parser (LParamInfo MCMem)
    -> Parser (LetDec MCMem)
    -> Parser (Op MCMem)
    -> BodyDec MCMem
    -> ExpDec MCMem
    -> PR MCMem
    forall rep.
    Parser (RetType rep)
    -> Parser (BranchType rep)
    -> Parser (FParamInfo rep)
    -> Parser (LParamInfo rep)
    -> Parser (LetDec rep)
    -> Parser (Op rep)
    -> BodyDec rep
    -> ExpDec rep
    -> PR rep
    PR Parser (RetType MCMem)
    Parser RetTypeMem
    pRetTypeMem Parser (BranchType MCMem)
    Parser BranchTypeMem
    pBranchTypeMem Parser (FParamInfo MCMem)
    Parser FParamMem
    pFParamMem Parser (LParamInfo MCMem)
    Parser LParamMem
    pLParamMem Parser (LetDec MCMem)
    Parser LParamMem
    pLetDecMem Parser (Op MCMem)
    Parser (MemOp (MCOp NoOp) MCMem)
    forall {op :: * -> *}. Parser (MemOp (MCOp op) MCMem)
    op () ()
      where
        op :: Parser (MemOp (MCOp op) MCMem)
    op = Parser (MCOp op MCMem) -> Parser (MemOp (MCOp op) MCMem)
    forall (inner :: * -> *) rep.
    Parser (inner rep) -> Parser (MemOp inner rep)
    pMemOp (Parser (MCOp op MCMem) -> Parser (MemOp (MCOp op) MCMem))
    -> Parser (MCOp op MCMem) -> Parser (MemOp (MCOp op) MCMem)
    forall a b. (a -> b) -> a -> b
    $ PR MCMem -> Parser (op MCMem) -> Parser (MCOp op MCMem)
    forall rep (op :: * -> *).
    PR rep -> Parser (op rep) -> Parser (MCOp op rep)
    pMCOp PR MCMem
    prMCMem Parser (op MCMem)
    forall a. ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a
    empty

    parseFull :: Parser a -> FilePath -> T.Text -> Either T.Text a
    parseFull :: forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser a
    p String
    fname Text
    s =
      (ParseErrorBundle Text Void -> Either Text a)
    -> (a -> Either Text a)
    -> Either (ParseErrorBundle Text Void) a
    -> Either Text a
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either (Text -> Either Text a
    forall a b. a -> Either a b
    Left (Text -> Either Text a)
    -> (ParseErrorBundle Text Void -> Text)
    -> ParseErrorBundle Text Void
    -> Either Text a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Text
    T.pack (String -> Text)
    -> (ParseErrorBundle Text Void -> String)
    -> ParseErrorBundle Text Void
    -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParseErrorBundle Text Void -> String
    forall s e.
    (VisualStream s, TraversableStream s, ShowErrorComponent e) =>
    ParseErrorBundle s e -> String
    errorBundlePretty) a -> Either Text a
    forall a b. b -> Either a b
    Right (Either (ParseErrorBundle Text Void) a -> Either Text a)
    -> Either (ParseErrorBundle Text Void) a -> Either Text a
    forall a b. (a -> b) -> a -> b
    $
        Parser a -> String -> Text -> Either (ParseErrorBundle Text Void) a
    forall e s a.
    Parsec e s a -> String -> s -> Either (ParseErrorBundle s e) a
    parse (ParsecT Void Text Identity ()
    whitespace ParsecT Void Text Identity () -> Parser a -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser a
    p Parser a -> ParsecT Void Text Identity () -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    forall e s (m :: * -> *). MonadParsec e s m => m ()
    eof) String
    fname Text
    s

    parseRep :: PR rep -> FilePath -> T.Text -> Either T.Text (Prog rep)
    parseRep :: forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep = Parser (Prog rep) -> String -> Text -> Either Text (Prog rep)
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull (Parser (Prog rep) -> String -> Text -> Either Text (Prog rep))
    -> (PR rep -> Parser (Prog rep))
    -> PR rep
    -> String
    -> Text
    -> Either Text (Prog rep)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . PR rep -> Parser (Prog rep)
    forall rep. PR rep -> Parser (Prog rep)
    pProg

    parseSOACS :: FilePath -> T.Text -> Either T.Text (Prog SOACS)
    parseSOACS :: String -> Text -> Either Text (Prog SOACS)
    parseSOACS = PR SOACS -> String -> Text -> Either Text (Prog SOACS)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR SOACS
    prSOACS

    parseSeq :: FilePath -> T.Text -> Either T.Text (Prog Seq)
    parseSeq :: String -> Text -> Either Text (Prog Seq)
    parseSeq = PR Seq -> String -> Text -> Either Text (Prog Seq)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR Seq
    prSeq

    parseSeqMem :: FilePath -> T.Text -> Either T.Text (Prog SeqMem)
    parseSeqMem :: String -> Text -> Either Text (Prog SeqMem)
    parseSeqMem = PR SeqMem -> String -> Text -> Either Text (Prog SeqMem)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR SeqMem
    prSeqMem

    parseGPU :: FilePath -> T.Text -> Either T.Text (Prog GPU)
    parseGPU :: String -> Text -> Either Text (Prog GPU)
    parseGPU = PR GPU -> String -> Text -> Either Text (Prog GPU)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR GPU
    prGPU

    parseGPUMem :: FilePath -> T.Text -> Either T.Text (Prog GPUMem)
    parseGPUMem :: String -> Text -> Either Text (Prog GPUMem)
    parseGPUMem = PR GPUMem -> String -> Text -> Either Text (Prog GPUMem)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR GPUMem
    prGPUMem

    parseMC :: FilePath -> T.Text -> Either T.Text (Prog MC)
    parseMC :: String -> Text -> Either Text (Prog MC)
    parseMC = PR MC -> String -> Text -> Either Text (Prog MC)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR MC
    prMC

    parseMCMem :: FilePath -> T.Text -> Either T.Text (Prog MCMem)
    parseMCMem :: String -> Text -> Either Text (Prog MCMem)
    parseMCMem = PR MCMem -> String -> Text -> Either Text (Prog MCMem)
    forall rep. PR rep -> String -> Text -> Either Text (Prog rep)
    parseRep PR MCMem
    prMCMem

    --- Fragment parsers

    parseType :: FilePath -> T.Text -> Either T.Text Type
    parseType :: String -> Text -> Either Text Type
    parseType = Parser Type -> String -> Text -> Either Text Type
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser Type
    pType

    parseDeclExtType :: FilePath -> T.Text -> Either T.Text DeclExtType
    parseDeclExtType :: String -> Text -> Either Text DeclExtType
    parseDeclExtType = Parser DeclExtType -> String -> Text -> Either Text DeclExtType
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser DeclExtType
    pDeclExtType

    parseDeclType :: FilePath -> T.Text -> Either T.Text DeclType
    parseDeclType :: String -> Text -> Either Text DeclType
    parseDeclType = Parser DeclType -> String -> Text -> Either Text DeclType
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser DeclType
    pDeclType

    parseVName :: FilePath -> T.Text -> Either T.Text VName
    parseVName :: String -> Text -> Either Text VName
    parseVName = Parser VName -> String -> Text -> Either Text VName
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser VName
    pVName

    parseSubExp :: FilePath -> T.Text -> Either T.Text SubExp
    parseSubExp :: String -> Text -> Either Text SubExp
    parseSubExp = ParsecT Void Text Identity SubExp
    -> String -> Text -> Either Text SubExp
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull ParsecT Void Text Identity SubExp
    pSubExp

    parseSubExpRes :: FilePath -> T.Text -> Either T.Text SubExpRes
    parseSubExpRes :: String -> Text -> Either Text SubExpRes
    parseSubExpRes = Parser SubExpRes -> String -> Text -> Either Text SubExpRes
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull Parser SubExpRes
    pSubExpRes

    parseBodyGPU :: FilePath -> T.Text -> Either T.Text (Body GPU)
    parseBodyGPU :: String -> Text -> Either Text (Body GPU)
    parseBodyGPU = Parser (Body GPU) -> String -> Text -> Either Text (Body GPU)
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull (Parser (Body GPU) -> String -> Text -> Either Text (Body GPU))
    -> Parser (Body GPU) -> String -> Text -> Either Text (Body GPU)
    forall a b. (a -> b) -> a -> b
    $ PR GPU -> Parser (Body GPU)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR GPU
    prGPU

    parseStmGPU :: FilePath -> T.Text -> Either T.Text (Stm GPU)
    parseStmGPU :: String -> Text -> Either Text (Stm GPU)
    parseStmGPU = Parser (Stm GPU) -> String -> Text -> Either Text (Stm GPU)
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull (Parser (Stm GPU) -> String -> Text -> Either Text (Stm GPU))
    -> Parser (Stm GPU) -> String -> Text -> Either Text (Stm GPU)
    forall a b. (a -> b) -> a -> b
    $ PR GPU -> Parser (Stm GPU)
    forall rep. PR rep -> Parser (Stm rep)
    pStm PR GPU
    prGPU

    parseBodyMC :: FilePath -> T.Text -> Either T.Text (Body MC)
    parseBodyMC :: String -> Text -> Either Text (Body MC)
    parseBodyMC = Parser (Body MC) -> String -> Text -> Either Text (Body MC)
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull (Parser (Body MC) -> String -> Text -> Either Text (Body MC))
    -> Parser (Body MC) -> String -> Text -> Either Text (Body MC)
    forall a b. (a -> b) -> a -> b
    $ PR MC -> Parser (Body MC)
    forall rep. PR rep -> Parser (Body rep)
    pBody PR MC
    prMC

    parseStmMC :: FilePath -> T.Text -> Either T.Text (Stm MC)
    parseStmMC :: String -> Text -> Either Text (Stm MC)
    parseStmMC = Parser (Stm MC) -> String -> Text -> Either Text (Stm MC)
    forall a. Parser a -> String -> Text -> Either Text a
    parseFull (Parser (Stm MC) -> String -> Text -> Either Text (Stm MC))
    -> Parser (Stm MC) -> String -> Text -> Either Text (Stm MC)
    forall a b. (a -> b) -> a -> b
    $ PR MC -> Parser (Stm MC)
    forall rep. PR rep -> Parser (Stm rep)
    pStm PR MC
    prMC