-- |
--
-- Functions for generic traversals across Futhark syntax trees.  The
-- motivation for this module came from dissatisfaction with rewriting
-- the same trivial tree recursions for every module.  A possible
-- alternative would be to use normal \"Scrap your
-- boilerplate\"-techniques, but these are rejected for two reasons:
--
--    * They are too slow.
--
--    * More importantly, they do not tell you whether you have missed
--      some cases.
--
-- Instead, this module defines various traversals of the Futhark syntax
-- tree.  The implementation is rather tedious, but the interface is
-- easy to use.
--
-- A traversal of the Futhark syntax tree is expressed as a record of
-- functions expressing the operations to be performed on the various
-- types of nodes.
module Language.Futhark.Traversals
  ( ASTMapper (..),
    ASTMappable (..),
    identityMapper,
    bareExp,
  )
where

import Data.List.NonEmpty qualified as NE
import Data.Set qualified as S
import Language.Futhark.Syntax

-- | Express a monad mapping operation on a syntax node.  Each element
-- of this structure expresses the operation to be performed on a
-- given child.
data ASTMapper m = ASTMapper
  { forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp :: ExpBase Info VName -> m (ExpBase Info VName),
    forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName :: VName -> m VName,
    forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType :: StructType -> m StructType,
    forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType :: PatType -> m PatType,
    forall (m :: * -> *).
ASTMapper m -> StructRetType -> m StructRetType
mapOnStructRetType :: StructRetType -> m StructRetType,
    forall (m :: * -> *). ASTMapper m -> PatRetType -> m PatRetType
mapOnPatRetType :: PatRetType -> m PatRetType
  }

-- | An 'ASTMapper' that just leaves its input unchanged.
identityMapper :: Monad m => ASTMapper m
identityMapper :: forall (m :: * -> *). Monad m => ASTMapper m
identityMapper =
  ASTMapper
    { mapOnExp :: ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp = forall (f :: * -> *) a. Applicative f => a -> f a
pure,
      mapOnName :: VName -> m VName
mapOnName = forall (f :: * -> *) a. Applicative f => a -> f a
pure,
      mapOnStructType :: StructType -> m StructType
mapOnStructType = forall (f :: * -> *) a. Applicative f => a -> f a
pure,
      mapOnPatType :: PatType -> m PatType
mapOnPatType = forall (f :: * -> *) a. Applicative f => a -> f a
pure,
      mapOnStructRetType :: StructRetType -> m StructRetType
mapOnStructRetType = forall (f :: * -> *) a. Applicative f => a -> f a
pure,
      mapOnPatRetType :: PatRetType -> m PatRetType
mapOnPatRetType = forall (f :: * -> *) a. Applicative f => a -> f a
pure
    }

-- | The class of things that we can map an 'ASTMapper' across.
class ASTMappable x where
  -- | Map a monadic action across the immediate children of an
  -- object.  Importantly, the 'astMap' action is not invoked for
  -- the object itself, and the mapping does not descend recursively
  -- into subexpressions.  The mapping is done left-to-right.
  astMap :: Monad m => ASTMapper m -> x -> m x

instance ASTMappable (QualName VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> QualName VName -> m (QualName VName)
astMap ASTMapper m
tv = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv)

instance ASTMappable (AppExpBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> AppExpBase Info VName -> m (AppExpBase Info VName)
astMap ASTMapper m
tv (Range ExpBase Info VName
start Maybe (ExpBase Info VName)
next Inclusiveness (ExpBase Info VName)
end SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> Maybe (ExpBase f vn)
-> Inclusiveness (ExpBase f vn)
-> SrcLoc
-> AppExpBase f vn
Range
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
start
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
next
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Inclusiveness (ExpBase Info VName)
end
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (If ExpBase Info VName
c ExpBase Info VName
texp ExpBase Info VName
fexp SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn -> ExpBase f vn -> SrcLoc -> AppExpBase f vn
If forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
c forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
texp forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
fexp forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Match ExpBase Info VName
e NonEmpty (CaseBase Info VName)
cases SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> NonEmpty (CaseBase f vn) -> SrcLoc -> AppExpBase f vn
Match forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv NonEmpty (CaseBase Info VName)
cases forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Apply ExpBase Info VName
f ExpBase Info VName
arg Info (Diet, Maybe VName)
d SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> f (Diet, Maybe VName)
-> SrcLoc
-> AppExpBase f vn
Apply forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
f forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Info (Diet, Maybe VName)
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetPat [SizeBinder VName]
sizes PatBase Info VName
pat ExpBase Info VName
e ExpBase Info VName
body SrcLoc
loc) =
    forall (f :: * -> *) vn.
[SizeBinder vn]
-> PatBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetPat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv [SizeBinder VName]
sizes forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
pat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetFun VName
name ([TypeParamBase VName]
fparams, [PatBase Info VName]
params, Maybe (TypeExp VName)
ret, Info StructRetType
t, ExpBase Info VName
e) ExpBase Info VName
body SrcLoc
loc) =
    forall (f :: * -> *) vn.
vn
-> ([TypeParamBase vn], [PatBase f vn], Maybe (TypeExp vn),
    f StructRetType, ExpBase f vn)
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetFun
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,,,,)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [TypeParamBase VName]
fparams
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatBase Info VName]
params
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) Maybe (TypeExp VName)
ret
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *).
ASTMapper m -> StructRetType -> m StructRetType
mapOnStructRetType ASTMapper m
tv) Info StructRetType
t
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e
          )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetWith IdentBase Info VName
dest IdentBase Info VName
src SliceBase Info VName
idxexps ExpBase Info VName
vexp ExpBase Info VName
body SrcLoc
loc) =
    forall (f :: * -> *) vn.
