{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Array.Accelerate.Trafo.Substitution (
inline, inlineVars, compose,
subTop, subAtop,
(:>), Sink(..), SinkExp(..), weakenVars,
(:?>), strengthen, strengthenE,
RebuildAcc, Rebuildable(..), RebuildableAcc,
RebuildableExp(..), rebuildWeakenVar, rebuildLHS,
OpenAccFun(..), OpenAccExp(..),
isIdentity, isIdentityIndexing, extractExpVars,
bindingIsTrivial,
) where
import Data.Array.Accelerate.AST
import Data.Array.Accelerate.AST.LeftHandSide
import Data.Array.Accelerate.AST.Var
import Data.Array.Accelerate.AST.Idx
import Data.Array.Accelerate.AST.Environment
import Data.Array.Accelerate.Analysis.Match
import Data.Array.Accelerate.Error
import Data.Array.Accelerate.Representation.Type
import Data.Array.Accelerate.Representation.Array
import qualified Data.Array.Accelerate.Debug.Internal.Stats as Stats
import Data.Kind
import Control.Applicative hiding ( Const )
import Control.Monad
import Prelude hiding ( exp, seq )
infixr `compose`
lhsFullVars :: forall s a env1 env2. LeftHandSide s a env1 env2 -> Maybe (Vars s env2 a)
lhsFullVars :: forall (s :: * -> *) a env1 env2.
LeftHandSide s a env1 env2 -> Maybe (Vars s env2 a)
lhsFullVars = ((env1 :> env2, Vars s env2 a) -> Vars s env2 a)
-> Maybe (env1 :> env2, Vars s env2 a) -> Maybe (Vars s env2 a)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (env1 :> env2, Vars s env2 a) -> Vars s env2 a
forall a b. (a, b) -> b
snd (Maybe (env1 :> env2, Vars s env2 a) -> Maybe (Vars s env2 a))
-> (LeftHandSide s a env1 env2
-> Maybe (env1 :> env2, Vars s env2 a))
-> LeftHandSide s a env1 env2
-> Maybe (Vars s env2 a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (env2 :> env2)
-> LeftHandSide s a env1 env2
-> Maybe (env1 :> env2, Vars s env2 a)
forall env env' b.
(env' :> env2)
-> LeftHandSide s b env env' -> Maybe (env :> env2, Vars s env2 b)
go env2 :> env2
forall env. env :> env
weakenId
where
go :: forall env env' b. (env' :> env2) -> LeftHandSide s b env env' -> Maybe (env :> env2, Vars s env2 b)
go :: forall env env' b.
(env' :> env2)
-> LeftHandSide s b env env' -> Maybe (env :> env2, Vars s env2 b)
go env' :> env2
k (LeftHandSideWildcard TupR s b
TupRunit) = (env :> env2, Vars s env2 b) -> Maybe (env :> env2, Vars s env2 b)
forall a. a -> Maybe a
Just (env :> env2
env' :> env2
k, Vars s env2 b
TupR (Var s env2) ()
forall (s :: * -> *). TupR s ()
TupRunit)
go env' :> env2
k (LeftHandSideSingle s b
s) = (env :> env2, Vars s env2 b) -> Maybe (env :> env2, Vars s env2 b)
forall a. a -> Maybe a
Just ((env :> env2, Vars s env2 b)
-> Maybe (env :> env2, Vars s env2 b))
-> (env :> env2, Vars s env2 b)
-> Maybe (env :> env2, Vars s env2 b)
forall a b. (a -> b) -> a -> b
$ (((env, b) :> env2) -> env :> env2
forall env t env'. ((env, t) :> env') -> env :> env'
weakenSucc (((env, b) :> env2) -> env :> env2)
-> ((env, b) :> env2) -> env :> env2
forall a b. (a -> b) -> a -> b
$ env' :> env2
(env, b) :> env2
k, Var s env2 b -> Vars s env2 b
forall (s :: * -> *) a. s a -> TupR s a
TupRsingle (Var s env2 b -> Vars s env2 b) -> Var s env2 b -> Vars s env2 b
forall a b. (a -> b) -> a -> b
$ s b -> Idx env2 b -> Var s env2 b
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var s b
s (Idx env2 b -> Var s env2 b) -> Idx env2 b -> Var s env2 b
forall a b. (a -> b) -> a -> b
$ env' :> env2
k (env' :> env2) -> forall t'. Idx env' t' -> Idx env2 t'
forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
>:> Idx env' b
forall envt t env. (envt ~ (env, t)) => Idx envt t
ZeroIdx)
go env' :> env2
k (LeftHandSidePair LeftHandSide s v1 env env'1
l1 LeftHandSide s v2 env'1 env'
l2)
| Just (env'1 :> env2
k', Vars s env2 v2
v2) <- (env' :> env2)
-> LeftHandSide s v2 env'1 env'
-> Maybe (env'1 :> env2, Vars s env2 v2)
forall env env' b.
(env' :> env2)
-> LeftHandSide s b env env' -> Maybe (env :> env2, Vars s env2 b)
go env' :> env2
k LeftHandSide s v2 env'1 env'
l2
, Just (env :> env2
k'', Vars s env2 v1
v1) <- (env'1 :> env2)
-> LeftHandSide s v1 env env'1
-> Maybe (env :> env2, Vars s env2 v1)
forall env env' b.
(env' :> env2)
-> LeftHandSide s b env env' -> Maybe (env :> env2, Vars s env2 b)
go env'1 :> env2
k' LeftHandSide s v1 env env'1
l1 = (env :> env2, Vars s env2 b) -> Maybe (env :> env2, Vars s env2 b)
forall a. a -> Maybe a
Just (env :> env2
k'', Vars s env2 v1 -> Vars s env2 v2 -> TupR (Var s env2) (v1, v2)
forall (s :: * -> *) a1 b. TupR s a1 -> TupR s b -> TupR s (a1, b)
TupRpair Vars s env2 v1
v1 Vars s env2 v2
v2)
go env' :> env2
_ LeftHandSide s b env env'
_ = Maybe (env :> env2, Vars s env2 b)
forall a. Maybe a
Nothing
bindingIsTrivial :: LeftHandSide s a env1 env2 -> Vars s env2 b -> Maybe (a :~: b)
bindingIsTrivial :: forall (s :: * -> *) a env1 env2 b.
LeftHandSide s a env1 env2 -> Vars s env2 b -> Maybe (a :~: b)
bindingIsTrivial LeftHandSide s a env1 env2
lhs Vars s env2 b
vars
| Just Vars s env2 a
lhsVars <- LeftHandSide s a env1 env2 -> Maybe (Vars s env2 a)
forall (s :: * -> *) a env1 env2.
LeftHandSide s a env1 env2 -> Maybe (Vars s env2 a)
lhsFullVars LeftHandSide s a env1 env2
lhs
, Just b :~: a
Refl <- Vars s env2 b -> Vars s env2 a -> Maybe (b :~: a)
forall (s :: * -> *) env t1 t2.
Vars s env t1 -> Vars s env t2 -> Maybe (t1 :~: t2)
matchVars Vars s env2 b
vars Vars s env2 a
lhsVars
= (a :~: b) -> Maybe (a :~: b)
forall a. a -> Maybe a
Just a :~: a
a :~: b
forall {k} (a :: k). a :~: a
Refl
bindingIsTrivial LeftHandSide s a env1 env2
_ Vars s env2 b
_ = Maybe (a :~: b)
forall a. Maybe a
Nothing
isIdentity :: OpenFun env aenv (a -> b) -> Maybe (a :~: b)
isIdentity :: forall env aenv a b. OpenFun env aenv (a -> b) -> Maybe (a :~: b)
isIdentity (Lam ELeftHandSide a env env'
lhs (Body (OpenExp env' aenv t1 -> Maybe (ExpVars env' t1)
forall env aenv a. OpenExp env aenv a -> Maybe (ExpVars env a)
extractExpVars -> Just ExpVars env' t1
vars))) = LeftHandSide ScalarType a env env'
-> Vars ScalarType env' b -> Maybe (a :~: b)
forall (s :: * -> *) a env1 env2 b.
LeftHandSide s a env1 env2 -> Vars s env2 b -> Maybe (a :~: b)
bindingIsTrivial LeftHandSide ScalarType a env env'
ELeftHandSide a env env'
lhs Vars ScalarType env' b
ExpVars env' t1
vars
isIdentity OpenFun env aenv (a -> b)
_ = Maybe (a :~: b)
forall a. Maybe a
Nothing
isIdentityIndexing :: OpenFun env aenv (a -> b) -> Maybe (ArrayVar aenv (Array a b))
isIdentityIndexing :: forall env aenv a b.
OpenFun env aenv (a -> b) -> Maybe (ArrayVar aenv (Array a b))
isIdentityIndexing (Lam ELeftHandSide a env env'
lhs (Body OpenExp env' aenv t1
body))
| Index ArrayVar aenv (Array dim t1)
avar OpenExp env' aenv dim
ix <- OpenExp env' aenv t1
body
, Just ExpVars env' dim
vars <- OpenExp env' aenv dim -> Maybe (ExpVars env' dim)
forall env aenv a. OpenExp env aenv a -> Maybe (ExpVars env a)
extractExpVars OpenExp env' aenv dim
ix
, Just a :~: dim
Refl <- ELeftHandSide a env env' -> ExpVars env' dim -> Maybe (a :~: dim)
forall (s :: * -> *) a env1 env2 b.
LeftHandSide s a env1 env2 -> Vars s env2 b -> Maybe (a :~: b)
bindingIsTrivial ELeftHandSide a env env'
lhs ExpVars env' dim
vars
= ArrayVar aenv (Array a b) -> Maybe (ArrayVar aenv (Array a b))
forall a. a -> Maybe a
Just ArrayVar aenv (Array a b)
ArrayVar aenv (Array dim t1)
avar
isIdentityIndexing OpenFun env aenv (a -> b)
_ = Maybe (ArrayVar aenv (Array a b))
forall a. Maybe a
Nothing
inline :: OpenExp (env, s) aenv t
-> OpenExp env aenv s
-> OpenExp env aenv t
inline :: forall env s aenv t.
OpenExp (env, s) aenv t -> OpenExp env aenv s -> OpenExp env aenv t
inline OpenExp (env, s) aenv t
f OpenExp env aenv s
g = Text -> OpenExp env aenv t -> OpenExp env aenv t
forall a. Text -> a -> a
Stats.substitution Text
"inline" (OpenExp env aenv t -> OpenExp env aenv t)
-> OpenExp env aenv t -> OpenExp env aenv t
forall a b. (a -> b) -> a -> b
$ (forall e'. ExpVar (env, s) e' -> OpenExp env aenv e')
-> OpenExp (env, s) aenv t -> OpenExp env aenv t
forall (f :: * -> * -> * -> *) (fe :: * -> * -> * -> *) env env'
aenv e.
(RebuildableExp f, SyntacticExp fe) =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> f env aenv e -> f env' aenv e
forall (fe :: * -> * -> * -> *) env env' aenv e.
SyntacticExp fe =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> OpenExp env aenv e -> OpenExp env' aenv e
rebuildE (OpenExp env aenv s
-> Var ScalarType (env, s) e' -> OpenExp env aenv e'
forall env aenv s t.
OpenExp env aenv s -> ExpVar (env, s) t -> OpenExp env aenv t
subTop OpenExp env aenv s
g) OpenExp (env, s) aenv t
f
inlineVars :: forall env env' aenv t1 t2.
ELeftHandSide t1 env env'
-> OpenExp env' aenv t2
-> OpenExp env aenv t1
-> Maybe (OpenExp env aenv t2)
inlineVars :: forall env env' aenv t1 t2.
ELeftHandSide t1 env env'
-> OpenExp env' aenv t2
-> OpenExp env aenv t1
-> Maybe (OpenExp env aenv t2)
inlineVars ELeftHandSide t1 env env'
lhsBound OpenExp env' aenv t2
expr OpenExp env aenv t1
bound
| Just Vars ScalarType env' t1
vars <- ELeftHandSide t1 env env' -> Maybe (Vars ScalarType env' t1)
forall (s :: * -> *) a env1 env2.
LeftHandSide s a env1 env2 -> Maybe (Vars s env2 a)
lhsFullVars ELeftHandSide t1 env env'
lhsBound = (env' :?> env)
-> (env :> env)
-> Vars ScalarType env' t1
-> OpenExp env' aenv t2
-> Maybe (OpenExp env aenv t2)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute (ELeftHandSide t1 env env' -> env' :?> env
forall (s :: * -> *) t env1 env2.
LeftHandSide s t env1 env2 -> env2 :?> env1
strengthenWithLHS ELeftHandSide t1 env env'
lhsBound) env :> env
forall env. env :> env
weakenId Vars ScalarType env' t1
vars OpenExp env' aenv t2
expr
where
substitute
:: forall env1 env2 t.
env1 :?> env2
-> env :> env2
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute :: forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute env1 :?> env2
_ env :> env2
k2 ExpVars env1 t1
vars (OpenExp env1 aenv t -> Maybe (ExpVars env1 t)
forall env aenv a. OpenExp env aenv a -> Maybe (ExpVars env a)
extractExpVars -> Just ExpVars env1 t
vars')
| Just t1 :~: t
Refl <- ExpVars env1 t1 -> ExpVars env1 t -> Maybe (t1 :~: t)
forall (s :: * -> *) env t1 t2.
Vars s env t1 -> Vars s env t2 -> Maybe (t1 :~: t2)
matchVars ExpVars env1 t1
vars ExpVars env1 t
vars' = OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just (OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t))
-> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a b. (a -> b) -> a -> b
$ (env :> env2) -> OpenExp env aenv t -> OpenExp env2 aenv t
forall env env' aenv t.
(env :> env') -> OpenExp env aenv t -> OpenExp env' aenv t
forall (f :: * -> * -> * -> *) env env' aenv t.
SinkExp f =>
(env :> env') -> f env aenv t -> f env' aenv t
weakenE env :> env2
k2 OpenExp env aenv t1
OpenExp env aenv t
bound
substitute env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars OpenExp env1 aenv t
topExp = case OpenExp env1 aenv t
topExp of
Let ELeftHandSide bnd_t env1 env'
lhs OpenExp env1 aenv bnd_t
e1 OpenExp env' aenv t
e2
| Exists LeftHandSide ScalarType bnd_t env2 a
lhs' <- ELeftHandSide bnd_t env1 env'
-> Exists (LeftHandSide ScalarType bnd_t env2)
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ELeftHandSide bnd_t env1 env'
lhs
-> LeftHandSide ScalarType bnd_t env2 a
-> OpenExp env2 aenv bnd_t
-> OpenExp a aenv t
-> OpenExp env2 aenv t
forall bnd_t env env' aenv t.
ELeftHandSide bnd_t env env'
-> OpenExp env aenv bnd_t
-> OpenExp env' aenv t
-> OpenExp env aenv t
Let LeftHandSide ScalarType bnd_t env2 a
lhs' (OpenExp env2 aenv bnd_t
-> OpenExp a aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv bnd_t)
-> Maybe (OpenExp a aenv t -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv bnd_t -> Maybe (OpenExp env2 aenv bnd_t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv bnd_t
e1 Maybe (OpenExp a aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenExp a aenv t) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (env' :?> a)
-> (env :> a)
-> ExpVars env' t1
-> OpenExp env' aenv t
-> Maybe (OpenExp a aenv t)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute (ELeftHandSide bnd_t env1 env'
-> LeftHandSide ScalarType bnd_t env2 a
-> (env1 :?> env2)
-> env' :?> a
forall (s :: * -> *) t env1 env2 env1' env2'.
LeftHandSide s t env1 env2
-> LeftHandSide s t env1' env2'
-> (env1 :?> env1')
-> env2 :?> env2'
strengthenAfter ELeftHandSide bnd_t env1 env'
lhs LeftHandSide ScalarType bnd_t env2 a
lhs' Idx env1 t' -> Maybe (Idx env2 t')
env1 :?> env2
k1) (LeftHandSide ScalarType bnd_t env2 a -> env2 :> a
forall (s :: * -> *) t env env'.
LeftHandSide s t env env' -> env :> env'
weakenWithLHS LeftHandSide ScalarType bnd_t env2 a
lhs' (env2 :> a) -> (env :> env2) -> env :> a
forall env2 env3 env1.
(env2 :> env3) -> (env1 :> env2) -> env1 :> env3
.> env :> env2
k2) (ELeftHandSide bnd_t env1 env' -> env1 :> env'
forall (s :: * -> *) t env env'.
LeftHandSide s t env env' -> env :> env'
weakenWithLHS ELeftHandSide bnd_t env1 env'
lhs (env1 :> env') -> ExpVars env1 t1 -> ExpVars env' t1
forall env env' (s :: * -> *) t.
(env :> env') -> Vars s env t -> Vars s env' t
`weakenVars` ExpVars env1 t1
vars) OpenExp env' aenv t
e2
Evar (Var ScalarType t
t Idx env1 t
ix) -> ExpVar env2 t -> OpenExp env2 aenv t
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar (ExpVar env2 t -> OpenExp env2 aenv t)
-> (Idx env2 t -> ExpVar env2 t)
-> Idx env2 t
-> OpenExp env2 aenv t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScalarType t -> Idx env2 t -> ExpVar env2 t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t
t (Idx env2 t -> OpenExp env2 aenv t)
-> Maybe (Idx env2 t) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Idx env1 t -> Maybe (Idx env2 t)
env1 :?> env2
k1 Idx env1 t
ix
Foreign TypeR t
tp asm (x -> t)
asm Fun () (x -> t)
f OpenExp env1 aenv x
e1 -> TypeR t
-> asm (x -> t)
-> Fun () (x -> t)
-> OpenExp env2 aenv x
-> OpenExp env2 aenv t
forall (asm :: * -> *) t x env aenv.
Foreign asm =>
TypeR t
-> asm (x -> t)
-> Fun () (x -> t)
-> OpenExp env aenv x
-> OpenExp env aenv t
Foreign TypeR t
tp asm (x -> t)
asm Fun () (x -> t)
f (OpenExp env2 aenv x -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv x) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv x -> Maybe (OpenExp env2 aenv x)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv x
e1
Pair OpenExp env1 aenv t1
e1 OpenExp env1 aenv t2
e2 -> OpenExp env2 aenv t1 -> OpenExp env2 aenv t2 -> OpenExp env2 aenv t
OpenExp env2 aenv t1
-> OpenExp env2 aenv t2 -> OpenExp env2 aenv (t1, t2)
forall env aenv t1 t2.
OpenExp env aenv t1
-> OpenExp env aenv t2 -> OpenExp env aenv (t1, t2)
Pair (OpenExp env2 aenv t1
-> OpenExp env2 aenv t2 -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t1)
-> Maybe (OpenExp env2 aenv t2 -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv t1 -> Maybe (OpenExp env2 aenv t1)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t1
e1 Maybe (OpenExp env2 aenv t2 -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t2) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv t2 -> Maybe (OpenExp env2 aenv t2)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t2
e2
OpenExp env1 aenv t
Nil -> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just OpenExp env2 aenv t
OpenExp env2 aenv ()
forall env aenv. OpenExp env aenv ()
Nil
VecPack VecR n s tup
vec OpenExp env1 aenv tup
e1 -> VecR n s tup
-> OpenExp env2 aenv tup -> OpenExp env2 aenv (Vec n s)
forall (n :: Nat) s tup env aenv.
KnownNat n =>
VecR n s tup -> OpenExp env aenv tup -> OpenExp env aenv (Vec n s)
VecPack VecR n s tup
vec (OpenExp env2 aenv tup -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv tup) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv tup -> Maybe (OpenExp env2 aenv tup)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv tup
e1
VecUnpack VecR n s t
vec OpenExp env1 aenv (Vec n s)
e1 -> VecR n s t -> OpenExp env2 aenv (Vec n s) -> OpenExp env2 aenv t
forall (n :: Nat) s t env aenv.
KnownNat n =>
VecR n s t -> OpenExp env aenv (Vec n s) -> OpenExp env aenv t
VecUnpack VecR n s t
vec (OpenExp env2 aenv (Vec n s) -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv (Vec n s))
-> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv (Vec n s) -> Maybe (OpenExp env2 aenv (Vec n s))
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv (Vec n s)
e1
IndexSlice SliceIndex slix t co sh
si OpenExp env1 aenv slix
e1 OpenExp env1 aenv sh
e2 -> SliceIndex slix t co sh
-> OpenExp env2 aenv slix
-> OpenExp env2 aenv sh
-> OpenExp env2 aenv t
forall slix t co sh env aenv.
SliceIndex slix t co sh
-> OpenExp env aenv slix
-> OpenExp env aenv sh
-> OpenExp env aenv t
IndexSlice SliceIndex slix t co sh
si (OpenExp env2 aenv slix
-> OpenExp env2 aenv sh -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv slix)
-> Maybe (OpenExp env2 aenv sh -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv slix -> Maybe (OpenExp env2 aenv slix)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv slix
e1 Maybe (OpenExp env2 aenv sh -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv sh) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv sh -> Maybe (OpenExp env2 aenv sh)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv sh
e2
IndexFull SliceIndex slix sl co t
si OpenExp env1 aenv slix
e1 OpenExp env1 aenv sl
e2 -> SliceIndex slix sl co t
-> OpenExp env2 aenv slix
-> OpenExp env2 aenv sl
-> OpenExp env2 aenv t
forall slix sl co t env aenv.
SliceIndex slix sl co t
-> OpenExp env aenv slix
-> OpenExp env aenv sl
-> OpenExp env aenv t
IndexFull SliceIndex slix sl co t
si (OpenExp env2 aenv slix
-> OpenExp env2 aenv sl -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv slix)
-> Maybe (OpenExp env2 aenv sl -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv slix -> Maybe (OpenExp env2 aenv slix)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv slix
e1 Maybe (OpenExp env2 aenv sl -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv sl) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv sl -> Maybe (OpenExp env2 aenv sl)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv sl
e2
ToIndex ShapeR sh
shr OpenExp env1 aenv sh
e1 OpenExp env1 aenv sh
e2 -> ShapeR sh
-> OpenExp env2 aenv sh
-> OpenExp env2 aenv sh
-> OpenExp env2 aenv Int
forall sh env aenv.
ShapeR sh
-> OpenExp env aenv sh
-> OpenExp env aenv sh
-> OpenExp env aenv Int
ToIndex ShapeR sh
shr (OpenExp env2 aenv sh
-> OpenExp env2 aenv sh -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv sh)
-> Maybe (OpenExp env2 aenv sh -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv sh -> Maybe (OpenExp env2 aenv sh)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv sh
e1 Maybe (OpenExp env2 aenv sh -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv sh) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv sh -> Maybe (OpenExp env2 aenv sh)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv sh
e2
FromIndex ShapeR t
shr OpenExp env1 aenv t
e1 OpenExp env1 aenv Int
e2 -> ShapeR t
-> OpenExp env2 aenv t
-> OpenExp env2 aenv Int
-> OpenExp env2 aenv t
forall t env aenv.
ShapeR t
-> OpenExp env aenv t -> OpenExp env aenv Int -> OpenExp env aenv t
FromIndex ShapeR t
shr (OpenExp env2 aenv t
-> OpenExp env2 aenv Int -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv Int -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv t -> Maybe (OpenExp env2 aenv t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t
e1 Maybe (OpenExp env2 aenv Int -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv Int) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv Int -> Maybe (OpenExp env2 aenv Int)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv Int
e2
Case OpenExp env1 aenv TAG
e1 [(TAG, OpenExp env1 aenv t)]
rhs Maybe (OpenExp env1 aenv t)
def -> OpenExp env2 aenv TAG
-> [(TAG, OpenExp env2 aenv t)]
-> Maybe (OpenExp env2 aenv t)
-> OpenExp env2 aenv t
forall env aenv t.
OpenExp env aenv TAG
-> [(TAG, OpenExp env aenv t)]
-> Maybe (OpenExp env aenv t)
-> OpenExp env aenv t
Case (OpenExp env2 aenv TAG
-> [(TAG, OpenExp env2 aenv t)]
-> Maybe (OpenExp env2 aenv t)
-> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv TAG)
-> Maybe
([(TAG, OpenExp env2 aenv t)]
-> Maybe (OpenExp env2 aenv t) -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv TAG -> Maybe (OpenExp env2 aenv TAG)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv TAG
e1 Maybe
([(TAG, OpenExp env2 aenv t)]
-> Maybe (OpenExp env2 aenv t) -> OpenExp env2 aenv t)
-> Maybe [(TAG, OpenExp env2 aenv t)]
-> Maybe (Maybe (OpenExp env2 aenv t) -> OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((TAG, OpenExp env1 aenv t) -> Maybe (TAG, OpenExp env2 aenv t))
-> [(TAG, OpenExp env1 aenv t)]
-> Maybe [(TAG, OpenExp env2 aenv t)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\(TAG
t,OpenExp env1 aenv t
c) -> (TAG
t,) (OpenExp env2 aenv t -> (TAG, OpenExp env2 aenv t))
-> Maybe (OpenExp env2 aenv t) -> Maybe (TAG, OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv t -> Maybe (OpenExp env2 aenv t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t
c) [(TAG, OpenExp env1 aenv t)]
rhs Maybe (Maybe (OpenExp env2 aenv t) -> OpenExp env2 aenv t)
-> Maybe (Maybe (OpenExp env2 aenv t))
-> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe (OpenExp env1 aenv t) -> Maybe (Maybe (OpenExp env2 aenv t))
forall s.
Maybe (OpenExp env1 aenv s) -> Maybe (Maybe (OpenExp env2 aenv s))
travMaybeE Maybe (OpenExp env1 aenv t)
def
Cond OpenExp env1 aenv TAG
e1 OpenExp env1 aenv t
e2 OpenExp env1 aenv t
e3 -> OpenExp env2 aenv TAG
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t
forall env aenv t.
OpenExp env aenv TAG
-> OpenExp env aenv t -> OpenExp env aenv t -> OpenExp env aenv t
Cond (OpenExp env2 aenv TAG
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv TAG)
-> Maybe
(OpenExp env2 aenv t -> OpenExp env2 aenv t -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv TAG -> Maybe (OpenExp env2 aenv TAG)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv TAG
e1 Maybe
(OpenExp env2 aenv t -> OpenExp env2 aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t -> OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv t -> Maybe (OpenExp env2 aenv t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t
e2 Maybe (OpenExp env2 aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv t -> Maybe (OpenExp env2 aenv t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t
e3
While OpenFun env1 aenv (t -> TAG)
f1 OpenFun env1 aenv (t -> t)
f2 OpenExp env1 aenv t
e1 -> OpenFun env2 aenv (t -> TAG)
-> OpenFun env2 aenv (t -> t)
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t
forall env aenv t.
OpenFun env aenv (t -> TAG)
-> OpenFun env aenv (t -> t)
-> OpenExp env aenv t
-> OpenExp env aenv t
While (OpenFun env2 aenv (t -> TAG)
-> OpenFun env2 aenv (t -> t)
-> OpenExp env2 aenv t
-> OpenExp env2 aenv t)
-> Maybe (OpenFun env2 aenv (t -> TAG))
-> Maybe
(OpenFun env2 aenv (t -> t)
-> OpenExp env2 aenv t -> OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenFun env1 aenv (t -> TAG)
-> Maybe (OpenFun env2 aenv (t -> TAG))
forall s. OpenFun env1 aenv s -> Maybe (OpenFun env2 aenv s)
travF OpenFun env1 aenv (t -> TAG)
f1 Maybe
(OpenFun env2 aenv (t -> t)
-> OpenExp env2 aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenFun env2 aenv (t -> t))
-> Maybe (OpenExp env2 aenv t -> OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenFun env1 aenv (t -> t) -> Maybe (OpenFun env2 aenv (t -> t))
forall s. OpenFun env1 aenv s -> Maybe (OpenFun env2 aenv s)
travF OpenFun env1 aenv (t -> t)
f2 Maybe (OpenExp env2 aenv t -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv t) -> Maybe (OpenExp env2 aenv t)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env1 aenv t -> Maybe (OpenExp env2 aenv t)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv t
e1
Const ScalarType t
t t
c -> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just (OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t))
-> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a b. (a -> b) -> a -> b
$ ScalarType t -> t -> OpenExp env2 aenv t
forall t env aenv. ScalarType t -> t -> OpenExp env aenv t
Const ScalarType t
t t
c
PrimConst PrimConst t
c -> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just (OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t))
-> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a b. (a -> b) -> a -> b
$ PrimConst t -> OpenExp env2 aenv t
forall t env aenv. PrimConst t -> OpenExp env aenv t
PrimConst PrimConst t
c
PrimApp PrimFun (a -> t)
p OpenExp env1 aenv a
e1 -> PrimFun (a -> t) -> OpenExp env2 aenv a -> OpenExp env2 aenv t
forall a t env aenv.
PrimFun (a -> t) -> OpenExp env aenv a -> OpenExp env aenv t
PrimApp PrimFun (a -> t)
p (OpenExp env2 aenv a -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv a) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv a -> Maybe (OpenExp env2 aenv a)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv a
e1
Index ArrayVar aenv (Array dim t)
a OpenExp env1 aenv dim
e1 -> ArrayVar aenv (Array dim t)
-> OpenExp env2 aenv dim -> OpenExp env2 aenv t
forall aenv dim t env.
ArrayVar aenv (Array dim t)
-> OpenExp env aenv dim -> OpenExp env aenv t
Index ArrayVar aenv (Array dim t)
a (OpenExp env2 aenv dim -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv dim) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv dim -> Maybe (OpenExp env2 aenv dim)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv dim
e1
LinearIndex ArrayVar aenv (Array dim t)
a OpenExp env1 aenv Int
e1 -> ArrayVar aenv (Array dim t)
-> OpenExp env2 aenv Int -> OpenExp env2 aenv t
forall aenv dim t env.
ArrayVar aenv (Array dim t)
-> OpenExp env aenv Int -> OpenExp env aenv t
LinearIndex ArrayVar aenv (Array dim t)
a (OpenExp env2 aenv Int -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv Int) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv Int -> Maybe (OpenExp env2 aenv Int)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv Int
e1
Shape ArrayVar aenv (Array t e)
a -> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just (OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t))
-> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a b. (a -> b) -> a -> b
$ ArrayVar aenv (Array t e) -> OpenExp env2 aenv t
forall aenv t e env.
ArrayVar aenv (Array t e) -> OpenExp env aenv t
Shape ArrayVar aenv (Array t e)
a
ShapeSize ShapeR dim
shr OpenExp env1 aenv dim
e1 -> ShapeR dim -> OpenExp env2 aenv dim -> OpenExp env2 aenv Int
forall dim env aenv.
ShapeR dim -> OpenExp env aenv dim -> OpenExp env aenv Int
ShapeSize ShapeR dim
shr (OpenExp env2 aenv dim -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv dim) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv dim -> Maybe (OpenExp env2 aenv dim)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv dim
e1
Undef ScalarType t
t -> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a. a -> Maybe a
Just (OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t))
-> OpenExp env2 aenv t -> Maybe (OpenExp env2 aenv t)
forall a b. (a -> b) -> a -> b
$ ScalarType t -> OpenExp env2 aenv t
forall t env aenv. ScalarType t -> OpenExp env aenv t
Undef ScalarType t
t
Coerce ScalarType a
t1 ScalarType t
t2 OpenExp env1 aenv a
e1 -> ScalarType a
-> ScalarType t -> OpenExp env2 aenv a -> OpenExp env2 aenv t
forall a t env aenv.
BitSizeEq a t =>
ScalarType a
-> ScalarType t -> OpenExp env aenv a -> OpenExp env aenv t
Coerce ScalarType a
t1 ScalarType t
t2 (OpenExp env2 aenv a -> OpenExp env2 aenv t)
-> Maybe (OpenExp env2 aenv a) -> Maybe (OpenExp env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv a -> Maybe (OpenExp env2 aenv a)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv a
e1
where
travE :: OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE :: forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE = (env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv s
-> Maybe (OpenExp env2 aenv s)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute Idx env1 t' -> Maybe (Idx env2 t')
env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars
travF :: OpenFun env1 aenv s -> Maybe (OpenFun env2 aenv s)
travF :: forall s. OpenFun env1 aenv s -> Maybe (OpenFun env2 aenv s)
travF = (env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenFun env1 aenv s
-> Maybe (OpenFun env2 aenv s)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenFun env1 aenv t
-> Maybe (OpenFun env2 aenv t)
substituteF Idx env1 t' -> Maybe (Idx env2 t')
env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars
travMaybeE :: Maybe (OpenExp env1 aenv s) -> Maybe (Maybe (OpenExp env2 aenv s))
travMaybeE :: forall s.
Maybe (OpenExp env1 aenv s) -> Maybe (Maybe (OpenExp env2 aenv s))
travMaybeE Maybe (OpenExp env1 aenv s)
Nothing = Maybe (OpenExp env2 aenv s) -> Maybe (Maybe (OpenExp env2 aenv s))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (OpenExp env2 aenv s)
forall a. Maybe a
Nothing
travMaybeE (Just OpenExp env1 aenv s
x) = OpenExp env2 aenv s -> Maybe (OpenExp env2 aenv s)
forall a. a -> Maybe a
Just (OpenExp env2 aenv s -> Maybe (OpenExp env2 aenv s))
-> Maybe (OpenExp env2 aenv s)
-> Maybe (Maybe (OpenExp env2 aenv s))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
forall s. OpenExp env1 aenv s -> Maybe (OpenExp env2 aenv s)
travE OpenExp env1 aenv s
x
substituteF :: forall env1 env2 t.
env1 :?> env2
-> env :> env2
-> ExpVars env1 t1
-> OpenFun env1 aenv t
-> Maybe (OpenFun env2 aenv t)
substituteF :: forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenFun env1 aenv t
-> Maybe (OpenFun env2 aenv t)
substituteF env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars (Body OpenExp env1 aenv t
e) = OpenExp env2 aenv t -> OpenFun env2 aenv t
forall env aenv t. OpenExp env aenv t -> OpenFun env aenv t
Body (OpenExp env2 aenv t -> OpenFun env2 aenv t)
-> Maybe (OpenExp env2 aenv t) -> Maybe (OpenFun env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenExp env1 aenv t
-> Maybe (OpenExp env2 aenv t)
substitute Idx env1 t' -> Maybe (Idx env2 t')
env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars OpenExp env1 aenv t
e
substituteF env1 :?> env2
k1 env :> env2
k2 ExpVars env1 t1
vars (Lam ELeftHandSide a env1 env'
lhs OpenFun env' aenv t1
f)
| Exists LeftHandSide ScalarType a env2 a
lhs' <- ELeftHandSide a env1 env'
-> Exists (LeftHandSide ScalarType a env2)
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ELeftHandSide a env1 env'
lhs = LeftHandSide ScalarType a env2 a
-> OpenFun a aenv t1 -> OpenFun env2 aenv (a -> t1)
forall a env env' aenv t1.
ELeftHandSide a env env'
-> OpenFun env' aenv t1 -> OpenFun env aenv (a -> t1)
Lam LeftHandSide ScalarType a env2 a
lhs' (OpenFun a aenv t1 -> OpenFun env2 aenv t)
-> Maybe (OpenFun a aenv t1) -> Maybe (OpenFun env2 aenv t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (env' :?> a)
-> (env :> a)
-> ExpVars env' t1
-> OpenFun env' aenv t1
-> Maybe (OpenFun a aenv t1)
forall env1 env2 t.
(env1 :?> env2)
-> (env :> env2)
-> ExpVars env1 t1
-> OpenFun env1 aenv t
-> Maybe (OpenFun env2 aenv t)
substituteF (ELeftHandSide a env1 env'
-> LeftHandSide ScalarType a env2 a
-> (env1 :?> env2)
-> env' :?> a
forall (s :: * -> *) t env1 env2 env1' env2'.
LeftHandSide s t env1 env2
-> LeftHandSide s t env1' env2'
-> (env1 :?> env1')
-> env2 :?> env2'
strengthenAfter ELeftHandSide a env1 env'
lhs LeftHandSide ScalarType a env2 a
lhs' Idx env1 t' -> Maybe (Idx env2 t')
env1 :?> env2
k1) (LeftHandSide ScalarType a env2 a -> env2 :> a
forall (s :: * -> *) t env env'.
LeftHandSide s t env env' -> env :> env'
weakenWithLHS LeftHandSide ScalarType a env2 a
lhs' (env2 :> a) -> (env :> env2) -> env :> a
forall env2 env3 env1.
(env2 :> env3) -> (env1 :> env2) -> env1 :> env3
.> env :> env2
k2) (ELeftHandSide a env1 env' -> env1 :> env'
forall (s :: * -> *) t env env'.
LeftHandSide s t env env' -> env :> env'
weakenWithLHS ELeftHandSide a env1 env'
lhs (env1 :> env') -> ExpVars env1 t1 -> ExpVars env' t1
forall env env' (s :: * -> *) t.
(env :> env') -> Vars s env t -> Vars s env' t
`weakenVars` ExpVars env1 t1
vars) OpenFun env' aenv t1
f
inlineVars ELeftHandSide t1 env env'
_ OpenExp env' aenv t2
_ OpenExp env aenv t1
_ = Maybe (OpenExp env aenv t2)
forall a. Maybe a
Nothing
compose :: HasCallStack
=> OpenFun env aenv (b -> c)
-> OpenFun env aenv (a -> b)
-> OpenFun env aenv (a -> c)
compose :: forall env aenv b c a.
HasCallStack =>
OpenFun env aenv (b -> c)
-> OpenFun env aenv (a -> b) -> OpenFun env aenv (a -> c)
compose f :: OpenFun env aenv (b -> c)
f@(Lam ELeftHandSide a env env'
lhsB (Body OpenExp env' aenv t1
c)) g :: OpenFun env aenv (a -> b)
g@(Lam ELeftHandSide a env env'
lhsA (Body OpenExp env' aenv t1
b))
| Text -> Bool -> Bool
forall a. Text -> a -> a
Stats.substitution Text
"compose" Bool
False = OpenFun env aenv (a -> c)
forall a. HasCallStack => a
undefined
| Just b :~: c
Refl <- OpenFun env aenv (b -> c) -> Maybe (b :~: c)
forall env aenv a b. OpenFun env aenv (a -> b) -> Maybe (a :~: b)
isIdentity OpenFun env aenv (b -> c)
f = OpenFun env aenv (a -> b)
OpenFun env aenv (a -> c)
g
| Just a :~: b
Refl <- OpenFun env aenv (a -> b) -> Maybe (a :~: b)
forall env aenv a b. OpenFun env aenv (a -> b) -> Maybe (a :~: b)
isIdentity OpenFun env aenv (a -> b)
g = OpenFun env aenv (b -> c)
OpenFun env aenv (a -> c)
f
| Exists LeftHandSide ScalarType a env' a
lhsB' <- ELeftHandSide a env env' -> Exists (LeftHandSide ScalarType a env')
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ELeftHandSide a env env'
lhsB
= ELeftHandSide a env env'
-> OpenFun env' aenv c -> OpenFun env aenv (a -> c)
forall a env env' aenv t1.
ELeftHandSide a env env'
-> OpenFun env' aenv t1 -> OpenFun env aenv (a -> t1)
Lam ELeftHandSide a env env'
ELeftHandSide a env env'
lhsA
(OpenFun env' aenv c -> OpenFun env aenv (a -> c))
-> OpenFun env' aenv c -> OpenFun env aenv (a -> c)
forall a b. (a -> b) -> a -> b
$ OpenExp env' aenv c -> OpenFun env' aenv c
forall env aenv t. OpenExp env aenv t -> OpenFun env aenv t
Body
(OpenExp env' aenv c -> OpenFun env' aenv c)
-> OpenExp env' aenv c -> OpenFun env' aenv c
forall a b. (a -> b) -> a -> b
$ LeftHandSide ScalarType a env' a
-> OpenExp env' aenv a -> OpenExp a aenv c -> OpenExp env' aenv c
forall bnd_t env env' aenv t.
ELeftHandSide bnd_t env env'
-> OpenExp env aenv bnd_t
-> OpenExp env' aenv t
-> OpenExp env aenv t
Let LeftHandSide ScalarType a env' a
lhsB' OpenExp env' aenv a
OpenExp env' aenv t1
b
(OpenExp a aenv c -> OpenExp env' aenv c)
-> OpenExp a aenv c -> OpenExp env' aenv c
forall a b. (a -> b) -> a -> b
$ (env' :> a) -> OpenExp env' aenv c -> OpenExp a aenv c
forall env env' aenv t.
(env :> env') -> OpenExp env aenv t -> OpenExp env' aenv t
forall (f :: * -> * -> * -> *) env env' aenv t.
SinkExp f =>
(env :> env') -> f env aenv t -> f env' aenv t
weakenE (ELeftHandSide a env env'
-> LeftHandSide ScalarType a env' a -> (env :> env') -> env' :> a
forall (s :: * -> *) t env1 env1' env2 env2'.
HasCallStack =>
LeftHandSide s t env1 env1'
-> LeftHandSide s t env2 env2' -> (env1 :> env2) -> env1' :> env2'
sinkWithLHS ELeftHandSide a env env'
lhsB LeftHandSide ScalarType a env' a
lhsB' ((env :> env') -> env' :> a) -> (env :> env') -> env' :> a
forall a b. (a -> b) -> a -> b
$ ELeftHandSide a env env' -> env :> env'
forall (s :: * -> *) t env env'.
LeftHandSide s t env env' -> env :> env'
weakenWithLHS ELeftHandSide a env env'
lhsA) OpenExp env' aenv c
OpenExp env' aenv t1
c
compose OpenFun env aenv (b -> c)
_
OpenFun env aenv (a -> b)
_ = [Char] -> OpenFun env aenv (a -> c)
forall a. HasCallStack => [Char] -> a
error [Char]
"compose: impossible evaluation"
subTop :: OpenExp env aenv s -> ExpVar (env, s) t -> OpenExp env aenv t
subTop :: forall env aenv s t.
OpenExp env aenv s -> ExpVar (env, s) t -> OpenExp env aenv t
subTop OpenExp env aenv s
s (Var ScalarType t
_ Idx (env, s) t
ZeroIdx ) = OpenExp env aenv s
OpenExp env aenv t
s
subTop OpenExp env aenv s
_ (Var ScalarType t
tp (SuccIdx Idx env t
ix)) = ExpVar env t -> OpenExp env aenv t
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar (ExpVar env t -> OpenExp env aenv t)
-> ExpVar env t -> OpenExp env aenv t
forall a b. (a -> b) -> a -> b
$ ScalarType t -> Idx env t -> ExpVar env t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t
tp Idx env t
Idx env t
ix
subAtop :: PreOpenAcc acc aenv t -> ArrayVar (aenv, t) (Array sh2 e2) -> PreOpenAcc acc aenv (Array sh2 e2)
subAtop :: forall (acc :: * -> * -> *) aenv t sh2 e2.
PreOpenAcc acc aenv t
-> ArrayVar (aenv, t) (Array sh2 e2)
-> PreOpenAcc acc aenv (Array sh2 e2)
subAtop PreOpenAcc acc aenv t
t (Var ArrayR (Array sh2 e2)
_ Idx (aenv, t) (Array sh2 e2)
ZeroIdx ) = PreOpenAcc acc aenv t
PreOpenAcc acc aenv (Array sh2 e2)
t
subAtop PreOpenAcc acc aenv t
_ (Var ArrayR (Array sh2 e2)
repr (SuccIdx Idx env (Array sh2 e2)
idx)) = ArrayVar aenv (Array sh2 e2) -> PreOpenAcc acc aenv (Array sh2 e2)
forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
Avar (ArrayVar aenv (Array sh2 e2)
-> PreOpenAcc acc aenv (Array sh2 e2))
-> ArrayVar aenv (Array sh2 e2)
-> PreOpenAcc acc aenv (Array sh2 e2)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh2 e2)
-> Idx aenv (Array sh2 e2) -> ArrayVar aenv (Array sh2 e2)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh2 e2)
repr Idx aenv (Array sh2 e2)
Idx env (Array sh2 e2)
idx
data Identity a = Identity { forall a. Identity a -> a
runIdentity :: a }
instance Functor Identity where
{-# INLINE fmap #-}
fmap :: forall a b. (a -> b) -> Identity a -> Identity b
fmap a -> b
f (Identity a
a) = b -> Identity b
forall a. a -> Identity a
Identity (a -> b
f a
a)
instance Applicative Identity where
{-# INLINE (<*>) #-}
{-# INLINE pure #-}
Identity a -> b
f <*> :: forall a b. Identity (a -> b) -> Identity a -> Identity b
<*> Identity a
a = b -> Identity b
forall a. a -> Identity a
Identity (a -> b
f a
a)
pure :: forall a. a -> Identity a
pure a
a = a -> Identity a
forall a. a -> Identity a
Identity a
a
class Rebuildable f where
{-# MINIMAL rebuildPartial #-}
type AccClo f :: Type -> Type -> Type
rebuildPartial :: (Applicative f', SyntacticAcc fa)
=> (forall sh e. ArrayVar aenv (Array sh e) -> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a
-> f' (f aenv' a)
{-# INLINEABLE rebuildA #-}
rebuildA :: (SyntacticAcc fa)
=> (forall sh e. ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e))
-> f aenv a
-> f aenv' a
rebuildA forall sh e.
ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e)
av = Identity (f aenv' a) -> f aenv' a
forall a. Identity a -> a
runIdentity (Identity (f aenv' a) -> f aenv' a)
-> (f aenv a -> Identity (f aenv' a)) -> f aenv a -> f aenv' a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall sh e.
ArrayVar aenv (Array sh e)
-> Identity (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> Identity (f aenv' a)
forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> f' (f aenv' a)
forall (f :: * -> * -> *) (f' :: * -> *)
(fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
(Rebuildable f, Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> f' (f aenv' a)
rebuildPartial (fa (AccClo f) aenv' (Array sh e)
-> Identity (fa (AccClo f) aenv' (Array sh e))
forall a. a -> Identity a
Identity (fa (AccClo f) aenv' (Array sh e)
-> Identity (fa (AccClo f) aenv' (Array sh e)))
-> (ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e))
-> ArrayVar aenv (Array sh e)
-> Identity (fa (AccClo f) aenv' (Array sh e))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e)
forall sh e.
ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e)
av)
class RebuildableExp f where
{-# MINIMAL rebuildPartialE #-}
rebuildPartialE :: (Applicative f', SyntacticExp fe)
=> (forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> f env aenv e
-> f' (f env' aenv e)
{-# INLINEABLE rebuildE #-}
rebuildE :: SyntacticExp fe
=> (forall e'. ExpVar env e' -> fe env' aenv e')
-> f env aenv e
-> f env' aenv e
rebuildE forall e'. ExpVar env e' -> fe env' aenv e'
v = Identity (f env' aenv e) -> f env' aenv e
forall a. Identity a -> a
runIdentity (Identity (f env' aenv e) -> f env' aenv e)
-> (f env aenv e -> Identity (f env' aenv e))
-> f env aenv e
-> f env' aenv e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall e'. ExpVar env e' -> Identity (fe env' aenv e'))
-> f env aenv e -> Identity (f env' aenv e)
forall (f' :: * -> *) (fe :: * -> * -> * -> *) env env' aenv e.
(Applicative f', SyntacticExp fe) =>
(forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> f env aenv e -> f' (f env' aenv e)
forall (f :: * -> * -> * -> *) (f' :: * -> *)
(fe :: * -> * -> * -> *) env env' aenv e.
(RebuildableExp f, Applicative f', SyntacticExp fe) =>
(forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> f env aenv e -> f' (f env' aenv e)
rebuildPartialE (fe env' aenv e' -> Identity (fe env' aenv e')
forall a. a -> Identity a
Identity (fe env' aenv e' -> Identity (fe env' aenv e'))
-> (ExpVar env e' -> fe env' aenv e')
-> ExpVar env e'
-> Identity (fe env' aenv e')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env e' -> fe env' aenv e'
forall e'. ExpVar env e' -> fe env' aenv e'
v)
type RebuildableAcc acc = (Rebuildable acc, AccClo acc ~ acc)
data OpenAccExp (acc :: Type -> Type -> Type) env aenv a where
OpenAccExp :: { forall env aenv a (acc :: * -> * -> *).
OpenAccExp acc env aenv a -> OpenExp env aenv a
unOpenAccExp :: OpenExp env aenv a } -> OpenAccExp acc env aenv a
data OpenAccFun (acc :: Type -> Type -> Type) env aenv a where
OpenAccFun :: { forall env aenv a (acc :: * -> * -> *).
OpenAccFun acc env aenv a -> OpenFun env aenv a
unOpenAccFun :: OpenFun env aenv a } -> OpenAccFun acc env aenv a
instance Rebuildable (OpenAccExp acc env) where
type AccClo (OpenAccExp acc env) = acc
{-# INLINEABLE rebuildPartial #-}
rebuildPartial :: forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccExp acc env)) aenv' (Array sh e)))
-> OpenAccExp acc env aenv a -> f' (OpenAccExp acc env aenv' a)
rebuildPartial forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccExp acc env)) aenv' (Array sh e))
v (OpenAccExp OpenExp env aenv a
e) = OpenExp env aenv' a -> OpenAccExp acc env aenv' a
forall env aenv a (acc :: * -> * -> *).
OpenExp env aenv a -> OpenAccExp acc env aenv a
OpenAccExp (OpenExp env aenv' a -> OpenAccExp acc env aenv' a)
-> f' (OpenExp env aenv' a) -> f' (OpenAccExp acc env aenv' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> f' (OpenExp env aenv' a) -> f' (OpenExp env aenv' a)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" (RebuildEvar f' IdxE env env aenv'
-> ReindexAvar f' aenv aenv'
-> OpenExp env aenv a
-> f' (OpenExp env aenv' a)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE env aenv' t' -> f' (IdxE env aenv' t')
forall a. a -> f' a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE env aenv' t' -> f' (IdxE env aenv' t'))
-> (ExpVar env t' -> IdxE env aenv' t')
-> ExpVar env t'
-> f' (IdxE env aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env t' -> IdxE env aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) (RebuildAvar f' fa acc aenv aenv' -> ReindexAvar f' aenv aenv'
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv'.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAvar f fa acc aenv aenv' -> ReindexAvar f aenv aenv'
reindexAvar Var ArrayR aenv (Array sh e) -> f' (fa acc aenv' (Array sh e))
Var ArrayR aenv (Array sh e)
-> f' (fa (AccClo (OpenAccExp acc env)) aenv' (Array sh e))
RebuildAvar f' fa acc aenv aenv'
forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccExp acc env)) aenv' (Array sh e))
v) OpenExp env aenv a
e)
instance Rebuildable (OpenAccFun acc env) where
type AccClo (OpenAccFun acc env) = acc
{-# INLINEABLE rebuildPartial #-}
rebuildPartial :: forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccFun acc env)) aenv' (Array sh e)))
-> OpenAccFun acc env aenv a -> f' (OpenAccFun acc env aenv' a)
rebuildPartial forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccFun acc env)) aenv' (Array sh e))
v (OpenAccFun OpenFun env aenv a
f) = OpenFun env aenv' a -> OpenAccFun acc env aenv' a
forall env aenv a (acc :: * -> * -> *).
OpenFun env aenv a -> OpenAccFun acc env aenv a
OpenAccFun (OpenFun env aenv' a -> OpenAccFun acc env aenv' a)
-> f' (OpenFun env aenv' a) -> f' (OpenAccFun acc env aenv' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> f' (OpenFun env aenv' a) -> f' (OpenFun env aenv' a)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" (RebuildEvar f' IdxE env env aenv'
-> ReindexAvar f' aenv aenv'
-> OpenFun env aenv a
-> f' (OpenFun env aenv' a)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE env aenv' t' -> f' (IdxE env aenv' t')
forall a. a -> f' a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE env aenv' t' -> f' (IdxE env aenv' t'))
-> (ExpVar env t' -> IdxE env aenv' t')
-> ExpVar env t'
-> f' (IdxE env aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env t' -> IdxE env aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) (RebuildAvar f' fa acc aenv aenv' -> ReindexAvar f' aenv aenv'
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv'.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAvar f fa acc aenv aenv' -> ReindexAvar f aenv aenv'
reindexAvar Var ArrayR aenv (Array sh e) -> f' (fa acc aenv' (Array sh e))
Var ArrayR aenv (Array sh e)
-> f' (fa (AccClo (OpenAccFun acc env)) aenv' (Array sh e))
RebuildAvar f' fa acc aenv aenv'
forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (OpenAccFun acc env)) aenv' (Array sh e))
v) OpenFun env aenv a
f)
instance RebuildableAcc acc => Rebuildable (PreOpenAcc acc) where
type AccClo (PreOpenAcc acc) = acc
{-# INLINEABLE rebuildPartial #-}
rebuildPartial :: forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAcc acc)) aenv' (Array sh e)))
-> PreOpenAcc acc aenv a -> f' (PreOpenAcc acc aenv' a)
rebuildPartial forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAcc acc)) aenv' (Array sh e))
x = Text
-> (PreOpenAcc acc aenv a -> f' (PreOpenAcc acc aenv' a))
-> PreOpenAcc acc aenv a
-> f' (PreOpenAcc acc aenv' a)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" ((PreOpenAcc acc aenv a -> f' (PreOpenAcc acc aenv' a))
-> PreOpenAcc acc aenv a -> f' (PreOpenAcc acc aenv' a))
-> (PreOpenAcc acc aenv a -> f' (PreOpenAcc acc aenv' a))
-> PreOpenAcc acc aenv a
-> f' (PreOpenAcc acc aenv' a)
forall a b. (a -> b) -> a -> b
$ RebuildAcc acc
-> RebuildAvar f' fa acc aenv aenv'
-> PreOpenAcc acc aenv a
-> f' (PreOpenAcc acc aenv' a)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAcc acc aenv t
-> f (PreOpenAcc acc aenv' t)
rebuildPreOpenAcc RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
(forall sh e.
ArrayVar aenv (Array sh e)
-> f (fa (AccClo acc) aenv' (Array sh e)))
-> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo acc) aenv' (Array sh e)))
-> acc aenv a -> f' (acc aenv' a)
forall (f :: * -> * -> *) (f' :: * -> *)
(fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
(Rebuildable f, Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> f' (f aenv' a)
rebuildPartial Var ArrayR aenv (Array sh e) -> f' (fa acc aenv' (Array sh e))
Var ArrayR aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAcc acc)) aenv' (Array sh e))
RebuildAvar f' fa acc aenv aenv'
forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAcc acc)) aenv' (Array sh e))
x
instance RebuildableAcc acc => Rebuildable (PreOpenAfun acc) where
type AccClo (PreOpenAfun acc) = acc
{-# INLINEABLE rebuildPartial #-}
rebuildPartial :: forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAfun acc)) aenv' (Array sh e)))
-> PreOpenAfun acc aenv a -> f' (PreOpenAfun acc aenv' a)
rebuildPartial forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAfun acc)) aenv' (Array sh e))
x = Text
-> (PreOpenAfun acc aenv a -> f' (PreOpenAfun acc aenv' a))
-> PreOpenAfun acc aenv a
-> f' (PreOpenAfun acc aenv' a)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" ((PreOpenAfun acc aenv a -> f' (PreOpenAfun acc aenv' a))
-> PreOpenAfun acc aenv a -> f' (PreOpenAfun acc aenv' a))
-> (PreOpenAfun acc aenv a -> f' (PreOpenAfun acc aenv' a))
-> PreOpenAfun acc aenv a
-> f' (PreOpenAfun acc aenv' a)
forall a b. (a -> b) -> a -> b
$ RebuildAcc acc
-> RebuildAvar f' fa acc aenv aenv'
-> PreOpenAfun acc aenv a
-> f' (PreOpenAfun acc aenv' a)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
(forall sh e.
ArrayVar aenv (Array sh e)
-> f (fa (AccClo acc) aenv' (Array sh e)))
-> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo acc) aenv' (Array sh e)))
-> acc aenv a -> f' (acc aenv' a)
forall (f :: * -> * -> *) (f' :: * -> *)
(fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
(Rebuildable f, Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> f' (f aenv' a)
rebuildPartial Var ArrayR aenv (Array sh e) -> f' (fa acc aenv' (Array sh e))
Var ArrayR aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAfun acc)) aenv' (Array sh e))
RebuildAvar f' fa acc aenv aenv'
forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo (PreOpenAfun acc)) aenv' (Array sh e))
x
instance Rebuildable OpenAcc where
type AccClo OpenAcc = OpenAcc
{-# INLINEABLE rebuildPartial #-}
rebuildPartial :: forall (f' :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo OpenAcc) aenv' (Array sh e)))
-> OpenAcc aenv a -> f' (OpenAcc aenv' a)
rebuildPartial forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo OpenAcc) aenv' (Array sh e))
x = Text
-> (OpenAcc aenv a -> f' (OpenAcc aenv' a))
-> OpenAcc aenv a
-> f' (OpenAcc aenv' a)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" ((OpenAcc aenv a -> f' (OpenAcc aenv' a))
-> OpenAcc aenv a -> f' (OpenAcc aenv' a))
-> (OpenAcc aenv a -> f' (OpenAcc aenv' a))
-> OpenAcc aenv a
-> f' (OpenAcc aenv' a)
forall a b. (a -> b) -> a -> b
$ (forall sh e.
ArrayVar aenv (Array sh e) -> f' (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv a -> f' (OpenAcc aenv' a)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv t -> f (OpenAcc aenv' t)
rebuildOpenAcc Var ArrayR aenv (Array sh e) -> f' (fa OpenAcc aenv' (Array sh e))
Var ArrayR aenv (Array sh e)
-> f' (fa (AccClo OpenAcc) aenv' (Array sh e))
forall sh e.
ArrayVar aenv (Array sh e) -> f' (fa OpenAcc aenv' (Array sh e))
forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo OpenAcc) aenv' (Array sh e))
x
instance RebuildableExp OpenExp where
{-# INLINEABLE rebuildPartialE #-}
rebuildPartialE :: forall (f' :: * -> *) (fe :: * -> * -> * -> *) env env' aenv e.
(Applicative f', SyntacticExp fe) =>
(forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> OpenExp env aenv e -> f' (OpenExp env' aenv e)
rebuildPartialE forall e'. ExpVar env e' -> f' (fe env' aenv e')
v OpenExp env aenv e
x = Text -> f' (OpenExp env' aenv e) -> f' (OpenExp env' aenv e)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" (f' (OpenExp env' aenv e) -> f' (OpenExp env' aenv e))
-> f' (OpenExp env' aenv e) -> f' (OpenExp env' aenv e)
forall a b. (a -> b) -> a -> b
$ (forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> ReindexAvar f' aenv aenv
-> OpenExp env aenv e
-> f' (OpenExp env' aenv e)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f' (fe env' aenv t')
forall e'. ExpVar env e' -> f' (fe env' aenv e')
v ((forall sh e.
ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e)))
-> ReindexAvar f' aenv aenv
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e))
forall a. a -> f' a
forall sh e.
ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure) OpenExp env aenv e
x
instance RebuildableExp OpenFun where
{-# INLINEABLE rebuildPartialE #-}
rebuildPartialE :: forall (f' :: * -> *) (fe :: * -> * -> * -> *) env env' aenv e.
(Applicative f', SyntacticExp fe) =>
(forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> OpenFun env aenv e -> f' (OpenFun env' aenv e)
rebuildPartialE forall e'. ExpVar env e' -> f' (fe env' aenv e')
v OpenFun env aenv e
x = Text -> f' (OpenFun env' aenv e) -> f' (OpenFun env' aenv e)
forall a. Text -> a -> a
Stats.substitution Text
"rebuild" (f' (OpenFun env' aenv e) -> f' (OpenFun env' aenv e))
-> f' (OpenFun env' aenv e) -> f' (OpenFun env' aenv e)
forall a b. (a -> b) -> a -> b
$ (forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> ReindexAvar f' aenv aenv
-> OpenFun env aenv e
-> f' (OpenFun env' aenv e)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun ExpVar env t' -> f' (fe env' aenv t')
forall e'. ExpVar env e' -> f' (fe env' aenv e')
v ((forall sh e.
ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e)))
-> ReindexAvar f' aenv aenv
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e))
forall a. a -> f' a
forall sh e.
ArrayVar aenv (Array sh e) -> f' (ArrayVar aenv (Array sh e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure) OpenFun env aenv e
x
class Sink f where
weaken :: env :> env' -> forall t. f env t -> f env' t
instance Sink Idx where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
weaken = (env :> env') -> Idx env t -> Idx env' t
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
(>:>)
instance Sink (Var s) where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t. Var s env t -> Var s env' t
weaken env :> env'
k (Var s t
s Idx env t
ix) = s t -> Idx env' t -> Var s env' t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var s t
s (env :> env'
k (env :> env') -> forall t'. Idx env t' -> Idx env' t'
forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
>:> Idx env t
ix)
weakenVars :: env :> env' -> Vars s env t -> Vars s env' t
weakenVars :: forall env env' (s :: * -> *) t.
(env :> env') -> Vars s env t -> Vars s env' t
weakenVars env :> env'
_ TupR (Var s env) t
TupRunit = TupR (Var s env') t
TupR (Var s env') ()
forall (s :: * -> *). TupR s ()
TupRunit
weakenVars env :> env'
k (TupRsingle Var s env t
v) = Var s env' t -> TupR (Var s env') t
forall (s :: * -> *) a. s a -> TupR s a
TupRsingle (Var s env' t -> TupR (Var s env') t)
-> Var s env' t -> TupR (Var s env') t
forall a b. (a -> b) -> a -> b
$ (env :> env') -> forall t. Var s env t -> Var s env' t
forall env env'.
(env :> env') -> forall t. Var s env t -> Var s env' t
forall (f :: * -> * -> *) env env'.
Sink f =>
(env :> env') -> forall t. f env t -> f env' t
weaken env :> env'
k Var s env t
v
weakenVars env :> env'
k (TupRpair TupR (Var s env) a1
v TupR (Var s env) b
w) = TupR (Var s env') a1
-> TupR (Var s env') b -> TupR (Var s env') (a1, b)
forall (s :: * -> *) a1 b. TupR s a1 -> TupR s b -> TupR s (a1, b)
TupRpair ((env :> env') -> TupR (Var s env) a1 -> TupR (Var s env') a1
forall env env' (s :: * -> *) t.
(env :> env') -> Vars s env t -> Vars s env' t
weakenVars env :> env'
k TupR (Var s env) a1
v) ((env :> env') -> TupR (Var s env) b -> TupR (Var s env') b
forall env env' (s :: * -> *) t.
(env :> env') -> Vars s env t -> Vars s env' t
weakenVars env :> env'
k TupR (Var s env) b
w)
rebuildWeakenVar :: env :> env' -> ArrayVar env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
rebuildWeakenVar :: forall env env' sh e (acc :: * -> * -> *).
(env :> env')
-> ArrayVar env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
rebuildWeakenVar env :> env'
k (Var ArrayR (Array sh e)
s Idx env (Array sh e)
idx) = ArrayVar env' (Array sh e) -> PreOpenAcc acc env' (Array sh e)
forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
Avar (ArrayVar env' (Array sh e) -> PreOpenAcc acc env' (Array sh e))
-> ArrayVar env' (Array sh e) -> PreOpenAcc acc env' (Array sh e)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh e)
-> Idx env' (Array sh e) -> ArrayVar env' (Array sh e)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh e)
s (Idx env' (Array sh e) -> ArrayVar env' (Array sh e))
-> Idx env' (Array sh e) -> ArrayVar env' (Array sh e)
forall a b. (a -> b) -> a -> b
$ env :> env'
k (env :> env') -> forall t'. Idx env t' -> Idx env' t'
forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
>:> Idx env (Array sh e)
idx
rebuildWeakenEvar :: env :> env' -> ExpVar env t -> OpenExp env' aenv t
rebuildWeakenEvar :: forall env env' t aenv.
(env :> env') -> ExpVar env t -> OpenExp env' aenv t
rebuildWeakenEvar env :> env'
k (Var ScalarType t
s Idx env t
idx) = ExpVar env' t -> OpenExp env' aenv t
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar (ExpVar env' t -> OpenExp env' aenv t)
-> ExpVar env' t -> OpenExp env' aenv t
forall a b. (a -> b) -> a -> b
$ ScalarType t -> Idx env' t -> ExpVar env' t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t
s (Idx env' t -> ExpVar env' t) -> Idx env' t -> ExpVar env' t
forall a b. (a -> b) -> a -> b
$ env :> env'
k (env :> env') -> forall t'. Idx env t' -> Idx env' t'
forall env env'.
(env :> env') -> forall t'. Idx env t' -> Idx env' t'
>:> Idx env t
idx
instance RebuildableAcc acc => Sink (PreOpenAcc acc) where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env')
-> forall t. PreOpenAcc acc env t -> PreOpenAcc acc env' t
weaken env :> env'
k = Text -> PreOpenAcc acc env' t -> PreOpenAcc acc env' t
forall a. Text -> a -> a
Stats.substitution Text
"weaken" (PreOpenAcc acc env' t -> PreOpenAcc acc env' t)
-> (PreOpenAcc acc env t -> PreOpenAcc acc env' t)
-> PreOpenAcc acc env t
-> PreOpenAcc acc env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall sh e.
ArrayVar env (Array sh e)
-> PreOpenAcc (AccClo (PreOpenAcc acc)) env' (Array sh e))
-> PreOpenAcc acc env t -> PreOpenAcc acc env' t
forall (f :: * -> * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Rebuildable f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e))
-> f aenv a -> f aenv' a
forall (fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
SyntacticAcc fa =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> fa (AccClo (PreOpenAcc acc)) aenv' (Array sh e))
-> PreOpenAcc acc aenv a -> PreOpenAcc acc aenv' a
rebuildA ((env :> env')
-> Var ArrayR env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
forall env env' sh e (acc :: * -> * -> *).
(env :> env')
-> ArrayVar env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
rebuildWeakenVar env :> env'
k)
instance RebuildableAcc acc => Sink (PreOpenAfun acc) where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env')
-> forall t. PreOpenAfun acc env t -> PreOpenAfun acc env' t
weaken env :> env'
k = Text -> PreOpenAfun acc env' t -> PreOpenAfun acc env' t
forall a. Text -> a -> a
Stats.substitution Text
"weaken" (PreOpenAfun acc env' t -> PreOpenAfun acc env' t)
-> (PreOpenAfun acc env t -> PreOpenAfun acc env' t)
-> PreOpenAfun acc env t
-> PreOpenAfun acc env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall sh e.
ArrayVar env (Array sh e)
-> PreOpenAcc (AccClo (PreOpenAfun acc)) env' (Array sh e))
-> PreOpenAfun acc env t -> PreOpenAfun acc env' t
forall (f :: * -> * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Rebuildable f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e))
-> f aenv a -> f aenv' a
forall (fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
SyntacticAcc fa =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> fa (AccClo (PreOpenAfun acc)) aenv' (Array sh e))
-> PreOpenAfun acc aenv a -> PreOpenAfun acc aenv' a
rebuildA ((env :> env')
-> Var ArrayR env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
forall env env' sh e (acc :: * -> * -> *).
(env :> env')
-> ArrayVar env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
rebuildWeakenVar env :> env'
k)
instance Sink (OpenExp env) where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t. OpenExp env env t -> OpenExp env env' t
weaken env :> env'
k = Text -> OpenExp env env' t -> OpenExp env env' t
forall a. Text -> a -> a
Stats.substitution Text
"weaken" (OpenExp env env' t -> OpenExp env env' t)
-> (OpenExp env env t -> OpenExp env env' t)
-> OpenExp env env t
-> OpenExp env env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (OpenExp env env' t) -> OpenExp env env' t
forall a. Identity a -> a
runIdentity (Identity (OpenExp env env' t) -> OpenExp env env' t)
-> (OpenExp env env t -> Identity (OpenExp env env' t))
-> OpenExp env env t
-> OpenExp env env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RebuildEvar Identity OpenExp env env env'
-> ReindexAvar Identity env env'
-> OpenExp env env t
-> Identity (OpenExp env env' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (OpenExp env env' t' -> Identity (OpenExp env env' t')
forall a. a -> Identity a
Identity (OpenExp env env' t' -> Identity (OpenExp env env' t'))
-> (ExpVar env t' -> OpenExp env env' t')
-> ExpVar env t'
-> Identity (OpenExp env env' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env t' -> OpenExp env env' t'
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar) ((forall sh e.
ArrayVar env (Array sh e) -> Identity (ArrayVar env' (Array sh e)))
-> ReindexAvar Identity env env'
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar (ArrayVar env' (Array sh e) -> Identity (ArrayVar env' (Array sh e))
forall a. a -> Identity a
Identity (ArrayVar env' (Array sh e)
-> Identity (ArrayVar env' (Array sh e)))
-> (ArrayVar env (Array sh e) -> ArrayVar env' (Array sh e))
-> ArrayVar env (Array sh e)
-> Identity (ArrayVar env' (Array sh e))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (env :> env') -> forall t. Var ArrayR env t -> Var ArrayR env' t
forall env env'.
(env :> env') -> forall t. Var ArrayR env t -> Var ArrayR env' t
forall (f :: * -> * -> *) env env'.
Sink f =>
(env :> env') -> forall t. f env t -> f env' t
weaken env :> env'
k))
instance Sink (OpenFun env) where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t. OpenFun env env t -> OpenFun env env' t
weaken env :> env'
k = Text -> OpenFun env env' t -> OpenFun env env' t
forall a. Text -> a -> a
Stats.substitution Text
"weaken" (OpenFun env env' t -> OpenFun env env' t)
-> (OpenFun env env t -> OpenFun env env' t)
-> OpenFun env env t
-> OpenFun env env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (OpenFun env env' t) -> OpenFun env env' t
forall a. Identity a -> a
runIdentity (Identity (OpenFun env env' t) -> OpenFun env env' t)
-> (OpenFun env env t -> Identity (OpenFun env env' t))
-> OpenFun env env t
-> OpenFun env env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RebuildEvar Identity OpenExp env env env'
-> ReindexAvar Identity env env'
-> OpenFun env env t
-> Identity (OpenFun env env' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (OpenExp env env' t' -> Identity (OpenExp env env' t')
forall a. a -> Identity a
Identity (OpenExp env env' t' -> Identity (OpenExp env env' t'))
-> (ExpVar env t' -> OpenExp env env' t')
-> ExpVar env t'
-> Identity (OpenExp env env' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env t' -> OpenExp env env' t'
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar) ((forall sh e.
ArrayVar env (Array sh e) -> Identity (ArrayVar env' (Array sh e)))
-> ReindexAvar Identity env env'
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar (ArrayVar env' (Array sh e) -> Identity (ArrayVar env' (Array sh e))
forall a. a -> Identity a
Identity (ArrayVar env' (Array sh e)
-> Identity (ArrayVar env' (Array sh e)))
-> (ArrayVar env (Array sh e) -> ArrayVar env' (Array sh e))
-> ArrayVar env (Array sh e)
-> Identity (ArrayVar env' (Array sh e))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (env :> env') -> forall t. Var ArrayR env t -> Var ArrayR env' t
forall env env'.
(env :> env') -> forall t. Var ArrayR env t -> Var ArrayR env' t
forall (f :: * -> * -> *) env env'.
Sink f =>
(env :> env') -> forall t. f env t -> f env' t
weaken env :> env'
k))
instance Sink Boundary where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t. Boundary env t -> Boundary env' t
weaken env :> env'
k Boundary env t
bndy =
case Boundary env t
bndy of
Boundary env t
Clamp -> Boundary env' t
forall aenv t. Boundary aenv t
Clamp
Boundary env t
Mirror -> Boundary env' t
forall aenv t. Boundary aenv t
Mirror
Boundary env t
Wrap -> Boundary env' t
forall aenv t. Boundary aenv t
Wrap
Constant e
c -> e -> Boundary env' (Array sh e)
forall e aenv sh. e -> Boundary aenv (Array sh e)
Constant e
c
Function Fun env (sh -> e)
f -> Fun env' (sh -> e) -> Boundary env' (Array sh e)
forall aenv sh e. Fun aenv (sh -> e) -> Boundary aenv (Array sh e)
Function ((env :> env') -> forall t. OpenFun () env t -> OpenFun () env' t
forall env env'.
(env :> env') -> forall t. OpenFun () env t -> OpenFun () env' t
forall (f :: * -> * -> *) env env'.
Sink f =>
(env :> env') -> forall t. f env t -> f env' t
weaken env :> env'
k Fun env (sh -> e)
f)
instance Sink OpenAcc where
{-# INLINEABLE weaken #-}
weaken :: forall env env'.
(env :> env') -> forall t. OpenAcc env t -> OpenAcc env' t
weaken env :> env'
k = Text -> OpenAcc env' t -> OpenAcc env' t
forall a. Text -> a -> a
Stats.substitution Text
"weaken" (OpenAcc env' t -> OpenAcc env' t)
-> (OpenAcc env t -> OpenAcc env' t)
-> OpenAcc env t
-> OpenAcc env' t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall sh e.
ArrayVar env (Array sh e)
-> PreOpenAcc (AccClo OpenAcc) env' (Array sh e))
-> OpenAcc env t -> OpenAcc env' t
forall (f :: * -> * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' a.
(Rebuildable f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> fa (AccClo f) aenv' (Array sh e))
-> f aenv a -> f aenv' a
forall (fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
SyntacticAcc fa =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> fa (AccClo OpenAcc) aenv' (Array sh e))
-> OpenAcc aenv a -> OpenAcc aenv' a
rebuildA ((env :> env')
-> Var ArrayR env (Array sh e)
-> PreOpenAcc OpenAcc env' (Array sh e)
forall env env' sh e (acc :: * -> * -> *).
(env :> env')
-> ArrayVar env (Array sh e) -> PreOpenAcc acc env' (Array sh e)
rebuildWeakenVar env :> env'
k)
class SinkExp f where
weakenE :: env :> env' -> f env aenv t -> f env' aenv t
instance SinkExp OpenExp where
{-# INLINEABLE weakenE #-}
weakenE :: forall env env' aenv t.
(env :> env') -> OpenExp env aenv t -> OpenExp env' aenv t
weakenE env :> env'
v = Text -> OpenExp env' aenv t -> OpenExp env' aenv t
forall a. Text -> a -> a
Stats.substitution Text
"weakenE" (OpenExp env' aenv t -> OpenExp env' aenv t)
-> (OpenExp env aenv t -> OpenExp env' aenv t)
-> OpenExp env aenv t
-> OpenExp env' aenv t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall e'. ExpVar env e' -> OpenExp env' aenv e')
-> OpenExp env aenv t -> OpenExp env' aenv t
forall (f :: * -> * -> * -> *) (fe :: * -> * -> * -> *) env env'
aenv e.
(RebuildableExp f, SyntacticExp fe) =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> f env aenv e -> f env' aenv e
forall (fe :: * -> * -> * -> *) env env' aenv e.
SyntacticExp fe =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> OpenExp env aenv e -> OpenExp env' aenv e
rebuildE ((env :> env') -> Var ScalarType env e' -> OpenExp env' aenv e'
forall env env' t aenv.
(env :> env') -> ExpVar env t -> OpenExp env' aenv t
rebuildWeakenEvar env :> env'
v)
instance SinkExp OpenFun where
{-# INLINEABLE weakenE #-}
weakenE :: forall env env' aenv t.
(env :> env') -> OpenFun env aenv t -> OpenFun env' aenv t
weakenE env :> env'
v = Text -> OpenFun env' aenv t -> OpenFun env' aenv t
forall a. Text -> a -> a
Stats.substitution Text
"weakenE" (OpenFun env' aenv t -> OpenFun env' aenv t)
-> (OpenFun env aenv t -> OpenFun env' aenv t)
-> OpenFun env aenv t
-> OpenFun env' aenv t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall e'. ExpVar env e' -> OpenExp env' aenv e')
-> OpenFun env aenv t -> OpenFun env' aenv t
forall (f :: * -> * -> * -> *) (fe :: * -> * -> * -> *) env env'
aenv e.
(RebuildableExp f, SyntacticExp fe) =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> f env aenv e -> f env' aenv e
forall (fe :: * -> * -> * -> *) env env' aenv e.
SyntacticExp fe =>
(forall e'. ExpVar env e' -> fe env' aenv e')
-> OpenFun env aenv e -> OpenFun env' aenv e
rebuildE ((env :> env') -> Var ScalarType env e' -> OpenExp env' aenv e'
forall env env' t aenv.
(env :> env') -> ExpVar env t -> OpenExp env' aenv t
rebuildWeakenEvar env :> env'
v)
type env :?> env' = forall t'. Idx env t' -> Maybe (Idx env' t')
{-# INLINEABLE strengthen #-}
strengthen :: forall f env env' t. Rebuildable f => env :?> env' -> f env t -> Maybe (f env' t)
strengthen :: forall (f :: * -> * -> *) env env' t.
Rebuildable f =>
(env :?> env') -> f env t -> Maybe (f env' t)
strengthen env :?> env'
k f env t
x = Text -> Maybe (f env' t) -> Maybe (f env' t)
forall a. Text -> a -> a
Stats.substitution Text
"strengthen" (Maybe (f env' t) -> Maybe (f env' t))
-> Maybe (f env' t) -> Maybe (f env' t)
forall a b. (a -> b) -> a -> b
$ forall (f :: * -> * -> *) (f' :: * -> *)
(fa :: (* -> * -> *) -> * -> * -> *) aenv aenv' a.
(Rebuildable f, Applicative f', SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e)
-> f' (fa (AccClo f) aenv' (Array sh e)))
-> f aenv a -> f' (f aenv' a)
rebuildPartial @f @Maybe @IdxA (\(Var ArrayR (Array sh e)
s Idx env (Array sh e)
ix) -> (Idx env' (Array sh e) -> IdxA (AccClo f) env' (Array sh e))
-> Maybe (Idx env' (Array sh e))
-> Maybe (IdxA (AccClo f) env' (Array sh e))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ArrayVar env' (Array sh e) -> IdxA (AccClo f) env' (Array sh e)
forall (acc :: * -> * -> *) aenv t.
ArrayVar aenv t -> IdxA acc aenv t
IA (ArrayVar env' (Array sh e) -> IdxA (AccClo f) env' (Array sh e))
-> (Idx env' (Array sh e) -> ArrayVar env' (Array sh e))
-> Idx env' (Array sh e)
-> IdxA (AccClo f) env' (Array sh e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ArrayR (Array sh e)
-> Idx env' (Array sh e) -> ArrayVar env' (Array sh e)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh e)
s) (Maybe (Idx env' (Array sh e))
-> Maybe (IdxA (AccClo f) env' (Array sh e)))
-> Maybe (Idx env' (Array sh e))
-> Maybe (IdxA (AccClo f) env' (Array sh e))
forall a b. (a -> b) -> a -> b
$ Idx env (Array sh e) -> Maybe (Idx env' (Array sh e))
env :?> env'
k Idx env (Array sh e)
ix) f env t
x
{-# INLINEABLE strengthenE #-}
strengthenE :: forall f env env' aenv t. RebuildableExp f => env :?> env' -> f env aenv t -> Maybe (f env' aenv t)
strengthenE :: forall (f :: * -> * -> * -> *) env env' aenv t.
RebuildableExp f =>
(env :?> env') -> f env aenv t -> Maybe (f env' aenv t)
strengthenE env :?> env'
k f env aenv t
x = Text -> Maybe (f env' aenv t) -> Maybe (f env' aenv t)
forall a. Text -> a -> a
Stats.substitution Text
"strengthenE" (Maybe (f env' aenv t) -> Maybe (f env' aenv t))
-> Maybe (f env' aenv t) -> Maybe (f env' aenv t)
forall a b. (a -> b) -> a -> b
$ forall (f :: * -> * -> * -> *) (f' :: * -> *)
(fe :: * -> * -> * -> *) env env' aenv e.
(RebuildableExp f, Applicative f', SyntacticExp fe) =>
(forall e'. ExpVar env e' -> f' (fe env' aenv e'))
-> f env aenv e -> f' (f env' aenv e)
rebuildPartialE @f @Maybe @IdxE (\(Var ScalarType e'
tp Idx env e'
ix) -> (Idx env' e' -> IdxE env' aenv e')
-> Maybe (Idx env' e') -> Maybe (IdxE env' aenv e')
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ExpVar env' e' -> IdxE env' aenv e'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE (ExpVar env' e' -> IdxE env' aenv e')
-> (Idx env' e' -> ExpVar env' e')
-> Idx env' e'
-> IdxE env' aenv e'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScalarType e' -> Idx env' e' -> ExpVar env' e'
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType e'
tp) (Maybe (Idx env' e') -> Maybe (IdxE env' aenv e'))
-> Maybe (Idx env' e') -> Maybe (IdxE env' aenv e')
forall a b. (a -> b) -> a -> b
$ Idx env e' -> Maybe (Idx env' e')
env :?> env'
k Idx env e'
ix) f env aenv t
x
strengthenWithLHS :: LeftHandSide s t env1 env2 -> env2 :?> env1
strengthenWithLHS :: forall (s :: * -> *) t env1 env2.
LeftHandSide s t env1 env2 -> env2 :?> env1
strengthenWithLHS (LeftHandSideWildcard TupR s t
_) = Idx env2 t' -> Maybe (Idx env1 t')
Idx env2 t' -> Maybe (Idx env2 t')
forall a. a -> Maybe a
Just
strengthenWithLHS (LeftHandSideSingle s t
_) = \Idx env2 t'
ix -> case Idx env2 t'
ix of
Idx env2 t'
ZeroIdx -> Maybe (Idx env1 t')
forall a. Maybe a
Nothing
SuccIdx Idx env t'
i -> Idx env1 t' -> Maybe (Idx env1 t')
forall a. a -> Maybe a
Just Idx env1 t'
Idx env t'
i
strengthenWithLHS (LeftHandSidePair LeftHandSide s v1 env1 env'1
l1 LeftHandSide s v2 env'1 env2
l2) = LeftHandSide s v2 env'1 env2 -> env2 :?> env'1
forall (s :: * -> *) t env1 env2.
LeftHandSide s t env1 env2 -> env2 :?> env1
strengthenWithLHS LeftHandSide s v2 env'1 env2
l2 (Idx env2 t' -> Maybe (Idx env'1 t'))
-> (Idx env'1 t' -> Maybe (Idx env1 t'))
-> Idx env2 t'
-> Maybe (Idx env1 t')
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> LeftHandSide s v1 env1 env'1 -> env'1 :?> env1
forall (s :: * -> *) t env1 env2.
LeftHandSide s t env1 env2 -> env2 :?> env1
strengthenWithLHS LeftHandSide s v1 env1 env'1
l1
strengthenAfter :: LeftHandSide s t env1 env2 -> LeftHandSide s t env1' env2' -> env1 :?> env1' -> env2 :?> env2'
strengthenAfter :: forall (s :: * -> *) t env1 env2 env1' env2'.
LeftHandSide s t env1 env2
-> LeftHandSide s t env1' env2'
-> (env1 :?> env1')
-> env2 :?> env2'
strengthenAfter (LeftHandSideWildcard TupR s t
_) (LeftHandSideWildcard TupR s t
_) env1 :?> env1'
k = Idx env1 t' -> Maybe (Idx env1' t')
Idx env2 t' -> Maybe (Idx env2' t')
env1 :?> env1'
k
strengthenAfter (LeftHandSideSingle s t
_) (LeftHandSideSingle s t
_) env1 :?> env1'
k = \Idx env2 t'
ix -> case Idx env2 t'
ix of
Idx env2 t'
ZeroIdx -> Idx env2' t' -> Maybe (Idx env2' t')
forall a. a -> Maybe a
Just Idx env2' t'
forall envt t env. (envt ~ (env, t)) => Idx envt t
ZeroIdx
SuccIdx Idx env t'
i -> Idx env1' t' -> Idx env2' t'
forall envs t s env. (envs ~ (env, s)) => Idx env t -> Idx envs t
SuccIdx (Idx env1' t' -> Idx env2' t')
-> Maybe (Idx env1' t') -> Maybe (Idx env2' t')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Idx env1 t' -> Maybe (Idx env1' t')
env1 :?> env1'
k Idx env1 t'
Idx env t'
i
strengthenAfter (LeftHandSidePair LeftHandSide s v1 env1 env'1
l1 LeftHandSide s v2 env'1 env2
l2) (LeftHandSidePair LeftHandSide s v1 env1' env'1
l1' LeftHandSide s v2 env'1 env2'
l2') env1 :?> env1'
k =
LeftHandSide s v2 env'1 env2
-> LeftHandSide s v2 env'1 env2'
-> (forall t'. Idx env'1 t' -> Maybe (Idx env'1 t'))
-> forall {t'}. Idx env2 t' -> Maybe (Idx env2' t')
forall (s :: * -> *) t env1 env2 env1' env2'.
LeftHandSide s t env1 env2
-> LeftHandSide s t env1' env2'
-> (env1 :?> env1')
-> env2 :?> env2'
strengthenAfter LeftHandSide s v2 env'1 env2
l2 LeftHandSide s v2 env'1 env2'
LeftHandSide s v2 env'1 env2'
l2' ((forall t'. Idx env'1 t' -> Maybe (Idx env'1 t'))
-> forall {t'}. Idx env2 t' -> Maybe (Idx env2' t'))
-> (forall t'. Idx env'1 t' -> Maybe (Idx env'1 t'))
-> forall {t'}. Idx env2 t' -> Maybe (Idx env2' t')
forall a b. (a -> b) -> a -> b
$ LeftHandSide s v1 env1 env'1
-> LeftHandSide s v1 env1' env'1
-> (env1 :?> env1')
-> forall t'. Idx env'1 t' -> Maybe (Idx env'1 t')
forall (s :: * -> *) t env1 env2 env1' env2'.
LeftHandSide s t env1 env2
-> LeftHandSide s t env1' env2'
-> (env1 :?> env1')
-> env2 :?> env2'
strengthenAfter LeftHandSide s v1 env1 env'1
l1 LeftHandSide s v1 env1' env'1
LeftHandSide s v1 env1' env'1
l1' Idx env1 t' -> Maybe (Idx env1' t')
env1 :?> env1'
k
strengthenAfter LeftHandSide s t env1 env2
_ LeftHandSide s t env1' env2'
_ env1 :?> env1'
_ = [Char] -> Idx env2 t' -> Maybe (Idx env2' t')
forall a. HasCallStack => [Char] -> a
error [Char]
"Substitution.strengthenAfter: left hand sides do not match"
class SyntacticExp f where
varIn :: ExpVar env t -> f env aenv t
expOut :: f env aenv t -> OpenExp env aenv t
weakenExp :: f env aenv t -> f (env, s) aenv t
newtype IdxE env aenv t = IE { forall env aenv t. IdxE env aenv t -> ExpVar env t
unIE :: ExpVar env t }
instance SyntacticExp IdxE where
varIn :: forall env t aenv. ExpVar env t -> IdxE env aenv t
varIn = ExpVar env t -> IdxE env aenv t
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE
expOut :: forall env aenv t. IdxE env aenv t -> OpenExp env aenv t
expOut = ExpVar env t -> OpenExp env aenv t
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar (ExpVar env t -> OpenExp env aenv t)
-> (IdxE env aenv t -> ExpVar env t)
-> IdxE env aenv t
-> OpenExp env aenv t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IdxE env aenv t -> ExpVar env t
forall env aenv t. IdxE env aenv t -> ExpVar env t
unIE
weakenExp :: forall env aenv t s. IdxE env aenv t -> IdxE (env, s) aenv t
weakenExp (IE (Var ScalarType t
tp Idx env t
ix)) = ExpVar (env, s) t -> IdxE (env, s) aenv t
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE (ExpVar (env, s) t -> IdxE (env, s) aenv t)
-> ExpVar (env, s) t -> IdxE (env, s) aenv t
forall a b. (a -> b) -> a -> b
$ ScalarType t -> Idx (env, s) t -> ExpVar (env, s) t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t
tp (Idx (env, s) t -> ExpVar (env, s) t)
-> Idx (env, s) t -> ExpVar (env, s) t
forall a b. (a -> b) -> a -> b
$ Idx env t -> Idx (env, s) t
forall envs t s env. (envs ~ (env, s)) => Idx env t -> Idx envs t
SuccIdx Idx env t
ix
instance SyntacticExp OpenExp where
varIn :: forall env t aenv. ExpVar env t -> OpenExp env aenv t
varIn = ExpVar env t -> OpenExp env aenv t
forall env t aenv. ExpVar env t -> OpenExp env aenv t
Evar
expOut :: forall env aenv t. OpenExp env aenv t -> OpenExp env aenv t
expOut = OpenExp env aenv t -> OpenExp env aenv t
forall a. a -> a
id
weakenExp :: forall env aenv t s. OpenExp env aenv t -> OpenExp (env, s) aenv t
weakenExp = Identity (OpenExp (env, s) aenv t) -> OpenExp (env, s) aenv t
forall a. Identity a -> a
runIdentity (Identity (OpenExp (env, s) aenv t) -> OpenExp (env, s) aenv t)
-> (OpenExp env aenv t -> Identity (OpenExp (env, s) aenv t))
-> OpenExp env aenv t
-> OpenExp (env, s) aenv t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RebuildEvar Identity IdxE env (env, s) aenv
-> ReindexAvar Identity aenv aenv
-> OpenExp env aenv t
-> Identity (OpenExp (env, s) aenv t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE (env, s) aenv t' -> Identity (IdxE (env, s) aenv t')
forall a. a -> Identity a
Identity (IdxE (env, s) aenv t' -> Identity (IdxE (env, s) aenv t'))
-> (ExpVar env t' -> IdxE (env, s) aenv t')
-> ExpVar env t'
-> Identity (IdxE (env, s) aenv t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IdxE env aenv t' -> IdxE (env, s) aenv t'
forall env aenv t s. IdxE env aenv t -> IdxE (env, s) aenv t
forall (f :: * -> * -> * -> *) env aenv t s.
SyntacticExp f =>
f env aenv t -> f (env, s) aenv t
weakenExp (IdxE env aenv t' -> IdxE (env, s) aenv t')
-> (ExpVar env t' -> IdxE env aenv t')
-> ExpVar env t'
-> IdxE (env, s) aenv t'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar env t' -> IdxE env aenv t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ((forall sh e.
ArrayVar aenv (Array sh e)
-> Identity (ArrayVar aenv (Array sh e)))
-> ReindexAvar Identity aenv aenv
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar ArrayVar aenv (Array sh e) -> Identity (ArrayVar aenv (Array sh e))
forall a. a -> Identity a
forall sh e.
ArrayVar aenv (Array sh e) -> Identity (ArrayVar aenv (Array sh e))
Identity)
{-# INLINEABLE shiftE #-}
shiftE
:: (Applicative f, SyntacticExp fe)
=> RebuildEvar f fe env env' aenv
-> RebuildEvar f fe (env, s) (env', s) aenv
shiftE :: forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv s.
(Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv
-> RebuildEvar f fe (env, s) (env', s) aenv
shiftE RebuildEvar f fe env env' aenv
_ (Var ScalarType t'
tp Idx (env, s) t'
ZeroIdx) = fe (env', s) aenv t' -> f (fe (env', s) aenv t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (fe (env', s) aenv t' -> f (fe (env', s) aenv t'))
-> fe (env', s) aenv t' -> f (fe (env', s) aenv t')
forall a b. (a -> b) -> a -> b
$ ExpVar (env', s) t' -> fe (env', s) aenv t'
forall env t aenv. ExpVar env t -> fe env aenv t
forall (f :: * -> * -> * -> *) env t aenv.
SyntacticExp f =>
ExpVar env t -> f env aenv t
varIn (ScalarType t' -> Idx (env', s) t' -> ExpVar (env', s) t'
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t'
tp Idx (env', s) t'
forall envt t env. (envt ~ (env, t)) => Idx envt t
ZeroIdx)
shiftE RebuildEvar f fe env env' aenv
v (Var ScalarType t'
tp (SuccIdx Idx env t'
ix)) = fe env' aenv t' -> fe (env', s) aenv t'
forall env aenv t s. fe env aenv t -> fe (env, s) aenv t
forall (f :: * -> * -> * -> *) env aenv t s.
SyntacticExp f =>
f env aenv t -> f (env, s) aenv t
weakenExp (fe env' aenv t' -> fe (env', s) aenv t')
-> f (fe env' aenv t') -> f (fe (env', s) aenv t')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExpVar env t' -> f (fe env' aenv t')
RebuildEvar f fe env env' aenv
v (ScalarType t' -> Idx env t' -> ExpVar env t'
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ScalarType t'
tp Idx env t'
Idx env t'
ix)
{-# INLINEABLE shiftE' #-}
shiftE'
:: (Applicative f, SyntacticExp fa)
=> ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' :: forall (f :: * -> *) (fa :: * -> * -> * -> *) t env1 env1' env2
env2' aenv.
(Applicative f, SyntacticExp fa) =>
ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' (LeftHandSideWildcard TupR ScalarType t
_) (LeftHandSideWildcard TupR ScalarType t
_) RebuildEvar f fa env1 env2 aenv
v = ExpVar env1 t' -> f (fa env2 aenv t')
Var ScalarType env1' t' -> f (fa env2' aenv t')
RebuildEvar f fa env1 env2 aenv
v
shiftE' (LeftHandSideSingle ScalarType t
_) (LeftHandSideSingle ScalarType t
_) RebuildEvar f fa env1 env2 aenv
v = RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa (env1, t) (env2, t) aenv
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv s.
(Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv
-> RebuildEvar f fe (env, s) (env', s) aenv
shiftE ExpVar env1 t' -> f (fa env2 aenv t')
RebuildEvar f fa env1 env2 aenv
v
shiftE' (LeftHandSidePair LeftHandSide ScalarType v1 env1 env'1
a1 LeftHandSide ScalarType v2 env'1 env1'
b1) (LeftHandSidePair LeftHandSide ScalarType v1 env2 env'1
a2 LeftHandSide ScalarType v2 env'1 env2'
b2) RebuildEvar f fa env1 env2 aenv
v = LeftHandSide ScalarType v2 env'1 env1'
-> ELeftHandSide v2 env'1 env2'
-> (forall {t'}. ExpVar env'1 t' -> f (fa env'1 aenv t'))
-> forall {t'}. ExpVar env1' t' -> f (fa env2' aenv t')
forall (f :: * -> *) (fa :: * -> * -> * -> *) t env1 env1' env2
env2' aenv.
(Applicative f, SyntacticExp fa) =>
ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' LeftHandSide ScalarType v2 env'1 env1'
b1 ELeftHandSide v2 env'1 env2'
LeftHandSide ScalarType v2 env'1 env2'
b2 ((forall {t'}. ExpVar env'1 t' -> f (fa env'1 aenv t'))
-> forall {t'}. ExpVar env1' t' -> f (fa env2' aenv t'))
-> (forall {t'}. ExpVar env'1 t' -> f (fa env'1 aenv t'))
-> forall {t'}. ExpVar env1' t' -> f (fa env2' aenv t')
forall a b. (a -> b) -> a -> b
$ LeftHandSide ScalarType v1 env1 env'1
-> ELeftHandSide v1 env2 env'1
-> RebuildEvar f fa env1 env2 aenv
-> forall {t'}. ExpVar env'1 t' -> f (fa env'1 aenv t')
forall (f :: * -> *) (fa :: * -> * -> * -> *) t env1 env1' env2
env2' aenv.
(Applicative f, SyntacticExp fa) =>
ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' LeftHandSide ScalarType v1 env1 env'1
a1 ELeftHandSide v1 env2 env'1
LeftHandSide ScalarType v1 env2 env'1
a2 ExpVar env1 t' -> f (fa env2 aenv t')
RebuildEvar f fa env1 env2 aenv
v
shiftE' ELeftHandSide t env1 env1'
_ ELeftHandSide t env2 env2'
_ RebuildEvar f fa env1 env2 aenv
_ = [Char] -> Var ScalarType env1' t' -> f (fa env2' aenv t')
forall a. HasCallStack => [Char] -> a
error [Char]
"Substitution: left hand sides do not match"
{-# INLINEABLE rebuildMaybeExp #-}
rebuildMaybeExp
:: (HasCallStack, Applicative f, SyntacticExp fe)
=> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp :: forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp RebuildEvar f fe env env' aenv'
_ ReindexAvar f aenv aenv'
_ Maybe (OpenExp env aenv t)
Nothing = Maybe (OpenExp env' aenv' t) -> f (Maybe (OpenExp env' aenv' t))
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (OpenExp env' aenv' t)
forall a. Maybe a
Nothing
rebuildMaybeExp RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av (Just OpenExp env aenv t
x) = OpenExp env' aenv' t -> Maybe (OpenExp env' aenv' t)
forall a. a -> Maybe a
Just (OpenExp env' aenv' t -> Maybe (OpenExp env' aenv' t))
-> f (OpenExp env' aenv' t) -> f (Maybe (OpenExp env' aenv' t))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
x
{-# INLINEABLE rebuildOpenExp #-}
rebuildOpenExp
:: (HasCallStack, Applicative f, SyntacticExp fe)
=> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp :: forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp RebuildEvar f fe env env' aenv'
v av :: ReindexAvar f aenv aenv'
av@(ReindexAvar forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
reindex) OpenExp env aenv t
exp =
case OpenExp env aenv t
exp of
Const ScalarType t
t t
c -> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OpenExp env' aenv' t -> f (OpenExp env' aenv' t))
-> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a b. (a -> b) -> a -> b
$ ScalarType t -> t -> OpenExp env' aenv' t
forall t env aenv. ScalarType t -> t -> OpenExp env aenv t
Const ScalarType t
t t
c
PrimConst PrimConst t
c -> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OpenExp env' aenv' t -> f (OpenExp env' aenv' t))
-> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a b. (a -> b) -> a -> b
$ PrimConst t -> OpenExp env' aenv' t
forall t env aenv. PrimConst t -> OpenExp env aenv t
PrimConst PrimConst t
c
Undef ScalarType t
t -> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OpenExp env' aenv' t -> f (OpenExp env' aenv' t))
-> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a b. (a -> b) -> a -> b
$ ScalarType t -> OpenExp env' aenv' t
forall t env aenv. ScalarType t -> OpenExp env aenv t
Undef ScalarType t
t
Evar ExpVar env t
var -> fe env' aenv' t -> OpenExp env' aenv' t
forall env aenv t. fe env aenv t -> OpenExp env aenv t
forall (f :: * -> * -> * -> *) env aenv t.
SyntacticExp f =>
f env aenv t -> OpenExp env aenv t
expOut (fe env' aenv' t -> OpenExp env' aenv' t)
-> f (fe env' aenv' t) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ExpVar env t -> f (fe env' aenv' t)
RebuildEvar f fe env env' aenv'
v ExpVar env t
var
Let ELeftHandSide bnd_t env env'
lhs OpenExp env aenv bnd_t
a OpenExp env' aenv t
b
| Exists LeftHandSide ScalarType bnd_t env' a
lhs' <- ELeftHandSide bnd_t env env'
-> Exists (LeftHandSide ScalarType bnd_t env')
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ELeftHandSide bnd_t env env'
lhs
-> LeftHandSide ScalarType bnd_t env' a
-> OpenExp env' aenv' bnd_t
-> OpenExp a aenv' t
-> OpenExp env' aenv' t
forall bnd_t env env' aenv t.
ELeftHandSide bnd_t env env'
-> OpenExp env aenv bnd_t
-> OpenExp env' aenv t
-> OpenExp env aenv t
Let LeftHandSide ScalarType bnd_t env' a
lhs' (OpenExp env' aenv' bnd_t
-> OpenExp a aenv' t -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' bnd_t)
-> f (OpenExp a aenv' t -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv bnd_t
-> f (OpenExp env' aenv' bnd_t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv bnd_t
a f (OpenExp a aenv' t -> OpenExp env' aenv' t)
-> f (OpenExp a aenv' t) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env' a aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env' aenv t
-> f (OpenExp a aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (ELeftHandSide bnd_t env env'
-> LeftHandSide ScalarType bnd_t env' a
-> RebuildEvar f fe env env' aenv'
-> RebuildEvar f fe env' a aenv'
forall (f :: * -> *) (fa :: * -> * -> * -> *) t env1 env1' env2
env2' aenv.
(Applicative f, SyntacticExp fa) =>
ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' ELeftHandSide bnd_t env env'
lhs LeftHandSide ScalarType bnd_t env' a
lhs' Var ScalarType env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v) ReindexAvar f aenv aenv'
av OpenExp env' aenv t
b
Pair OpenExp env aenv t1
e1 OpenExp env aenv t2
e2 -> OpenExp env' aenv' t1
-> OpenExp env' aenv' t2 -> OpenExp env' aenv' t
OpenExp env' aenv' t1
-> OpenExp env' aenv' t2 -> OpenExp env' aenv' (t1, t2)
forall env aenv t1 t2.
OpenExp env aenv t1
-> OpenExp env aenv t2 -> OpenExp env aenv (t1, t2)
Pair (OpenExp env' aenv' t1
-> OpenExp env' aenv' t2 -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t1)
-> f (OpenExp env' aenv' t2 -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t1
-> f (OpenExp env' aenv' t1)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t1
e1 f (OpenExp env' aenv' t2 -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t2) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t2
-> f (OpenExp env' aenv' t2)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t2
e2
OpenExp env aenv t
Nil -> OpenExp env' aenv' t -> f (OpenExp env' aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure OpenExp env' aenv' t
OpenExp env' aenv' ()
forall env aenv. OpenExp env aenv ()
Nil
VecPack VecR n s tup
vec OpenExp env aenv tup
e -> VecR n s tup
-> OpenExp env' aenv' tup -> OpenExp env' aenv' (Vec n s)
forall (n :: Nat) s tup env aenv.
KnownNat n =>
VecR n s tup -> OpenExp env aenv tup -> OpenExp env aenv (Vec n s)
VecPack VecR n s tup
vec (OpenExp env' aenv' tup -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' tup) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv tup
-> f (OpenExp env' aenv' tup)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv tup
e
VecUnpack VecR n s t
vec OpenExp env aenv (Vec n s)
e -> VecR n s t -> OpenExp env' aenv' (Vec n s) -> OpenExp env' aenv' t
forall (n :: Nat) s t env aenv.
KnownNat n =>
VecR n s t -> OpenExp env aenv (Vec n s) -> OpenExp env aenv t
VecUnpack VecR n s t
vec (OpenExp env' aenv' (Vec n s) -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' (Vec n s)) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv (Vec n s)
-> f (OpenExp env' aenv' (Vec n s))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv (Vec n s)
e
IndexSlice SliceIndex slix t co sh
x OpenExp env aenv slix
ix OpenExp env aenv sh
sh -> SliceIndex slix t co sh
-> OpenExp env' aenv' slix
-> OpenExp env' aenv' sh
-> OpenExp env' aenv' t
forall slix t co sh env aenv.
SliceIndex slix t co sh
-> OpenExp env aenv slix
-> OpenExp env aenv sh
-> OpenExp env aenv t
IndexSlice SliceIndex slix t co sh
x (OpenExp env' aenv' slix
-> OpenExp env' aenv' sh -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' slix)
-> f (OpenExp env' aenv' sh -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv slix
-> f (OpenExp env' aenv' slix)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv slix
ix f (OpenExp env' aenv' sh -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' sh) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv sh
-> f (OpenExp env' aenv' sh)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv sh
sh
IndexFull SliceIndex slix sl co t
x OpenExp env aenv slix
ix OpenExp env aenv sl
sl -> SliceIndex slix sl co t
-> OpenExp env' aenv' slix
-> OpenExp env' aenv' sl
-> OpenExp env' aenv' t
forall slix sl co t env aenv.
SliceIndex slix sl co t
-> OpenExp env aenv slix
-> OpenExp env aenv sl
-> OpenExp env aenv t
IndexFull SliceIndex slix sl co t
x (OpenExp env' aenv' slix
-> OpenExp env' aenv' sl -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' slix)
-> f (OpenExp env' aenv' sl -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv slix
-> f (OpenExp env' aenv' slix)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv slix
ix f (OpenExp env' aenv' sl -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' sl) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv sl
-> f (OpenExp env' aenv' sl)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv sl
sl
ToIndex ShapeR sh
shr OpenExp env aenv sh
sh OpenExp env aenv sh
ix -> ShapeR sh
-> OpenExp env' aenv' sh
-> OpenExp env' aenv' sh
-> OpenExp env' aenv' Int
forall sh env aenv.
ShapeR sh
-> OpenExp env aenv sh
-> OpenExp env aenv sh
-> OpenExp env aenv Int
ToIndex ShapeR sh
shr (OpenExp env' aenv' sh
-> OpenExp env' aenv' sh -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' sh)
-> f (OpenExp env' aenv' sh -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv sh
-> f (OpenExp env' aenv' sh)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv sh
sh f (OpenExp env' aenv' sh -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' sh) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv sh
-> f (OpenExp env' aenv' sh)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv sh
ix
FromIndex ShapeR t
shr OpenExp env aenv t
sh OpenExp env aenv Int
ix -> ShapeR t
-> OpenExp env' aenv' t
-> OpenExp env' aenv' Int
-> OpenExp env' aenv' t
forall t env aenv.
ShapeR t
-> OpenExp env aenv t -> OpenExp env aenv Int -> OpenExp env aenv t
FromIndex ShapeR t
shr (OpenExp env' aenv' t
-> OpenExp env' aenv' Int -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t)
-> f (OpenExp env' aenv' Int -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
sh f (OpenExp env' aenv' Int -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' Int) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv Int
-> f (OpenExp env' aenv' Int)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv Int
ix
Case OpenExp env aenv TAG
e [(TAG, OpenExp env aenv t)]
rhs Maybe (OpenExp env aenv t)
def -> OpenExp env' aenv' TAG
-> [(TAG, OpenExp env' aenv' t)]
-> Maybe (OpenExp env' aenv' t)
-> OpenExp env' aenv' t
forall env aenv t.
OpenExp env aenv TAG
-> [(TAG, OpenExp env aenv t)]
-> Maybe (OpenExp env aenv t)
-> OpenExp env aenv t
Case (OpenExp env' aenv' TAG
-> [(TAG, OpenExp env' aenv' t)]
-> Maybe (OpenExp env' aenv' t)
-> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' TAG)
-> f ([(TAG, OpenExp env' aenv' t)]
-> Maybe (OpenExp env' aenv' t) -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv TAG
-> f (OpenExp env' aenv' TAG)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv TAG
e f ([(TAG, OpenExp env' aenv' t)]
-> Maybe (OpenExp env' aenv' t) -> OpenExp env' aenv' t)
-> f [(TAG, OpenExp env' aenv' t)]
-> f (Maybe (OpenExp env' aenv' t) -> OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [f (TAG, OpenExp env' aenv' t)] -> f [(TAG, OpenExp env' aenv' t)]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
forall (f :: * -> *) a. Applicative f => [f a] -> f [a]
sequenceA [ (TAG
t,) (OpenExp env' aenv' t -> (TAG, OpenExp env' aenv' t))
-> f (OpenExp env' aenv' t) -> f (TAG, OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
c | (TAG
t,OpenExp env aenv t
c) <- [(TAG, OpenExp env aenv t)]
rhs ] f (Maybe (OpenExp env' aenv' t) -> OpenExp env' aenv' t)
-> f (Maybe (OpenExp env' aenv' t)) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av Maybe (OpenExp env aenv t)
def
Cond OpenExp env aenv TAG
p OpenExp env aenv t
t OpenExp env aenv t
e -> OpenExp env' aenv' TAG
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t
forall env aenv t.
OpenExp env aenv TAG
-> OpenExp env aenv t -> OpenExp env aenv t -> OpenExp env aenv t
Cond (OpenExp env' aenv' TAG
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' TAG)
-> f (OpenExp env' aenv' t
-> OpenExp env' aenv' t -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv TAG
-> f (OpenExp env' aenv' TAG)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv TAG
p f (OpenExp env' aenv' t
-> OpenExp env' aenv' t -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t -> OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
t f (OpenExp env' aenv' t -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
e
While OpenFun env aenv (t -> TAG)
p OpenFun env aenv (t -> t)
f OpenExp env aenv t
x -> OpenFun env' aenv' (t -> TAG)
-> OpenFun env' aenv' (t -> t)
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t
forall env aenv t.
OpenFun env aenv (t -> TAG)
-> OpenFun env aenv (t -> t)
-> OpenExp env aenv t
-> OpenExp env aenv t
While (OpenFun env' aenv' (t -> TAG)
-> OpenFun env' aenv' (t -> t)
-> OpenExp env' aenv' t
-> OpenExp env' aenv' t)
-> f (OpenFun env' aenv' (t -> TAG))
-> f (OpenFun env' aenv' (t -> t)
-> OpenExp env' aenv' t -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv (t -> TAG)
-> f (OpenFun env' aenv' (t -> TAG))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenFun env aenv (t -> TAG)
p f (OpenFun env' aenv' (t -> t)
-> OpenExp env' aenv' t -> OpenExp env' aenv' t)
-> f (OpenFun env' aenv' (t -> t))
-> f (OpenExp env' aenv' t -> OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv (t -> t)
-> f (OpenFun env' aenv' (t -> t))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenFun env aenv (t -> t)
f f (OpenExp env' aenv' t -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' t) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
x
PrimApp PrimFun (a -> t)
f OpenExp env aenv a
x -> PrimFun (a -> t) -> OpenExp env' aenv' a -> OpenExp env' aenv' t
forall a t env aenv.
PrimFun (a -> t) -> OpenExp env aenv a -> OpenExp env aenv t
PrimApp PrimFun (a -> t)
f (OpenExp env' aenv' a -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' a) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv a
-> f (OpenExp env' aenv' a)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv a
x
Index ArrayVar aenv (Array dim t)
a OpenExp env aenv dim
sh -> ArrayVar aenv' (Array dim t)
-> OpenExp env' aenv' dim -> OpenExp env' aenv' t
forall aenv dim t env.
ArrayVar aenv (Array dim t)
-> OpenExp env aenv dim -> OpenExp env aenv t
Index (ArrayVar aenv' (Array dim t)
-> OpenExp env' aenv' dim -> OpenExp env' aenv' t)
-> f (ArrayVar aenv' (Array dim t))
-> f (OpenExp env' aenv' dim -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array dim t) -> f (ArrayVar aenv' (Array dim t))
forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
reindex ArrayVar aenv (Array dim t)
a f (OpenExp env' aenv' dim -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' dim) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv dim
-> f (OpenExp env' aenv' dim)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv dim
sh
LinearIndex ArrayVar aenv (Array dim t)
a OpenExp env aenv Int
i -> ArrayVar aenv' (Array dim t)
-> OpenExp env' aenv' Int -> OpenExp env' aenv' t
forall aenv dim t env.
ArrayVar aenv (Array dim t)
-> OpenExp env aenv Int -> OpenExp env aenv t
LinearIndex (ArrayVar aenv' (Array dim t)
-> OpenExp env' aenv' Int -> OpenExp env' aenv' t)
-> f (ArrayVar aenv' (Array dim t))
-> f (OpenExp env' aenv' Int -> OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array dim t) -> f (ArrayVar aenv' (Array dim t))
forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
reindex ArrayVar aenv (Array dim t)
a f (OpenExp env' aenv' Int -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' Int) -> f (OpenExp env' aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv Int
-> f (OpenExp env' aenv' Int)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv Int
i
Shape ArrayVar aenv (Array t e)
a -> ArrayVar aenv' (Array t e) -> OpenExp env' aenv' t
forall aenv t e env.
ArrayVar aenv (Array t e) -> OpenExp env aenv t
Shape (ArrayVar aenv' (Array t e) -> OpenExp env' aenv' t)
-> f (ArrayVar aenv' (Array t e)) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array t e) -> f (ArrayVar aenv' (Array t e))
forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
reindex ArrayVar aenv (Array t e)
a
ShapeSize ShapeR dim
shr OpenExp env aenv dim
sh -> ShapeR dim -> OpenExp env' aenv' dim -> OpenExp env' aenv' Int
forall dim env aenv.
ShapeR dim -> OpenExp env aenv dim -> OpenExp env aenv Int
ShapeSize ShapeR dim
shr (OpenExp env' aenv' dim -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' dim) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv dim
-> f (OpenExp env' aenv' dim)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv dim
sh
Foreign TypeR t
tp asm (x -> t)
ff Fun () (x -> t)
f OpenExp env aenv x
e -> TypeR t
-> asm (x -> t)
-> Fun () (x -> t)
-> OpenExp env' aenv' x
-> OpenExp env' aenv' t
forall (asm :: * -> *) t x env aenv.
Foreign asm =>
TypeR t
-> asm (x -> t)
-> Fun () (x -> t)
-> OpenExp env aenv x
-> OpenExp env aenv t
Foreign TypeR t
tp asm (x -> t)
ff Fun () (x -> t)
f (OpenExp env' aenv' x -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' x) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv x
-> f (OpenExp env' aenv' x)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv x
e
Coerce ScalarType a
t1 ScalarType t
t2 OpenExp env aenv a
e -> ScalarType a
-> ScalarType t -> OpenExp env' aenv' a -> OpenExp env' aenv' t
forall a t env aenv.
BitSizeEq a t =>
ScalarType a
-> ScalarType t -> OpenExp env aenv a -> OpenExp env aenv t
Coerce ScalarType a
t1 ScalarType t
t2 (OpenExp env' aenv' a -> OpenExp env' aenv' t)
-> f (OpenExp env' aenv' a) -> f (OpenExp env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv a
-> f (OpenExp env' aenv' a)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv a
e
{-# INLINEABLE rebuildFun #-}
rebuildFun
:: (HasCallStack, Applicative f, SyntacticExp fe)
=> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun :: forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenFun env aenv t
fun =
case OpenFun env aenv t
fun of
Body OpenExp env aenv t
e -> OpenExp env' aenv' t -> OpenFun env' aenv' t
forall env aenv t. OpenExp env aenv t -> OpenFun env aenv t
Body (OpenExp env' aenv' t -> OpenFun env' aenv' t)
-> f (OpenExp env' aenv' t) -> f (OpenFun env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v ReindexAvar f aenv aenv'
av OpenExp env aenv t
e
Lam ELeftHandSide a env env'
lhs OpenFun env' aenv t1
f
| Exists LeftHandSide ScalarType a env' a
lhs' <- ELeftHandSide a env env' -> Exists (LeftHandSide ScalarType a env')
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ELeftHandSide a env env'
lhs
-> LeftHandSide ScalarType a env' a
-> OpenFun a aenv' t1 -> OpenFun env' aenv' (a -> t1)
forall a env env' aenv t1.
ELeftHandSide a env env'
-> OpenFun env' aenv t1 -> OpenFun env aenv (a -> t1)
Lam LeftHandSide ScalarType a env' a
lhs' (OpenFun a aenv' t1 -> OpenFun env' aenv' t)
-> f (OpenFun a aenv' t1) -> f (OpenFun env' aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f fe env' a aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env' aenv t1
-> f (OpenFun a aenv' t1)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (ELeftHandSide a env env'
-> LeftHandSide ScalarType a env' a
-> RebuildEvar f fe env env' aenv'
-> RebuildEvar f fe env' a aenv'
forall (f :: * -> *) (fa :: * -> * -> * -> *) t env1 env1' env2
env2' aenv.
(Applicative f, SyntacticExp fa) =>
ELeftHandSide t env1 env1'
-> ELeftHandSide t env2 env2'
-> RebuildEvar f fa env1 env2 aenv
-> RebuildEvar f fa env1' env2' aenv
shiftE' ELeftHandSide a env env'
lhs LeftHandSide ScalarType a env' a
lhs' ExpVar env t' -> f (fe env' aenv' t')
RebuildEvar f fe env env' aenv'
v) ReindexAvar f aenv aenv'
av OpenFun env' aenv t1
f
type RebuildAcc acc =
forall aenv aenv' f fa a. (HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAvar f fa acc aenv aenv'
-> acc aenv a
-> f (acc aenv' a)
newtype IdxA (acc :: Type -> Type -> Type) aenv t = IA { forall (acc :: * -> * -> *) aenv t.
IdxA acc aenv t -> ArrayVar aenv t
unIA :: ArrayVar aenv t }
class SyntacticAcc f where
avarIn :: ArrayVar aenv (Array sh e) -> f acc aenv (Array sh e)
accOut :: f acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
weakenAcc :: RebuildAcc acc -> f acc aenv (Array sh e) -> f acc (aenv, s) (Array sh e)
instance SyntacticAcc IdxA where
avarIn :: forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> IdxA acc aenv (Array sh e)
avarIn = ArrayVar aenv (Array sh e) -> IdxA acc aenv (Array sh e)
forall (acc :: * -> * -> *) aenv t.
ArrayVar aenv t -> IdxA acc aenv t
IA
accOut :: forall (acc :: * -> * -> *) aenv sh e.
IdxA acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
accOut = ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
Avar (ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e))
-> (IdxA acc aenv (Array sh e) -> ArrayVar aenv (Array sh e))
-> IdxA acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IdxA acc aenv (Array sh e) -> ArrayVar aenv (Array sh e)
forall (acc :: * -> * -> *) aenv t.
IdxA acc aenv t -> ArrayVar aenv t
unIA
weakenAcc :: forall (acc :: * -> * -> *) aenv sh e s.
RebuildAcc acc
-> IdxA acc aenv (Array sh e) -> IdxA acc (aenv, s) (Array sh e)
weakenAcc RebuildAcc acc
_ (IA (Var ArrayR (Array sh e)
s Idx aenv (Array sh e)
idx)) = ArrayVar (aenv, s) (Array sh e) -> IdxA acc (aenv, s) (Array sh e)
forall (acc :: * -> * -> *) aenv t.
ArrayVar aenv t -> IdxA acc aenv t
IA (ArrayVar (aenv, s) (Array sh e)
-> IdxA acc (aenv, s) (Array sh e))
-> ArrayVar (aenv, s) (Array sh e)
-> IdxA acc (aenv, s) (Array sh e)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh e)
-> Idx (aenv, s) (Array sh e) -> ArrayVar (aenv, s) (Array sh e)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh e)
s (Idx (aenv, s) (Array sh e) -> ArrayVar (aenv, s) (Array sh e))
-> Idx (aenv, s) (Array sh e) -> ArrayVar (aenv, s) (Array sh e)
forall a b. (a -> b) -> a -> b
$ Idx aenv (Array sh e) -> Idx (aenv, s) (Array sh e)
forall envs t s env. (envs ~ (env, s)) => Idx env t -> Idx envs t
SuccIdx Idx aenv (Array sh e)
idx
instance SyntacticAcc PreOpenAcc where
avarIn :: forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
avarIn = ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
Avar
accOut :: forall (acc :: * -> * -> *) aenv sh e.
PreOpenAcc acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh e)
accOut = PreOpenAcc acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh e)
forall a. a -> a
id
weakenAcc :: forall (acc :: * -> * -> *) aenv sh e s.
RebuildAcc acc
-> PreOpenAcc acc aenv (Array sh e)
-> PreOpenAcc acc (aenv, s) (Array sh e)
weakenAcc RebuildAcc acc
k = Identity (PreOpenAcc acc (aenv, s) (Array sh e))
-> PreOpenAcc acc (aenv, s) (Array sh e)
forall a. Identity a -> a
runIdentity (Identity (PreOpenAcc acc (aenv, s) (Array sh e))
-> PreOpenAcc acc (aenv, s) (Array sh e))
-> (PreOpenAcc acc aenv (Array sh e)
-> Identity (PreOpenAcc acc (aenv, s) (Array sh e)))
-> PreOpenAcc acc aenv (Array sh e)
-> PreOpenAcc acc (aenv, s) (Array sh e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RebuildAcc acc
-> RebuildAvar Identity IdxA acc aenv (aenv, s)
-> PreOpenAcc acc aenv (Array sh e)
-> Identity (PreOpenAcc acc (aenv, s) (Array sh e))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAcc acc aenv t
-> f (PreOpenAcc acc aenv' t)
rebuildPreOpenAcc RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k (IdxA acc (aenv, s) (Array sh e)
-> Identity (IdxA acc (aenv, s) (Array sh e))
forall a. a -> Identity a
Identity (IdxA acc (aenv, s) (Array sh e)
-> Identity (IdxA acc (aenv, s) (Array sh e)))
-> (ArrayVar aenv (Array sh e) -> IdxA acc (aenv, s) (Array sh e))
-> ArrayVar aenv (Array sh e)
-> Identity (IdxA acc (aenv, s) (Array sh e))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RebuildAcc acc
-> IdxA acc aenv (Array sh e) -> IdxA acc (aenv, s) (Array sh e)
forall (acc :: * -> * -> *) aenv sh e s.
RebuildAcc acc
-> IdxA acc aenv (Array sh e) -> IdxA acc (aenv, s) (Array sh e)
forall (f :: (* -> * -> *) -> * -> * -> *) (acc :: * -> * -> *)
aenv sh e s.
SyntacticAcc f =>
RebuildAcc acc
-> f acc aenv (Array sh e) -> f acc (aenv, s) (Array sh e)
weakenAcc RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k (IdxA acc aenv (Array sh e) -> IdxA acc (aenv, s) (Array sh e))
-> (ArrayVar aenv (Array sh e) -> IdxA acc aenv (Array sh e))
-> ArrayVar aenv (Array sh e)
-> IdxA acc (aenv, s) (Array sh e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ArrayVar aenv (Array sh e) -> IdxA acc aenv (Array sh e)
forall (acc :: * -> * -> *) aenv t.
ArrayVar aenv t -> IdxA acc aenv t
IA)
type RebuildAvar f (fa :: (Type -> Type -> Type) -> Type -> Type -> Type) acc aenv aenv'
= forall sh e. ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
type RebuildEvar f fe env env' aenv' =
forall t'. ExpVar env t' -> f (fe env' aenv' t')
newtype ReindexAvar f aenv aenv' =
ReindexAvar (forall sh e. ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
reindexAvar
:: forall f fa acc aenv aenv'.
(HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAvar f fa acc aenv aenv'
-> ReindexAvar f aenv aenv'
reindexAvar :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv'.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAvar f fa acc aenv aenv' -> ReindexAvar f aenv aenv'
reindexAvar RebuildAvar f fa acc aenv aenv'
v = (forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
forall (f :: * -> *) aenv aenv'.
(forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e)))
-> ReindexAvar f aenv aenv'
ReindexAvar ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
f where
f :: forall sh e. ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
f :: forall sh e.
ArrayVar aenv (Array sh e) -> f (ArrayVar aenv' (Array sh e))
f ArrayVar aenv (Array sh e)
var = fa acc aenv' (Array sh e) -> ArrayVar aenv' (Array sh e)
forall sh e.
fa acc aenv' (Array sh e) -> ArrayVar aenv' (Array sh e)
g (fa acc aenv' (Array sh e) -> ArrayVar aenv' (Array sh e))
-> f (fa acc aenv' (Array sh e)) -> f (ArrayVar aenv' (Array sh e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
v ArrayVar aenv (Array sh e)
var
g :: fa acc aenv' (Array sh e) -> ArrayVar aenv' (Array sh e)
g :: forall sh e.
fa acc aenv' (Array sh e) -> ArrayVar aenv' (Array sh e)
g fa acc aenv' (Array sh e)
fa = case fa acc aenv' (Array sh e) -> PreOpenAcc acc aenv' (Array sh e)
forall (acc :: * -> * -> *) aenv sh e.
fa acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
forall (f :: (* -> * -> *) -> * -> * -> *) (acc :: * -> * -> *)
aenv sh e.
SyntacticAcc f =>
f acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
accOut fa acc aenv' (Array sh e)
fa of
Avar ArrayVar aenv' (Array sh e)
var' -> Var ArrayR aenv' (Array sh e)
ArrayVar aenv' (Array sh e)
var'
PreOpenAcc acc aenv' (Array sh e)
_ -> Format
(Var ArrayR aenv' (Array sh e)) (Var ArrayR aenv' (Array sh e))
-> Var ArrayR aenv' (Array sh e)
forall r a. HasCallStack => Format r a -> a
internalError Format
(Var ArrayR aenv' (Array sh e)) (Var ArrayR aenv' (Array sh e))
"An Avar which was used in an Exp was mapped to an array term other than Avar. This mapping is invalid as an Exp can only contain array variables."
{-# INLINEABLE shiftA #-}
shiftA
:: (HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> ArrayVar (aenv, s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e))
shiftA :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' s sh e.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> ArrayVar (aenv, s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e))
shiftA RebuildAcc acc
_ RebuildAvar f fa acc aenv aenv'
_ (Var ArrayR (Array sh e)
s Idx (aenv, s) (Array sh e)
ZeroIdx) = fa acc (aenv', s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e))
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (fa acc (aenv', s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e)))
-> fa acc (aenv', s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e))
forall a b. (a -> b) -> a -> b
$ ArrayVar (aenv', s) (Array sh e) -> fa acc (aenv', s) (Array sh e)
forall aenv sh e (acc :: * -> * -> *).
ArrayVar aenv (Array sh e) -> fa acc aenv (Array sh e)
forall (f :: (* -> * -> *) -> * -> * -> *) aenv sh e
(acc :: * -> * -> *).
SyntacticAcc f =>
ArrayVar aenv (Array sh e) -> f acc aenv (Array sh e)
avarIn (ArrayVar (aenv', s) (Array sh e)
-> fa acc (aenv', s) (Array sh e))
-> ArrayVar (aenv', s) (Array sh e)
-> fa acc (aenv', s) (Array sh e)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh e)
-> Idx (aenv', s) (Array sh e) -> ArrayVar (aenv', s) (Array sh e)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh e)
s Idx (aenv', s) (Array sh e)
forall envt t env. (envt ~ (env, t)) => Idx envt t
ZeroIdx
shiftA RebuildAcc acc
k RebuildAvar f fa acc aenv aenv'
v (Var ArrayR (Array sh e)
s (SuccIdx Idx env (Array sh e)
ix)) = RebuildAcc acc
-> fa acc aenv' (Array sh e) -> fa acc (aenv', s) (Array sh e)
forall (acc :: * -> * -> *) aenv sh e s.
RebuildAcc acc
-> fa acc aenv (Array sh e) -> fa acc (aenv, s) (Array sh e)
forall (f :: (* -> * -> *) -> * -> * -> *) (acc :: * -> * -> *)
aenv sh e s.
SyntacticAcc f =>
RebuildAcc acc
-> f acc aenv (Array sh e) -> f acc (aenv, s) (Array sh e)
weakenAcc RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k (fa acc aenv' (Array sh e) -> fa acc (aenv', s) (Array sh e))
-> f (fa acc aenv' (Array sh e))
-> f (fa acc (aenv', s) (Array sh e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
v (ArrayR (Array sh e)
-> Idx aenv (Array sh e) -> ArrayVar aenv (Array sh e)
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var ArrayR (Array sh e)
s Idx aenv (Array sh e)
Idx env (Array sh e)
ix)
shiftA'
:: (HasCallStack, Applicative f, SyntacticAcc fa)
=> ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) t aenv1
aenv1' aenv2 aenv2' (acc :: * -> * -> *).
(HasCallStack, Applicative f, SyntacticAcc fa) =>
ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' (LeftHandSideWildcard TupR ArrayR t
_) (LeftHandSideWildcard TupR ArrayR t
_) RebuildAcc acc
_ RebuildAvar f fa acc aenv1 aenv2
v = ArrayVar aenv1 (Array sh e) -> f (fa acc aenv2 (Array sh e))
ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e))
RebuildAvar f fa acc aenv1 aenv2
v
shiftA' (LeftHandSideSingle ArrayR t
_) (LeftHandSideSingle ArrayR t
_) RebuildAcc acc
k RebuildAvar f fa acc aenv1 aenv2
v = RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> ArrayVar (aenv1, t) (Array sh e)
-> f (fa acc (aenv2, t) (Array sh e))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' s sh e.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> ArrayVar (aenv, s) (Array sh e)
-> f (fa acc (aenv', s) (Array sh e))
shiftA RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv1 (Array sh e) -> f (fa acc aenv2 (Array sh e))
RebuildAvar f fa acc aenv1 aenv2
v
shiftA' (LeftHandSidePair LeftHandSide ArrayR v1 aenv1 env'1
a1 LeftHandSide ArrayR v2 env'1 aenv1'
b1) (LeftHandSidePair LeftHandSide ArrayR v1 aenv2 env'1
a2 LeftHandSide ArrayR v2 env'1 aenv2'
b2) RebuildAcc acc
k RebuildAvar f fa acc aenv1 aenv2
v = LeftHandSide ArrayR v2 env'1 aenv1'
-> ALeftHandSide v2 env'1 aenv2'
-> RebuildAcc acc
-> (forall {sh} {e}.
ArrayVar env'1 (Array sh e) -> f (fa acc env'1 (Array sh e)))
-> forall {sh} {e}.
ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) t aenv1
aenv1' aenv2 aenv2' (acc :: * -> * -> *).
(HasCallStack, Applicative f, SyntacticAcc fa) =>
ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' LeftHandSide ArrayR v2 env'1 aenv1'
b1 ALeftHandSide v2 env'1 aenv2'
LeftHandSide ArrayR v2 env'1 aenv2'
b2 RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ((forall {sh} {e}.
ArrayVar env'1 (Array sh e) -> f (fa acc env'1 (Array sh e)))
-> forall {sh} {e}.
ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e)))
-> (forall {sh} {e}.
ArrayVar env'1 (Array sh e) -> f (fa acc env'1 (Array sh e)))
-> forall {sh} {e}.
ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e))
forall a b. (a -> b) -> a -> b
$ LeftHandSide ArrayR v1 aenv1 env'1
-> ALeftHandSide v1 aenv2 env'1
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> forall {sh} {e}.
ArrayVar env'1 (Array sh e) -> f (fa acc env'1 (Array sh e))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) t aenv1
aenv1' aenv2 aenv2' (acc :: * -> * -> *).
(HasCallStack, Applicative f, SyntacticAcc fa) =>
ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' LeftHandSide ArrayR v1 aenv1 env'1
a1 ALeftHandSide v1 aenv2 env'1
LeftHandSide ArrayR v1 aenv2 env'1
a2 RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv1 (Array sh e) -> f (fa acc aenv2 (Array sh e))
RebuildAvar f fa acc aenv1 aenv2
v
shiftA' ALeftHandSide t aenv1 aenv1'
_ ALeftHandSide t aenv2 aenv2'
_ RebuildAcc acc
_ RebuildAvar f fa acc aenv1 aenv2
_ = Format
(ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e)))
(ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e)))
-> ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e))
forall r a. HasCallStack => Format r a -> a
internalError Format
(ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e)))
(ArrayVar aenv1' (Array sh e) -> f (fa acc aenv2' (Array sh e)))
"left hand sides do not match"
{-# INLINEABLE rebuildOpenAcc #-}
rebuildOpenAcc
:: (HasCallStack, Applicative f, SyntacticAcc fa)
=> (forall sh e. ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv t
-> f (OpenAcc aenv' t)
rebuildOpenAcc :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv t -> f (OpenAcc aenv' t)
rebuildOpenAcc forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e))
av (OpenAcc PreOpenAcc OpenAcc aenv t
acc) = PreOpenAcc OpenAcc aenv' t -> OpenAcc aenv' t
forall aenv t. PreOpenAcc OpenAcc aenv t -> OpenAcc aenv t
OpenAcc (PreOpenAcc OpenAcc aenv' t -> OpenAcc aenv' t)
-> f (PreOpenAcc OpenAcc aenv' t) -> f (OpenAcc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAcc OpenAcc
-> (forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> PreOpenAcc OpenAcc aenv t
-> f (PreOpenAcc OpenAcc aenv' t)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAcc acc aenv t
-> f (PreOpenAcc acc aenv' t)
rebuildPreOpenAcc (forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv a -> f (OpenAcc aenv' a)
RebuildAcc OpenAcc
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) aenv
aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
(forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e)))
-> OpenAcc aenv t -> f (OpenAcc aenv' t)
rebuildOpenAcc ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e))
forall sh e.
ArrayVar aenv (Array sh e) -> f (fa OpenAcc aenv' (Array sh e))
av PreOpenAcc OpenAcc aenv t
acc
{-# INLINEABLE rebuildPreOpenAcc #-}
rebuildPreOpenAcc
:: (HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAcc acc aenv t
-> f (PreOpenAcc acc aenv' t)
rebuildPreOpenAcc :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAcc acc aenv t
-> f (PreOpenAcc acc aenv' t)
rebuildPreOpenAcc RebuildAcc acc
k RebuildAvar f fa acc aenv aenv'
av PreOpenAcc acc aenv t
acc =
case PreOpenAcc acc aenv t
acc of
Use ArrayR (Array sh e)
repr Array sh e
a -> PreOpenAcc acc aenv' t -> f (PreOpenAcc acc aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PreOpenAcc acc aenv' t -> f (PreOpenAcc acc aenv' t))
-> PreOpenAcc acc aenv' t -> f (PreOpenAcc acc aenv' t)
forall a b. (a -> b) -> a -> b
$ ArrayR (Array sh e)
-> Array sh e -> PreOpenAcc acc aenv' (Array sh e)
forall sh e (acc :: * -> * -> *) aenv.
ArrayR (Array sh e)
-> Array sh e -> PreOpenAcc acc aenv (Array sh e)
Use ArrayR (Array sh e)
repr Array sh e
a
Alet ALeftHandSide bndArrs aenv aenv'
lhs acc aenv bndArrs
a acc aenv' t
b -> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> ALeftHandSide bndArrs aenv aenv'
-> acc aenv bndArrs
-> acc aenv' t
-> f (PreOpenAcc acc aenv' t)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv1 aenv1' aenv2 bndArrs arrs.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> ALeftHandSide bndArrs aenv1 aenv1'
-> acc aenv1 bndArrs
-> acc aenv1' arrs
-> f (PreOpenAcc acc aenv2 arrs)
rebuildAlet RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av ALeftHandSide bndArrs aenv aenv'
lhs acc aenv bndArrs
a acc aenv' t
b
Avar ArrayVar aenv (Array sh e)
ix -> fa acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t
fa acc aenv' (Array sh e) -> PreOpenAcc acc aenv' (Array sh e)
forall (acc :: * -> * -> *) aenv sh e.
fa acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
forall (f :: (* -> * -> *) -> * -> * -> *) (acc :: * -> * -> *)
aenv sh e.
SyntacticAcc f =>
f acc aenv (Array sh e) -> PreOpenAcc acc aenv (Array sh e)
accOut (fa acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (fa acc aenv' (Array sh e)) -> f (PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av ArrayVar aenv (Array sh e)
ix
Apair acc aenv as
as acc aenv bs
bs -> acc aenv' as -> acc aenv' bs -> PreOpenAcc acc aenv' t
acc aenv' as -> acc aenv' bs -> PreOpenAcc acc aenv' (as, bs)
forall (acc :: * -> * -> *) aenv as bs.
acc aenv as -> acc aenv bs -> PreOpenAcc acc aenv (as, bs)
Apair (acc aenv' as -> acc aenv' bs -> PreOpenAcc acc aenv' t)
-> f (acc aenv' as) -> f (acc aenv' bs -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv aenv' -> acc aenv as -> f (acc aenv' as)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv as
as f (acc aenv' bs -> PreOpenAcc acc aenv' t)
-> f (acc aenv' bs) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv' -> acc aenv bs -> f (acc aenv' bs)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv bs
bs
PreOpenAcc acc aenv t
Anil -> PreOpenAcc acc aenv' t -> f (PreOpenAcc acc aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure PreOpenAcc acc aenv' t
PreOpenAcc acc aenv' ()
forall (acc :: * -> * -> *) aenv. PreOpenAcc acc aenv ()
Anil
Atrace Message arrs1
msg acc aenv arrs1
as acc aenv t
bs -> Message arrs1
-> acc aenv' arrs1 -> acc aenv' t -> PreOpenAcc acc aenv' t
forall arrs1 (acc :: * -> * -> *) aenv a.
Message arrs1
-> acc aenv arrs1 -> acc aenv a -> PreOpenAcc acc aenv a
Atrace Message arrs1
msg (acc aenv' arrs1 -> acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (acc aenv' arrs1) -> f (acc aenv' t -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv aenv'
-> acc aenv arrs1 -> f (acc aenv' arrs1)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv arrs1
as f (acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (acc aenv' t) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv' -> acc aenv t -> f (acc aenv' t)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv t
bs
Apply ArraysR t
repr PreOpenAfun acc aenv (arrs1 -> t)
f acc aenv arrs1
a -> ArraysR t
-> PreOpenAfun acc aenv' (arrs1 -> t)
-> acc aenv' arrs1
-> PreOpenAcc acc aenv' t
forall a (acc :: * -> * -> *) aenv arrs1.
ArraysR a
-> PreOpenAfun acc aenv (arrs1 -> a)
-> acc aenv arrs1
-> PreOpenAcc acc aenv a
Apply ArraysR t
repr (PreOpenAfun acc aenv' (arrs1 -> t)
-> acc aenv' arrs1 -> PreOpenAcc acc aenv' t)
-> f (PreOpenAfun acc aenv' (arrs1 -> t))
-> f (acc aenv' arrs1 -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv (arrs1 -> t)
-> f (PreOpenAfun acc aenv' (arrs1 -> t))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av PreOpenAfun acc aenv (arrs1 -> t)
f f (acc aenv' arrs1 -> PreOpenAcc acc aenv' t)
-> f (acc aenv' arrs1) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv arrs1 -> f (acc aenv' arrs1)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv arrs1
a
Acond Exp aenv TAG
p acc aenv t
t acc aenv t
e -> Exp aenv' TAG
-> acc aenv' t -> acc aenv' t -> PreOpenAcc acc aenv' t
forall aenv (acc :: * -> * -> *) a.
Exp aenv TAG -> acc aenv a -> acc aenv a -> PreOpenAcc acc aenv a
Acond (Exp aenv' TAG
-> acc aenv' t -> acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' TAG)
-> f (acc aenv' t -> acc aenv' t -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv TAG -> f (Exp aenv' TAG)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv TAG
p f (acc aenv' t -> acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (acc aenv' t) -> f (acc aenv' t -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv' -> acc aenv t -> f (acc aenv' t)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv t
t f (acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (acc aenv' t) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv' -> acc aenv t -> f (acc aenv' t)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv t
e
Awhile PreOpenAfun acc aenv (t -> Scalar TAG)
p PreOpenAfun acc aenv (t -> t)
f acc aenv t
a -> PreOpenAfun acc aenv' (t -> Scalar TAG)
-> PreOpenAfun acc aenv' (t -> t)
-> acc aenv' t
-> PreOpenAcc acc aenv' t
forall (acc :: * -> * -> *) aenv a.
PreOpenAfun acc aenv (a -> Scalar TAG)
-> PreOpenAfun acc aenv (a -> a)
-> acc aenv a
-> PreOpenAcc acc aenv a
Awhile (PreOpenAfun acc aenv' (t -> Scalar TAG)
-> PreOpenAfun acc aenv' (t -> t)
-> acc aenv' t
-> PreOpenAcc acc aenv' t)
-> f (PreOpenAfun acc aenv' (t -> Scalar TAG))
-> f (PreOpenAfun acc aenv' (t -> t)
-> acc aenv' t -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv (t -> Scalar TAG)
-> f (PreOpenAfun acc aenv' (t -> Scalar TAG))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av PreOpenAfun acc aenv (t -> Scalar TAG)
p f (PreOpenAfun acc aenv' (t -> t)
-> acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (PreOpenAfun acc aenv' (t -> t))
-> f (acc aenv' t -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv (t -> t)
-> f (PreOpenAfun acc aenv' (t -> t))
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av PreOpenAfun acc aenv (t -> t)
f f (acc aenv' t -> PreOpenAcc acc aenv' t)
-> f (acc aenv' t) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv' -> acc aenv t -> f (acc aenv' t)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv t
a
Unit TypeR e
tp Exp aenv e
e -> TypeR e -> Exp aenv' e -> PreOpenAcc acc aenv' (Array () e)
forall e aenv (acc :: * -> * -> *).
TypeR e -> Exp aenv e -> PreOpenAcc acc aenv (Array () e)
Unit TypeR e
tp (Exp aenv' e -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' e) -> f (PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv e -> f (Exp aenv' e)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv e
e
Reshape ShapeR sh
shr Exp aenv sh
e acc aenv (Array sh' e)
a -> ShapeR sh
-> Exp aenv' sh
-> acc aenv' (Array sh' e)
-> PreOpenAcc acc aenv' (Array sh e)
forall sh aenv (acc :: * -> * -> *) sh' e.
ShapeR sh
-> Exp aenv sh
-> acc aenv (Array sh' e)
-> PreOpenAcc acc aenv (Array sh e)
Reshape ShapeR sh
shr (Exp aenv' sh -> acc aenv' (Array sh' e) -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' sh)
-> f (acc aenv' (Array sh' e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv sh -> f (Exp aenv' sh)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv sh
e f (acc aenv' (Array sh' e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh' e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh' e) -> f (acc aenv' (Array sh' e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh' e)
a
Generate ArrayR (Array sh e)
repr Exp aenv sh
e Fun aenv (sh -> e)
f -> ArrayR (Array sh e)
-> Exp aenv' sh
-> Fun aenv' (sh -> e)
-> PreOpenAcc acc aenv' (Array sh e)
forall sh e aenv (acc :: * -> * -> *).
ArrayR (Array sh e)
-> Exp aenv sh
-> Fun aenv (sh -> e)
-> PreOpenAcc acc aenv (Array sh e)
Generate ArrayR (Array sh e)
repr (Exp aenv' sh -> Fun aenv' (sh -> e) -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' sh)
-> f (Fun aenv' (sh -> e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv sh -> f (Exp aenv' sh)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv sh
e f (Fun aenv' (sh -> e) -> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (sh -> e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (sh -> e)
-> f (Fun aenv' (sh -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (sh -> e)
f
Transform ArrayR (Array sh' b)
repr Exp aenv sh'
sh Fun aenv (sh' -> sh)
ix Fun aenv (a1 -> b)
f acc aenv (Array sh a1)
a -> ArrayR (Array sh' b)
-> Exp aenv' sh'
-> Fun aenv' (sh' -> sh)
-> Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1)
-> PreOpenAcc acc aenv' (Array sh' b)
forall sh' b aenv sh a1 (acc :: * -> * -> *).
ArrayR (Array sh' b)
-> Exp aenv sh'
-> Fun aenv (sh' -> sh)
-> Fun aenv (a1 -> b)
-> acc aenv (Array sh a1)
-> PreOpenAcc acc aenv (Array sh' b)
Transform ArrayR (Array sh' b)
repr (Exp aenv' sh'
-> Fun aenv' (sh' -> sh)
-> Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1)
-> PreOpenAcc acc aenv' t)
-> f (Exp aenv' sh')
-> f (Fun aenv' (sh' -> sh)
-> Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1)
-> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv sh' -> f (Exp aenv' sh')
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv sh'
sh f (Fun aenv' (sh' -> sh)
-> Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (sh' -> sh))
-> f (Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (sh' -> sh)
-> f (Fun aenv' (sh' -> sh))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (sh' -> sh)
ix f (Fun aenv' (a1 -> b)
-> acc aenv' (Array sh a1) -> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (a1 -> b))
-> f (acc aenv' (Array sh a1) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (a1 -> b)
-> f (Fun aenv' (a1 -> b))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (a1 -> b)
f f (acc aenv' (Array sh a1) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh a1)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh a1) -> f (acc aenv' (Array sh a1))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh a1)
a
Replicate SliceIndex slix sl co sh
sl Exp aenv slix
slix acc aenv (Array sl e)
a -> SliceIndex slix sl co sh
-> Exp aenv' slix
-> acc aenv' (Array sl e)
-> PreOpenAcc acc aenv' (Array sh e)
forall slix sl co sh aenv (acc :: * -> * -> *) e.
SliceIndex slix sl co sh
-> Exp aenv slix
-> acc aenv (Array sl e)
-> PreOpenAcc acc aenv (Array sh e)
Replicate SliceIndex slix sl co sh
sl (Exp aenv' slix
-> acc aenv' (Array sl e) -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' slix)
-> f (acc aenv' (Array sl e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv slix -> f (Exp aenv' slix)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv slix
slix f (acc aenv' (Array sl e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sl e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sl e) -> f (acc aenv' (Array sl e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sl e)
a
Slice SliceIndex slix sl co sh
sl acc aenv (Array sh e)
a Exp aenv slix
slix -> SliceIndex slix sl co sh
-> acc aenv' (Array sh e)
-> Exp aenv' slix
-> PreOpenAcc acc aenv' (Array sl e)
forall slix sl co sh (acc :: * -> * -> *) aenv e.
SliceIndex slix sl co sh
-> acc aenv (Array sh e)
-> Exp aenv slix
-> PreOpenAcc acc aenv (Array sl e)
Slice SliceIndex slix sl co sh
sl (acc aenv' (Array sh e)
-> Exp aenv' slix -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e))
-> f (Exp aenv' slix -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e) -> f (acc aenv' (Array sh e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e)
a f (Exp aenv' slix -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' slix) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv slix -> f (Exp aenv' slix)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv slix
slix
Map TypeR e'
tp Fun aenv (e -> e')
f acc aenv (Array sh e)
a -> TypeR e'
-> Fun aenv' (e -> e')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' (Array sh e')
forall e' aenv e (acc :: * -> * -> *) sh.
TypeR e'
-> Fun aenv (e -> e')
-> acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh e')
Map TypeR e'
tp (Fun aenv' (e -> e')
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e'))
-> f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e')
-> f (Fun aenv' (e -> e'))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e')
f f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e) -> f (acc aenv' (Array sh e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e)
a
ZipWith TypeR e3
tp Fun aenv (e1 -> e2 -> e3)
f acc aenv (Array sh e1)
a1 acc aenv (Array sh e2)
a2 -> TypeR e3
-> Fun aenv' (e1 -> e2 -> e3)
-> acc aenv' (Array sh e1)
-> acc aenv' (Array sh e2)
-> PreOpenAcc acc aenv' (Array sh e3)
forall e3 aenv e1 e2 (acc :: * -> * -> *) sh.
TypeR e3
-> Fun aenv (e1 -> e2 -> e3)
-> acc aenv (Array sh e1)
-> acc aenv (Array sh e2)
-> PreOpenAcc acc aenv (Array sh e3)
ZipWith TypeR e3
tp (Fun aenv' (e1 -> e2 -> e3)
-> acc aenv' (Array sh e1)
-> acc aenv' (Array sh e2)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e1 -> e2 -> e3))
-> f (acc aenv' (Array sh e1)
-> acc aenv' (Array sh e2) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e1 -> e2 -> e3)
-> f (Fun aenv' (e1 -> e2 -> e3))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e1 -> e2 -> e3)
f f (acc aenv' (Array sh e1)
-> acc aenv' (Array sh e2) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e1))
-> f (acc aenv' (Array sh e2) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e1) -> f (acc aenv' (Array sh e1))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e1)
a1 f (acc aenv' (Array sh e2) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e2)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e2) -> f (acc aenv' (Array sh e2))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e2)
a2
Fold Fun aenv (e -> e -> e)
f Maybe (Exp aenv e)
z acc aenv (Array (sh, Int) e)
a -> Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' t
Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' (Array sh e)
forall aenv e (acc :: * -> * -> *) sh.
Fun aenv (e -> e -> e)
-> Maybe (Exp aenv e)
-> acc aenv (Array (sh, Int) e)
-> PreOpenAcc acc aenv (Array sh e)
Fold (Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e -> e))
-> f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e -> e)
-> f (Fun aenv' (e -> e -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e -> e)
f f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (Maybe (Exp aenv' e))
-> f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (Exp aenv e)
-> f (Maybe (Exp aenv' e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Maybe (Exp aenv e)
z f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array (sh, Int) e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array (sh, Int) e)
-> f (acc aenv' (Array (sh, Int) e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array (sh, Int) e)
a
FoldSeg IntegralType i
itp Fun aenv (e -> e -> e)
f Maybe (Exp aenv e)
z acc aenv (Array (sh, Int) e)
a acc aenv (Segments i)
s -> IntegralType i
-> Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i)
-> PreOpenAcc acc aenv' (Array (sh, Int) e)
forall i aenv e (acc :: * -> * -> *) sh.
IntegralType i
-> Fun aenv (e -> e -> e)
-> Maybe (Exp aenv e)
-> acc aenv (Array (sh, Int) e)
-> acc aenv (Segments i)
-> PreOpenAcc acc aenv (Array (sh, Int) e)
FoldSeg IntegralType i
itp (Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e -> e))
-> f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i)
-> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e -> e)
-> f (Fun aenv' (e -> e -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e -> e)
f f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i)
-> PreOpenAcc acc aenv' t)
-> f (Maybe (Exp aenv' e))
-> f (acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (Exp aenv e)
-> f (Maybe (Exp aenv' e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Maybe (Exp aenv e)
z f (acc aenv' (Array (sh, Int) e)
-> acc aenv' (Segments i) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array (sh, Int) e))
-> f (acc aenv' (Segments i) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array (sh, Int) e)
-> f (acc aenv' (Array (sh, Int) e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array (sh, Int) e)
a f (acc aenv' (Segments i) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Segments i)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Segments i) -> f (acc aenv' (Segments i))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Segments i)
s
Scan Direction
d Fun aenv (e -> e -> e)
f Maybe (Exp aenv e)
z acc aenv (Array (sh, Int) e)
a -> Direction
-> Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' (Array (sh, Int) e)
forall aenv e (acc :: * -> * -> *) sh.
Direction
-> Fun aenv (e -> e -> e)
-> Maybe (Exp aenv e)
-> acc aenv (Array (sh, Int) e)
-> PreOpenAcc acc aenv (Array (sh, Int) e)
Scan Direction
d (Fun aenv' (e -> e -> e)
-> Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e -> e))
-> f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e -> e)
-> f (Fun aenv' (e -> e -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e -> e)
f f (Maybe (Exp aenv' e)
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (Maybe (Exp aenv' e))
-> f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (Exp aenv e)
-> f (Maybe (Exp aenv' e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> Maybe (OpenExp env aenv t)
-> f (Maybe (OpenExp env' aenv' t))
rebuildMaybeExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Maybe (Exp aenv e)
z f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array (sh, Int) e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array (sh, Int) e)
-> f (acc aenv' (Array (sh, Int) e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array (sh, Int) e)
a
Scan' Direction
d Fun aenv (e -> e -> e)
f Exp aenv e
z acc aenv (Array (sh, Int) e)
a -> Direction
-> Fun aenv' (e -> e -> e)
-> Exp aenv' e
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' (Array (sh, Int) e, Array sh e)
forall aenv e (acc :: * -> * -> *) sh.
Direction
-> Fun aenv (e -> e -> e)
-> Exp aenv e
-> acc aenv (Array (sh, Int) e)
-> PreOpenAcc acc aenv (Array (sh, Int) e, Array sh e)
Scan' Direction
d (Fun aenv' (e -> e -> e)
-> Exp aenv' e
-> acc aenv' (Array (sh, Int) e)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e -> e))
-> f (Exp aenv' e
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e -> e)
-> f (Fun aenv' (e -> e -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e -> e)
f f (Exp aenv' e
-> acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (Exp aenv' e)
-> f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv e -> f (Exp aenv' e)
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv e
z f (acc aenv' (Array (sh, Int) e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array (sh, Int) e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array (sh, Int) e)
-> f (acc aenv' (Array (sh, Int) e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array (sh, Int) e)
a
Permute Fun aenv (e -> e -> e)
f1 acc aenv (Array sh' e)
a1 Fun aenv (sh -> PrimMaybe sh')
f2 acc aenv (Array sh e)
a2 -> Fun aenv' (e -> e -> e)
-> acc aenv' (Array sh' e)
-> Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t
Fun aenv' (e -> e -> e)
-> acc aenv' (Array sh' e)
-> Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' (Array sh' e)
forall aenv e (acc :: * -> * -> *) sh' sh.
Fun aenv (e -> e -> e)
-> acc aenv (Array sh' e)
-> Fun aenv (sh -> PrimMaybe sh')
-> acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh' e)
Permute (Fun aenv' (e -> e -> e)
-> acc aenv' (Array sh' e)
-> Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (e -> e -> e))
-> f (acc aenv' (Array sh' e)
-> Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (e -> e -> e)
-> f (Fun aenv' (e -> e -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (e -> e -> e)
f1 f (acc aenv' (Array sh' e)
-> Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh' e))
-> f (Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh' e) -> f (acc aenv' (Array sh' e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh' e)
a1 f (Fun aenv' (sh -> PrimMaybe sh')
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (sh -> PrimMaybe sh'))
-> f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (sh -> PrimMaybe sh')
-> f (Fun aenv' (sh -> PrimMaybe sh'))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (sh -> PrimMaybe sh')
f2 f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e) -> f (acc aenv' (Array sh e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e)
a2
Backpermute ShapeR sh'
shr Exp aenv sh'
sh Fun aenv (sh' -> sh)
f acc aenv (Array sh e)
a -> ShapeR sh'
-> Exp aenv' sh'
-> Fun aenv' (sh' -> sh)
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' (Array sh' e)
forall sh' aenv sh (acc :: * -> * -> *) e.
ShapeR sh'
-> Exp aenv sh'
-> Fun aenv (sh' -> sh)
-> acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh' e)
Backpermute ShapeR sh'
shr (Exp aenv' sh'
-> Fun aenv' (sh' -> sh)
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t)
-> f (Exp aenv' sh')
-> f (Fun aenv' (sh' -> sh)
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv' -> Exp aenv sh' -> f (Exp aenv' sh')
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenExp env aenv t
-> f (OpenExp env' aenv' t)
rebuildOpenExp (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Exp aenv sh'
sh f (Fun aenv' (sh' -> sh)
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (sh' -> sh))
-> f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (sh' -> sh)
-> f (Fun aenv' (sh' -> sh))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (sh' -> sh)
f f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e) -> f (acc aenv' (Array sh e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e)
a
Stencil StencilR sh e stencil
sr TypeR e'
tp Fun aenv (stencil -> e')
f Boundary aenv (Array sh e)
b acc aenv (Array sh e)
a -> StencilR sh e stencil
-> TypeR e'
-> Fun aenv' (stencil -> e')
-> Boundary aenv' (Array sh e)
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' (Array sh e')
forall sh e stencil e' aenv (acc :: * -> * -> *).
StencilR sh e stencil
-> TypeR e'
-> Fun aenv (stencil -> e')
-> Boundary aenv (Array sh e)
-> acc aenv (Array sh e)
-> PreOpenAcc acc aenv (Array sh e')
Stencil StencilR sh e stencil
sr TypeR e'
tp (Fun aenv' (stencil -> e')
-> Boundary aenv' (Array sh e)
-> acc aenv' (Array sh e)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (stencil -> e'))
-> f (Boundary aenv' (Array sh e)
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (stencil -> e')
-> f (Fun aenv' (stencil -> e'))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (stencil -> e')
f f (Boundary aenv' (Array sh e)
-> acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (Boundary aenv' (Array sh e))
-> f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReindexAvar f aenv aenv'
-> Boundary aenv (Array sh e) -> f (Boundary aenv' (Array sh e))
forall (f :: * -> *) aenv aenv' t.
Applicative f =>
ReindexAvar f aenv aenv' -> Boundary aenv t -> f (Boundary aenv' t)
rebuildBoundary ReindexAvar f aenv aenv'
av' Boundary aenv (Array sh e)
b f (acc aenv' (Array sh e) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh e)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh e) -> f (acc aenv' (Array sh e))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh e)
a
Stencil2 StencilR sh a1 stencil1
s1 StencilR sh b stencil2
s2 TypeR c
tp Fun aenv (stencil1 -> stencil2 -> c)
f Boundary aenv (Array sh a1)
b1 acc aenv (Array sh a1)
a1 Boundary aenv (Array sh b)
b2 acc aenv (Array sh b)
a2
-> StencilR sh a1 stencil1
-> StencilR sh b stencil2
-> TypeR c
-> Fun aenv' (stencil1 -> stencil2 -> c)
-> Boundary aenv' (Array sh a1)
-> acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' (Array sh c)
forall sh a1 stencil1 b stencil2 c aenv (acc :: * -> * -> *).
StencilR sh a1 stencil1
-> StencilR sh b stencil2
-> TypeR c
-> Fun aenv (stencil1 -> stencil2 -> c)
-> Boundary aenv (Array sh a1)
-> acc aenv (Array sh a1)
-> Boundary aenv (Array sh b)
-> acc aenv (Array sh b)
-> PreOpenAcc acc aenv (Array sh c)
Stencil2 StencilR sh a1 stencil1
s1 StencilR sh b stencil2
s2 TypeR c
tp (Fun aenv' (stencil1 -> stencil2 -> c)
-> Boundary aenv' (Array sh a1)
-> acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' t)
-> f (Fun aenv' (stencil1 -> stencil2 -> c))
-> f (Boundary aenv' (Array sh a1)
-> acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (stencil1 -> stencil2 -> c)
-> f (Fun aenv' (stencil1 -> stencil2 -> c))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av' Fun aenv (stencil1 -> stencil2 -> c)
f f (Boundary aenv' (Array sh a1)
-> acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' t)
-> f (Boundary aenv' (Array sh a1))
-> f (acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReindexAvar f aenv aenv'
-> Boundary aenv (Array sh a1) -> f (Boundary aenv' (Array sh a1))
forall (f :: * -> *) aenv aenv' t.
Applicative f =>
ReindexAvar f aenv aenv' -> Boundary aenv t -> f (Boundary aenv' t)
rebuildBoundary ReindexAvar f aenv aenv'
av' Boundary aenv (Array sh a1)
b1 f (acc aenv' (Array sh a1)
-> Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b)
-> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh a1))
-> f (Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh a1) -> f (acc aenv' (Array sh a1))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh a1)
a1 f (Boundary aenv' (Array sh b)
-> acc aenv' (Array sh b) -> PreOpenAcc acc aenv' t)
-> f (Boundary aenv' (Array sh b))
-> f (acc aenv' (Array sh b) -> PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReindexAvar f aenv aenv'
-> Boundary aenv (Array sh b) -> f (Boundary aenv' (Array sh b))
forall (f :: * -> *) aenv aenv' t.
Applicative f =>
ReindexAvar f aenv aenv' -> Boundary aenv t -> f (Boundary aenv' t)
rebuildBoundary ReindexAvar f aenv aenv'
av' Boundary aenv (Array sh b)
b2 f (acc aenv' (Array sh b) -> PreOpenAcc acc aenv' t)
-> f (acc aenv' (Array sh b)) -> f (PreOpenAcc acc aenv' t)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv aenv'
-> acc aenv (Array sh b) -> f (acc aenv' (Array sh b))
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv (Array sh b)
a2
Aforeign ArraysR t
repr asm (as -> t)
ff PreAfun acc (as -> t)
afun acc aenv as
as -> ArraysR t
-> asm (as -> t)
-> PreAfun acc (as -> t)
-> acc aenv' as
-> PreOpenAcc acc aenv' t
forall (asm :: * -> *) a as (acc :: * -> * -> *) aenv.
Foreign asm =>
ArraysR a
-> asm (as -> a)
-> PreAfun acc (as -> a)
-> acc aenv as
-> PreOpenAcc acc aenv a
Aforeign ArraysR t
repr asm (as -> t)
ff PreAfun acc (as -> t)
afun (acc aenv' as -> PreOpenAcc acc aenv' t)
-> f (acc aenv' as) -> f (PreOpenAcc acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv aenv' -> acc aenv as -> f (acc aenv' as)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv as
as
where
av' :: ReindexAvar f aenv aenv'
av' = RebuildAvar f fa acc aenv aenv' -> ReindexAvar f aenv aenv'
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv'.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAvar f fa acc aenv aenv' -> ReindexAvar f aenv aenv'
reindexAvar ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av
{-# INLINEABLE rebuildAfun #-}
rebuildAfun
:: (HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAcc acc
k RebuildAvar f fa acc aenv aenv'
av (Abody acc aenv t
b) = acc aenv' t -> PreOpenAfun acc aenv' t
forall (acc :: * -> * -> *) aenv t.
acc aenv t -> PreOpenAfun acc aenv t
Abody (acc aenv' t -> PreOpenAfun acc aenv' t)
-> f (acc aenv' t) -> f (PreOpenAfun acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv aenv' -> acc aenv t -> f (acc aenv' t)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av acc aenv t
b
rebuildAfun RebuildAcc acc
k RebuildAvar f fa acc aenv aenv'
av (Alam ALeftHandSide a aenv aenv'
lhs1 PreOpenAfun acc aenv' t1
f)
| Exists LeftHandSide ArrayR a aenv' a
lhs2 <- ALeftHandSide a aenv aenv' -> Exists (LeftHandSide ArrayR a aenv')
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ALeftHandSide a aenv aenv'
lhs1
= LeftHandSide ArrayR a aenv' a
-> PreOpenAfun acc a t1 -> PreOpenAfun acc aenv' (a -> t1)
forall a aenv aenv' (acc :: * -> * -> *) t1.
ALeftHandSide a aenv aenv'
-> PreOpenAfun acc aenv' t1 -> PreOpenAfun acc aenv (a -> t1)
Alam LeftHandSide ArrayR a aenv' a
lhs2 (PreOpenAfun acc a t1 -> PreOpenAfun acc aenv' t)
-> f (PreOpenAfun acc a t1) -> f (PreOpenAfun acc aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAcc acc
-> RebuildAvar f fa acc aenv' a
-> PreOpenAfun acc aenv' t1
-> f (PreOpenAfun acc a t1)
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv aenv' t.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> PreOpenAfun acc aenv t
-> f (PreOpenAfun acc aenv' t)
rebuildAfun RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k (ALeftHandSide a aenv aenv'
-> LeftHandSide ArrayR a aenv' a
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv aenv'
-> RebuildAvar f fa acc aenv' a
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) t aenv1
aenv1' aenv2 aenv2' (acc :: * -> * -> *).
(HasCallStack, Applicative f, SyntacticAcc fa) =>
ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' ALeftHandSide a aenv aenv'
lhs1 LeftHandSide ArrayR a aenv' a
lhs2 RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k ArrayVar aenv (Array sh e) -> f (fa acc aenv' (Array sh e))
RebuildAvar f fa acc aenv aenv'
av) PreOpenAfun acc aenv' t1
f
rebuildAlet
:: forall f fa acc aenv1 aenv1' aenv2 bndArrs arrs. (HasCallStack, Applicative f, SyntacticAcc fa)
=> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> ALeftHandSide bndArrs aenv1 aenv1'
-> acc aenv1 bndArrs
-> acc aenv1' arrs
-> f (PreOpenAcc acc aenv2 arrs)
rebuildAlet :: forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *)
(acc :: * -> * -> *) aenv1 aenv1' aenv2 bndArrs arrs.
(HasCallStack, Applicative f, SyntacticAcc fa) =>
RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> ALeftHandSide bndArrs aenv1 aenv1'
-> acc aenv1 bndArrs
-> acc aenv1' arrs
-> f (PreOpenAcc acc aenv2 arrs)
rebuildAlet RebuildAcc acc
k RebuildAvar f fa acc aenv1 aenv2
av ALeftHandSide bndArrs aenv1 aenv1'
lhs1 acc aenv1 bndArrs
bind1 acc aenv1' arrs
body1
| Exists LeftHandSide ArrayR bndArrs aenv2 a
lhs2 <- ALeftHandSide bndArrs aenv1 aenv1'
-> Exists (LeftHandSide ArrayR bndArrs aenv2)
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS ALeftHandSide bndArrs aenv1 aenv1'
lhs1
= LeftHandSide ArrayR bndArrs aenv2 a
-> acc aenv2 bndArrs -> acc a arrs -> PreOpenAcc acc aenv2 arrs
forall bndArrs aenv aenv' (acc :: * -> * -> *) a.
ALeftHandSide bndArrs aenv aenv'
-> acc aenv bndArrs -> acc aenv' a -> PreOpenAcc acc aenv a
Alet LeftHandSide ArrayR bndArrs aenv2 a
lhs2 (acc aenv2 bndArrs -> acc a arrs -> PreOpenAcc acc aenv2 arrs)
-> f (acc aenv2 bndArrs)
-> f (acc a arrs -> PreOpenAcc acc aenv2 arrs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildAvar f fa acc aenv1 aenv2
-> acc aenv1 bndArrs -> f (acc aenv2 bndArrs)
RebuildAcc acc
k ArrayVar aenv1 (Array sh e) -> f (fa acc aenv2 (Array sh e))
RebuildAvar f fa acc aenv1 aenv2
av acc aenv1 bndArrs
bind1 f (acc a arrs -> PreOpenAcc acc aenv2 arrs)
-> f (acc a arrs) -> f (PreOpenAcc acc aenv2 arrs)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> RebuildAvar f fa acc aenv1' a -> acc aenv1' arrs -> f (acc a arrs)
RebuildAcc acc
k (ALeftHandSide bndArrs aenv1 aenv1'
-> LeftHandSide ArrayR bndArrs aenv2 a
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' a
forall (f :: * -> *) (fa :: (* -> * -> *) -> * -> * -> *) t aenv1
aenv1' aenv2 aenv2' (acc :: * -> * -> *).
(HasCallStack, Applicative f, SyntacticAcc fa) =>
ALeftHandSide t aenv1 aenv1'
-> ALeftHandSide t aenv2 aenv2'
-> RebuildAcc acc
-> RebuildAvar f fa acc aenv1 aenv2
-> RebuildAvar f fa acc aenv1' aenv2'
shiftA' ALeftHandSide bndArrs aenv1 aenv1'
lhs1 LeftHandSide ArrayR bndArrs aenv2 a
lhs2 RebuildAvar f fa acc aenv aenv' -> acc aenv a -> f (acc aenv' a)
RebuildAcc acc
k Var ArrayR aenv1 (Array sh e) -> f (fa acc aenv2 (Array sh e))
RebuildAvar f fa acc aenv1 aenv2
av) acc aenv1' arrs
body1
{-# INLINEABLE rebuildLHS #-}
rebuildLHS :: LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS :: forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS (LeftHandSideWildcard TupR s t
r) = LeftHandSide s t aenv2 aenv2 -> Exists (LeftHandSide s t aenv2)
forall (f :: * -> *) a. f a -> Exists f
Exists (LeftHandSide s t aenv2 aenv2 -> Exists (LeftHandSide s t aenv2))
-> LeftHandSide s t aenv2 aenv2 -> Exists (LeftHandSide s t aenv2)
forall a b. (a -> b) -> a -> b
$ TupR s t -> LeftHandSide s t aenv2 aenv2
forall (s :: * -> *) v env. TupR s v -> LeftHandSide s v env env
LeftHandSideWildcard TupR s t
r
rebuildLHS (LeftHandSideSingle s t
s) = LeftHandSide s t aenv2 (aenv2, t)
-> Exists (LeftHandSide s t aenv2)
forall (f :: * -> *) a. f a -> Exists f
Exists (LeftHandSide s t aenv2 (aenv2, t)
-> Exists (LeftHandSide s t aenv2))
-> LeftHandSide s t aenv2 (aenv2, t)
-> Exists (LeftHandSide s t aenv2)
forall a b. (a -> b) -> a -> b
$ s t -> LeftHandSide s t aenv2 (aenv2, t)
forall (s :: * -> *) v env. s v -> LeftHandSide s v env (env, v)
LeftHandSideSingle s t
s
rebuildLHS (LeftHandSidePair LeftHandSide s v1 aenv1 env'1
as LeftHandSide s v2 env'1 aenv1'
bs)
| Exists LeftHandSide s v1 aenv2 a
as' <- LeftHandSide s v1 aenv1 env'1 -> Exists (LeftHandSide s v1 aenv2)
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS LeftHandSide s v1 aenv1 env'1
as
, Exists LeftHandSide s v2 a a
bs' <- LeftHandSide s v2 env'1 aenv1' -> Exists (LeftHandSide s v2 a)
forall (s :: * -> *) t aenv1 aenv1' aenv2.
LeftHandSide s t aenv1 aenv1' -> Exists (LeftHandSide s t aenv2)
rebuildLHS LeftHandSide s v2 env'1 aenv1'
bs
= LeftHandSide s t aenv2 a -> Exists (LeftHandSide s t aenv2)
forall (f :: * -> *) a. f a -> Exists f
Exists (LeftHandSide s t aenv2 a -> Exists (LeftHandSide s t aenv2))
-> LeftHandSide s t aenv2 a -> Exists (LeftHandSide s t aenv2)
forall a b. (a -> b) -> a -> b
$ LeftHandSide s v1 aenv2 a
-> LeftHandSide s v2 a a -> LeftHandSide s (v1, v2) aenv2 a
forall (s :: * -> *) v1 env env'1 v2 env'.
LeftHandSide s v1 env env'1
-> LeftHandSide s v2 env'1 env' -> LeftHandSide s (v1, v2) env env'
LeftHandSidePair LeftHandSide s v1 aenv2 a
as' LeftHandSide s v2 a a
bs'
{-# INLINEABLE rebuildBoundary #-}
rebuildBoundary
:: Applicative f
=> ReindexAvar f aenv aenv'
-> Boundary aenv t
-> f (Boundary aenv' t)
rebuildBoundary :: forall (f :: * -> *) aenv aenv' t.
Applicative f =>
ReindexAvar f aenv aenv' -> Boundary aenv t -> f (Boundary aenv' t)
rebuildBoundary ReindexAvar f aenv aenv'
av Boundary aenv t
bndy =
case Boundary aenv t
bndy of
Boundary aenv t
Clamp -> Boundary aenv' t -> f (Boundary aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Boundary aenv' t
forall aenv t. Boundary aenv t
Clamp
Boundary aenv t
Mirror -> Boundary aenv' t -> f (Boundary aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Boundary aenv' t
forall aenv t. Boundary aenv t
Mirror
Boundary aenv t
Wrap -> Boundary aenv' t -> f (Boundary aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Boundary aenv' t
forall aenv t. Boundary aenv t
Wrap
Constant e
v -> Boundary aenv' t -> f (Boundary aenv' t)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (e -> Boundary aenv' (Array sh e)
forall e aenv sh. e -> Boundary aenv (Array sh e)
Constant e
v)
Function Fun aenv (sh -> e)
f -> Fun aenv' (sh -> e) -> Boundary aenv' t
Fun aenv' (sh -> e) -> Boundary aenv' (Array sh e)
forall aenv sh e. Fun aenv (sh -> e) -> Boundary aenv (Array sh e)
Function (Fun aenv' (sh -> e) -> Boundary aenv' t)
-> f (Fun aenv' (sh -> e)) -> f (Boundary aenv' t)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RebuildEvar f IdxE () () aenv'
-> ReindexAvar f aenv aenv'
-> Fun aenv (sh -> e)
-> f (Fun aenv' (sh -> e))
forall (f :: * -> *) (fe :: * -> * -> * -> *) env env' aenv' aenv
t.
(HasCallStack, Applicative f, SyntacticExp fe) =>
RebuildEvar f fe env env' aenv'
-> ReindexAvar f aenv aenv'
-> OpenFun env aenv t
-> f (OpenFun env' aenv' t)
rebuildFun (IdxE () aenv' t' -> f (IdxE () aenv' t')
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (IdxE () aenv' t' -> f (IdxE () aenv' t'))
-> (ExpVar () t' -> IdxE () aenv' t')
-> ExpVar () t'
-> f (IdxE () aenv' t')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExpVar () t' -> IdxE () aenv' t'
forall env aenv t. ExpVar env t -> IdxE env aenv t
IE) ReindexAvar f aenv aenv'
av Fun aenv (sh -> e)
f
extractExpVars :: OpenExp env aenv a -> Maybe (ExpVars env a)
OpenExp env aenv a
Nil = ExpVars env a -> Maybe (ExpVars env a)
forall a. a -> Maybe a
Just ExpVars env a
TupR (Var ScalarType env) ()
forall (s :: * -> *). TupR s ()
TupRunit
extractExpVars (Pair OpenExp env aenv t1
e1 OpenExp env aenv t2
e2) = TupR (Var ScalarType env) t1
-> TupR (Var ScalarType env) t2 -> ExpVars env a
TupR (Var ScalarType env) t1
-> TupR (Var ScalarType env) t2
-> TupR (Var ScalarType env) (t1, t2)
forall (s :: * -> *) a1 b. TupR s a1 -> TupR s b -> TupR s (a1, b)
TupRpair (TupR (Var ScalarType env) t1
-> TupR (Var ScalarType env) t2 -> ExpVars env a)
-> Maybe (TupR (Var ScalarType env) t1)
-> Maybe (TupR (Var ScalarType env) t2 -> ExpVars env a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> OpenExp env aenv t1 -> Maybe (TupR (Var ScalarType env) t1)
forall env aenv a. OpenExp env aenv a -> Maybe (ExpVars env a)
extractExpVars OpenExp env aenv t1
e1 Maybe (TupR (Var ScalarType env) t2 -> ExpVars env a)
-> Maybe (TupR (Var ScalarType env) t2) -> Maybe (ExpVars env a)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> OpenExp env aenv t2 -> Maybe (TupR (Var ScalarType env) t2)
forall env aenv a. OpenExp env aenv a -> Maybe (ExpVars env a)
extractExpVars OpenExp env aenv t2
e2
extractExpVars (Evar ExpVar env a
v) = ExpVars env a -> Maybe (ExpVars env a)
forall a. a -> Maybe a
Just (ExpVars env a -> Maybe (ExpVars env a))
-> ExpVars env a -> Maybe (ExpVars env a)
forall a b. (a -> b) -> a -> b
$ ExpVar env a -> ExpVars env a
forall (s :: * -> *) a. s a -> TupR s a
TupRsingle ExpVar env a
v
extractExpVars OpenExp env aenv a
_ = Maybe (ExpVars env a)
forall a. Maybe a
Nothing