{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}

-- | = Definition of the Futhark core language IR
--
-- For actually /constructing/ ASTs, see "Futhark.Construct".
--
-- == Types and values
--
-- The core language type system is much more restricted than the core
-- language.  This is a theme that repeats often.  The only types that
-- are supported in the core language are various primitive types
-- t'PrimType' which can be combined in arrays (ignore v'Mem' for
-- now).  Types are represented as t'TypeBase', which is parameterised
-- by the shape of the array and whether we keep uniqueness
-- information.  The t'Type' alias, which is the most commonly used,
-- uses t'Shape' and t'NoUniqueness'.
--
-- This means that the records, tuples, and sum types of the source
-- language are represented merely as collections of primitives and
-- arrays.  This is implemented in "Futhark.Internalise", but the
-- specifics are not important for writing passes on the core
-- language.  What /is/ important is that many constructs that
-- conceptually return tuples instead return /multiple values/.  This
-- is not merely syntactic sugar for a tuple: each of those values are
-- eventually bound to distinct variables.  The prettyprinter for the
-- IR will typically print such collections of values or types in
-- curly braces.
--
-- The system of primitive types is interesting in itself.  See
-- "Futhark.IR.Primitive".
--
-- == Overall AST design
--
-- Internally, the Futhark compiler core intermediate representation
-- resembles a traditional compiler for an imperative language more
-- than it resembles, say, a Haskell or ML compiler.  All functions
-- are monomorphic (except for sizes), first-order, and defined at the
-- top level.  Notably, the IR does /not/ use continuation-passing
-- style (CPS) at any time.  Instead it uses Administrative Normal
-- Form (ANF), where all subexpressions t'SubExp' are either
-- constants 'PrimValue' or variables 'VName'.  Variables are
-- represented as a human-readable t'Name' (which doesn't matter to
-- the compiler) as well as a numeric /tag/, which is what the
-- compiler actually looks at.  All variable names when prettyprinted
-- are of the form @foo_123@.  Function names are just t'Name's,
-- though.
--
-- The body of a function ('FunDef') is a t'Body', which consists of
-- a sequence of statements ('Stms') and a t'Result'.  Execution of a
-- t'Body' consists of executing all of the statements, then returning
-- the values of the variables indicated by the result.
--
-- A statement ('Stm') consists of a t'Pattern' alongside an
-- expression 'ExpT'.  A pattern contains a "context" part and a
-- "value" part.  The context is used for things like the size of
-- arrays in the value part whose size is existential.
--
-- For example, the source language expression @let z = x + y - 1 in
-- z@ would in the core language be represented (in prettyprinted
-- form) as something like:
--
-- @
-- let {a_12} = x_10 + y_11
-- let {b_13} = a_12 - 1
-- in {b_13}
-- @
--
-- == Lores
--
-- Most AST types ('Stm', 'ExpT', t'Prog', etc) are parameterised by a
-- type parameter with the somewhat silly name @lore@.  The lore
-- specifies how to fill out various polymorphic parts of the AST.
-- For example, 'ExpT' has a constructor v'Op' whose payload depends
-- on @lore@, via the use of a type family called t'Op' (a kind of
-- type-level function) which is applied to the @lore@.  The SOACS
-- representation ("Futhark.IR.SOACS") thus uses a lore
-- called @SOACS@, and defines that @Op SOACS@ is a SOAC, while the
-- Kernels representation ("Futhark.IR.Kernels") defines
-- @Op Kernels@ as some kind of kernel construct.  Similarly, various
-- other decorations (e.g. what information we store in a t'PatElemT')
-- are also type families.
--
-- The full list of possible decorations is defined as part of the
-- type class 'Decorations' (although other type families are also
-- used elsewhere in the compiler on an ad hoc basis).
--
-- Essentially, the @lore@ type parameter functions as a kind of
-- proxy, saving us from having to parameterise the AST type with all
-- the different forms of decorations that we desire (it would easily
-- become a type with a dozen type parameters).
--
-- Defining a new representation (or /lore/) thus requires you to
-- define an empty datatype and implement a handful of type class
-- instances for it.  See the source of "Futhark.IR.Seq"
-- for what is likely the simplest example.
module Futhark.IR.Syntax
  ( module Language.Futhark.Core,
    module Futhark.IR.Decorations,
    module Futhark.IR.Syntax.Core,

    -- * Types
    Uniqueness (..),
    NoUniqueness (..),
    Rank (..),
    ArrayShape (..),
    Space (..),
    TypeBase (..),
    Diet (..),

    -- * Attributes
    Attr (..),
    Attrs (..),
    oneAttr,
    inAttrs,
    withoutAttrs,

    -- * Abstract syntax tree
    Ident (..),
    SubExp (..),
    PatElem,
    PatElemT (..),
    PatternT (..),
    Pattern,
    StmAux (..),
    Stm (..),
    Stms,
    Result,
    BodyT (..),
    Body,
    BasicOp (..),
    UnOp (..),
    BinOp (..),
    CmpOp (..),
    ConvOp (..),
    DimChange (..),
    ShapeChange,
    ExpT (..),
    Exp,
    LoopForm (..),
    IfDec (..),
    IfSort (..),
    Safety (..),
    LambdaT (..),
    Lambda,

    -- * Definitions
    Param (..),
    FParam,
    LParam,
    FunDef (..),
    EntryPoint,
    EntryPointType (..),
    Prog (..),

    -- * Utils
    oneStm,
    stmsFromList,
    stmsToList,
    stmsHead,
  )
where

import Control.Category
import Data.Foldable
import qualified Data.Sequence as Seq
import qualified Data.Set as S
import Data.String
import qualified Data.Text as T
import Data.Traversable (fmapDefault, foldMapDefault)
import Futhark.IR.Decorations
import Futhark.IR.Syntax.Core
import GHC.Generics (Generic)
import Language.Futhark.Core
import Language.SexpGrammar as Sexp
import Language.SexpGrammar.Generic
import Prelude hiding (id, (.))

-- | A single attribute.
data Attr
  = AttrAtom Name
  | AttrComp Name [Attr]
  deriving (Eq Attr
Eq Attr
-> (Attr -> Attr -> Ordering)
-> (Attr -> Attr -> Bool)
-> (Attr -> Attr -> Bool)
-> (Attr -> Attr -> Bool)
-> (Attr -> Attr -> Bool)
-> (Attr -> Attr -> Attr)
-> (Attr -> Attr -> Attr)
-> Ord Attr
Attr -> Attr -> Bool
Attr -> Attr -> Ordering
Attr -> Attr -> Attr
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Attr -> Attr -> Attr
$cmin :: Attr -> Attr -> Attr
max :: Attr -> Attr -> Attr
$cmax :: Attr -> Attr -> Attr
>= :: Attr -> Attr -> Bool
$c>= :: Attr -> Attr -> Bool
> :: Attr -> Attr -> Bool
$c> :: Attr -> Attr -> Bool
<= :: Attr -> Attr -> Bool
$c<= :: Attr -> Attr -> Bool
< :: Attr -> Attr -> Bool
$c< :: Attr -> Attr -> Bool
compare :: Attr -> Attr -> Ordering
$ccompare :: Attr -> Attr -> Ordering
$cp1Ord :: Eq Attr
Ord, Int -> Attr -> ShowS
[Attr] -> ShowS
Attr -> String
(Int -> Attr -> ShowS)
-> (Attr -> String) -> ([Attr] -> ShowS) -> Show Attr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attr] -> ShowS
$cshowList :: [Attr] -> ShowS
show :: Attr -> String
$cshow :: Attr -> String
showsPrec :: Int -> Attr -> ShowS
$cshowsPrec :: Int -> Attr -> ShowS
Show, Attr -> Attr -> Bool
(Attr -> Attr -> Bool) -> (Attr -> Attr -> Bool) -> Eq Attr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attr -> Attr -> Bool
$c/= :: Attr -> Attr -> Bool
== :: Attr -> Attr -> Bool
$c== :: Attr -> Attr -> Bool
Eq, (forall x. Attr -> Rep Attr x)
-> (forall x. Rep Attr x -> Attr) -> Generic Attr
forall x. Rep Attr x -> Attr
forall x. Attr -> Rep Attr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attr x -> Attr
$cfrom :: forall x. Attr -> Rep Attr x
Generic)

instance SexpIso Attr where
  sexpIso :: Grammar Position (Sexp :- t) (Attr :- t)
sexpIso =
    Coproduct
  Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t
-> Grammar Position (Sexp :- t) (Attr :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct
   Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t
 -> Grammar Position (Sexp :- t) (Attr :- t))
-> Coproduct
     Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t
-> Grammar Position (Sexp :- t) (Attr :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position (Name :- t) (Attr :- t)
 -> Grammar Position (Sexp :- t) (Attr :- t))
-> Coproduct Position (Sexp :- t) '[[Attr] :- (Name :- t)] Attr t
-> Coproduct
     Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (Name :- t) (Attr :- t)