IdentBase f vn
-> IdentBase f vn
-> SliceBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetWith
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
dest
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
src
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) SliceBase Info VName
idxexps
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
vexp
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Coerce ExpBase Info VName
e TypeExp VName
tdecl SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn -> TypeExp vn -> SrcLoc -> AppExpBase f vn
Coerce forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
tdecl forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (BinOp (QualName VName
fname, SrcLoc
fname_loc) Info PatType
t (ExpBase Info VName
x, Info (StructType
xt, Maybe VName
xext)) (ExpBase Info VName
y, Info (StructType
yt, Maybe VName
yext)) SrcLoc
loc) =
    forall (f :: * -> *) vn.
(QualName vn, SrcLoc)
-> f PatType
-> (ExpBase f vn, f (StructType, Maybe VName))
-> (ExpBase f vn, f (StructType, Maybe VName))
-> SrcLoc
-> AppExpBase f vn
BinOp
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
fname forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
fname_loc)
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
x
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
xt forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
xext))
          )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
y
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
yt forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
yext))
          )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (DoLoop [VName]
sparams PatBase Info VName
mergepat ExpBase Info VName
mergeexp LoopFormBase Info VName
form ExpBase Info VName
loopbody SrcLoc
loc) =
    forall (f :: * -> *) vn.
[VName]
-> PatBase f vn
-> ExpBase f vn
-> LoopFormBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
DoLoop
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv) [VName]
sparams
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
mergepat
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
mergeexp
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv LoopFormBase Info VName
form
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
loopbody
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Index ExpBase Info VName
arr SliceBase Info VName
idxexps SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn -> SliceBase f vn -> SrcLoc -> AppExpBase f vn
Index forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arr forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) SliceBase Info VName
idxexps forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (ExpBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
astMap ASTMapper m
tv (Var QualName VName
name Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
QualName vn -> f PatType -> SrcLoc -> ExpBase f vn
Var
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Hole Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn. f PatType -> SrcLoc -> ExpBase f vn
Hole forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
_ (Literal PrimValue
val SrcLoc
loc) =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) vn. PrimValue -> SrcLoc -> ExpBase f vn
Literal PrimValue
val SrcLoc
loc
  astMap ASTMapper m
_ (StringLit [Word8]
vs SrcLoc
loc) =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) vn. [Word8] -> SrcLoc -> ExpBase f vn
StringLit [Word8]
vs SrcLoc
loc
  astMap ASTMapper m
tv (IntLit Integer
val Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
Integer -> f PatType -> SrcLoc -> ExpBase f vn
IntLit Integer
val forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (FloatLit Double
val Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
Double -> f PatType -> SrcLoc -> ExpBase f vn
FloatLit Double
val forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Parens ExpBase Info VName
e SrcLoc
loc) =
    forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Parens forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (QualParens (QualName VName
name, SrcLoc
nameloc) ExpBase Info VName
e SrcLoc
loc) =
    forall (f :: * -> *) vn.
(QualName vn, SrcLoc) -> ExpBase f vn -> SrcLoc -> ExpBase f vn
QualParens
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
name forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
nameloc)
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TupLit [ExpBase Info VName]
els SrcLoc
loc) =
    forall (f :: * -> *) vn. [ExpBase f vn] -> SrcLoc -> ExpBase f vn
TupLit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
els forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordLit [FieldBase Info VName]
fields SrcLoc
loc) =
    forall (f :: * -> *) vn. [FieldBase f vn] -> SrcLoc -> ExpBase f vn
RecordLit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv [FieldBase Info VName]
fields forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (ArrayLit [ExpBase Info VName]
els Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
[ExpBase f vn] -> f PatType -> SrcLoc -> ExpBase f vn
ArrayLit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
els forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Ascript ExpBase Info VName
e TypeExp VName
tdecl SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn -> TypeExp vn -> SrcLoc -> ExpBase f vn
Ascript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
tdecl forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Negate ExpBase Info VName
x SrcLoc
loc) =
    forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Negate forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Not ExpBase Info VName
x SrcLoc
loc) =
    forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Not forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Update ExpBase Info VName
src SliceBase Info VName
slice ExpBase Info VName
v SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> SliceBase f vn -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Update
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
src
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) SliceBase Info VName
slice
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
v
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordUpdate ExpBase Info VName
src [Name]
fs ExpBase Info VName
v (Info PatType
t) SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn
-> [Name] -> ExpBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
RecordUpdate
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
src
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure [Name]
fs
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
v
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t)
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Project Name
field ExpBase Info VName
e Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
Name -> ExpBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
Project Name
field forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Assert ExpBase Info VName
e1 ExpBase Info VName
e2 Info Text
desc SrcLoc
loc) =
    forall (f :: * -> *) vn.
ExpBase f vn -> ExpBase f vn -> f Text -> SrcLoc -> ExpBase f vn
Assert forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Info Text
desc forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Lambda [PatBase Info VName]
params ExpBase Info VName
body Maybe (TypeExp VName)
ret Info (Aliasing, StructRetType)
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
[PatBase f vn]
-> ExpBase f vn
-> Maybe (TypeExp vn)
-> f (Aliasing, StructRetType)
-> SrcLoc
-> ExpBase f vn
Lambda
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatBase Info VName]
params
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) Maybe (TypeExp VName)
ret
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
ASTMapper m -> StructRetType -> m StructRetType
mapOnStructRetType ASTMapper m
tv) Info (Aliasing, StructRetType)
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSection QualName VName
name Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
QualName vn -> f PatType -> SrcLoc -> ExpBase f vn
OpSection
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSectionLeft QualName VName
name Info PatType
t ExpBase Info VName
arg (Info (PName
pa, StructType
t1a, Maybe VName
argext), Info (PName
pb, StructType
t1b)) (Info PatRetType
ret, Info [VName]
retext) SrcLoc
loc) =
    forall (f :: * -> *) vn.
QualName vn
-> f PatType
-> ExpBase f vn
-> (f (PName, StructType, Maybe VName), f (PName, StructType))
-> (f PatRetType, f [VName])
-> SrcLoc
-> ExpBase f vn
OpSectionLeft
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pa,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
argext))
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pb,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1b))
          )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatRetType -> m PatRetType
mapOnPatRetType ASTMapper m
tv) Info PatRetType
ret forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv)) Info [VName]
retext)
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSectionRight QualName VName
name Info PatType
t ExpBase Info VName
arg (Info (PName
pa, StructType
t1a), Info (PName
pb, StructType
t1b, Maybe VName
argext)) Info PatRetType
t2 SrcLoc
loc) =
    forall (f :: * -> *) vn.
QualName vn
-> f PatType
-> ExpBase f vn
-> (f (PName, StructType), f (PName, StructType, Maybe VName))
-> f PatRetType
-> SrcLoc
-> ExpBase f vn
OpSectionRight
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pa,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1a))
              forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pb,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
argext))
          )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatRetType -> m PatRetType
mapOnPatRetType ASTMapper m
tv) Info PatRetType
t2
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (ProjectSection [Name]
fields Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
[Name] -> f PatType -> SrcLoc -> ExpBase f vn
ProjectSection [Name]
fields forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (IndexSection SliceBase Info VName
idxs Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
SliceBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
IndexSection
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) SliceBase Info VName
idxs
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Constr Name
name [ExpBase Info VName]
es Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
Name -> [ExpBase f vn] -> f PatType -> SrcLoc -> ExpBase f vn
Constr Name
name forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
es forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Attr AttrInfo VName
attr ExpBase Info VName
e SrcLoc
loc) =
    forall (f :: * -> *) vn.
AttrInfo vn -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Attr AttrInfo VName
attr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (AppExp AppExpBase Info VName
e Info AppRes
res) =
    forall (f :: * -> *) vn.
AppExpBase f vn -> f AppRes -> ExpBase f vn
AppExp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv AppExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv Info AppRes
res

instance ASTMappable (LoopFormBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m
-> LoopFormBase Info VName -> m (LoopFormBase Info VName)
astMap ASTMapper m
tv (For IdentBase Info VName
i ExpBase Info VName
bound) = forall (f :: * -> *) vn.
IdentBase f vn -> ExpBase f vn -> LoopFormBase f vn
For forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
i forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
bound
  astMap ASTMapper m
tv (ForIn PatBase Info VName
pat ExpBase Info VName
e) = forall (f :: * -> *) vn.
PatBase f vn -> ExpBase f vn -> LoopFormBase f vn
ForIn forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
pat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e
  astMap ASTMapper m
tv (While ExpBase Info VName
e) = forall (f :: * -> *) vn. ExpBase f vn -> LoopFormBase f vn
While forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e

instance ASTMappable (TypeExp VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> TypeExp VName -> m (TypeExp VName)
astMap ASTMapper m
tv (TEVar QualName VName
qn SrcLoc
loc) = forall vn. QualName vn -> SrcLoc -> TypeExp vn
TEVar forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
qn forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TETuple [TypeExp VName]
ts SrcLoc
loc) = forall vn. [TypeExp vn] -> SrcLoc -> TypeExp vn
TETuple forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [TypeExp VName]
ts forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TERecord [(Name, TypeExp VName)]
ts SrcLoc
loc) =
    forall vn. [(Name, TypeExp vn)] -> SrcLoc -> TypeExp vn
TERecord forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, TypeExp VName)]
ts forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEArray SizeExp VName
te TypeExp VName
dim SrcLoc
loc) =
    forall vn. SizeExp vn -> TypeExp vn -> SrcLoc -> TypeExp vn
TEArray forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv SizeExp VName
te forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
dim forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEUnique TypeExp VName
t SrcLoc
loc) = forall vn. TypeExp vn -> SrcLoc -> TypeExp vn
TEUnique forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEApply TypeExp VName
t1 TypeArgExp VName
t2 SrcLoc
loc) =
    forall vn. TypeExp vn -> TypeArgExp vn -> SrcLoc -> TypeExp vn
TEApply forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeArgExp VName
t2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEArrow Maybe VName
v TypeExp VName
t1 TypeExp VName
t2 SrcLoc
loc) =
    forall vn.
Maybe vn -> TypeExp vn -> TypeExp vn -> SrcLoc -> TypeExp vn
TEArrow Maybe VName
v forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t2 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TESum [(Name, [TypeExp VName])]
cs SrcLoc
loc) =
    forall vn. [(Name, [TypeExp vn])] -> SrcLoc -> TypeExp vn
TESum forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, [TypeExp VName])]
cs forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEDim [VName]
dims TypeExp VName
t SrcLoc
loc) =
    forall vn. [vn] -> TypeExp vn -> SrcLoc -> TypeExp vn
TEDim [VName]
dims forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (TypeArgExp VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> TypeArgExp VName -> m (TypeArgExp VName)
astMap ASTMapper m
tv (TypeArgExpDim SizeExp VName
dim SrcLoc
loc) =
    forall vn. SizeExp vn -> SrcLoc -> TypeArgExp vn
TypeArgExpDim forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv SizeExp VName
dim forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TypeArgExpType TypeExp VName
te) =
    forall vn. TypeExp vn -> TypeArgExp vn
TypeArgExpType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
te

instance ASTMappable (SizeExp VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> SizeExp VName -> m (SizeExp VName)
astMap ASTMapper m
tv (SizeExpNamed QualName VName
vn SrcLoc
loc) =
    forall vn. QualName vn -> SrcLoc -> SizeExp vn
SizeExpNamed forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
vn forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
_ (SizeExpConst Int
k SrcLoc
loc) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall vn. Int -> SrcLoc -> SizeExp vn
SizeExpConst Int
k SrcLoc
loc
  astMap ASTMapper m
_ SizeExp VName
SizeExpAny = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall vn. SizeExp vn
SizeExpAny

instance ASTMappable Size where
  astMap :: forall (m :: * -> *). Monad m => ASTMapper m -> Size -> m Size
astMap ASTMapper m
tv (NamedSize QualName VName
vn) = QualName VName -> Size
NamedSize forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv QualName VName
vn
  astMap ASTMapper m
_ (ConstSize Int
k) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Int -> Size
ConstSize Int
k
  astMap ASTMapper m
tv (AnySize Maybe VName
vn) = Maybe VName -> Size
AnySize forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv) Maybe VName
vn