-> Grammar Position (Sexp :- t) (Name :- t)
-> Grammar Position (Sexp :- t) (Attr :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (Name :- t))
-> Grammar Position (Sexp :- t) (Name :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"atom") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (Name :- t))
-> Grammar Position (List :- t) (List :- (Name :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Name :- t)
-> Grammar Position (List :- t) (List :- (Name :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Name :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[[Attr] :- (Name :- t)] Attr t
 -> Coproduct
      Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t)
-> Coproduct Position (Sexp :- t) '[[Attr] :- (Name :- t)] Attr t
-> Coproduct
     Position (Sexp :- t) '[Name :- t, [Attr] :- (Name :- t)] Attr t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position ([Attr] :- (Name :- t)) (Attr :- t)
 -> Grammar Position (Sexp :- t) (Attr :- t))
-> Coproduct Position (Sexp :- t) '[] Attr t
-> Coproduct Position (Sexp :- t) '[[Attr] :- (Name :- t)] Attr t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
          (Grammar Position ([Attr] :- (Name :- t)) (Attr :- t)
-> Grammar Position (Sexp :- t) ([Attr] :- (Name :- t))
-> Grammar Position (Sexp :- t) (Attr :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- ([Attr] :- (Name :- t)))
-> Grammar Position (Sexp :- t) ([Attr] :- (Name :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"comp") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- ([Attr] :- (Name :- t)))
-> Grammar Position (List :- t) (List :- ([Attr] :- (Name :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Name :- t)
-> Grammar Position (List :- t) (List :- (Name :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Name :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Name :- t))
-> Grammar
     Position (List :- (Name :- t)) (List :- ([Attr] :- (Name :- t)))
-> Grammar Position (List :- t) (List :- ([Attr] :- (Name :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (Name :- t)) ([Attr] :- (Name :- t))
-> Grammar
     Position (List :- (Name :- t)) (List :- ([Attr] :- (Name :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (Name :- t)) ([Attr] :- (Name :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso))
          Coproduct Position (Sexp :- t) '[] Attr t
forall p s a t. Coproduct p s '[] a t
End

instance IsString Attr where
  fromString :: String -> Attr
fromString = Name -> Attr
AttrAtom (Name -> Attr) -> (String -> Name) -> String -> Attr
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> Name
forall a. IsString a => String -> a
fromString

-- | Every statement is associated with a set of attributes, which can
-- have various effects throughout the compiler.
newtype Attrs = Attrs {Attrs -> Set Attr
unAttrs :: S.Set Attr}
  deriving (Eq Attrs
Eq Attrs
-> (Attrs -> Attrs -> Ordering)
-> (Attrs -> Attrs -> Bool)
-> (Attrs -> Attrs -> Bool)
-> (Attrs -> Attrs -> Bool)
-> (Attrs -> Attrs -> Bool)
-> (Attrs -> Attrs -> Attrs)
-> (Attrs -> Attrs -> Attrs)
-> Ord Attrs
Attrs -> Attrs -> Bool
Attrs -> Attrs -> Ordering
Attrs -> Attrs -> Attrs
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Attrs -> Attrs -> Attrs
$cmin :: Attrs -> Attrs -> Attrs
max :: Attrs -> Attrs -> Attrs
$cmax :: Attrs -> Attrs -> Attrs
>= :: Attrs -> Attrs -> Bool
$c>= :: Attrs -> Attrs -> Bool
> :: Attrs -> Attrs -> Bool
$c> :: Attrs -> Attrs -> Bool
<= :: Attrs -> Attrs -> Bool
$c<= :: Attrs -> Attrs -> Bool
< :: Attrs -> Attrs -> Bool
$c< :: Attrs -> Attrs -> Bool
compare :: Attrs -> Attrs -> Ordering
$ccompare :: Attrs -> Attrs -> Ordering
$cp1Ord :: Eq Attrs
Ord, Int -> Attrs -> ShowS
[Attrs] -> ShowS
Attrs -> String
(Int -> Attrs -> ShowS)
-> (Attrs -> String) -> ([Attrs] -> ShowS) -> Show Attrs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attrs] -> ShowS
$cshowList :: [Attrs] -> ShowS
show :: Attrs -> String
$cshow :: Attrs -> String
showsPrec :: Int -> Attrs -> ShowS
$cshowsPrec :: Int -> Attrs -> ShowS
Show, Attrs -> Attrs -> Bool
(Attrs -> Attrs -> Bool) -> (Attrs -> Attrs -> Bool) -> Eq Attrs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attrs -> Attrs -> Bool
$c/= :: Attrs -> Attrs -> Bool
== :: Attrs -> Attrs -> Bool
$c== :: Attrs -> Attrs -> Bool
Eq, Semigroup Attrs
Attrs
Semigroup Attrs
-> Attrs
-> (Attrs -> Attrs -> Attrs)
-> ([Attrs] -> Attrs)
-> Monoid Attrs
[Attrs] -> Attrs
Attrs -> Attrs -> Attrs
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [Attrs] -> Attrs
$cmconcat :: [Attrs] -> Attrs
mappend :: Attrs -> Attrs -> Attrs
$cmappend :: Attrs -> Attrs -> Attrs
mempty :: Attrs
$cmempty :: Attrs
$cp1Monoid :: Semigroup Attrs
Monoid, b -> Attrs -> Attrs
NonEmpty Attrs -> Attrs
Attrs -> Attrs -> Attrs
(Attrs -> Attrs -> Attrs)
-> (NonEmpty Attrs -> Attrs)
-> (forall b. Integral b => b -> Attrs -> Attrs)
-> Semigroup Attrs
forall b. Integral b => b -> Attrs -> Attrs
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Attrs -> Attrs
$cstimes :: forall b. Integral b => b -> Attrs -> Attrs
sconcat :: NonEmpty Attrs -> Attrs
$csconcat :: NonEmpty Attrs -> Attrs
<> :: Attrs -> Attrs -> Attrs
$c<> :: Attrs -> Attrs -> Attrs
Semigroup, (forall x. Attrs -> Rep Attrs x)
-> (forall x. Rep Attrs x -> Attrs) -> Generic Attrs
forall x. Rep Attrs x -> Attrs
forall x. Attrs -> Rep Attrs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attrs x -> Attrs
$cfrom :: forall x. Attrs -> Rep Attrs x
Generic)

instance SexpIso Attrs where
  sexpIso :: Grammar Position (Sexp :- t) (Attrs :- t)
sexpIso = (Grammar Position (Set Attr :- t) (Attrs :- t)
 -> Grammar Position (Sexp :- t) (Attrs :- t))
-> Grammar Position (Sexp :- t) (Attrs :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar Position (Set Attr :- t) (Attrs :- t)
  -> Grammar Position (Sexp :- t) (Attrs :- t))
 -> Grammar Position (Sexp :- t) (Attrs :- t))
-> (Grammar Position (Set Attr :- t) (Attrs :- t)
    -> Grammar Position (Sexp :- t) (Attrs :- t))
-> Grammar Position (Sexp :- t) (Attrs :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar Position (Set Attr :- t) (Attrs :- t)
attrs -> Grammar Position (Sexp :- t) (Set Attr :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (Sexp :- t) (Set Attr :- t)
-> Grammar Position (Set Attr :- t) (Attrs :- t)
-> Grammar Position (Sexp :- t) (Attrs :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Set Attr :- t) (Attrs :- t)
attrs

-- | Construct 'Attrs' from a single 'Attr'.
oneAttr :: Attr -> Attrs
oneAttr :: Attr -> Attrs
oneAttr = Set Attr -> Attrs
Attrs (Set Attr -> Attrs) -> (Attr -> Set Attr) -> Attr -> Attrs
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Attr -> Set Attr
forall a. a -> Set a
S.singleton

-- | Is the given attribute to be found in the attribute set?
inAttrs :: Attr -> Attrs -> Bool
inAttrs :: Attr -> Attrs -> Bool
inAttrs Attr
attr (Attrs Set Attr
attrs) = Attr
attr Attr -> Set Attr -> Bool
forall a. Ord a => a -> Set a -> Bool
`S.member` Set Attr
attrs

-- | @x `withoutAttrs` y@ gives @x@ except for any attributes also in @y@.
withoutAttrs :: Attrs -> Attrs -> Attrs
withoutAttrs :: Attrs -> Attrs -> Attrs
withoutAttrs (Attrs Set Attr
x) (Attrs Set Attr
y) = Set Attr -> Attrs
Attrs (Set Attr -> Attrs) -> Set Attr -> Attrs
forall a b. (a -> b) -> a -> b
$ Set Attr
x Set Attr -> Set Attr -> Set Attr
forall a. Ord a => Set a -> Set a -> Set a
`S.difference` Set Attr
y

-- | A type alias for namespace control.
type PatElem lore = PatElemT (LetDec lore)

-- | A pattern is conceptually just a list of names and their types.
data PatternT dec = Pattern
  { -- | existential context (sizes and memory blocks)
    PatternT dec -> [PatElemT dec]
patternContextElements :: [PatElemT dec],
    -- | "real" values
    PatternT dec -> [PatElemT dec]
patternValueElements :: [PatElemT dec]
  }
  deriving (Eq (PatternT dec)
Eq (PatternT dec)
-> (PatternT dec -> PatternT dec -> Ordering)
-> (PatternT dec -> PatternT dec -> Bool)
-> (PatternT dec -> PatternT dec -> Bool)
-> (PatternT dec -> PatternT dec -> Bool)
-> (PatternT dec -> PatternT dec -> Bool)
-> (PatternT dec -> PatternT dec -> PatternT dec)
-> (PatternT dec -> PatternT dec -> PatternT dec)
-> Ord (PatternT dec)
PatternT dec -> PatternT dec -> Bool
PatternT dec -> PatternT dec -> Ordering
PatternT dec -> PatternT dec -> PatternT dec
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall dec. Ord dec => Eq (PatternT dec)
forall dec. Ord dec => PatternT dec -> PatternT dec -> Bool
forall dec. Ord dec => PatternT dec -> PatternT dec -> Ordering
forall dec. Ord dec => PatternT dec -> PatternT dec -> PatternT dec
min :: PatternT dec -> PatternT dec -> PatternT dec
$cmin :: forall dec. Ord dec => PatternT dec -> PatternT dec -> PatternT dec
max :: PatternT dec -> PatternT dec -> PatternT dec
$cmax :: forall dec. Ord dec => PatternT dec -> PatternT dec -> PatternT dec
>= :: PatternT dec -> PatternT dec -> Bool
$c>= :: forall dec. Ord dec => PatternT dec -> PatternT dec -> Bool
> :: PatternT dec -> PatternT dec -> Bool
$c> :: forall dec. Ord dec => PatternT dec -> PatternT dec -> Bool
<= :: PatternT dec -> PatternT dec -> Bool
$c<= :: forall dec. Ord dec => PatternT dec -> PatternT dec -> Bool
< :: PatternT dec -> PatternT dec -> Bool
$c< :: forall dec. Ord dec => PatternT dec -> PatternT dec -> Bool
compare :: PatternT dec -> PatternT dec -> Ordering
$ccompare :: forall dec. Ord dec => PatternT dec -> PatternT dec -> Ordering
$cp1Ord :: forall dec. Ord dec => Eq (PatternT dec)
Ord, Int -> PatternT dec -> ShowS
[PatternT dec] -> ShowS
PatternT dec -> String
(Int -> PatternT dec -> ShowS)
-> (PatternT dec -> String)
-> ([PatternT dec] -> ShowS)
-> Show (PatternT dec)
forall dec. Show dec => Int -> PatternT dec -> ShowS
forall dec. Show dec => [PatternT dec] -> ShowS
forall dec. Show dec => PatternT dec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PatternT dec] -> ShowS
$cshowList :: forall dec. Show dec => [PatternT dec] -> ShowS
show :: PatternT dec -> String
$cshow :: forall dec. Show dec => PatternT dec -> String
showsPrec :: Int -> PatternT dec -> ShowS
$cshowsPrec :: forall dec. Show dec => Int -> PatternT dec -> ShowS
Show, PatternT dec -> PatternT dec -> Bool
(PatternT dec -> PatternT dec -> Bool)
-> (PatternT dec -> PatternT dec -> Bool) -> Eq (PatternT dec)
forall dec. Eq dec => PatternT dec -> PatternT dec -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PatternT dec -> PatternT dec -> Bool
$c/= :: forall dec. Eq dec => PatternT dec -> PatternT dec -> Bool
== :: PatternT dec -> PatternT dec -> Bool
$c== :: forall dec. Eq dec => PatternT dec -> PatternT dec -> Bool
Eq, (forall x. PatternT dec -> Rep (PatternT dec) x)
-> (forall x. Rep (PatternT dec) x -> PatternT dec)
-> Generic (PatternT dec)
forall x. Rep (PatternT dec) x -> PatternT dec
forall x. PatternT dec -> Rep (PatternT dec) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall dec x. Rep (PatternT dec) x -> PatternT dec
forall dec x. PatternT dec -> Rep (PatternT dec) x
$cto :: forall dec x. Rep (PatternT dec) x -> PatternT dec
$cfrom :: forall dec x. PatternT dec -> Rep (PatternT dec) x
Generic)

instance SexpIso dec => SexpIso (PatternT dec) where
  sexpIso :: Grammar Position (Sexp :- t) (PatternT dec :- t)
sexpIso = (Grammar
   Position
   ([PatElemT dec] :- ([PatElemT dec] :- t))
   (PatternT dec :- t)
 -> Grammar Position (Sexp :- t) (PatternT dec :- t))
-> Grammar Position (Sexp :- t) (PatternT dec :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    ([PatElemT dec] :- ([PatElemT dec] :- t))
    (PatternT dec :- t)
  -> Grammar Position (Sexp :- t) (PatternT dec :- t))
 -> Grammar Position (Sexp :- t) (PatternT dec :- t))
-> (Grammar
      Position
      ([PatElemT dec] :- ([PatElemT dec] :- t))
      (PatternT dec :- t)
    -> Grammar Position (Sexp :- t) (PatternT dec :- t))
-> Grammar Position (Sexp :- t) (PatternT dec :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  ([PatElemT dec] :- ([PatElemT dec] :- t))
  (PatternT dec :- t)
vname ->
    Grammar
  Position
  (List :- t)
  (List :- ([PatElemT dec] :- ([PatElemT dec] :- t)))
-> Grammar
     Position (Sexp :- t) ([PatElemT dec] :- ([PatElemT dec] :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) ([PatElemT dec] :- t)
-> Grammar Position (List :- t) (List :- ([PatElemT dec] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([PatElemT dec] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- ([PatElemT dec] :- t))
-> Grammar
     Position
     (List :- ([PatElemT dec] :- t))
     (List :- ([PatElemT dec] :- ([PatElemT dec] :- t)))
-> Grammar
     Position
     (List :- t)
     (List :- ([PatElemT dec] :- ([PatElemT dec] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([PatElemT dec] :- t))
  ([PatElemT dec] :- ([PatElemT dec] :- t))
-> Grammar
     Position
     (List :- ([PatElemT dec] :- t))
     (List :- ([PatElemT dec] :- ([PatElemT dec] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([PatElemT dec] :- t))
  ([PatElemT dec] :- ([PatElemT dec] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position (Sexp :- t) ([PatElemT dec] :- ([PatElemT dec] :- t))
-> Grammar
     Position
     ([PatElemT dec] :- ([PatElemT dec] :- t))
     (PatternT dec :- t)
-> Grammar Position (Sexp :- t) (PatternT dec :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  ([PatElemT dec] :- ([PatElemT dec] :- t))
  (PatternT dec :- t)
vname

instance Semigroup (PatternT dec) where
  Pattern [PatElemT dec]
cs1 [PatElemT dec]
vs1 <> :: PatternT dec -> PatternT dec -> PatternT dec
<> Pattern [PatElemT dec]
cs2 [PatElemT dec]
vs2 = [PatElemT dec] -> [PatElemT dec] -> PatternT dec
forall dec. [PatElemT dec] -> [PatElemT dec] -> PatternT dec
Pattern ([PatElemT dec]
cs1 [PatElemT dec] -> [PatElemT dec] -> [PatElemT dec]
forall a. [a] -> [a] -> [a]
++ [PatElemT dec]
cs2) ([PatElemT dec]
vs1 [PatElemT dec] -> [PatElemT dec] -> [PatElemT dec]
forall a. [a] -> [a] -> [a]
++ [PatElemT dec]
vs2)

instance Monoid (PatternT dec) where
  mempty :: PatternT dec
mempty = [PatElemT dec] -> [PatElemT dec] -> PatternT dec
forall dec. [PatElemT dec] -> [PatElemT dec] -> PatternT dec
Pattern [] []

instance Functor PatternT where
  fmap :: (a -> b) -> PatternT a -> PatternT b
fmap = (a -> b) -> PatternT a -> PatternT b
forall (t :: * -> *) a b. Traversable t => (a -> b) -> t a -> t b
fmapDefault

instance Foldable PatternT where
  foldMap :: (a -> m) -> PatternT a -> m
foldMap = (a -> m) -> PatternT a -> m
forall (t :: * -> *) m a.
(Traversable t, Monoid m) =>
(a -> m) -> t a -> m
foldMapDefault

instance Traversable PatternT where
  traverse :: (a -> f b) -> PatternT a -> f (PatternT b)
traverse a -> f b
f (Pattern [PatElemT a]
ctx [PatElemT a]
vals) =
    [PatElemT b] -> [PatElemT b] -> PatternT b
forall dec. [PatElemT dec] -> [PatElemT dec] -> PatternT dec
Pattern ([PatElemT b] -> [PatElemT b] -> PatternT b)
-> f [PatElemT b] -> f ([PatElemT b] -> PatternT b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatElemT a -> f (PatElemT b)) -> [PatElemT a] -> f [PatElemT b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((a -> f b) -> PatElemT a -> f (PatElemT b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f) [PatElemT a]
ctx f ([PatElemT b] -> PatternT b) -> f [PatElemT b] -> f (PatternT b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatElemT a -> f (PatElemT b)) -> [PatElemT a] -> f [PatElemT b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((a -> f b) -> PatElemT a -> f (PatElemT b)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f) [PatElemT a]
vals

-- | A type alias for namespace control.
type Pattern lore = PatternT (LetDec lore)

-- | Auxilliary Information associated with a statement.
data StmAux dec = StmAux
  { StmAux dec -> Certificates
stmAuxCerts :: !Certificates,
    StmAux dec -> Attrs
stmAuxAttrs :: Attrs,
    StmAux dec -> dec
stmAuxDec :: dec
  }
  deriving (Eq (StmAux dec)
Eq (StmAux dec)
-> (StmAux dec -> StmAux dec -> Ordering)
-> (StmAux dec -> StmAux dec -> Bool)
-> (StmAux dec -> StmAux dec -> Bool)
-> (StmAux dec -> StmAux dec -> Bool)
-> (StmAux dec -> StmAux dec -> Bool)
-> (StmAux dec -> StmAux dec -> StmAux dec)
-> (StmAux dec -> StmAux dec -> StmAux dec)
-> Ord (StmAux dec)
StmAux dec -> StmAux dec -> Bool
StmAux dec -> StmAux dec -> Ordering
StmAux dec -> StmAux dec -> StmAux dec
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall dec. Ord dec => Eq (StmAux dec)
forall dec. Ord dec => StmAux dec -> StmAux dec -> Bool
forall dec. Ord dec => StmAux dec -> StmAux dec -> Ordering
forall dec. Ord dec => StmAux dec -> StmAux dec -> StmAux dec
min :: StmAux dec -> StmAux dec -> StmAux dec
$cmin :: forall dec. Ord dec => StmAux dec -> StmAux dec -> StmAux dec
max :: StmAux dec -> StmAux dec -> StmAux dec
$cmax :: forall dec. Ord dec => StmAux dec -> StmAux dec -> StmAux dec
>= :: StmAux dec -> StmAux dec -> Bool
$c>= :: forall dec. Ord dec => StmAux dec -> StmAux dec -> Bool
> :: StmAux dec -> StmAux dec -> Bool
$c> :: forall dec. Ord dec => StmAux dec -> StmAux dec -> Bool
<= :: StmAux dec -> StmAux dec -> Bool
$c<= :: forall dec. Ord dec => StmAux dec -> StmAux dec -> Bool
< :: StmAux dec -> StmAux dec -> Bool
$c< :: forall dec. Ord dec => StmAux dec -> StmAux dec -> Bool
compare :: StmAux dec -> StmAux dec -> Ordering
$ccompare :: forall dec. Ord dec => StmAux dec -> StmAux dec -> Ordering
$cp1Ord :: forall dec. Ord dec => Eq (StmAux dec)
Ord, Int -> StmAux dec -> ShowS
[StmAux dec] -> ShowS
StmAux dec -> String
(Int -> StmAux dec -> ShowS)
-> (StmAux dec -> String)
-> ([StmAux dec] -> ShowS)
-> Show (StmAux dec)
forall dec. Show dec => Int -> StmAux dec -> ShowS
forall dec. Show dec => [StmAux dec] -> ShowS
forall dec. Show dec => StmAux dec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StmAux dec] -> ShowS
$cshowList :: forall dec. Show dec => [StmAux dec] -> ShowS
show :: StmAux dec -> String
$cshow :: forall dec. Show dec => StmAux dec -> String
showsPrec :: Int -> StmAux dec -> ShowS
$cshowsPrec :: forall dec. Show dec => Int -> StmAux dec -> ShowS
Show, StmAux dec -> StmAux dec -> Bool
(StmAux dec -> StmAux dec -> Bool)
-> (StmAux dec -> StmAux dec -> Bool) -> Eq (StmAux dec)
forall dec. Eq dec => StmAux dec -> StmAux dec -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StmAux dec -> StmAux dec -> Bool
$c/= :: forall dec. Eq dec => StmAux dec -> StmAux dec -> Bool
== :: StmAux dec -> StmAux dec -> Bool
$c== :: forall dec. Eq dec => StmAux dec -> StmAux dec -> Bool
Eq, (forall x. StmAux dec -> Rep (StmAux dec) x)
-> (forall x. Rep (StmAux dec) x -> StmAux dec)
-> Generic (StmAux dec)
forall x. Rep (StmAux dec) x -> StmAux dec
forall x. StmAux dec -> Rep (StmAux dec) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall dec x. Rep (StmAux dec) x -> StmAux dec
forall dec x. StmAux dec -> Rep (StmAux dec) x
$cto :: forall dec x. Rep (StmAux dec) x -> StmAux dec
$cfrom :: forall dec x. StmAux dec -> Rep (StmAux dec) x
Generic)

instance SexpIso dec => SexpIso (StmAux dec) where
  sexpIso :: Grammar Position (Sexp :- t) (StmAux dec :- t)
sexpIso = (Grammar
   Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
 -> Grammar Position (Sexp :- t) (StmAux dec :- t))
-> Grammar Position (Sexp :- t) (StmAux dec :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
  -> Grammar Position (Sexp :- t) (StmAux dec :- t))
 -> Grammar Position (Sexp :- t) (StmAux dec :- t))
-> (Grammar
      Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
    -> Grammar Position (Sexp :- t) (StmAux dec :- t))
-> Grammar Position (Sexp :- t) (StmAux dec :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
vname ->
    Grammar
  Position
  (List :- t)
  (List :- (dec :- (Attrs :- (Certificates :- t))))
-> Grammar
     Position (Sexp :- t) (dec :- (Attrs :- (Certificates :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"aux")
          Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- (dec :- (Attrs :- (Certificates :- t))))
-> Grammar
     Position
     (List :- t)
     (List :- (dec :- (Attrs :- (Certificates :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Certificates :- t)
-> Grammar Position (List :- t) (List :- (Certificates :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Certificates :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- (Certificates :- t))
-> Grammar
     Position
     (List :- (Certificates :- t))
     (List :- (dec :- (Attrs :- (Certificates :- t))))
-> Grammar
     Position
     (List :- t)
     (List :- (dec :- (Attrs :- (Certificates :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Certificates :- t))
  (Attrs :- (Certificates :- t))
-> Grammar
     Position
     (List :- (Certificates :- t))
     (List :- (Attrs :- (Certificates :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Certificates :- t))
  (Attrs :- (Certificates :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (Certificates :- t))
  (List :- (Attrs :- (Certificates :- t)))
-> Grammar
     Position
     (List :- (Attrs :- (Certificates :- t)))
     (List :- (dec :- (Attrs :- (Certificates :- t))))
-> Grammar
     Position
     (List :- (Certificates :- t))
     (List :- (dec :- (Attrs :- (Certificates :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Attrs :- (Certificates :- t)))
  (dec :- (Attrs :- (Certificates :- t)))
-> Grammar
     Position
     (List :- (Attrs :- (Certificates :- t)))
     (List :- (dec :- (Attrs :- (Certificates :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Attrs :- (Certificates :- t)))
  (dec :- (Attrs :- (Certificates :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position (Sexp :- t) (dec :- (Attrs :- (Certificates :- t)))
-> Grammar
     Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
-> Grammar Position (Sexp :- t) (StmAux dec :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (dec :- (Attrs :- (Certificates :- t))) (StmAux dec :- t)
vname

instance Semigroup dec => Semigroup (StmAux dec) where
  StmAux Certificates
cs1 Attrs
attrs1 dec
dec1 <> :: StmAux dec -> StmAux dec -> StmAux dec
<> StmAux Certificates
cs2 Attrs
attrs2 dec
dec2 =
    Certificates -> Attrs -> dec -> StmAux dec
forall dec. Certificates -> Attrs -> dec -> StmAux dec
StmAux (Certificates
cs1 Certificates -> Certificates -> Certificates
forall a. Semigroup a => a -> a -> a
<> Certificates
cs2) (Attrs
attrs1 Attrs -> Attrs -> Attrs
forall a. Semigroup a => a -> a -> a
<> Attrs
attrs2) (dec
dec1 dec -> dec -> dec
forall a. Semigroup a => a -> a -> a
<> dec
dec2)

-- | A local variable binding.
data Stm lore = Let
  { -- | Pattern.
    Stm lore -> Pattern lore
stmPattern :: Pattern lore,
    -- | Auxiliary information statement.
    Stm lore -> StmAux (ExpDec lore)
stmAux :: StmAux (ExpDec lore),
    -- | Expression.
    Stm lore -> Exp lore
stmExp :: Exp lore
  }
  deriving ((forall x. Stm lore -> Rep (Stm lore) x)
-> (forall x. Rep (Stm lore) x -> Stm lore) -> Generic (Stm lore)
forall x. Rep (Stm lore) x -> Stm lore
forall x. Stm lore -> Rep (Stm lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (Stm lore) x -> Stm lore
forall lore x. Stm lore -> Rep (Stm lore) x
$cto :: forall lore x. Rep (Stm lore) x -> Stm lore
$cfrom :: forall lore x. Stm lore -> Rep (Stm lore) x
Generic)

instance Decorations lore => SexpIso (Stm lore) where
  sexpIso :: Grammar Position (Sexp :- t) (Stm lore :- t)
sexpIso = (Grammar
   Position
   (ExpT lore
    :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
   (Stm lore :- t)
 -> Grammar Position (Sexp :- t) (Stm lore :- t))
-> Grammar Position (Sexp :- t) (Stm lore :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    (ExpT lore
     :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
    (Stm lore :- t)
  -> Grammar Position (Sexp :- t) (Stm lore :- t))
 -> Grammar Position (Sexp :- t) (Stm lore :- t))
-> (Grammar
      Position
      (ExpT lore
       :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
      (Stm lore :- t)
    -> Grammar Position (Sexp :- t) (Stm lore :- t))
-> Grammar Position (Sexp :- t) (Stm lore :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  (ExpT lore
   :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
  (Stm lore :- t)
stm ->
    Grammar
  Position
  (List :- t)
  (List
   :- (ExpT lore
       :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
-> Grammar
     Position
     (Sexp :- t)
     (ExpT lore
      :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"let")
          Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (PatternT (LetDec lore) :- t)
-> Grammar
     Position (List :- t) (List :- (PatternT (LetDec lore) :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (PatternT (LetDec lore) :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position (List :- t) (List :- (PatternT (LetDec lore) :- t))
-> Grammar
     Position
     (List :- (PatternT (LetDec lore) :- t))
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (PatternT (LetDec lore) :- t))
  (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))
-> Grammar
     Position
     (List :- (PatternT (LetDec lore) :- t))
     (List :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (PatternT (LetDec lore) :- t))
  (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (PatternT (LetDec lore) :- t))
  (List :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
-> Grammar
     Position
     (List :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
-> Grammar
     Position
     (List :- (PatternT (LetDec lore) :- t))
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
  (ExpT lore
   :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
-> Grammar
     Position
     (List :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
     (List
      :- (ExpT lore
          :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
  (ExpT lore
   :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position
  (Sexp :- t)
  (ExpT lore
   :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
-> Grammar
     Position
     (ExpT lore
      :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
     (Stm lore :- t)
-> Grammar Position (Sexp :- t) (Stm lore :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (ExpT lore
   :- (StmAux (ExpDec lore) :- (PatternT (LetDec lore) :- t)))
  (Stm lore :- t)
stm

deriving instance Decorations lore => Ord (Stm lore)

deriving instance Decorations lore => Show (Stm lore)

deriving instance Decorations lore => Eq (Stm lore)

-- | A sequence of statements.
type Stms lore = Seq.Seq (Stm lore)

instance Decorations lore => SexpIso (Stms lore) where
  sexpIso :: Grammar Position (Sexp :- t) (Stms lore :- t)
sexpIso = ([Stm lore] -> Stms lore)
-> (Stms lore -> [Stm lore])
-> Grammar Position ([Stm lore] :- t) (Stms lore :- t)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso [Stm lore] -> Stms lore
forall lore. [Stm lore] -> Stms lore
stmsFromList Stms lore -> [Stm lore]
forall lore. Stms lore -> [Stm lore]
stmsToList Grammar Position ([Stm lore] :- t) (Stms lore :- t)
-> Grammar Position (Sexp :- t) ([Stm lore] :- t)
-> Grammar Position (Sexp :- t) (Stms lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t) ([Stm lore] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso

-- | A single statement.
oneStm :: Stm lore -> Stms lore
oneStm :: Stm lore -> Stms lore
oneStm = Stm lore -> Stms lore
forall a. a -> Seq a
Seq.singleton

-- | Convert a statement list to a statement sequence.
stmsFromList :: [Stm lore] -> Stms lore
stmsFromList :: [Stm lore] -> Stms lore
stmsFromList = [Stm lore] -> Stms lore
forall a. [a] -> Seq a
Seq.fromList

-- | Convert a statement sequence to a statement list.
stmsToList :: Stms lore -> [Stm lore]
stmsToList :: Stms lore -> [Stm lore]
stmsToList = Stms lore -> [Stm lore]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList

-- | The first statement in the sequence, if any.
stmsHead :: Stms lore -> Maybe (Stm lore, Stms lore)
stmsHead :: Stms lore -> Maybe (Stm lore, Stms lore)
stmsHead Stms lore
stms = case Stms lore -> ViewL (Stm lore)
forall a. Seq a -> ViewL a
Seq.viewl Stms lore
stms of
  Stm lore
stm Seq.:< Stms lore
stms' -> (Stm lore, Stms lore) -> Maybe (Stm lore, Stms lore)
forall a. a -> Maybe a
Just (Stm lore
stm, Stms lore
stms')
  ViewL (Stm lore)
Seq.EmptyL -> Maybe (Stm lore, Stms lore)
forall a. Maybe a
Nothing

-- | The result of a body is a sequence of subexpressions.
type Result = [SubExp]

-- | A body consists of a number of bindings, terminating in a result
-- (essentially a tuple literal).
data BodyT lore = Body
  { BodyT lore -> BodyDec lore
bodyDec :: BodyDec lore,
    BodyT lore -> Stms lore
bodyStms :: Stms lore,
    BodyT lore -> Result
bodyResult :: Result
  }
  deriving ((forall x. BodyT lore -> Rep (BodyT lore) x)
-> (forall x. Rep (BodyT lore) x -> BodyT lore)
-> Generic (BodyT lore)
forall x. Rep (BodyT lore) x -> BodyT lore
forall x. BodyT lore -> Rep (BodyT lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (BodyT lore) x -> BodyT lore
forall lore x. BodyT lore -> Rep (BodyT lore) x
$cto :: forall lore x. Rep (BodyT lore) x -> BodyT lore
$cfrom :: forall lore x. BodyT lore -> Rep (BodyT lore) x
Generic)

instance Decorations lore => SexpIso (BodyT lore) where
  sexpIso :: Grammar Position (Sexp :- t) (BodyT lore :- t)
sexpIso = (Grammar
   Position
   (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
   (BodyT lore :- t)
 -> Grammar Position (Sexp :- t) (BodyT lore :- t))
-> Grammar Position (Sexp :- t) (BodyT lore :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
    (BodyT lore :- t)
  -> Grammar Position (Sexp :- t) (BodyT lore :- t))
 -> Grammar Position (Sexp :- t) (BodyT lore :- t))
-> (Grammar
      Position
      (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
      (BodyT lore :- t)
    -> Grammar Position (Sexp :- t) (BodyT lore :- t))
-> Grammar Position (Sexp :- t) (BodyT lore :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
  (BodyT lore :- t)
stm ->
    Grammar
  Position
  (List :- t)
  (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
-> Grammar
     Position
     (Sexp :- t)
     (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) (BodyDec lore :- t)
-> Grammar Position (List :- t) (List :- (BodyDec lore :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (BodyDec lore :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- (BodyDec lore :- t))
-> Grammar
     Position
     (List :- (BodyDec lore :- t))
     (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
-> Grammar
     Position
     (List :- t)
     (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (BodyDec lore :- t))
  (Seq (Stm lore) :- (BodyDec lore :- t))
-> Grammar
     Position
     (List :- (BodyDec lore :- t))
     (List :- (Seq (Stm lore) :- (BodyDec lore :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (BodyDec lore :- t))
  (Seq (Stm lore) :- (BodyDec lore :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (BodyDec lore :- t))
  (List :- (Seq (Stm lore) :- (BodyDec lore :- t)))
-> Grammar
     Position
     (List :- (Seq (Stm lore) :- (BodyDec lore :- t)))
     (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
-> Grammar
     Position
     (List :- (BodyDec lore :- t))
     (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Seq (Stm lore) :- (BodyDec lore :- t)))
  (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
-> Grammar
     Position
     (List :- (Seq (Stm lore) :- (BodyDec lore :- t)))
     (List :- (Result :- (Seq (Stm lore) :- (BodyDec lore :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Seq (Stm lore) :- (BodyDec lore :- t)))
  (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position
  (Sexp :- t)
  (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
-> Grammar
     Position
     (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
     (BodyT lore :- t)
-> Grammar Position (Sexp :- t) (BodyT lore :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Result :- (Seq (Stm lore) :- (BodyDec lore :- t)))
  (BodyT lore :- t)
stm

deriving instance Decorations lore => Ord (BodyT lore)

deriving instance Decorations lore => Show (BodyT lore)

deriving instance Decorations lore => Eq (BodyT lore)

-- | Type alias for namespace reasons.
type Body = BodyT

-- | The new dimension in a 'Reshape'-like operation.  This allows us to
-- disambiguate "real" reshapes, that change the actual shape of the
-- array, from type coercions that are just present to make the types
-- work out.  The two constructors are considered equal for purposes of 'Eq'.
data DimChange d
  = -- | The new dimension is guaranteed to be numerically
    -- equal to the old one.
    DimCoercion d
  | -- | The new dimension is not necessarily numerically
    -- equal to the old one.
    DimNew d
  deriving (Eq (DimChange d)
Eq (DimChange d)
-> (DimChange d -> DimChange d -> Ordering)
-> (DimChange d -> DimChange d -> Bool)
-> (DimChange d -> DimChange d -> Bool)
-> (DimChange d -> DimChange d -> Bool)
-> (DimChange d -> DimChange d -> Bool)
-> (DimChange d -> DimChange d -> DimChange d)
-> (DimChange d -> DimChange d -> DimChange d)
-> Ord (DimChange d)
DimChange d -> DimChange d -> Bool
DimChange d -> DimChange d -> Ordering
DimChange d -> DimChange d -> DimChange d
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall d. Ord d => Eq (DimChange d)
forall d. Ord d => DimChange d -> DimChange d -> Bool
forall d. Ord d => DimChange d -> DimChange d -> Ordering
forall d. Ord d => DimChange d -> DimChange d -> DimChange d
min :: DimChange d -> DimChange d -> DimChange d
$cmin :: forall d. Ord d => DimChange d -> DimChange d -> DimChange d
max :: DimChange d -> DimChange d -> DimChange d
$cmax :: forall d. Ord d => DimChange d -> DimChange d -> DimChange d
>= :: DimChange d -> DimChange d -> Bool
$c>= :: forall d. Ord d => DimChange d -> DimChange d -> Bool
> :: DimChange d -> DimChange d -> Bool
$c> :: forall d. Ord d => DimChange d -> DimChange d -> Bool
<= :: DimChange d -> DimChange d -> Bool
$c<= :: forall d. Ord d => DimChange d -> DimChange d -> Bool
< :: DimChange d -> DimChange d -> Bool
$c< :: forall d. Ord d => DimChange d -> DimChange d -> Bool
compare :: DimChange d -> DimChange d -> Ordering
$ccompare :: forall d. Ord d => DimChange d -> DimChange d -> Ordering
$cp1Ord :: forall d. Ord d => Eq (DimChange d)
Ord, Int -> DimChange d -> ShowS
[DimChange d] -> ShowS
DimChange d -> String
(Int -> DimChange d -> ShowS)
-> (DimChange d -> String)
-> ([DimChange d] -> ShowS)
-> Show (DimChange d)
forall d. Show d => Int -> DimChange d -> ShowS
forall d. Show d => [DimChange d] -> ShowS
forall d. Show d => DimChange d -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DimChange d] -> ShowS
$cshowList :: forall d. Show d => [DimChange d] -> ShowS
show :: DimChange d -> String
$cshow :: forall d. Show d => DimChange d -> String
showsPrec :: Int -> DimChange d -> ShowS
$cshowsPrec :: forall d. Show d => Int -> DimChange d -> ShowS
Show, (forall x. DimChange d -> Rep (DimChange d) x)
-> (forall x. Rep (DimChange d) x -> DimChange d)
-> Generic (DimChange d)
forall x. Rep (DimChange d) x -> DimChange d
forall x. DimChange d -> Rep (DimChange d) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall d x. Rep (DimChange d) x -> DimChange d
forall d x. DimChange d -> Rep (DimChange d) x
$cto :: forall d x. Rep (DimChange d) x -> DimChange d
$cfrom :: forall d x. DimChange d -> Rep (DimChange d) x
Generic)

instance SexpIso d => SexpIso (DimChange d) where
  sexpIso :: Grammar Position (Sexp :- t) (DimChange d :- t)
sexpIso =
    Coproduct Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t
-> Grammar Position (Sexp :- t) (DimChange d :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t
 -> Grammar Position (Sexp :- t) (DimChange d :- t))
-> Coproduct Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t
-> Grammar Position (Sexp :- t) (DimChange d :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position (d :- t) (DimChange d :- t)
 -> Grammar Position (Sexp :- t) (DimChange d :- t))
-> Coproduct Position (Sexp :- t) '[d :- t] (DimChange d) t
-> Coproduct Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (d :- t) (DimChange d :- t)
-> Grammar Position (Sexp :- t) (d :- t)
-> Grammar Position (Sexp :- t) (DimChange d :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (d :- t))
-> Grammar Position (Sexp :- t) (d :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"coercion") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (d :- t))
-> Grammar Position (List :- t) (List :- (d :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (d :- t)
-> Grammar Position (List :- t) (List :- (d :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (d :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[d :- t] (DimChange d) t
 -> Coproduct
      Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t)
-> Coproduct Position (Sexp :- t) '[d :- t] (DimChange d) t
-> Coproduct Position (Sexp :- t) '[d :- t, d :- t] (DimChange d) t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position (d :- t) (DimChange d :- t)
 -> Grammar Position (Sexp :- t) (DimChange d :- t))
-> Coproduct Position (Sexp :- t) '[] (DimChange d) t
-> Coproduct Position (Sexp :- t) '[d :- t] (DimChange d) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
          (Grammar Position (d :- t) (DimChange d :- t)
-> Grammar Position (Sexp :- t) (d :- t)
-> Grammar Position (Sexp :- t) (DimChange d :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (d :- t))
-> Grammar Position (Sexp :- t) (d :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"new") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (d :- t))
-> Grammar Position (List :- t) (List :- (d :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (d :- t)
-> Grammar Position (List :- t) (List :- (d :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (d :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso))
          Coproduct Position (Sexp :- t) '[] (DimChange d) t
forall p s a t. Coproduct p s '[] a t
End

instance Eq d => Eq (DimChange d) where
  DimCoercion d
x == :: DimChange d -> DimChange d -> Bool
== DimNew d
y = d
x d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
y
  DimCoercion d
x == DimCoercion d
y = d
x d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
y
  DimNew d
x == DimCoercion d
y = d
x d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
y
  DimNew d
x == DimNew d
y = d
x d -> d -> Bool
forall a. Eq a => a -> a -> Bool
== d
y

instance Functor DimChange where
  fmap :: (a -> b) -> DimChange a -> DimChange b
fmap a -> b
f (DimCoercion a
d) = b -> DimChange b
forall d. d -> DimChange d
DimCoercion (b -> DimChange b) -> b -> DimChange b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
d
  fmap a -> b
f (DimNew a
d) = b -> DimChange b
forall d. d -> DimChange d
DimNew (b -> DimChange b) -> b -> DimChange b
forall a b. (a -> b) -> a -> b
$ a -> b
f a
d

instance Foldable DimChange where
  foldMap :: (a -> m) -> DimChange a -> m
foldMap a -> m
f (DimCoercion a
d) = a -> m
f a
d
  foldMap a -> m
f (DimNew a
d) = a -> m
f a
d

instance Traversable DimChange where
  traverse :: (a -> f b) -> DimChange a -> f (DimChange b)
traverse a -> f b
f (DimCoercion a
d) = b -> DimChange b
forall d. d -> DimChange d
DimCoercion (b -> DimChange b) -> f b -> f (DimChange b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
d
  traverse a -> f b
f (DimNew a
d) = b -> DimChange b
forall d. d -> DimChange d
DimNew (b -> DimChange b) -> f b -> f (DimChange b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
d

-- | A list of 'DimChange's, indicating the new dimensions of an array.
type ShapeChange d = [DimChange d]

-- | A primitive operation that returns something of known size and
-- does not itself contain any bindings.
data BasicOp
  = -- | A variable or constant.
    SubExp SubExp
  | -- | Semantically and operationally just identity, but is
    -- invisible/impenetrable to optimisations (hopefully).  This is
    -- just a hack to avoid optimisation (so, to work around compiler
    -- limitations).
    Opaque SubExp
  | -- | Array literals, e.g., @[ [1+x, 3], [2, 1+4] ]@.
    -- Second arg is the element type of the rows of the array.
    ArrayLit [SubExp] Type
  | -- | Unary operation.
    UnOp UnOp SubExp
  | -- | Binary operation.
    BinOp BinOp SubExp SubExp
  | -- | Comparison - result type is always boolean.
    CmpOp CmpOp SubExp SubExp
  | -- | Conversion "casting".
    ConvOp ConvOp SubExp
  | -- | Turn a boolean into a certificate, halting the program with the
    -- given error message if the boolean is false.
    Assert SubExp (ErrorMsg SubExp) (SrcLoc, [SrcLoc])
  | -- Primitive array operations

    -- | The certificates for bounds-checking are part of the 'Stm'.
    Index VName (Slice SubExp)
  | -- | An in-place update of the given array at the given position.
    -- Consumes the array.
    Update VName (Slice SubExp) SubExp
  | -- | @concat@0([1],[2, 3, 4]) = [1, 2, 3, 4]@.
    Concat Int VName [VName] SubExp
  | -- | Copy the given array.  The result will not alias anything.
    Copy VName
  | -- | Manifest an array with dimensions represented in the given
    -- order.  The result will not alias anything.
    Manifest [Int] VName
  | -- Array construction.

    -- | @iota(n, x, s) = [x,x+s,..,x+(n-1)*s]@.
    --
    -- The t'IntType' indicates the type of the array returned and the
    -- offset/stride arguments, but not the length argument.
    Iota SubExp SubExp SubExp IntType
  | -- | @replicate([3][2],1) = [[1,1], [1,1], [1,1]]@
    Replicate Shape SubExp
  | -- | Create array of given type and shape, with undefined elements.
    Scratch PrimType [SubExp]
  | -- Array index space transformation.

    -- | 1st arg is the new shape, 2nd arg is the input array *)
    Reshape (ShapeChange SubExp) VName
  | -- | Permute the dimensions of the input array.  The list
    -- of integers is a list of dimensions (0-indexed), which
    -- must be a permutation of @[0,n-1]@, where @n@ is the
    -- number of dimensions in the input array.
    Rearrange [Int] VName
  | -- | Rotate the dimensions of the input array.  The list of
    -- subexpressions specify how much each dimension is rotated.  The
    -- length of this list must be equal to the rank of the array.
    Rotate [SubExp] VName
  deriving (BasicOp -> BasicOp -> Bool
(BasicOp -> BasicOp -> Bool)
-> (BasicOp -> BasicOp -> Bool) -> Eq BasicOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BasicOp -> BasicOp -> Bool
$c/= :: BasicOp -> BasicOp -> Bool
== :: BasicOp -> BasicOp -> Bool
$c== :: BasicOp -> BasicOp -> Bool
Eq, Eq BasicOp
Eq BasicOp
-> (BasicOp -> BasicOp -> Ordering)
-> (BasicOp -> BasicOp -> Bool)
-> (BasicOp -> BasicOp -> Bool)
-> (BasicOp -> BasicOp -> Bool)
-> (BasicOp -> BasicOp -> Bool)
-> (BasicOp -> BasicOp -> BasicOp)
-> (BasicOp -> BasicOp -> BasicOp)
-> Ord BasicOp
BasicOp -> BasicOp -> Bool
BasicOp -> BasicOp -> Ordering
BasicOp -> BasicOp -> BasicOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: BasicOp -> BasicOp -> BasicOp
$cmin :: BasicOp -> BasicOp -> BasicOp
max :: BasicOp -> BasicOp -> BasicOp
$cmax :: BasicOp -> BasicOp -> BasicOp
>= :: BasicOp -> BasicOp -> Bool
$c>= :: BasicOp -> BasicOp -> Bool
> :: BasicOp -> BasicOp -> Bool
$c> :: BasicOp -> BasicOp -> Bool
<= :: BasicOp -> BasicOp -> Bool
$c<= :: BasicOp -> BasicOp -> Bool
< :: BasicOp -> BasicOp -> Bool
$c< :: BasicOp -> BasicOp -> Bool
compare :: BasicOp -> BasicOp -> Ordering
$ccompare :: BasicOp -> BasicOp -> Ordering
$cp1Ord :: Eq BasicOp
Ord, Int -> BasicOp -> ShowS
[BasicOp] -> ShowS
BasicOp -> String
(Int -> BasicOp -> ShowS)
-> (BasicOp -> String) -> ([BasicOp] -> ShowS) -> Show BasicOp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BasicOp] -> ShowS
$cshowList :: [BasicOp] -> ShowS
show :: BasicOp -> String
$cshow :: BasicOp -> String
showsPrec :: Int -> BasicOp -> ShowS
$cshowsPrec :: Int -> BasicOp -> ShowS
Show, (forall x. BasicOp -> Rep BasicOp x)
-> (forall x. Rep BasicOp x -> BasicOp) -> Generic BasicOp
forall x. Rep BasicOp x -> BasicOp
forall x. BasicOp -> Rep BasicOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BasicOp x -> BasicOp
$cfrom :: forall x. BasicOp -> Rep BasicOp x
Generic)

instance SexpIso BasicOp where
  sexpIso :: Grammar Position (Sexp :- t) (BasicOp :- t)
sexpIso =
    Coproduct
  Position
  (Sexp :- t)
  '[SubExp :- t, SubExp :- t,
    TypeBase Shape NoUniqueness :- (Result :- t),
    SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
    SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
    (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
    [DimIndex SubExp] :- (VName :- t),
    SubExp :- ([DimIndex SubExp] :- (VName :- t)),
    SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
    VName :- ([Int] :- t),
    IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
    SubExp :- (Shape :- t), Result :- (PrimType :- t),
    VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
    VName :- (Result :- t)]
  BasicOp
  t
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- t, SubExp :- t,
     TypeBase Shape NoUniqueness :- (Result :- t),
     SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
     SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, SubExp :- t,
       TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position (SubExp :- t) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, SubExp :- t,
       TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (SubExp :- t) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar Position (Sexp :- t) (SubExp :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (SubExp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
     SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
     SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- t, SubExp :- t,
        TypeBase Shape NoUniqueness :- (Result :- t),
        SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
        SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, SubExp :- t,
       TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position (SubExp :- t) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (SubExp :- t) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar Position (Sexp :- t) (SubExp :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"opaque") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (SubExp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[TypeBase Shape NoUniqueness :- (Result :- t),
     SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
     SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
        SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
        SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- t, TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
          (Grammar
   Position
   (TypeBase Shape NoUniqueness :- (Result :- t))
   (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (TypeBase Shape NoUniqueness :- (Result :- t))
  (BasicOp :- t)
-> Grammar
     Position (Sexp :- t) (TypeBase Shape NoUniqueness :- (Result :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
-> Grammar
     Position (Sexp :- t) (TypeBase Shape NoUniqueness :- (Result :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"array") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
-> Grammar
     Position
     (List :- t)
     (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Result :- t)
-> Grammar Position (List :- t) (List :- (Result :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Result :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Result :- t))
-> Grammar
     Position
     (List :- (Result :- t))
     (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
-> Grammar
     Position
     (List :- t)
     (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Result :- t))
  (TypeBase Shape NoUniqueness :- (Result :- t))
-> Grammar
     Position
     (List :- (Result :- t))
     (List :- (TypeBase Shape NoUniqueness :- (Result :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Result :- t))
  (TypeBase Shape NoUniqueness :- (Result :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
     SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[TypeBase Shape NoUniqueness :- (Result :- t),
        SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
        SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[TypeBase Shape NoUniqueness :- (Result :- t),
       SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
            (Grammar Position (SubExp :- (UnOp :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (SubExp :- (UnOp :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (SubExp :- (UnOp :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (SubExp :- (UnOp :- t)))
-> Grammar Position (Sexp :- t) (SubExp :- (UnOp :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) (UnOp :- t)
-> Grammar Position (List :- t) (List :- (UnOp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (UnOp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (UnOp :- t))
-> Grammar
     Position (List :- (UnOp :- t)) (List :- (SubExp :- (UnOp :- t)))
-> Grammar Position (List :- t) (List :- (SubExp :- (UnOp :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (UnOp :- t)) (SubExp :- (UnOp :- t))
-> Grammar
     Position (List :- (UnOp :- t)) (List :- (SubExp :- (UnOp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (UnOp :- t)) (SubExp :- (UnOp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- (SubExp :- (BinOp :- t)),
     SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
        SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (UnOp :- t), SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
              (Grammar
   Position (SubExp :- (SubExp :- (BinOp :- t))) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position (SubExp :- (SubExp :- (BinOp :- t))) (BasicOp :- t)
-> Grammar
     Position (Sexp :- t) (SubExp :- (SubExp :- (BinOp :- t)))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position (List :- t) (List :- (SubExp :- (SubExp :- (BinOp :- t))))
-> Grammar
     Position (Sexp :- t) (SubExp :- (SubExp :- (BinOp :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) (BinOp :- t)
-> Grammar Position (List :- t) (List :- (BinOp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (BinOp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (BinOp :- t))
-> Grammar
     Position
     (List :- (BinOp :- t))
     (List :- (SubExp :- (SubExp :- (BinOp :- t))))
-> Grammar
     Position (List :- t) (List :- (SubExp :- (SubExp :- (BinOp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (BinOp :- t)) (SubExp :- (BinOp :- t))
-> Grammar
     Position (List :- (BinOp :- t)) (List :- (SubExp :- (BinOp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (BinOp :- t)) (SubExp :- (BinOp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position (List :- (BinOp :- t)) (List :- (SubExp :- (BinOp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (BinOp :- t)))
     (List :- (SubExp :- (SubExp :- (BinOp :- t))))
-> Grammar
     Position
     (List :- (BinOp :- t))
     (List :- (SubExp :- (SubExp :- (BinOp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (SubExp :- (BinOp :- t)))
  (SubExp :- (SubExp :- (BinOp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (BinOp :- t)))
     (List :- (SubExp :- (SubExp :- (BinOp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (SubExp :- (BinOp :- t)))
  (SubExp :- (SubExp :- (BinOp :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- (SubExp :- (BinOp :- t)),
        SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (BinOp :- t)),
       SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                (Grammar
   Position (SubExp :- (SubExp :- (CmpOp :- t))) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position (SubExp :- (SubExp :- (CmpOp :- t))) (BasicOp :- t)
-> Grammar
     Position (Sexp :- t) (SubExp :- (SubExp :- (CmpOp :- t)))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position (List :- t) (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
-> Grammar
     Position (Sexp :- t) (SubExp :- (SubExp :- (CmpOp :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) (CmpOp :- t)
-> Grammar Position (List :- t) (List :- (CmpOp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (CmpOp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (CmpOp :- t))
-> Grammar
     Position
     (List :- (CmpOp :- t))
     (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
-> Grammar
     Position (List :- t) (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (CmpOp :- t)) (SubExp :- (CmpOp :- t))
-> Grammar
     Position (List :- (CmpOp :- t)) (List :- (SubExp :- (CmpOp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (CmpOp :- t)) (SubExp :- (CmpOp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position (List :- (CmpOp :- t)) (List :- (SubExp :- (CmpOp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (CmpOp :- t)))
     (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
-> Grammar
     Position
     (List :- (CmpOp :- t))
     (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (SubExp :- (CmpOp :- t)))
  (SubExp :- (SubExp :- (CmpOp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (CmpOp :- t)))
     (List :- (SubExp :- (SubExp :- (CmpOp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (SubExp :- (CmpOp :- t)))
  (SubExp :- (SubExp :- (CmpOp :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- (ConvOp :- t),
     (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (SubExp :- (CmpOp :- t)), SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                  (Grammar Position (SubExp :- (ConvOp :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (SubExp :- (ConvOp :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (SubExp :- (ConvOp :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (SubExp :- (ConvOp :- t)))
-> Grammar Position (Sexp :- t) (SubExp :- (ConvOp :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) (ConvOp :- t)
-> Grammar Position (List :- t) (List :- (ConvOp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (ConvOp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (ConvOp :- t))
-> Grammar
     Position
     (List :- (ConvOp :- t))
     (List :- (SubExp :- (ConvOp :- t)))
-> Grammar Position (List :- t) (List :- (SubExp :- (ConvOp :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (ConvOp :- t)) (SubExp :- (ConvOp :- t))
-> Grammar
     Position
     (List :- (ConvOp :- t))
     (List :- (SubExp :- (ConvOp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (ConvOp :- t)) (SubExp :- (ConvOp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
     [DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- (ConvOp :- t),
        (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (ConvOp :- t),
       (SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                    (Grammar
   Position
   ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
   (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[[DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
  (BasicOp :- t)
-> Grammar
     Position
     (Sexp :- t)
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List
   :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (Sexp :- t)
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"assert") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (SubExp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (SubExp :- t)) (ErrorMsg SubExp :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List :- (ErrorMsg SubExp :- (SubExp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (SubExp :- t)) (ErrorMsg SubExp :- (SubExp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (SubExp :- t))
  (List :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (ErrorMsg SubExp :- (SubExp :- t)))
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (ErrorMsg SubExp :- (SubExp :- t)))
     (List
      :- ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
assertHelper)) (Coproduct
   Position
   (Sexp :- t)
   '[[DimIndex SubExp] :- (VName :- t),
     SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
        [DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[[DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[(SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)),
       [DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                      (Grammar
   Position ([DimIndex SubExp] :- (VName :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[[DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position ([DimIndex SubExp] :- (VName :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) ([DimIndex SubExp] :- (VName :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position (List :- t) (List :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar Position (Sexp :- t) ([DimIndex SubExp] :- (VName :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"index") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position (List :- t) (List :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar
     Position (List :- t) (List :- ([DimIndex SubExp] :- (VName :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (VName :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar
     Position
     (List :- (VName :- t))
     (List :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar
     Position (List :- t) (List :- ([DimIndex SubExp] :- (VName :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (VName :- t)) ([DimIndex SubExp] :- (VName :- t))
-> Grammar
     Position
     (List :- (VName :- t))
     (List :- ([DimIndex SubExp] :- (VName :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (VName :- t)) ([DimIndex SubExp] :- (VName :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
     SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[[DimIndex SubExp] :- (VName :- t),
        SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[[DimIndex SubExp] :- (VName :- t),
       SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                        (Grammar
   Position
   (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
   (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
  (BasicOp :- t)
-> Grammar
     Position
     (Sexp :- t)
     (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
-> Grammar
     Position
     (Sexp :- t)
     (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"update") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (VName :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar
     Position
     (List :- (VName :- t))
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (VName :- t)) ([DimIndex SubExp] :- (VName :- t))
-> Grammar
     Position
     (List :- (VName :- t))
     (List :- ([DimIndex SubExp] :- (VName :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (VName :- t)) ([DimIndex SubExp] :- (VName :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (VName :- t))
  (List :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar
     Position
     (List :- ([DimIndex SubExp] :- (VName :- t)))
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
-> Grammar
     Position
     (List :- (VName :- t))
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([DimIndex SubExp] :- (VName :- t)))
  (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
-> Grammar
     Position
     (List :- ([DimIndex SubExp] :- (VName :- t)))
     (List :- (SubExp :- ([DimIndex SubExp] :- (VName :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([DimIndex SubExp] :- (VName :- t)))
  (SubExp :- ([DimIndex SubExp] :- (VName :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
     VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
        SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([DimIndex SubExp] :- (VName :- t)),
       SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                          (Grammar
   Position
   (SubExp :- ([VName] :- (VName :- (Int :- t))))
   (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- t, VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (SubExp :- ([VName] :- (VName :- (Int :- t))))
  (BasicOp :- t)
-> Grammar
     Position (Sexp :- t) (SubExp :- ([VName] :- (VName :- (Int :- t))))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
-> Grammar
     Position (Sexp :- t) (SubExp :- ([VName] :- (VName :- (Int :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"concat") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Int :- t)
-> Grammar Position (List :- t) (List :- (Int :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Int :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Int :- t))
-> Grammar
     Position
     (List :- (Int :- t))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
-> Grammar
     Position
     (List :- t)
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (Int :- t)) (VName :- (Int :- t))
-> Grammar
     Position (List :- (Int :- t)) (List :- (VName :- (Int :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (Int :- t)) (VName :- (Int :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position (List :- (Int :- t)) (List :- (VName :- (Int :- t)))
-> Grammar
     Position
     (List :- (VName :- (Int :- t)))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
-> Grammar
     Position
     (List :- (Int :- t))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (VName :- (Int :- t)))
  ([VName] :- (VName :- (Int :- t)))
-> Grammar
     Position
     (List :- (VName :- (Int :- t)))
     (List :- ([VName] :- (VName :- (Int :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (VName :- (Int :- t)))
  ([VName] :- (VName :- (Int :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (VName :- (Int :- t)))
  (List :- ([VName] :- (VName :- (Int :- t))))
-> Grammar
     Position
     (List :- ([VName] :- (VName :- (Int :- t))))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
-> Grammar
     Position
     (List :- (VName :- (Int :- t)))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([VName] :- (VName :- (Int :- t))))
  (SubExp :- ([VName] :- (VName :- (Int :- t))))
-> Grammar
     Position
     (List :- ([VName] :- (VName :- (Int :- t))))
     (List :- (SubExp :- ([VName] :- (VName :- (Int :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([VName] :- (VName :- (Int :- t))))
  (SubExp :- ([VName] :- (VName :- (Int :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[VName :- t, VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
        VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- t, VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- ([VName] :- (VName :- (Int :- t))), VName :- t,
       VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                            (Grammar Position (VName :- t) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- t, VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (VName :- t) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar Position (Sexp :- t) (VName :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"copy") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar Position (List :- t) (List :- (VName :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (VName :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[VName :- ([Int] :- t),
     IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[VName :- t, VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- t, VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                              (Grammar Position (VName :- ([Int] :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (VName :- ([Int] :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (VName :- ([Int] :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (Sexp :- t) (VName :- ([Int] :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"manifest") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) ([Int] :- t)
-> Grammar Position (List :- t) (List :- ([Int] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([Int] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- ([Int] :- t))
-> Grammar
     Position (List :- ([Int] :- t)) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- ([Int] :- t)) (VName :- ([Int] :- t))
-> Grammar
     Position (List :- ([Int] :- t)) (List :- (VName :- ([Int] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- ([Int] :- t)) (VName :- ([Int] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
     SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[VName :- ([Int] :- t),
        IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t),
       IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                (Grammar
   Position
   (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
   (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
  (BasicOp :- t)
-> Grammar
     Position
     (Sexp :- t)
     (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (Sexp :- t)
     (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"iota") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- t)
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (SubExp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- t)
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (SubExp :- t)) (SubExp :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List :- (SubExp :- (SubExp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (SubExp :- t)) (SubExp :- (SubExp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (SubExp :- t))
  (List :- (SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (SubExp :- t)))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (SubExp :- (SubExp :- t)))
  (SubExp :- (SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (SubExp :- (SubExp :- t)))
     (List :- (SubExp :- (SubExp :- (SubExp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (SubExp :- (SubExp :- t)))
  (SubExp :- (SubExp :- (SubExp :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (SubExp :- (SubExp :- t)))
  (List :- (SubExp :- (SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (SubExp :- (SubExp :- (SubExp :- t))))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- (SubExp :- (SubExp :- t)))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (SubExp :- (SubExp :- (SubExp :- t))))
  (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (SubExp :- (SubExp :- (SubExp :- t))))
     (List :- (IntType :- (SubExp :- (SubExp :- (SubExp :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (SubExp :- (SubExp :- (SubExp :- t))))
  (IntType :- (SubExp :- (SubExp :- (SubExp :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
     VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
        SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[IntType :- (SubExp :- (SubExp :- (SubExp :- t))),
       SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                  (Grammar Position (SubExp :- (Shape :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
       VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (SubExp :- (Shape :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (SubExp :- (Shape :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (SubExp :- (Shape :- t)))
-> Grammar Position (Sexp :- t) (SubExp :- (Shape :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"replicate") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- (Shape :- t)))
-> Grammar Position (List :- t) (List :- (SubExp :- (Shape :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Shape :- t)
-> Grammar Position (List :- t) (List :- (Shape :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Shape :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Shape :- t))
-> Grammar
     Position (List :- (Shape :- t)) (List :- (SubExp :- (Shape :- t)))
-> Grammar Position (List :- t) (List :- (SubExp :- (Shape :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (Shape :- t)) (SubExp :- (Shape :- t))
-> Grammar
     Position (List :- (Shape :- t)) (List :- (SubExp :- (Shape :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (Shape :- t)) (SubExp :- (Shape :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
     VName :- ([Int] :- t), VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
        VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
       VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[SubExp :- (Shape :- t), Result :- (PrimType :- t),
       VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                    (Grammar Position (Result :- (PrimType :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
       VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (Result :- (PrimType :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (Result :- (PrimType :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (Result :- (PrimType :- t)))
-> Grammar Position (Sexp :- t) (Result :- (PrimType :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"scratch") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position (List :- t) (List :- (Result :- (PrimType :- t)))
-> Grammar
     Position (List :- t) (List :- (Result :- (PrimType :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (PrimType :- t)
-> Grammar Position (List :- t) (List :- (PrimType :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (PrimType :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (PrimType :- t))
-> Grammar
     Position
     (List :- (PrimType :- t))
     (List :- (Result :- (PrimType :- t)))
-> Grammar
     Position (List :- t) (List :- (Result :- (PrimType :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (PrimType :- t)) (Result :- (PrimType :- t))
-> Grammar
     Position
     (List :- (PrimType :- t))
     (List :- (Result :- (PrimType :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (PrimType :- t)) (Result :- (PrimType :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
     VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
        VName :- ([Int] :- t), VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[Result :- (PrimType :- t), VName :- ([DimChange SubExp] :- t),
       VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                      (Grammar
   Position (VName :- ([DimChange SubExp] :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position (VName :- ([DimChange SubExp] :- t)) (BasicOp :- t)
-> Grammar
     Position (Sexp :- t) (VName :- ([DimChange SubExp] :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position (List :- t) (List :- (VName :- ([DimChange SubExp] :- t)))
-> Grammar
     Position (Sexp :- t) (VName :- ([DimChange SubExp] :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"reshape") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position (List :- t) (List :- (VName :- ([DimChange SubExp] :- t)))
-> Grammar
     Position (List :- t) (List :- (VName :- ([DimChange SubExp] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) ([DimChange SubExp] :- t)
-> Grammar Position (List :- t) (List :- ([DimChange SubExp] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([DimChange SubExp] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- ([DimChange SubExp] :- t))
-> Grammar
     Position
     (List :- ([DimChange SubExp] :- t))
     (List :- (VName :- ([DimChange SubExp] :- t)))
-> Grammar
     Position (List :- t) (List :- (VName :- ([DimChange SubExp] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([DimChange SubExp] :- t))
  (VName :- ([DimChange SubExp] :- t))
-> Grammar
     Position
     (List :- ([DimChange SubExp] :- t))
     (List :- (VName :- ([DimChange SubExp] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([DimChange SubExp] :- t))
  (VName :- ([DimChange SubExp] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[VName :- ([Int] :- t), VName :- (Result :- t)]
   BasicOp
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
        VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([DimChange SubExp] :- t), VName :- ([Int] :- t),
       VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                        (Grammar Position (VName :- ([Int] :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct
     Position (Sexp :- t) '[VName :- (Result :- t)] BasicOp t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (VName :- ([Int] :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (VName :- ([Int] :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (Sexp :- t) (VName :- ([Int] :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"rearrange") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) ([Int] :- t)
-> Grammar Position (List :- t) (List :- ([Int] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([Int] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- ([Int] :- t))
-> Grammar
     Position (List :- ([Int] :- t)) (List :- (VName :- ([Int] :- t)))
-> Grammar Position (List :- t) (List :- (VName :- ([Int] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- ([Int] :- t)) (VName :- ([Int] :- t))
-> Grammar
     Position (List :- ([Int] :- t)) (List :- (VName :- ([Int] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- ([Int] :- t)) (VName :- ([Int] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[VName :- (Result :- t)] BasicOp t
 -> Coproduct
      Position
      (Sexp :- t)
      '[VName :- ([Int] :- t), VName :- (Result :- t)]
      BasicOp
      t)
-> Coproduct
     Position (Sexp :- t) '[VName :- (Result :- t)] BasicOp t
-> Coproduct
     Position
     (Sexp :- t)
     '[VName :- ([Int] :- t), VName :- (Result :- t)]
     BasicOp
     t
forall a b. (a -> b) -> a -> b
$
                                          (Grammar Position (VName :- (Result :- t)) (BasicOp :- t)
 -> Grammar Position (Sexp :- t) (BasicOp :- t))
-> Coproduct Position (Sexp :- t) '[] BasicOp t
-> Coproduct
     Position (Sexp :- t) '[VName :- (Result :- t)] BasicOp t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
                                            (Grammar Position (VName :- (Result :- t)) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (VName :- (Result :- t))
-> Grammar Position (Sexp :- t) (BasicOp :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (VName :- (Result :- t)))
-> Grammar Position (Sexp :- t) (VName :- (Result :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"rotate") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (VName :- (Result :- t)))
-> Grammar Position (List :- t) (List :- (VName :- (Result :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Result :- t)
-> Grammar Position (List :- t) (List :- (Result :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Result :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Result :- t))
-> Grammar
     Position (List :- (Result :- t)) (List :- (VName :- (Result :- t)))
-> Grammar Position (List :- t) (List :- (VName :- (Result :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (Result :- t)) (VName :- (Result :- t))
-> Grammar
     Position (List :- (Result :- t)) (List :- (VName :- (Result :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (Result :- t)) (VName :- (Result :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso))
                                            Coproduct Position (Sexp :- t) '[] BasicOp t
forall p s a t. Coproduct p s '[] a t
End
    where
      assertHelper :: Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
assertHelper =
        (Grammar
   Position
   ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
   ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
 -> Grammar
      Position
      (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
      ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
    ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
  -> Grammar
       Position
       (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
       ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
 -> Grammar
      Position
      (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
      ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> (Grammar
      Position
      ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
      ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
    -> Grammar
         Position
         (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
         ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
tuple ->
          Grammar
  Position
  (List :- (ErrorMsg SubExp :- (SubExp :- t)))
  (List
   :- ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
            ( Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (ErrorMsg SubExp :- (SubExp :- t)))
     (List :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el ((Text -> SrcLoc)
-> (SrcLoc -> Text)
-> Grammar
     Position
     (Text :- (ErrorMsg SubExp :- (SubExp :- t)))
     (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso (SrcLoc -> Text -> SrcLoc
forall a b. a -> b -> a
const SrcLoc
forall a. Monoid a => a
mempty) (String -> Text
T.pack (String -> Text) -> (SrcLoc -> String) -> SrcLoc -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SrcLoc -> String
forall a. Show a => a -> String
show) Grammar
  Position
  (Text :- (ErrorMsg SubExp :- (SubExp :- t)))
  (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     (Text :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  (Text :- (ErrorMsg SubExp :- (SubExp :- t)))
forall t. Grammar Position (Sexp :- t) (Text :- t)
Sexp.symbol)
                Grammar
  Position
  (List :- (ErrorMsg SubExp :- (SubExp :- t)))
  (List :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
     (List
      :- ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- (ErrorMsg SubExp :- (SubExp :- t)))
     (List
      :- ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (forall t1. Grammar Position (Sexp :- t1) (SrcLoc :- t1))
-> Grammar
     Position
     (List :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
     (List
      :- ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t)))))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
Sexp.rest ((Text -> SrcLoc)
-> (SrcLoc -> Text) -> Grammar Position (Text :- t1) (SrcLoc :- t1)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso (SrcLoc -> Text -> SrcLoc
forall a b. a -> b -> a
const SrcLoc
forall a. Monoid a => a
mempty) (String -> Text
T.pack (String -> Text) -> (SrcLoc -> String) -> SrcLoc -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SrcLoc -> String
forall a. Show a => a -> String
show) Grammar Position (Text :- t1) (SrcLoc :- t1)
-> Grammar Position (Sexp :- t1) (Text :- t1)
-> Grammar Position (Sexp :- t1) (SrcLoc :- t1)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t1) (Text :- t1)
forall t. Grammar Position (Sexp :- t) (Text :- t)
Sexp.symbol)
            )
            Grammar
  Position
  (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
  ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
-> Grammar
     Position
     ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
-> Grammar
     Position
     (Sexp :- (ErrorMsg SubExp :- (SubExp :- t)))
     ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  ([SrcLoc] :- (SrcLoc :- (ErrorMsg SubExp :- (SubExp :- t))))
  ((SrcLoc, [SrcLoc]) :- (ErrorMsg SubExp :- (SubExp :- t)))
tuple

-- | The root Futhark expression type.  The v'Op' constructor contains
-- a lore-specific operation.  Do-loops, branches and function calls
-- are special.  Everything else is a simple t'BasicOp'.
data ExpT lore
  = -- | A simple (non-recursive) operation.
    BasicOp BasicOp
  | Apply Name [(SubExp, Diet)] [RetType lore] (Safety, SrcLoc, [SrcLoc])
  | If SubExp (BodyT lore) (BodyT lore) (IfDec (BranchType lore))
  | -- | @loop {a} = {v} (for i < n|while b) do b@.  The merge
    -- parameters are divided into context and value part.
    DoLoop [(FParam lore, SubExp)] [(FParam lore, SubExp)] (LoopForm lore) (BodyT lore)
  | Op (Op lore)
  deriving ((forall x. ExpT lore -> Rep (ExpT lore) x)
-> (forall x. Rep (ExpT lore) x -> ExpT lore)
-> Generic (ExpT lore)
forall x. Rep (ExpT lore) x -> ExpT lore
forall x. ExpT lore -> Rep (ExpT lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (ExpT lore) x -> ExpT lore
forall lore x. ExpT lore -> Rep (ExpT lore) x
$cto :: forall lore x. Rep (ExpT lore) x -> ExpT lore
$cfrom :: forall lore x. ExpT lore -> Rep (ExpT lore) x
Generic)

instance Decorations lore => SexpIso (ExpT lore) where
  sexpIso :: Grammar Position (Sexp :- t) (ExpT lore :- t)
sexpIso =
    Coproduct
  Position
  (Sexp :- t)
  '[BasicOp :- t,
    (Safety, SrcLoc, [SrcLoc])
    :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
    IfDec (BranchType lore)
    :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
    BodyT lore
    :- (LoopForm lore
        :- ([(Param (FParamInfo lore), SubExp)]
            :- ([(Param (FParamInfo lore), SubExp)] :- t))),
    Op lore :- t]
  (ExpT lore)
  t
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct
   Position
   (Sexp :- t)
   '[BasicOp :- t,
     (Safety, SrcLoc, [SrcLoc])
     :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
     IfDec (BranchType lore)
     :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
     BodyT lore
     :- (LoopForm lore
         :- ([(Param (FParamInfo lore), SubExp)]
             :- ([(Param (FParamInfo lore), SubExp)] :- t))),
     Op lore :- t]
   (ExpT lore)
   t
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[BasicOp :- t,
       (Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position (BasicOp :- t) (ExpT lore :- t)
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[(Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[BasicOp :- t,
       (Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (BasicOp :- t) (ExpT lore :- t)
-> Grammar Position (Sexp :- t) (BasicOp :- t)
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t) (BasicOp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso) (Coproduct
   Position
   (Sexp :- t)
   '[(Safety, SrcLoc, [SrcLoc])
     :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
     IfDec (BranchType lore)
     :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
     BodyT lore
     :- (LoopForm lore
         :- ([(Param (FParamInfo lore), SubExp)]
             :- ([(Param (FParamInfo lore), SubExp)] :- t))),
     Op lore :- t]
   (ExpT lore)
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[BasicOp :- t,
        (Safety, SrcLoc, [SrcLoc])
        :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
        IfDec (BranchType lore)
        :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
        BodyT lore
        :- (LoopForm lore
            :- ([(Param (FParamInfo lore), SubExp)]
                :- ([(Param (FParamInfo lore), SubExp)] :- t))),
        Op lore :- t]
      (ExpT lore)
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[(Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[BasicOp :- t,
       (Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall a b. (a -> b) -> a -> b
$
        (Grammar
   Position
   ((Safety, SrcLoc, [SrcLoc])
    :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
   (ExpT lore :- t)
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[(Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  (ExpT lore :- t)
-> Grammar
     Position
     (Sexp :- t)
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List
   :- ((Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (Sexp :- t)
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"apply") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Name :- t)
-> Grammar Position (List :- t) (List :- (Name :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Name :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (Name :- t))
-> Grammar
     Position
     (List :- (Name :- t))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (Name :- t)) ([(SubExp, Diet)] :- (Name :- t))
-> Grammar
     Position
     (List :- (Name :- t))
     (List :- ([(SubExp, Diet)] :- (Name :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (Name :- t)) ([(SubExp, Diet)] :- (Name :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (Name :- t))
  (List :- ([(SubExp, Diet)] :- (Name :- t)))
-> Grammar
     Position
     (List :- ([(SubExp, Diet)] :- (Name :- t)))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List :- (Name :- t))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([(SubExp, Diet)] :- (Name :- t)))
  ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))
-> Grammar
     Position
     (List :- ([(SubExp, Diet)] :- (Name :- t)))
     (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([(SubExp, Diet)] :- (Name :- t)))
  ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- ([(SubExp, Diet)] :- (Name :- t)))
  (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
-> Grammar
     Position
     (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List :- ([(SubExp, Diet)] :- (Name :- t)))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
-> Grammar
     Position
     (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     (List
      :- ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
applyHelper)) (Coproduct
   Position
   (Sexp :- t)
   '[IfDec (BranchType lore)
     :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
     BodyT lore
     :- (LoopForm lore
         :- ([(Param (FParamInfo lore), SubExp)]
             :- ([(Param (FParamInfo lore), SubExp)] :- t))),
     Op lore :- t]
   (ExpT lore)
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[(Safety, SrcLoc, [SrcLoc])
        :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
        IfDec (BranchType lore)
        :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
        BodyT lore
        :- (LoopForm lore
            :- ([(Param (FParamInfo lore), SubExp)]
                :- ([(Param (FParamInfo lore), SubExp)] :- t))),
        Op lore :- t]
      (ExpT lore)
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[(Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))),
       IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall a b. (a -> b) -> a -> b
$
          (Grammar
   Position
   (IfDec (BranchType lore)
    :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
   (ExpT lore :- t)
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (IfDec (BranchType lore)
   :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
  (ExpT lore :- t)
-> Grammar
     Position
     (Sexp :- t)
     (IfDec (BranchType lore)
      :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List
   :- (IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
-> Grammar
     Position
     (Sexp :- t)
     (IfDec (BranchType lore)
      :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"if") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (SubExp :- t)
-> Grammar Position (List :- t) (List :- (SubExp :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (SubExp :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- (SubExp :- t)) (BodyT lore :- (SubExp :- t))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List :- (BodyT lore :- (SubExp :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- (SubExp :- t)) (BodyT lore :- (SubExp :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (SubExp :- t))
  (List :- (BodyT lore :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (BodyT lore :- (SubExp :- t)))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- (SubExp :- t))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (BodyT lore :- (SubExp :- t)))
  (BodyT lore :- (BodyT lore :- (SubExp :- t)))
-> Grammar
     Position
     (List :- (BodyT lore :- (SubExp :- t)))
     (List :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (BodyT lore :- (SubExp :- t)))
  (BodyT lore :- (BodyT lore :- (SubExp :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (BodyT lore :- (SubExp :- t)))
  (List :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
-> Grammar
     Position
     (List :- (BodyT lore :- (SubExp :- t)))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
  (IfDec (BranchType lore)
   :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
-> Grammar
     Position
     (List :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
     (List
      :- (IfDec (BranchType lore)
          :- (BodyT lore :- (BodyT lore :- (SubExp :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
  (IfDec (BranchType lore)
   :- (BodyT lore :- (BodyT lore :- (SubExp :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct
   Position
   (Sexp :- t)
   '[BodyT lore
     :- (LoopForm lore
         :- ([(Param (FParamInfo lore), SubExp)]
             :- ([(Param (FParamInfo lore), SubExp)] :- t))),
     Op lore :- t]
   (ExpT lore)
   t
 -> Coproduct
      Position
      (Sexp :- t)
      '[IfDec (BranchType lore)
        :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
        BodyT lore
        :- (LoopForm lore
            :- ([(Param (FParamInfo lore), SubExp)]
                :- ([(Param (FParamInfo lore), SubExp)] :- t))),
        Op lore :- t]
      (ExpT lore)
      t)
-> Coproduct
     Position
     (Sexp :- t)
     '[BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
-> Coproduct
     Position
     (Sexp :- t)
     '[IfDec (BranchType lore)
       :- (BodyT lore :- (BodyT lore :- (SubExp :- t))),
       BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall a b. (a -> b) -> a -> b
$
            (Grammar
   Position
   (BodyT lore
    :- (LoopForm lore
        :- ([(Param (FParamInfo lore), SubExp)]
            :- ([(Param (FParamInfo lore), SubExp)] :- t))))
   (ExpT lore :- t)
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct Position (Sexp :- t) '[Op lore :- t] (ExpT lore) t
-> Coproduct
     Position
     (Sexp :- t)
     '[BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  (BodyT lore
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
  (ExpT lore :- t)
-> Grammar
     Position
     (Sexp :- t)
     (BodyT lore
      :- (LoopForm lore
          :- ([(Param (FParamInfo lore), SubExp)]
              :- ([(Param (FParamInfo lore), SubExp)] :- t))))
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List
   :- (BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
-> Grammar
     Position
     (Sexp :- t)
     (BodyT lore
      :- (LoopForm lore
          :- ([(Param (FParamInfo lore), SubExp)]
              :- ([(Param (FParamInfo lore), SubExp)] :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"loop") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position (Sexp :- t) ([(Param (FParamInfo lore), SubExp)] :- t)
-> Grammar
     Position
     (List :- t)
     (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position (Sexp :- t) ([(Param (FParamInfo lore), SubExp)] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- t)
  (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
-> Grammar
     Position
     (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([(Param (FParamInfo lore), SubExp)] :- t))
  ([(Param (FParamInfo lore), SubExp)]
   :- ([(Param (FParamInfo lore), SubExp)] :- t))
-> Grammar
     Position
     (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
     (List
      :- ([(Param (FParamInfo lore), SubExp)]
          :- ([(Param (FParamInfo lore), SubExp)] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([(Param (FParamInfo lore), SubExp)] :- t))
  ([(Param (FParamInfo lore), SubExp)]
   :- ([(Param (FParamInfo lore), SubExp)] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
  (List
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
-> Grammar
     Position
     (List
      :- ([(Param (FParamInfo lore), SubExp)]
          :- ([(Param (FParamInfo lore), SubExp)] :- t)))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
-> Grammar
     Position
     (List :- ([(Param (FParamInfo lore), SubExp)] :- t))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
  (LoopForm lore
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
-> Grammar
     Position
     (List
      :- ([(Param (FParamInfo lore), SubExp)]
          :- ([(Param (FParamInfo lore), SubExp)] :- t)))
     (List
      :- (LoopForm lore
          :- ([(Param (FParamInfo lore), SubExp)]
              :- ([(Param (FParamInfo lore), SubExp)] :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
  (LoopForm lore
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List
   :- ([(Param (FParamInfo lore), SubExp)]
       :- ([(Param (FParamInfo lore), SubExp)] :- t)))
  (List
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
-> Grammar
     Position
     (List
      :- (LoopForm lore
          :- ([(Param (FParamInfo lore), SubExp)]
              :- ([(Param (FParamInfo lore), SubExp)] :- t))))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
-> Grammar
     Position
     (List
      :- ([(Param (FParamInfo lore), SubExp)]
          :- ([(Param (FParamInfo lore), SubExp)] :- t)))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
  (BodyT lore
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
-> Grammar
     Position
     (List
      :- (LoopForm lore
          :- ([(Param (FParamInfo lore), SubExp)]
              :- ([(Param (FParamInfo lore), SubExp)] :- t))))
     (List
      :- (BodyT lore
          :- (LoopForm lore
              :- ([(Param (FParamInfo lore), SubExp)]
                  :- ([(Param (FParamInfo lore), SubExp)] :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
  (BodyT lore
   :- (LoopForm lore
       :- ([(Param (FParamInfo lore), SubExp)]
           :- ([(Param (FParamInfo lore), SubExp)] :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[Op lore :- t] (ExpT lore) t
 -> Coproduct
      Position
      (Sexp :- t)
      '[BodyT lore
        :- (LoopForm lore
            :- ([(Param (FParamInfo lore), SubExp)]
                :- ([(Param (FParamInfo lore), SubExp)] :- t))),
        Op lore :- t]
      (ExpT lore)
      t)
-> Coproduct Position (Sexp :- t) '[Op lore :- t] (ExpT lore) t
-> Coproduct
     Position
     (Sexp :- t)
     '[BodyT lore
       :- (LoopForm lore
           :- ([(Param (FParamInfo lore), SubExp)]
               :- ([(Param (FParamInfo lore), SubExp)] :- t))),
       Op lore :- t]
     (ExpT lore)
     t
forall a b. (a -> b) -> a -> b
$
              (Grammar Position (Op lore :- t) (ExpT lore :- t)
 -> Grammar Position (Sexp :- t) (ExpT lore :- t))
-> Coproduct Position (Sexp :- t) '[] (ExpT lore) t
-> Coproduct Position (Sexp :- t) '[Op lore :- t] (ExpT lore) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
                (Grammar Position (Op lore :- t) (ExpT lore :- t)
-> Grammar Position (Sexp :- t) (Op lore :- t)
-> Grammar Position (Sexp :- t) (ExpT lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t) (Op lore :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso)
                Coproduct Position (Sexp :- t) '[] (ExpT lore) t
forall p s a t. Coproduct p s '[] a t
End
    where
      applyHelper :: Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
applyHelper =
        (Grammar
   Position
   ([SrcLoc]
    :- (SrcLoc
        :- (Safety
            :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
   ((Safety, SrcLoc, [SrcLoc])
    :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
 -> Grammar
      Position
      (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
      ((Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    ([SrcLoc]
     :- (SrcLoc
         :- (Safety
             :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
    ((Safety, SrcLoc, [SrcLoc])
     :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  -> Grammar
       Position
       (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
       ((Safety, SrcLoc, [SrcLoc])
        :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
 -> Grammar
      Position
      (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
      ((Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> (Grammar
      Position
      ([SrcLoc]
       :- (SrcLoc
           :- (Safety
               :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
      ((Safety, SrcLoc, [SrcLoc])
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
    -> Grammar
         Position
         (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
         ((Safety, SrcLoc, [SrcLoc])
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  ([SrcLoc]
   :- (SrcLoc
       :- (Safety
           :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
triple ->
          Grammar
  Position
  (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  (List
   :- ([SrcLoc]
       :- (SrcLoc
           :- (Safety
               :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
-> Grammar
     Position
     (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     ([SrcLoc]
      :- (SrcLoc
          :- (Safety
              :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
            ( Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  (Safety :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
-> Grammar
     Position
     (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     (List
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  (Safety :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso
                Grammar
  Position
  (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  (List
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (List
      :- ([SrcLoc]
          :- (SrcLoc
              :- (Safety
                  :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
-> Grammar
     Position
     (List :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     (List
      :- ([SrcLoc]
          :- (SrcLoc
              :- (Safety
                  :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
  (SrcLoc
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (List
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (List
      :- (SrcLoc
          :- (Safety
              :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el ((Text -> SrcLoc)
-> (SrcLoc -> Text)
-> Grammar
     Position
     (Text
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (SrcLoc
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso (SrcLoc -> Text -> SrcLoc
forall a b. a -> b -> a
const SrcLoc
forall a. Monoid a => a
mempty) (String -> Text
T.pack (String -> Text) -> (SrcLoc -> String) -> SrcLoc -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SrcLoc -> String
forall a. Show a => a -> String
show) Grammar
  Position
  (Text
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
  (SrcLoc
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (Sexp
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (Text
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
-> Grammar
     Position
     (Sexp
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (SrcLoc
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (Sexp
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
  (Text
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
forall t. Grammar Position (Sexp :- t) (Text :- t)
Sexp.symbol)
                Grammar
  Position
  (List
   :- (Safety
       :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
  (List
   :- (SrcLoc
       :- (Safety
           :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
-> Grammar
     Position
     (List
      :- (SrcLoc
          :- (Safety
              :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
     (List
      :- ([SrcLoc]
          :- (SrcLoc
              :- (Safety
                  :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
-> Grammar
     Position
     (List
      :- (Safety
          :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))
     (List
      :- ([SrcLoc]
          :- (SrcLoc
              :- (Safety
                  :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (forall t1. Grammar Position (Sexp :- t1) (SrcLoc :- t1))
-> Grammar
     Position
     (List
      :- (SrcLoc
          :- (Safety
              :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
     (List
      :- ([SrcLoc]
          :- (SrcLoc
              :- (Safety
                  :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t)))))))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
Sexp.rest ((Text -> SrcLoc)
-> (SrcLoc -> Text) -> Grammar Position (Text :- t1) (SrcLoc :- t1)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso (SrcLoc -> Text -> SrcLoc
forall a b. a -> b -> a
const SrcLoc
forall a. Monoid a => a
mempty) (String -> Text
T.pack (String -> Text) -> (SrcLoc -> String) -> SrcLoc -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SrcLoc -> String
forall a. Show a => a -> String
show) Grammar Position (Text :- t1) (SrcLoc :- t1)
-> Grammar Position (Sexp :- t1) (Text :- t1)
-> Grammar Position (Sexp :- t1) (SrcLoc :- t1)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t1) (Text :- t1)
forall t. Grammar Position (Sexp :- t) (Text :- t)
Sexp.symbol)
            )
            Grammar
  Position
  (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
  ([SrcLoc]
   :- (SrcLoc
       :- (Safety
           :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
-> Grammar
     Position
     ([SrcLoc]
      :- (SrcLoc
          :- (Safety
              :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
-> Grammar
     Position
     (Sexp :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
     ((Safety, SrcLoc, [SrcLoc])
      :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  ([SrcLoc]
   :- (SrcLoc
       :- (Safety
           :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))))
  ((Safety, SrcLoc, [SrcLoc])
   :- ([RetType lore] :- ([(SubExp, Diet)] :- (Name :- t))))
triple

deriving instance Decorations lore => Eq (ExpT lore)

deriving instance Decorations lore => Show (ExpT lore)

deriving instance Decorations lore => Ord (ExpT lore)

-- | For-loop or while-loop?
data LoopForm lore
  = ForLoop VName IntType SubExp [(LParam lore, VName)]
  | WhileLoop VName
  deriving ((forall x. LoopForm lore -> Rep (LoopForm lore) x)
-> (forall x. Rep (LoopForm lore) x -> LoopForm lore)
-> Generic (LoopForm lore)
forall x. Rep (LoopForm lore) x -> LoopForm lore
forall x. LoopForm lore -> Rep (LoopForm lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (LoopForm lore) x -> LoopForm lore
forall lore x. LoopForm lore -> Rep (LoopForm lore) x
$cto :: forall lore x. Rep (LoopForm lore) x -> LoopForm lore
$cfrom :: forall lore x. LoopForm lore -> Rep (LoopForm lore) x
Generic)

instance Decorations lore => SexpIso (LoopForm lore) where
  sexpIso :: Grammar Position (Sexp :- t) (LoopForm lore :- t)
sexpIso =
    Coproduct
  Position
  (Sexp :- t)
  '[[(Param (LParamInfo lore), VName)]
    :- (SubExp :- (IntType :- (VName :- t))),
    VName :- t]
  (LoopForm lore)
  t
-> Grammar Position (Sexp :- t) (LoopForm lore :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct
   Position
   (Sexp :- t)
   '[[(Param (LParamInfo lore), VName)]
     :- (SubExp :- (IntType :- (VName :- t))),
     VName :- t]
   (LoopForm lore)
   t
 -> Grammar Position (Sexp :- t) (LoopForm lore :- t))
-> Coproduct
     Position
     (Sexp :- t)
     '[[(Param (LParamInfo lore), VName)]
       :- (SubExp :- (IntType :- (VName :- t))),
       VName :- t]
     (LoopForm lore)
     t
-> Grammar Position (Sexp :- t) (LoopForm lore :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar
   Position
   ([(Param (LParamInfo lore), VName)]
    :- (SubExp :- (IntType :- (VName :- t))))
   (LoopForm lore :- t)
 -> Grammar Position (Sexp :- t) (LoopForm lore :- t))
-> Coproduct Position (Sexp :- t) '[VName :- t] (LoopForm lore) t
-> Coproduct
     Position
     (Sexp :- t)
     '[[(Param (LParamInfo lore), VName)]
       :- (SubExp :- (IntType :- (VName :- t))),
       VName :- t]
     (LoopForm lore)
     t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar
  Position
  ([(Param (LParamInfo lore), VName)]
   :- (SubExp :- (IntType :- (VName :- t))))
  (LoopForm lore :- t)
-> Grammar
     Position
     (Sexp :- t)
     ([(Param (LParamInfo lore), VName)]
      :- (SubExp :- (IntType :- (VName :- t))))
-> Grammar Position (Sexp :- t) (LoopForm lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar
  Position
  (List :- t)
  (List
   :- ([(Param (LParamInfo lore), VName)]
       :- (SubExp :- (IntType :- (VName :- t)))))
-> Grammar
     Position
     (Sexp :- t)
     ([(Param (LParamInfo lore), VName)]
      :- (SubExp :- (IntType :- (VName :- t))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"for") Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (VName :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar
     Position
     (List :- (VName :- t))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (VName :- t)) (IntType :- (VName :- t))
-> Grammar
     Position (List :- (VName :- t)) (List :- (IntType :- (VName :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (VName :- t)) (IntType :- (VName :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position (List :- (VName :- t)) (List :- (IntType :- (VName :- t)))
-> Grammar
     Position
     (List :- (IntType :- (VName :- t)))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
-> Grammar
     Position
     (List :- (VName :- t))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (IntType :- (VName :- t)))
  (SubExp :- (IntType :- (VName :- t)))
-> Grammar
     Position
     (List :- (IntType :- (VName :- t)))
     (List :- (SubExp :- (IntType :- (VName :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (IntType :- (VName :- t)))
  (SubExp :- (IntType :- (VName :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso Grammar
  Position
  (List :- (IntType :- (VName :- t)))
  (List :- (SubExp :- (IntType :- (VName :- t))))
-> Grammar
     Position
     (List :- (SubExp :- (IntType :- (VName :- t))))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
-> Grammar
     Position
     (List :- (IntType :- (VName :- t)))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (SubExp :- (IntType :- (VName :- t))))
  ([(Param (LParamInfo lore), VName)]
   :- (SubExp :- (IntType :- (VName :- t))))
-> Grammar
     Position
     (List :- (SubExp :- (IntType :- (VName :- t))))
     (List
      :- ([(Param (LParamInfo lore), VName)]
          :- (SubExp :- (IntType :- (VName :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (SubExp :- (IntType :- (VName :- t))))
  ([(Param (LParamInfo lore), VName)]
   :- (SubExp :- (IntType :- (VName :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[VName :- t] (LoopForm lore) t
 -> Coproduct
      Position
      (Sexp :- t)
      '[[(Param (LParamInfo lore), VName)]
        :- (SubExp :- (IntType :- (VName :- t))),
        VName :- t]
      (LoopForm lore)
      t)
-> Coproduct Position (Sexp :- t) '[VName :- t] (LoopForm lore) t
-> Coproduct
     Position
     (Sexp :- t)
     '[[(Param (LParamInfo lore), VName)]
       :- (SubExp :- (IntType :- (VName :- t))),
       VName :- t]
     (LoopForm lore)
     t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position (VName :- t) (LoopForm lore :- t)
 -> Grammar Position (Sexp :- t) (LoopForm lore :- t))
-> Coproduct Position (Sexp :- t) '[] (LoopForm lore) t
-> Coproduct Position (Sexp :- t) '[VName :- t] (LoopForm lore) t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
          (Grammar Position (VName :- t) (LoopForm lore :- t)
-> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (Sexp :- t) (LoopForm lore :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar Position (Sexp :- t) (VName :- t)
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"while") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
-> Grammar Position (List :- t) (List :- (VName :- t))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (VName :- t)
-> Grammar Position (List :- t) (List :- (VName :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (VName :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso))
          Coproduct Position (Sexp :- t) '[] (LoopForm lore) t
forall p s a t. Coproduct p s '[] a t
End

deriving instance Decorations lore => Eq (LoopForm lore)

deriving instance Decorations lore => Show (LoopForm lore)

deriving instance Decorations lore => Ord (LoopForm lore)

-- | Data associated with a branch.
data IfDec rt = IfDec
  { IfDec rt -> [rt]
ifReturns :: [rt],
    IfDec rt -> IfSort
ifSort :: IfSort
  }
  deriving (IfDec rt -> IfDec rt -> Bool
(IfDec rt -> IfDec rt -> Bool)
-> (IfDec rt -> IfDec rt -> Bool) -> Eq (IfDec rt)
forall rt. Eq rt => IfDec rt -> IfDec rt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IfDec rt -> IfDec rt -> Bool
$c/= :: forall rt. Eq rt => IfDec rt -> IfDec rt -> Bool
== :: IfDec rt -> IfDec rt -> Bool
$c== :: forall rt. Eq rt => IfDec rt -> IfDec rt -> Bool
Eq, Int -> IfDec rt -> ShowS
[IfDec rt] -> ShowS
IfDec rt -> String
(Int -> IfDec rt -> ShowS)
-> (IfDec rt -> String) -> ([IfDec rt] -> ShowS) -> Show (IfDec rt)
forall rt. Show rt => Int -> IfDec rt -> ShowS
forall rt. Show rt => [IfDec rt] -> ShowS
forall rt. Show rt => IfDec rt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfDec rt] -> ShowS
$cshowList :: forall rt. Show rt => [IfDec rt] -> ShowS
show :: IfDec rt -> String
$cshow :: forall rt. Show rt => IfDec rt -> String
showsPrec :: Int -> IfDec rt -> ShowS
$cshowsPrec :: forall rt. Show rt => Int -> IfDec rt -> ShowS
Show, Eq (IfDec rt)
Eq (IfDec rt)
-> (IfDec rt -> IfDec rt -> Ordering)
-> (IfDec rt -> IfDec rt -> Bool)
-> (IfDec rt -> IfDec rt -> Bool)
-> (IfDec rt -> IfDec rt -> Bool)
-> (IfDec rt -> IfDec rt -> Bool)
-> (IfDec rt -> IfDec rt -> IfDec rt)
-> (IfDec rt -> IfDec rt -> IfDec rt)
-> Ord (IfDec rt)
IfDec rt -> IfDec rt -> Bool
IfDec rt -> IfDec rt -> Ordering
IfDec rt -> IfDec rt -> IfDec rt
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall rt. Ord rt => Eq (IfDec rt)
forall rt. Ord rt => IfDec rt -> IfDec rt -> Bool
forall rt. Ord rt => IfDec rt -> IfDec rt -> Ordering
forall rt. Ord rt => IfDec rt -> IfDec rt -> IfDec rt
min :: IfDec rt -> IfDec rt -> IfDec rt
$cmin :: forall rt. Ord rt => IfDec rt -> IfDec rt -> IfDec rt
max :: IfDec rt -> IfDec rt -> IfDec rt
$cmax :: forall rt. Ord rt => IfDec rt -> IfDec rt -> IfDec rt
>= :: IfDec rt -> IfDec rt -> Bool
$c>= :: forall rt. Ord rt => IfDec rt -> IfDec rt -> Bool
> :: IfDec rt -> IfDec rt -> Bool
$c> :: forall rt. Ord rt => IfDec rt -> IfDec rt -> Bool
<= :: IfDec rt -> IfDec rt -> Bool
$c<= :: forall rt. Ord rt => IfDec rt -> IfDec rt -> Bool
< :: IfDec rt -> IfDec rt -> Bool
$c< :: forall rt. Ord rt => IfDec rt -> IfDec rt -> Bool
compare :: IfDec rt -> IfDec rt -> Ordering
$ccompare :: forall rt. Ord rt => IfDec rt -> IfDec rt -> Ordering
$cp1Ord :: forall rt. Ord rt => Eq (IfDec rt)
Ord, (forall x. IfDec rt -> Rep (IfDec rt) x)
-> (forall x. Rep (IfDec rt) x -> IfDec rt) -> Generic (IfDec rt)
forall x. Rep (IfDec rt) x -> IfDec rt
forall x. IfDec rt -> Rep (IfDec rt) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall rt x. Rep (IfDec rt) x -> IfDec rt
forall rt x. IfDec rt -> Rep (IfDec rt) x
$cto :: forall rt x. Rep (IfDec rt) x -> IfDec rt
$cfrom :: forall rt x. IfDec rt -> Rep (IfDec rt) x
Generic)

instance SexpIso rt => SexpIso (IfDec rt) where
  sexpIso :: Grammar Position (Sexp :- t) (IfDec rt :- t)
sexpIso = (Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
 -> Grammar Position (Sexp :- t) (IfDec rt :- t))
-> Grammar Position (Sexp :- t) (IfDec rt :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
  -> Grammar Position (Sexp :- t) (IfDec rt :- t))
 -> Grammar Position (Sexp :- t) (IfDec rt :- t))
-> (Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
    -> Grammar Position (Sexp :- t) (IfDec rt :- t))
-> Grammar Position (Sexp :- t) (IfDec rt :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
stm ->
    Grammar Position (List :- t) (List :- (IfSort :- ([rt] :- t)))
-> Grammar Position (Sexp :- t) (IfSort :- ([rt] :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) ([rt] :- t)
-> Grammar Position (List :- t) (List :- ([rt] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([rt] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- ([rt] :- t))
-> Grammar
     Position (List :- ([rt] :- t)) (List :- (IfSort :- ([rt] :- t)))
-> Grammar Position (List :- t) (List :- (IfSort :- ([rt] :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- ([rt] :- t)) (IfSort :- ([rt] :- t))
-> Grammar
     Position (List :- ([rt] :- t)) (List :- (IfSort :- ([rt] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- ([rt] :- t)) (IfSort :- ([rt] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar Position (Sexp :- t) (IfSort :- ([rt] :- t))
-> Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
-> Grammar Position (Sexp :- t) (IfDec rt :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (IfSort :- ([rt] :- t)) (IfDec rt :- t)
stm

-- | What kind of branch is this?  This has no semantic meaning, but
-- provides hints to simplifications.
data IfSort
  = -- | An ordinary branch.
    IfNormal
  | -- | A branch where the "true" case is what we are
    -- actually interested in, and the "false" case is only
    -- present as a fallback for when the true case cannot
    -- be safely evaluated.  The compiler is permitted to
    -- optimise away the branch if the true case contains
    -- only safe statements.
    IfFallback
  | -- | Both of these branches are semantically equivalent,
    -- and it is fine to eliminate one if it turns out to
    -- have problems (e.g. contain things we cannot generate
    -- code for).
    IfEquiv
  deriving (IfSort -> IfSort -> Bool
(IfSort -> IfSort -> Bool)
-> (IfSort -> IfSort -> Bool) -> Eq IfSort
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IfSort -> IfSort -> Bool
$c/= :: IfSort -> IfSort -> Bool
== :: IfSort -> IfSort -> Bool
$c== :: IfSort -> IfSort -> Bool
Eq, Int -> IfSort -> ShowS
[IfSort] -> ShowS
IfSort -> String
(Int -> IfSort -> ShowS)
-> (IfSort -> String) -> ([IfSort] -> ShowS) -> Show IfSort
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IfSort] -> ShowS
$cshowList :: [IfSort] -> ShowS
show :: IfSort -> String
$cshow :: IfSort -> String
showsPrec :: Int -> IfSort -> ShowS
$cshowsPrec :: Int -> IfSort -> ShowS
Show, Eq IfSort
Eq IfSort
-> (IfSort -> IfSort -> Ordering)
-> (IfSort -> IfSort -> Bool)
-> (IfSort -> IfSort -> Bool)
-> (IfSort -> IfSort -> Bool)
-> (IfSort -> IfSort -> Bool)
-> (IfSort -> IfSort -> IfSort)
-> (IfSort -> IfSort -> IfSort)
-> Ord IfSort
IfSort -> IfSort -> Bool
IfSort -> IfSort -> Ordering
IfSort -> IfSort -> IfSort
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IfSort -> IfSort -> IfSort
$cmin :: IfSort -> IfSort -> IfSort
max :: IfSort -> IfSort -> IfSort
$cmax :: IfSort -> IfSort -> IfSort
>= :: IfSort -> IfSort -> Bool
$c>= :: IfSort -> IfSort -> Bool
> :: IfSort -> IfSort -> Bool
$c> :: IfSort -> IfSort -> Bool
<= :: IfSort -> IfSort -> Bool
$c<= :: IfSort -> IfSort -> Bool
< :: IfSort -> IfSort -> Bool
$c< :: IfSort -> IfSort -> Bool
compare :: IfSort -> IfSort -> Ordering
$ccompare :: IfSort -> IfSort -> Ordering
$cp1Ord :: Eq IfSort
Ord, (forall x. IfSort -> Rep IfSort x)
-> (forall x. Rep IfSort x -> IfSort) -> Generic IfSort
forall x. Rep IfSort x -> IfSort
forall x. IfSort -> Rep IfSort x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IfSort x -> IfSort
$cfrom :: forall x. IfSort -> Rep IfSort x
Generic)

instance SexpIso IfSort where
  sexpIso :: Grammar Position (Sexp :- t) (IfSort :- t)
sexpIso =
    Coproduct Position (Sexp :- t) '[t, t, t] IfSort t
-> Grammar Position (Sexp :- t) (IfSort :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct Position (Sexp :- t) '[t, t, t] IfSort t
 -> Grammar Position (Sexp :- t) (IfSort :- t))
-> Coproduct Position (Sexp :- t) '[t, t, t] IfSort t
-> Grammar Position (Sexp :- t) (IfSort :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position t (IfSort :- t)
 -> Grammar Position (Sexp :- t) (IfSort :- t))
-> Coproduct Position (Sexp :- t) '[t, t] IfSort t
-> Coproduct Position (Sexp :- t) '[t, t, t] IfSort t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"normal" Grammar Position (Sexp :- t) t
-> Grammar Position t (IfSort :- t)
-> Grammar Position (Sexp :- t) (IfSort :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>) (Coproduct Position (Sexp :- t) '[t, t] IfSort t
 -> Coproduct Position (Sexp :- t) '[t, t, t] IfSort t)
-> Coproduct Position (Sexp :- t) '[t, t] IfSort t
-> Coproduct Position (Sexp :- t) '[t, t, t] IfSort t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position t (IfSort :- t)
 -> Grammar Position (Sexp :- t) (IfSort :- t))
-> Coproduct Position (Sexp :- t) '[t] IfSort t
-> Coproduct Position (Sexp :- t) '[t, t] IfSort t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"fallback" Grammar Position (Sexp :- t) t
-> Grammar Position t (IfSort :- t)
-> Grammar Position (Sexp :- t) (IfSort :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>) (Coproduct Position (Sexp :- t) '[t] IfSort t
 -> Coproduct Position (Sexp :- t) '[t, t] IfSort t)
-> Coproduct Position (Sexp :- t) '[t] IfSort t
-> Coproduct Position (Sexp :- t) '[t, t] IfSort t
forall a b. (a -> b) -> a -> b
$
          (Grammar Position t (IfSort :- t)
 -> Grammar Position (Sexp :- t) (IfSort :- t))
-> Coproduct Position (Sexp :- t) '[] IfSort t
-> Coproduct Position (Sexp :- t) '[t] IfSort t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
            (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
sym Text
"equiv" Grammar Position (Sexp :- t) t
-> Grammar Position t (IfSort :- t)
-> Grammar Position (Sexp :- t) (IfSort :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>>)
            Coproduct Position (Sexp :- t) '[] IfSort t
forall p s a t. Coproduct p s '[] a t
End

-- | A type alias for namespace control.
type Exp = ExpT

-- | Anonymous function for use in a SOAC.
data LambdaT lore = Lambda
  { LambdaT lore -> [LParam lore]
lambdaParams :: [LParam lore],
    LambdaT lore -> BodyT lore
lambdaBody :: BodyT lore,
    LambdaT lore -> [TypeBase Shape NoUniqueness]
lambdaReturnType :: [Type]
  }
  deriving ((forall x. LambdaT lore -> Rep (LambdaT lore) x)
-> (forall x. Rep (LambdaT lore) x -> LambdaT lore)
-> Generic (LambdaT lore)
forall x. Rep (LambdaT lore) x -> LambdaT lore
forall x. LambdaT lore -> Rep (LambdaT lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (LambdaT lore) x -> LambdaT lore
forall lore x. LambdaT lore -> Rep (LambdaT lore) x
$cto :: forall lore x. Rep (LambdaT lore) x -> LambdaT lore
$cfrom :: forall lore x. LambdaT lore -> Rep (LambdaT lore) x
Generic)

instance Decorations lore => SexpIso (LambdaT lore) where
  sexpIso :: Grammar Position (Sexp :- t) (LambdaT lore :- t)
sexpIso = (Grammar
   Position
   ([TypeBase Shape NoUniqueness]
    :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
   (LambdaT lore :- t)
 -> Grammar Position (Sexp :- t) (LambdaT lore :- t))
-> Grammar Position (Sexp :- t) (LambdaT lore :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    ([TypeBase Shape NoUniqueness]
     :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
    (LambdaT lore :- t)
  -> Grammar Position (Sexp :- t) (LambdaT lore :- t))
 -> Grammar Position (Sexp :- t) (LambdaT lore :- t))
-> (Grammar
      Position
      ([TypeBase Shape NoUniqueness]
       :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
      (LambdaT lore :- t)
    -> Grammar Position (Sexp :- t) (LambdaT lore :- t))
-> Grammar Position (Sexp :- t) (LambdaT lore :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  ([TypeBase Shape NoUniqueness]
   :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
  (LambdaT lore :- t)
lambdat ->
    Grammar
  Position
  (List :- t)
  (List
   :- ([TypeBase Shape NoUniqueness]
       :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
-> Grammar
     Position
     (Sexp :- t)
     ([TypeBase Shape NoUniqueness]
      :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"lambda")
          Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) ([Param (LParamInfo lore)] :- t)
-> Grammar
     Position (List :- t) (List :- ([Param (LParamInfo lore)] :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) ([Param (LParamInfo lore)] :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position (List :- t) (List :- ([Param (LParamInfo lore)] :- t))
-> Grammar
     Position
     (List :- ([Param (LParamInfo lore)] :- t))
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
-> Grammar
     Position
     (List :- t)
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- ([Param (LParamInfo lore)] :- t))
  (BodyT lore :- ([Param (LParamInfo lore)] :- t))
-> Grammar
     Position
     (List :- ([Param (LParamInfo lore)] :- t))
     (List :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- ([Param (LParamInfo lore)] :- t))
  (BodyT lore :- ([Param (LParamInfo lore)] :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- ([Param (LParamInfo lore)] :- t))
  (List :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
-> Grammar
     Position
     (List :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
-> Grammar
     Position
     (List :- ([Param (LParamInfo lore)] :- t))
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
  ([TypeBase Shape NoUniqueness]
   :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
-> Grammar
     Position
     (List :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
     (List
      :- ([TypeBase Shape NoUniqueness]
          :- (BodyT lore :- ([Param (LParamInfo lore)] :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
  ([TypeBase Shape NoUniqueness]
   :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position
  (Sexp :- t)
  ([TypeBase Shape NoUniqueness]
   :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
-> Grammar
     Position
     ([TypeBase Shape NoUniqueness]
      :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
     (LambdaT lore :- t)
-> Grammar Position (Sexp :- t) (LambdaT lore :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  ([TypeBase Shape NoUniqueness]
   :- (BodyT lore :- ([Param (LParamInfo lore)] :- t)))
  (LambdaT lore :- t)
lambdat

deriving instance Decorations lore => Eq (LambdaT lore)

deriving instance Decorations lore => Show (LambdaT lore)

deriving instance Decorations lore => Ord (LambdaT lore)

-- | Type alias for namespacing reasons.
type Lambda = LambdaT

-- | A function and loop parameter.
type FParam lore = Param (FParamInfo lore)

-- | A lambda parameter.
type LParam lore = Param (LParamInfo lore)

-- | Function Declarations
data FunDef lore = FunDef
  { -- | Contains a value if this function is
    -- an entry point.
    FunDef lore -> Maybe EntryPoint
funDefEntryPoint :: Maybe EntryPoint,
    FunDef lore -> Attrs
funDefAttrs :: Attrs,
    FunDef lore -> Name
funDefName :: Name,
    FunDef lore -> [RetType lore]
funDefRetType :: [RetType lore],
    FunDef lore -> [FParam lore]
funDefParams :: [FParam lore],
    FunDef lore -> BodyT lore
funDefBody :: BodyT lore
  }
  deriving ((forall x. FunDef lore -> Rep (FunDef lore) x)
-> (forall x. Rep (FunDef lore) x -> FunDef lore)
-> Generic (FunDef lore)
forall x. Rep (FunDef lore) x -> FunDef lore
forall x. FunDef lore -> Rep (FunDef lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (FunDef lore) x -> FunDef lore
forall lore x. FunDef lore -> Rep (FunDef lore) x
$cto :: forall lore x. Rep (FunDef lore) x -> FunDef lore
$cfrom :: forall lore x. FunDef lore -> Rep (FunDef lore) x
Generic)

instance Decorations lore => SexpIso (FunDef lore) where
  sexpIso :: Grammar Position (Sexp :- t) (FunDef lore :- t)
sexpIso = (Grammar
   Position
   (BodyT lore
    :- ([Param (FParamInfo lore)]
        :- ([RetType lore]
            :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
   (FunDef lore :- t)
 -> Grammar Position (Sexp :- t) (FunDef lore :- t))
-> Grammar Position (Sexp :- t) (FunDef lore :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position
    (BodyT lore
     :- ([Param (FParamInfo lore)]
         :- ([RetType lore]
             :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
    (FunDef lore :- t)
  -> Grammar Position (Sexp :- t) (FunDef lore :- t))
 -> Grammar Position (Sexp :- t) (FunDef lore :- t))
-> (Grammar
      Position
      (BodyT lore
       :- ([Param (FParamInfo lore)]
           :- ([RetType lore]
               :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
      (FunDef lore :- t)
    -> Grammar Position (Sexp :- t) (FunDef lore :- t))
-> Grammar Position (Sexp :- t) (FunDef lore :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position
  (BodyT lore
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
  (FunDef lore :- t)
fundef ->
    Grammar
  Position
  (List :- t)
  (List
   :- (BodyT lore
       :- ([Param (FParamInfo lore)]
           :- ([RetType lore]
               :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (Sexp :- t)
     (BodyT lore
      :- ([Param (FParamInfo lore)]
          :- ([RetType lore]
              :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"fundef")
          Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Maybe EntryPoint :- t)
-> Grammar Position (List :- t) (List :- (Maybe EntryPoint :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Maybe EntryPoint :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- (Maybe EntryPoint :- t))
-> Grammar
     Position
     (List :- (Maybe EntryPoint :- t))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List :- t)
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Maybe EntryPoint :- t))
  (Attrs :- (Maybe EntryPoint :- t))
-> Grammar
     Position
     (List :- (Maybe EntryPoint :- t))
     (List :- (Attrs :- (Maybe EntryPoint :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Maybe EntryPoint :- t))
  (Attrs :- (Maybe EntryPoint :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (Maybe EntryPoint :- t))
  (List :- (Attrs :- (Maybe EntryPoint :- t)))
-> Grammar
     Position
     (List :- (Attrs :- (Maybe EntryPoint :- t)))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List :- (Maybe EntryPoint :- t))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Attrs :- (Maybe EntryPoint :- t)))
  (Name :- (Attrs :- (Maybe EntryPoint :- t)))
-> Grammar
     Position
     (List :- (Attrs :- (Maybe EntryPoint :- t)))
     (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Attrs :- (Maybe EntryPoint :- t)))
  (Name :- (Attrs :- (Maybe EntryPoint :- t)))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (Attrs :- (Maybe EntryPoint :- t)))
  (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
-> Grammar
     Position
     (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List :- (Attrs :- (Maybe EntryPoint :- t)))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
  ([RetType lore] :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
-> Grammar
     Position
     (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
     (List
      :- ([RetType lore]
          :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
  ([RetType lore] :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
  (List
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
-> Grammar
     Position
     (List
      :- ([RetType lore]
          :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
  ([Param (FParamInfo lore)]
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
-> Grammar
     Position
     (List
      :- ([RetType lore]
          :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
     (List
      :- ([Param (FParamInfo lore)]
          :- ([RetType lore]
              :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
  ([Param (FParamInfo lore)]
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar
  Position
  (List
   :- ([RetType lore]
       :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
  (List
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
-> Grammar
     Position
     (List
      :- ([Param (FParamInfo lore)]
          :- ([RetType lore]
              :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
-> Grammar
     Position
     (List
      :- ([RetType lore]
          :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (Sexp
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
  (BodyT lore
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
-> Grammar
     Position
     (List
      :- ([Param (FParamInfo lore)]
          :- ([RetType lore]
              :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
     (List
      :- (BodyT lore
          :- ([Param (FParamInfo lore)]
              :- ([RetType lore]
                  :- (Name :- (Attrs :- (Maybe EntryPoint :- t)))))))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar
  Position
  (Sexp
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
  (BodyT lore
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position
  (Sexp :- t)
  (BodyT lore
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
-> Grammar
     Position
     (BodyT lore
      :- ([Param (FParamInfo lore)]
          :- ([RetType lore]
              :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
     (FunDef lore :- t)
-> Grammar Position (Sexp :- t) (FunDef lore :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position
  (BodyT lore
   :- ([Param (FParamInfo lore)]
       :- ([RetType lore]
           :- (Name :- (Attrs :- (Maybe EntryPoint :- t))))))
  (FunDef lore :- t)
fundef

deriving instance Decorations lore => Eq (FunDef lore)

deriving instance Decorations lore => Show (FunDef lore)

deriving instance Decorations lore => Ord (FunDef lore)

-- | Information about the parameters and return value of an entry
-- point.  The first element is for parameters, the second for return
-- value.
type EntryPoint = ([EntryPointType], [EntryPointType])

-- | Every entry point argument and return value has an annotation
-- indicating how it maps to the original source program type.
data EntryPointType
  = -- | Is an unsigned integer or array of unsigned
    -- integers.
    TypeUnsigned
  | -- | A black box type comprising this many core
    -- values.  The string is a human-readable
    -- description with no other semantics.
    TypeOpaque String Int
  | -- | Maps directly.
    TypeDirect
  deriving (EntryPointType -> EntryPointType -> Bool
(EntryPointType -> EntryPointType -> Bool)
-> (EntryPointType -> EntryPointType -> Bool) -> Eq EntryPointType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntryPointType -> EntryPointType -> Bool
$c/= :: EntryPointType -> EntryPointType -> Bool
== :: EntryPointType -> EntryPointType -> Bool
$c== :: EntryPointType -> EntryPointType -> Bool
Eq, Int -> EntryPointType -> ShowS
[EntryPointType] -> ShowS
EntryPointType -> String
(Int -> EntryPointType -> ShowS)
-> (EntryPointType -> String)
-> ([EntryPointType] -> ShowS)
-> Show EntryPointType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntryPointType] -> ShowS
$cshowList :: [EntryPointType] -> ShowS
show :: EntryPointType -> String
$cshow :: EntryPointType -> String
showsPrec :: Int -> EntryPointType -> ShowS
$cshowsPrec :: Int -> EntryPointType -> ShowS
Show, Eq EntryPointType
Eq EntryPointType
-> (EntryPointType -> EntryPointType -> Ordering)
-> (EntryPointType -> EntryPointType -> Bool)
-> (EntryPointType -> EntryPointType -> Bool)
-> (EntryPointType -> EntryPointType -> Bool)
-> (EntryPointType -> EntryPointType -> Bool)
-> (EntryPointType -> EntryPointType -> EntryPointType)
-> (EntryPointType -> EntryPointType -> EntryPointType)
-> Ord EntryPointType
EntryPointType -> EntryPointType -> Bool
EntryPointType -> EntryPointType -> Ordering
EntryPointType -> EntryPointType -> EntryPointType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EntryPointType -> EntryPointType -> EntryPointType
$cmin :: EntryPointType -> EntryPointType -> EntryPointType
max :: EntryPointType -> EntryPointType -> EntryPointType
$cmax :: EntryPointType -> EntryPointType -> EntryPointType
>= :: EntryPointType -> EntryPointType -> Bool
$c>= :: EntryPointType -> EntryPointType -> Bool
> :: EntryPointType -> EntryPointType -> Bool
$c> :: EntryPointType -> EntryPointType -> Bool
<= :: EntryPointType -> EntryPointType -> Bool
$c<= :: EntryPointType -> EntryPointType -> Bool
< :: EntryPointType -> EntryPointType -> Bool
$c< :: EntryPointType -> EntryPointType -> Bool
compare :: EntryPointType -> EntryPointType -> Ordering
$ccompare :: EntryPointType -> EntryPointType -> Ordering
$cp1Ord :: Eq EntryPointType
Ord, (forall x. EntryPointType -> Rep EntryPointType x)
-> (forall x. Rep EntryPointType x -> EntryPointType)
-> Generic EntryPointType
forall x. Rep EntryPointType x -> EntryPointType
forall x. EntryPointType -> Rep EntryPointType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntryPointType x -> EntryPointType
$cfrom :: forall x. EntryPointType -> Rep EntryPointType x
Generic)

instance SexpIso EntryPointType where
  sexpIso :: Grammar Position (Sexp :- t) (EntryPointType :- t)
sexpIso =
    Coproduct
  Position (Sexp :- t) '[t, Int :- (String :- t), t] EntryPointType t
-> Grammar Position (Sexp :- t) (EntryPointType :- t)
forall a (bs :: [*]) t p s.
(Generic a, MkPrismList (Rep a), Match (Rep a) bs t,
 bs ~ Coll (Rep a) t) =>
Coproduct p s bs a t -> Grammar p s (a :- t)
match (Coproduct
   Position (Sexp :- t) '[t, Int :- (String :- t), t] EntryPointType t
 -> Grammar Position (Sexp :- t) (EntryPointType :- t))
-> Coproduct
     Position (Sexp :- t) '[t, Int :- (String :- t), t] EntryPointType t
-> Grammar Position (Sexp :- t) (EntryPointType :- t)
forall a b. (a -> b) -> a -> b
$
      (Grammar Position t (EntryPointType :- t)
 -> Grammar Position (Sexp :- t) (EntryPointType :- t))
-> Coproduct
     Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t
-> Coproduct
     Position (Sexp :- t) '[t, Int :- (String :- t), t] EntryPointType t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position t (EntryPointType :- t)
-> Grammar Position (Sexp :- t) t
-> Grammar Position (Sexp :- t) (EntryPointType :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"unsigned") (Coproduct
   Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t
 -> Coproduct
      Position
      (Sexp :- t)
      '[t, Int :- (String :- t), t]
      EntryPointType
      t)
-> Coproduct
     Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t
-> Coproduct
     Position (Sexp :- t) '[t, Int :- (String :- t), t] EntryPointType t
forall a b. (a -> b) -> a -> b
$
        (Grammar Position (Int :- (String :- t)) (EntryPointType :- t)
 -> Grammar Position (Sexp :- t) (EntryPointType :- t))
-> Coproduct Position (Sexp :- t) '[t] EntryPointType t
-> Coproduct
     Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With (Grammar Position (Int :- (String :- t)) (EntryPointType :- t)
-> Grammar Position (Sexp :- t) (Int :- (String :- t))
-> Grammar Position (Sexp :- t) (EntryPointType :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (List :- t) (List :- (Int :- (String :- t)))
-> Grammar Position (Sexp :- t) (Int :- (String :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list (Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"opaque") Grammar Position (List :- t) (List :- t)
-> Grammar Position (List :- t) (List :- (Int :- (String :- t)))
-> Grammar Position (List :- t) (List :- (Int :- (String :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (String :- t)
-> Grammar Position (List :- t) (List :- (String :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el ((Text -> String)
-> (String -> Text) -> Grammar Position (Text :- t) (String :- t)
forall a b p t. (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
iso Text -> String
T.unpack String -> Text
T.pack Grammar Position (Text :- t) (String :- t)
-> Grammar Position (Sexp :- t) (Text :- t)
-> Grammar Position (Sexp :- t) (String :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Grammar Position (Sexp :- t) (Text :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso) Grammar Position (List :- t) (List :- (String :- t))
-> Grammar
     Position (List :- (String :- t)) (List :- (Int :- (String :- t)))
-> Grammar Position (List :- t) (List :- (Int :- (String :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- (String :- t)) (Int :- (String :- t))
-> Grammar
     Position (List :- (String :- t)) (List :- (Int :- (String :- t)))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- (String :- t)) (Int :- (String :- t))
forall a. SexpIso a => SexpGrammar a
sexpIso)) (Coproduct Position (Sexp :- t) '[t] EntryPointType t
 -> Coproduct
      Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t)
-> Coproduct Position (Sexp :- t) '[t] EntryPointType t
-> Coproduct
     Position (Sexp :- t) '[Int :- (String :- t), t] EntryPointType t
forall a b. (a -> b) -> a -> b
$
          (Grammar Position t (EntryPointType :- t)
 -> Grammar Position (Sexp :- t) (EntryPointType :- t))
-> Coproduct Position (Sexp :- t) '[] EntryPointType t
-> Coproduct Position (Sexp :- t) '[t] EntryPointType t
forall p b a t s (bs1 :: [*]).
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Coproduct p s bs1 a t -> Coproduct p s (b : bs1) a t
With
            (Grammar Position t (EntryPointType :- t)
-> Grammar Position (Sexp :- t) t
-> Grammar Position (Sexp :- t) (EntryPointType :- t)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"direct")
            Coproduct Position (Sexp :- t) '[] EntryPointType t
forall p s a t. Coproduct p s '[] a t
End

-- | An entire Futhark program.
data Prog lore = Prog
  { -- | Top-level constants that are computed at program startup, and
    -- which are in scope inside all functions.
    Prog lore -> Stms lore
progConsts :: Stms lore,
    -- | The functions comprising the program.  All funtions are also
    -- available in scope in the definitions of the constants, so be
    -- careful not to introduce circular dependencies (not currently
    -- checked).
    Prog lore -> [FunDef lore]
progFuns :: [FunDef lore]
  }
  deriving (Prog lore -> Prog lore -> Bool
(Prog lore -> Prog lore -> Bool)
-> (Prog lore -> Prog lore -> Bool) -> Eq (Prog lore)
forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Prog lore -> Prog lore -> Bool
$c/= :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
== :: Prog lore -> Prog lore -> Bool
$c== :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
Eq, Eq (Prog lore)
Eq (Prog lore)
-> (Prog lore -> Prog lore -> Ordering)
-> (Prog lore -> Prog lore -> Bool)
-> (Prog lore -> Prog lore -> Bool)
-> (Prog lore -> Prog lore -> Bool)
-> (Prog lore -> Prog lore -> Bool)
-> (Prog lore -> Prog lore -> Prog lore)
-> (Prog lore -> Prog lore -> Prog lore)
-> Ord (Prog lore)
Prog lore -> Prog lore -> Bool
Prog lore -> Prog lore -> Ordering
Prog lore -> Prog lore -> Prog lore
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall lore. Decorations lore => Eq (Prog lore)
forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
forall lore. Decorations lore => Prog lore -> Prog lore -> Ordering
forall lore.
Decorations lore =>
Prog lore -> Prog lore -> Prog lore
min :: Prog lore -> Prog lore -> Prog lore
$cmin :: forall lore.
Decorations lore =>
Prog lore -> Prog lore -> Prog lore
max :: Prog lore -> Prog lore -> Prog lore
$cmax :: forall lore.
Decorations lore =>
Prog lore -> Prog lore -> Prog lore
>= :: Prog lore -> Prog lore -> Bool
$c>= :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
> :: Prog lore -> Prog lore -> Bool
$c> :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
<= :: Prog lore -> Prog lore -> Bool
$c<= :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
< :: Prog lore -> Prog lore -> Bool
$c< :: forall lore. Decorations lore => Prog lore -> Prog lore -> Bool
compare :: Prog lore -> Prog lore -> Ordering
$ccompare :: forall lore. Decorations lore => Prog lore -> Prog lore -> Ordering
$cp1Ord :: forall lore. Decorations lore => Eq (Prog lore)
Ord, Int -> Prog lore -> ShowS
[Prog lore] -> ShowS
Prog lore -> String
(Int -> Prog lore -> ShowS)
-> (Prog lore -> String)
-> ([Prog lore] -> ShowS)
-> Show (Prog lore)
forall lore. Decorations lore => Int -> Prog lore -> ShowS
forall lore. Decorations lore => [Prog lore] -> ShowS
forall lore. Decorations lore => Prog lore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Prog lore] -> ShowS
$cshowList :: forall lore. Decorations lore => [Prog lore] -> ShowS
show :: Prog lore -> String
$cshow :: forall lore. Decorations lore => Prog lore -> String
showsPrec :: Int -> Prog lore -> ShowS
$cshowsPrec :: forall lore. Decorations lore => Int -> Prog lore -> ShowS
Show, (forall x. Prog lore -> Rep (Prog lore) x)
-> (forall x. Rep (Prog lore) x -> Prog lore)
-> Generic (Prog lore)
forall x. Rep (Prog lore) x -> Prog lore
forall x. Prog lore -> Rep (Prog lore) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall lore x. Rep (Prog lore) x -> Prog lore
forall lore x. Prog lore -> Rep (Prog lore) x
$cto :: forall lore x. Rep (Prog lore) x -> Prog lore
$cfrom :: forall lore x. Prog lore -> Rep (Prog lore) x
Generic)

instance Decorations lore => SexpIso (Prog lore) where
  sexpIso :: Grammar Position (Sexp :- t) (Prog lore :- t)
sexpIso = (Grammar
   Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
 -> Grammar Position (Sexp :- t) (Prog lore :- t))
-> Grammar Position (Sexp :- t) (Prog lore :- t)
forall a b s t (c :: Meta) (d :: Meta) (f :: * -> *) p.
(Generic a, MkPrismList (Rep a), MkStackPrism f,
 Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) =>
(Grammar p b (a :- t) -> Grammar p s (a :- t))
-> Grammar p s (a :- t)
with ((Grammar
    Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
  -> Grammar Position (Sexp :- t) (Prog lore :- t))
 -> Grammar Position (Sexp :- t) (Prog lore :- t))
-> (Grammar
      Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
    -> Grammar Position (Sexp :- t) (Prog lore :- t))
-> Grammar Position (Sexp :- t) (Prog lore :- t)
forall a b. (a -> b) -> a -> b
$ \Grammar
  Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
prog ->
    Grammar
  Position
  (List :- t)
  (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
-> Grammar
     Position (Sexp :- t) ([FunDef lore] :- (Seq (Stm lore) :- t))
forall t t'.
Grammar Position (List :- t) (List :- t')
-> Grammar Position (Sexp :- t) t'
Sexp.list
      ( Grammar Position (Sexp :- t) t
-> Grammar Position (List :- t) (List :- t)
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el (Text -> Grammar Position (Sexp :- t) t
forall t. Text -> Grammar Position (Sexp :- t) t
Sexp.sym Text
"prog")
          Grammar Position (List :- t) (List :- t)
-> Grammar
     Position
     (List :- t)
     (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
-> Grammar
     Position
     (List :- t)
     (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar Position (Sexp :- t) (Seq (Stm lore) :- t)
-> Grammar Position (List :- t) (List :- (Seq (Stm lore) :- t))
forall t t'.
Grammar Position (Sexp :- t) t'
-> Grammar Position (List :- t) (List :- t')
Sexp.el Grammar Position (Sexp :- t) (Seq (Stm lore) :- t)
forall a. SexpIso a => SexpGrammar a
sexpIso
          Grammar Position (List :- t) (List :- (Seq (Stm lore) :- t))
-> Grammar
     Position
     (List :- (Seq (Stm lore) :- t))
     (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
-> Grammar
     Position
     (List :- t)
     (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> (forall t1. Grammar Position (Sexp :- t1) (FunDef lore :- t1))
-> Grammar
     Position
     (List :- (Seq (Stm lore) :- t))
     (List :- ([FunDef lore] :- (Seq (Stm lore) :- t)))
forall a t.
(forall t1. Grammar Position (Sexp :- t1) (a :- t1))
-> Grammar Position (List :- t) (List :- ([a] :- t))
Sexp.rest forall t1. Grammar Position (Sexp :- t1) (FunDef lore :- t1)
forall a. SexpIso a => SexpGrammar a
sexpIso
      )
      Grammar
  Position (Sexp :- t) ([FunDef lore] :- (Seq (Stm lore) :- t))
-> Grammar
     Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
-> Grammar Position (Sexp :- t) (Prog lore :- t)
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> Grammar
  Position ([FunDef lore] :- (Seq (Stm lore) :- t)) (Prog lore :- t)
prog