instance ASTMappable (TypeParamBase VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> TypeParamBase VName -> m (TypeParamBase VName)
astMap = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName

instance ASTMappable (DimIndexBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
astMap ASTMapper m
tv (DimFix ExpBase Info VName
j) = forall (f :: * -> *) vn. ExpBase f vn -> DimIndexBase f vn
DimFix forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
j
  astMap ASTMapper m
tv (DimSlice Maybe (ExpBase Info VName)
i Maybe (ExpBase Info VName)
j Maybe (ExpBase Info VName)
stride) =
    forall (f :: * -> *) vn.
Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> DimIndexBase f vn
DimSlice
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
i
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
j
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
stride

instance ASTMappable Alias where
  astMap :: forall (m :: * -> *). Monad m => ASTMapper m -> Alias -> m Alias
astMap ASTMapper m
tv (AliasBound VName
v) = VName -> Alias
AliasBound forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
v
  astMap ASTMapper m
tv (AliasFree VName
v) = VName -> Alias
AliasFree forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
v

instance ASTMappable Aliasing where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> Aliasing -> m Aliasing
astMap ASTMapper m
tv = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Ord a => [a] -> Set a
S.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
S.toList

instance ASTMappable AppRes where
  astMap :: forall (m :: * -> *). Monad m => ASTMapper m -> AppRes -> m AppRes
astMap ASTMapper m
tv (AppRes PatType
t [VName]
ext) =
    PatType -> [VName] -> AppRes
AppRes forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure [VName]
ext

type TypeTraverser f t dim1 als1 dim2 als2 =
  (QualName VName -> f (QualName VName)) ->
  (dim1 -> f dim2) ->
  (als1 -> f als2) ->
  t dim1 als1 ->
  f (t dim2 als2)

traverseScalarType ::
  Applicative f =>
  TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType :: forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType QualName VName -> f (QualName VName)
_ dim1 -> f dims
_ als1 -> f als2
_ (Prim PrimType
t) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall dim as. PrimType -> ScalarTypeBase dim as
Prim PrimType
t
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (Record Map Name (TypeBase dim1 als1)
fs) = forall dim as. Map Name (TypeBase dim as) -> ScalarTypeBase dim as
Record forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h) Map Name (TypeBase dim1 als1)
fs
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (TypeVar als1
als Uniqueness
u QualName VName
t [TypeArg dim1]
args) =
  forall dim as.
as
-> Uniqueness
-> QualName VName
-> [TypeArg dim]
-> ScalarTypeBase dim as
TypeVar forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Uniqueness
u forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> QualName VName -> f (QualName VName)
f QualName VName
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (f :: * -> *) dim1 dim2.
Applicative f =>
(QualName VName -> f (QualName VName))
-> (dim1 -> f dim2) -> TypeArg dim1 -> f (TypeArg dim2)
traverseTypeArg QualName VName -> f (QualName VName)
f dim1 -> f dims
g) [TypeArg dim1]
args
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (Arrow als1
als PName
v TypeBase dim1 ()
t1 (RetType [VName]
dims TypeBase dim1 als1
t2)) =
  forall dim as.
as
-> PName
-> TypeBase dim ()
-> RetTypeBase dim as
-> ScalarTypeBase dim as
Arrow
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure PName
v
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeBase dim1 ()
t1
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall dim as. [VName] -> TypeBase dim as -> RetTypeBase dim as
RetType [VName]
dims forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h TypeBase dim1 als1
t2)
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (Sum Map Name [TypeBase dim1 als1]
cs) =
  forall dim as. Map Name [TypeBase dim as] -> ScalarTypeBase dim as
Sum forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse) (forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h) Map Name [TypeBase dim1 als1]
cs

traverseType :: Applicative f => TypeTraverser f TypeBase dim1 als1 dims als2
traverseType :: forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (Array als1
als Uniqueness
u Shape dim1
shape ScalarTypeBase dim1 ()
et) =
  forall dim as.
as
-> Uniqueness
-> Shape dim
-> ScalarTypeBase dim ()
-> TypeBase dim as
Array forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure Uniqueness
u forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse dim1 -> f dims
g Shape dim1
shape forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g forall (f :: * -> *) a. Applicative f => a -> f a
pure ScalarTypeBase dim1 ()
et
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h (Scalar ScalarTypeBase dim1 als1
t) =
  forall dim as. ScalarTypeBase dim as -> TypeBase dim as
Scalar forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType QualName VName -> f (QualName VName)
f dim1 -> f dims
g als1 -> f als2
h ScalarTypeBase dim1 als1
t

traverseTypeArg ::
  Applicative f =>
  (QualName VName -> f (QualName VName)) ->
  (dim1 -> f dim2) ->
  TypeArg dim1 ->
  f (TypeArg dim2)
traverseTypeArg :: forall (f :: * -> *) dim1 dim2.
Applicative f =>
(QualName VName -> f (QualName VName))
-> (dim1 -> f dim2) -> TypeArg dim1 -> f (TypeArg dim2)
traverseTypeArg QualName VName -> f (QualName VName)
_ dim1 -> f dim2
g (TypeArgDim dim1
d SrcLoc
loc) =
  forall dim. dim -> SrcLoc -> TypeArg dim
TypeArgDim forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> dim1 -> f dim2
g dim1
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
traverseTypeArg QualName VName -> f (QualName VName)
f dim1 -> f dim2
g (TypeArgType TypeBase dim1 ()
t SrcLoc
loc) =
  forall dim. TypeBase dim () -> SrcLoc -> TypeArg dim
TypeArgType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType QualName VName -> f (QualName VName)
f dim1 -> f dim2
g forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeBase dim1 ()
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable StructType where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> StructType -> m StructType
astMap ASTMapper m
tv = forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) forall (f :: * -> *) a. Applicative f => a -> f a
pure

instance ASTMappable PatType where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> PatType -> m PatType
astMap ASTMapper m
tv = forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv)

instance ASTMappable StructRetType where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> StructRetType -> m StructRetType
astMap ASTMapper m
tv (RetType [VName]
ext StructType
t) = forall dim as. [VName] -> TypeBase dim as -> RetTypeBase dim as
RetType [VName]
ext forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv StructType
t

instance ASTMappable PatRetType where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> PatRetType -> m PatRetType
astMap ASTMapper m
tv (RetType [VName]
ext PatType
t) = forall dim as. [VName] -> TypeBase dim as -> RetTypeBase dim as
RetType [VName]
ext forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatType
t

instance ASTMappable (IdentBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> IdentBase Info VName -> m (IdentBase Info VName)
astMap ASTMapper m
tv (Ident VName
name (Info PatType
t) SrcLoc
loc) =
    forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> IdentBase f vn
Ident forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (SizeBinder VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> SizeBinder VName -> m (SizeBinder VName)
astMap ASTMapper m
tv (SizeBinder VName
name SrcLoc
loc) =
    forall vn. vn -> SrcLoc -> SizeBinder vn
SizeBinder forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (PatBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> PatBase Info VName -> m (PatBase Info VName)
astMap ASTMapper m
tv (Id VName
name (Info PatType
t) SrcLoc
loc) =
    forall (f :: * -> *) vn. vn -> f PatType -> SrcLoc -> PatBase f vn
Id forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TuplePat [PatBase Info VName]
pats SrcLoc
loc) =
    forall (f :: * -> *) vn. [PatBase f vn] -> SrcLoc -> PatBase f vn
TuplePat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatBase Info VName]
pats forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordPat [(Name, PatBase Info VName)]
fields SrcLoc
loc) =
    forall (f :: * -> *) vn.
[(Name, PatBase f vn)] -> SrcLoc -> PatBase f vn
RecordPat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, PatBase Info VName)]
fields forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatParens PatBase Info VName
pat SrcLoc
loc) =
    forall (f :: * -> *) vn. PatBase f vn -> SrcLoc -> PatBase f vn
PatParens forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
pat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatAscription PatBase Info VName
pat TypeExp VName
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
PatBase f vn -> TypeExp vn -> SrcLoc -> PatBase f vn
PatAscription forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
pat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Wildcard (Info PatType
t) SrcLoc
loc) =
    forall (f :: * -> *) vn. f PatType -> SrcLoc -> PatBase f vn
Wildcard forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatLit PatLit
v (Info PatType
t) SrcLoc
loc) =
    forall (f :: * -> *) vn.
PatLit -> f PatType -> SrcLoc -> PatBase f vn
PatLit PatLit
v forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatConstr Name
n (Info PatType
t) [PatBase Info VName]
ps SrcLoc
loc) =
    forall (f :: * -> *) vn.
Name -> f PatType -> [PatBase f vn] -> SrcLoc -> PatBase f vn
PatConstr Name
n forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. a -> Info a
Info forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv PatType
t) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatBase Info VName]
ps forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatAttr AttrInfo VName
attr PatBase Info VName
p SrcLoc
loc) =
    forall (f :: * -> *) vn.
AttrInfo vn -> PatBase f vn -> SrcLoc -> PatBase f vn
PatAttr AttrInfo VName
attr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (FieldBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> FieldBase Info VName -> m (FieldBase Info VName)
astMap ASTMapper m
tv (RecordFieldExplicit Name
name ExpBase Info VName
e SrcLoc
loc) =
    forall (f :: * -> *) vn.
Name -> ExpBase f vn -> SrcLoc -> FieldBase f vn
RecordFieldExplicit Name
name forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordFieldImplicit VName
name Info PatType
t SrcLoc
loc) =
    forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> FieldBase f vn
RecordFieldImplicit
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (m :: * -> *). ASTMapper m -> PatType -> m PatType
mapOnPatType ASTMapper m
tv) Info PatType
t
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (CaseBase Info VName) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> CaseBase Info VName -> m (CaseBase Info VName)
astMap ASTMapper m
tv (CasePat PatBase Info VName
pat ExpBase Info VName
e SrcLoc
loc) =
    forall (f :: * -> *) vn.
PatBase f vn -> ExpBase f vn -> SrcLoc -> CaseBase f vn
CasePat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatBase Info VName
pat forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable a => ASTMappable (Info a) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> Info a -> m (Info a)
astMap ASTMapper m
tv = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv

instance ASTMappable a => ASTMappable [a] where
  astMap :: forall (m :: * -> *). Monad m => ASTMapper m -> [a] -> m [a]
astMap ASTMapper m
tv = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv

instance ASTMappable a => ASTMappable (NE.NonEmpty a) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> NonEmpty a -> m (NonEmpty a)
astMap ASTMapper m
tv = forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall a b. (a -> b) -> a -> b
$ forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv

instance (ASTMappable a, ASTMappable b) => ASTMappable (a, b) where
  astMap :: forall (m :: * -> *). Monad m => ASTMapper m -> (a, b) -> m (a, b)
astMap ASTMapper m
tv (a
x, b
y) = (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv a
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv b
y

instance (ASTMappable a, ASTMappable b, ASTMappable c) => ASTMappable (a, b, c) where
  astMap :: forall (m :: * -> *).
Monad m =>
ASTMapper m -> (a, b, c) -> m (a, b, c)
astMap ASTMapper m
tv (a
x, b
y, c
z) = (,,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv a
x forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv b
y forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv c
z

-- It would be lovely if the following code would be written in terms
-- of ASTMappable, but unfortunately it involves changing the Info
-- functor.  For simplicity, the general traversals do not support
-- that.  Sometimes a little duplication is better than an overly
-- complex abstraction.  The types ensure that this will be correct
-- anyway, so it's just tedious, and not actually fragile.

bareField :: FieldBase Info VName -> FieldBase NoInfo VName
bareField :: FieldBase Info VName -> FieldBase NoInfo VName
bareField (RecordFieldExplicit Name
name ExpBase Info VName
e SrcLoc
loc) =
  forall (f :: * -> *) vn.
Name -> ExpBase f vn -> SrcLoc -> FieldBase f vn
RecordFieldExplicit Name
name (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc
bareField (RecordFieldImplicit VName
name Info PatType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> FieldBase f vn
RecordFieldImplicit VName
name forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc

barePat :: PatBase Info VName -> PatBase NoInfo VName
barePat :: PatBase Info VName -> PatBase NoInfo VName
barePat (TuplePat [PatBase Info VName]
ps SrcLoc
loc) = forall (f :: * -> *) vn. [PatBase f vn] -> SrcLoc -> PatBase f vn
TuplePat (forall a b. (a -> b) -> [a] -> [b]
map PatBase Info VName -> PatBase NoInfo VName
barePat [PatBase Info VName]
ps) SrcLoc
loc
barePat (RecordPat [(Name, PatBase Info VName)]
fs SrcLoc
loc) = forall (f :: * -> *) vn.
[(Name, PatBase f vn)] -> SrcLoc -> PatBase f vn
RecordPat (forall a b. (a -> b) -> [a] -> [b]
map (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PatBase Info VName -> PatBase NoInfo VName
barePat) [(Name, PatBase Info VName)]
fs) SrcLoc
loc
barePat (PatParens PatBase Info VName
p SrcLoc
loc) = forall (f :: * -> *) vn. PatBase f vn -> SrcLoc -> PatBase f vn
PatParens (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
p) SrcLoc
loc
barePat (Id VName
v Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn. vn -> f PatType -> SrcLoc -> PatBase f vn
Id VName
v forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
barePat (Wildcard Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn. f PatType -> SrcLoc -> PatBase f vn
Wildcard forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
barePat (PatAscription PatBase Info VName
pat TypeExp VName
t SrcLoc
loc) = forall (f :: * -> *) vn.
PatBase f vn -> TypeExp vn -> SrcLoc -> PatBase f vn
PatAscription (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
pat) TypeExp VName
t SrcLoc
loc
barePat (PatLit PatLit
v Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
PatLit -> f PatType -> SrcLoc -> PatBase f vn
PatLit PatLit
v forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
barePat (PatConstr Name
c Info PatType
_ [PatBase Info VName]
ps SrcLoc
loc) = forall (f :: * -> *) vn.
Name -> f PatType -> [PatBase f vn] -> SrcLoc -> PatBase f vn
PatConstr Name
c forall {k} (a :: k). NoInfo a
NoInfo (forall a b. (a -> b) -> [a] -> [b]
map PatBase Info VName -> PatBase NoInfo VName
barePat [PatBase Info VName]
ps) SrcLoc
loc
barePat (PatAttr AttrInfo VName
attr PatBase Info VName
p SrcLoc
loc) = forall (f :: * -> *) vn.
AttrInfo vn -> PatBase f vn -> SrcLoc -> PatBase f vn
PatAttr AttrInfo VName
attr (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
p) SrcLoc
loc

bareDimIndex :: DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex :: DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex (DimFix ExpBase Info VName
e) =
  forall (f :: * -> *) vn. ExpBase f vn -> DimIndexBase f vn
DimFix forall a b. (a -> b) -> a -> b
$ ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e
bareDimIndex (DimSlice Maybe (ExpBase Info VName)
x Maybe (ExpBase Info VName)
y Maybe (ExpBase Info VName)
z) =
  forall (f :: * -> *) vn.
Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> DimIndexBase f vn
DimSlice (ExpBase Info VName -> ExpBase NoInfo VName
bareExp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ExpBase Info VName)
x) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ExpBase Info VName)
y) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ExpBase Info VName)
z)

bareLoopForm :: LoopFormBase Info VName -> LoopFormBase NoInfo VName
bareLoopForm :: LoopFormBase Info VName -> LoopFormBase NoInfo VName
bareLoopForm (For (Ident VName
i Info PatType
_ SrcLoc
loc) ExpBase Info VName
e) = forall (f :: * -> *) vn.
IdentBase f vn -> ExpBase f vn -> LoopFormBase f vn
For (forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> IdentBase f vn
Ident VName
i forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e)
bareLoopForm (ForIn PatBase Info VName
pat ExpBase Info VName
e) = forall (f :: * -> *) vn.
PatBase f vn -> ExpBase f vn -> LoopFormBase f vn
ForIn (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
pat) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e)
bareLoopForm (While ExpBase Info VName
e) = forall (f :: * -> *) vn. ExpBase f vn -> LoopFormBase f vn
While (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e)

bareCase :: CaseBase Info VName -> CaseBase NoInfo VName
bareCase :: CaseBase Info VName -> CaseBase NoInfo VName
bareCase (CasePat PatBase Info VName
pat ExpBase Info VName
e SrcLoc
loc) = forall (f :: * -> *) vn.
PatBase f vn -> ExpBase f vn -> SrcLoc -> CaseBase f vn
CasePat (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
pat) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc

-- | Remove all annotations from an expression, but retain the
-- name/scope information.
bareExp :: ExpBase Info VName -> ExpBase NoInfo VName
bareExp :: ExpBase Info VName -> ExpBase NoInfo VName
bareExp (Var QualName VName
name Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
QualName vn -> f PatType -> SrcLoc -> ExpBase f vn
Var QualName VName
name forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Hole Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn. f PatType -> SrcLoc -> ExpBase f vn
Hole forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Literal PrimValue
v SrcLoc
loc) = forall (f :: * -> *) vn. PrimValue -> SrcLoc -> ExpBase f vn
Literal PrimValue
v SrcLoc
loc
bareExp (IntLit Integer
val Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
Integer -> f PatType -> SrcLoc -> ExpBase f vn
IntLit Integer
val forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (FloatLit Double
val Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
Double -> f PatType -> SrcLoc -> ExpBase f vn
FloatLit Double
val forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Parens ExpBase Info VName
e SrcLoc
loc) = forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Parens (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc
bareExp (QualParens (QualName VName, SrcLoc)
name ExpBase Info VName
e SrcLoc
loc) = forall (f :: * -> *) vn.
(QualName vn, SrcLoc) -> ExpBase f vn -> SrcLoc -> ExpBase f vn
QualParens (QualName VName, SrcLoc)
name (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc
bareExp (TupLit [ExpBase Info VName]
els SrcLoc
loc) = forall (f :: * -> *) vn. [ExpBase f vn] -> SrcLoc -> ExpBase f vn
TupLit (forall a b. (a -> b) -> [a] -> [b]
map ExpBase Info VName -> ExpBase NoInfo VName
bareExp [ExpBase Info VName]
els) SrcLoc
loc
bareExp (StringLit [Word8]
vs SrcLoc
loc) = forall (f :: * -> *) vn. [Word8] -> SrcLoc -> ExpBase f vn
StringLit [Word8]
vs SrcLoc
loc
bareExp (RecordLit [FieldBase Info VName]
fields SrcLoc
loc) = forall (f :: * -> *) vn. [FieldBase f vn] -> SrcLoc -> ExpBase f vn
RecordLit (forall a b. (a -> b) -> [a] -> [b]
map FieldBase Info VName -> FieldBase NoInfo VName
bareField [FieldBase Info VName]
fields) SrcLoc
loc
bareExp (ArrayLit [ExpBase Info VName]
els Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
[ExpBase f vn] -> f PatType -> SrcLoc -> ExpBase f vn
ArrayLit (forall a b. (a -> b) -> [a] -> [b]
map ExpBase Info VName -> ExpBase NoInfo VName
bareExp [ExpBase Info VName]
els) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Ascript ExpBase Info VName
e TypeExp VName
te SrcLoc
loc) = forall (f :: * -> *) vn.
ExpBase f vn -> TypeExp vn -> SrcLoc -> ExpBase f vn
Ascript (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) TypeExp VName
te SrcLoc
loc
bareExp (Negate ExpBase Info VName
x SrcLoc
loc) = forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Negate (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
x) SrcLoc
loc
bareExp (Not ExpBase Info VName
x SrcLoc
loc) = forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Not (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
x) SrcLoc
loc
bareExp (Update ExpBase Info VName
src SliceBase Info VName
slice ExpBase Info VName
v SrcLoc
loc) =
  forall (f :: * -> *) vn.
ExpBase f vn
-> SliceBase f vn -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Update (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
src) (forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex SliceBase Info VName
slice) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
v) SrcLoc
loc
bareExp (RecordUpdate ExpBase Info VName
src [Name]
fs ExpBase Info VName
v Info PatType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
ExpBase f vn
-> [Name] -> ExpBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
RecordUpdate (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
src) [Name]
fs (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
v) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Project Name
field ExpBase Info VName
e Info PatType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
Name -> ExpBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
Project Name
field (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Assert ExpBase Info VName
e1 ExpBase Info VName
e2 Info Text
_ SrcLoc
loc) = forall (f :: * -> *) vn.
ExpBase f vn -> ExpBase f vn -> f Text -> SrcLoc -> ExpBase f vn
Assert (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e1) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e2) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Lambda [PatBase Info VName]
params ExpBase Info VName
body Maybe (TypeExp VName)
ret Info (Aliasing, StructRetType)
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
[PatBase f vn]
-> ExpBase f vn
-> Maybe (TypeExp vn)
-> f (Aliasing, StructRetType)
-> SrcLoc
-> ExpBase f vn
Lambda (forall a b. (a -> b) -> [a] -> [b]
map PatBase Info VName -> PatBase NoInfo VName
barePat [PatBase Info VName]
params) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
body) Maybe (TypeExp VName)
ret forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (OpSection QualName VName
name Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
QualName vn -> f PatType -> SrcLoc -> ExpBase f vn
OpSection QualName VName
name forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (OpSectionLeft QualName VName
name Info PatType
_ ExpBase Info VName
arg (Info (PName, StructType, Maybe VName), Info (PName, StructType))
_ (Info PatRetType, Info [VName])
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
QualName vn
-> f PatType
-> ExpBase f vn
-> (f (PName, StructType, Maybe VName), f (PName, StructType))
-> (f PatRetType, f [VName])
-> SrcLoc
-> ExpBase f vn
OpSectionLeft QualName VName
name forall {k} (a :: k). NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arg) (forall {k} (a :: k). NoInfo a
NoInfo, forall {k} (a :: k). NoInfo a
NoInfo) (forall {k} (a :: k). NoInfo a
NoInfo, forall {k} (a :: k). NoInfo a
NoInfo) SrcLoc
loc
bareExp (OpSectionRight QualName VName
name Info PatType
_ ExpBase Info VName
arg (Info (PName, StructType), Info (PName, StructType, Maybe VName))
_ Info PatRetType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
QualName vn
-> f PatType
-> ExpBase f vn
-> (f (PName, StructType), f (PName, StructType, Maybe VName))
-> f PatRetType
-> SrcLoc
-> ExpBase f vn
OpSectionRight QualName VName
name forall {k} (a :: k). NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arg) (forall {k} (a :: k). NoInfo a
NoInfo, forall {k} (a :: k). NoInfo a
NoInfo) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (ProjectSection [Name]
fields Info PatType
_ SrcLoc
loc) = forall (f :: * -> *) vn.
[Name] -> f PatType -> SrcLoc -> ExpBase f vn
ProjectSection [Name]
fields forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (IndexSection SliceBase Info VName
slice Info PatType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
SliceBase f vn -> f PatType -> SrcLoc -> ExpBase f vn
IndexSection (forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex SliceBase Info VName
slice) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (Constr Name
name [ExpBase Info VName]
es Info PatType
_ SrcLoc
loc) =
  forall (f :: * -> *) vn.
Name -> [ExpBase f vn] -> f PatType -> SrcLoc -> ExpBase f vn
Constr Name
name (forall a b. (a -> b) -> [a] -> [b]
map ExpBase Info VName -> ExpBase NoInfo VName
bareExp [ExpBase Info VName]
es) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
bareExp (AppExp AppExpBase Info VName
appexp Info AppRes
_) =
  forall (f :: * -> *) vn.
AppExpBase f vn -> f AppRes -> ExpBase f vn
AppExp AppExpBase NoInfo VName
appexp' forall {k} (a :: k). NoInfo a
NoInfo
  where
    appexp' :: AppExpBase NoInfo VName
appexp' =
      case AppExpBase Info VName
appexp of
        Match ExpBase Info VName
e NonEmpty (CaseBase Info VName)
cases SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn
-> NonEmpty (CaseBase f vn) -> SrcLoc -> AppExpBase f vn
Match (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CaseBase Info VName -> CaseBase NoInfo VName
bareCase NonEmpty (CaseBase Info VName)
cases) SrcLoc
loc
        DoLoop [VName]
_ PatBase Info VName
mergepat ExpBase Info VName
mergeexp LoopFormBase Info VName
form ExpBase Info VName
loopbody SrcLoc
loc ->
          forall (f :: * -> *) vn.
[VName]
-> PatBase f vn
-> ExpBase f vn
-> LoopFormBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
DoLoop
            []
            (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
mergepat)
            (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
mergeexp)
            (LoopFormBase Info VName -> LoopFormBase NoInfo VName
bareLoopForm LoopFormBase Info VName
form)
            (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
loopbody)
            SrcLoc
loc
        LetWith (Ident VName
dest Info PatType
_ SrcLoc
destloc) (Ident VName
src Info PatType
_ SrcLoc
srcloc) SliceBase Info VName
idxexps ExpBase Info VName
vexp ExpBase Info VName
body SrcLoc
loc ->
          forall (f :: * -> *) vn.
IdentBase f vn
-> IdentBase f vn
-> SliceBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetWith
            (forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> IdentBase f vn
Ident VName
dest forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
destloc)
            (forall (f :: * -> *) vn.
vn -> f PatType -> SrcLoc -> IdentBase f vn
Ident VName
src forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
srcloc)
            (forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex SliceBase Info VName
idxexps)
            (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
vexp)
            (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
body)
            SrcLoc
loc
        BinOp (QualName VName, SrcLoc)
fname Info PatType
_ (ExpBase Info VName
x, Info (StructType, Maybe VName)
_) (ExpBase Info VName
y, Info (StructType, Maybe VName)
_) SrcLoc
loc ->
          forall (f :: * -> *) vn.
(QualName vn, SrcLoc)
-> f PatType
-> (ExpBase f vn, f (StructType, Maybe VName))
-> (ExpBase f vn, f (StructType, Maybe VName))
-> SrcLoc
-> AppExpBase f vn
BinOp (QualName VName, SrcLoc)
fname forall {k} (a :: k). NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
x, forall {k} (a :: k). NoInfo a
NoInfo) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
y, forall {k} (a :: k). NoInfo a
NoInfo) SrcLoc
loc
        If ExpBase Info VName
c ExpBase Info VName
texp ExpBase Info VName
fexp SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn -> ExpBase f vn -> SrcLoc -> AppExpBase f vn
If (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
c) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
texp) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
fexp) SrcLoc
loc
        Apply ExpBase Info VName
f ExpBase Info VName
arg Info (Diet, Maybe VName)
_ SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> f (Diet, Maybe VName)
-> SrcLoc
-> AppExpBase f vn
Apply (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
f) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arg) forall {k} (a :: k). NoInfo a
NoInfo SrcLoc
loc
        LetPat [SizeBinder VName]
sizes PatBase Info VName
pat ExpBase Info VName
e ExpBase Info VName
body SrcLoc
loc ->
          forall (f :: * -> *) vn.
[SizeBinder vn]
-> PatBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetPat [SizeBinder VName]
sizes (PatBase Info VName -> PatBase NoInfo VName
barePat PatBase Info VName
pat) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
body) SrcLoc
loc
        LetFun VName
name ([TypeParamBase VName]
fparams, [PatBase Info VName]
params, Maybe (TypeExp VName)
ret, Info StructRetType
_, ExpBase Info VName
e) ExpBase Info VName
body SrcLoc
loc ->
          forall (f :: * -> *) vn.
vn
-> ([TypeParamBase vn], [PatBase f vn], Maybe (TypeExp vn),
    f StructRetType, ExpBase f vn)
-> ExpBase f vn
-> SrcLoc
-> AppExpBase f vn
LetFun VName
name ([TypeParamBase VName]
fparams, forall a b. (a -> b) -> [a] -> [b]
map PatBase Info VName -> PatBase NoInfo VName
barePat [PatBase Info VName]
params, Maybe (TypeExp VName)
ret, forall {k} (a :: k). NoInfo a
NoInfo, ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
body) SrcLoc
loc
        Range ExpBase Info VName
start Maybe (ExpBase Info VName)
next Inclusiveness (ExpBase Info VName)
end SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn
-> Maybe (ExpBase f vn)
-> Inclusiveness (ExpBase f vn)
-> SrcLoc
-> AppExpBase f vn
Range (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
start) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ExpBase Info VName -> ExpBase NoInfo VName
bareExp Maybe (ExpBase Info VName)
next) (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ExpBase Info VName -> ExpBase NoInfo VName
bareExp Inclusiveness (ExpBase Info VName)
end) SrcLoc
loc
        Coerce ExpBase Info VName
e TypeExp VName
te SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn -> TypeExp vn -> SrcLoc -> AppExpBase f vn
Coerce (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) TypeExp VName
te SrcLoc
loc
        Index ExpBase Info VName
arr SliceBase Info VName
slice SrcLoc
loc ->
          forall (f :: * -> *) vn.
ExpBase f vn -> SliceBase f vn -> SrcLoc -> AppExpBase f vn
Index (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arr) (forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex SliceBase Info VName
slice) SrcLoc
loc
bareExp (Attr AttrInfo VName
attr ExpBase Info VName
e SrcLoc
loc) =
  forall (f :: * -> *) vn.
AttrInfo vn -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Attr AttrInfo VName
attr (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc