{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TupleSections #-}

-- |
--
-- 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 qualified Data.List.NonEmpty as NE
import qualified Data.Set 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
  { ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp :: ExpBase Info VName -> m (ExpBase Info VName),
    ASTMapper m -> VName -> m VName
mapOnName :: VName -> m VName,
    ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName :: QualName VName -> m (QualName VName),
    ASTMapper m -> StructType -> m StructType
mapOnStructType :: StructType -> m StructType,
    ASTMapper m -> PatternType -> m PatternType
mapOnPatternType :: PatternType -> m PatternType
  }

-- | An 'ASTMapper' that just leaves its input unchanged.
identityMapper :: Monad m => ASTMapper m
identityMapper :: ASTMapper m
identityMapper =
  ASTMapper :: forall (m :: * -> *).
(ExpBase Info VName -> m (ExpBase Info VName))
-> (VName -> m VName)
-> (QualName VName -> m (QualName VName))
-> (StructType -> m StructType)
-> (PatternType -> m PatternType)
-> ASTMapper m
ASTMapper
    { mapOnExp :: ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp = ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *) a. Monad m => a -> m a
return,
      mapOnName :: VName -> m VName
mapOnName = VName -> m VName
forall (m :: * -> *) a. Monad m => a -> m a
return,
      mapOnQualName :: QualName VName -> m (QualName VName)
mapOnQualName = QualName VName -> m (QualName VName)
forall (m :: * -> *) a. Monad m => a -> m a
return,
      mapOnStructType :: StructType -> m StructType
mapOnStructType = StructType -> m StructType
forall (m :: * -> *) a. Monad m => a -> m a
return,
      mapOnPatternType :: PatternType -> m PatternType
mapOnPatternType = PatternType -> m PatternType
forall (m :: * -> *) a. Monad m => a -> m a
return
    }

-- | 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 (ExpBase Info VName) where
  astMap :: ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
astMap ASTMapper m
tv (Var QualName VName
name Info PatternType
t SrcLoc
loc) =
    QualName VName -> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
QualName vn -> f PatternType -> SrcLoc -> ExpBase f vn
Var (QualName VName
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (QualName VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
name m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
_ (Literal PrimValue
val SrcLoc
loc) =
    ExpBase Info VName -> m (ExpBase Info VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExpBase Info VName -> m (ExpBase Info VName))
-> ExpBase Info VName -> m (ExpBase Info VName)
forall a b. (a -> b) -> a -> b
$ PrimValue -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. PrimValue -> SrcLoc -> ExpBase f vn
Literal PrimValue
val SrcLoc
loc
  astMap ASTMapper m
_ (StringLit [Word8]
vs SrcLoc
loc) =
    ExpBase Info VName -> m (ExpBase Info VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExpBase Info VName -> m (ExpBase Info VName))
-> ExpBase Info VName -> m (ExpBase Info VName)
forall a b. (a -> b) -> a -> b
$ [Word8] -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. [Word8] -> SrcLoc -> ExpBase f vn
StringLit [Word8]
vs SrcLoc
loc
  astMap ASTMapper m
tv (IntLit Integer
val Info PatternType
t SrcLoc
loc) =
    Integer -> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
Integer -> f PatternType -> SrcLoc -> ExpBase f vn
IntLit Integer
val (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (FloatLit Double
val Info PatternType
t SrcLoc
loc) =
    Double -> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
Double -> f PatternType -> SrcLoc -> ExpBase f vn
FloatLit Double
val (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Parens ExpBase Info VName
e SrcLoc
loc) =
    ExpBase Info VName -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Parens (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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) =
    (QualName VName, SrcLoc)
-> ExpBase Info VName -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
(QualName vn, SrcLoc) -> ExpBase f vn -> SrcLoc -> ExpBase f vn
QualParens ((QualName VName, SrcLoc)
 -> ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (QualName VName, SrcLoc)
-> m (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (QualName VName -> SrcLoc -> (QualName VName, SrcLoc))
-> m (QualName VName) -> m (SrcLoc -> (QualName VName, SrcLoc))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
name m (SrcLoc -> (QualName VName, SrcLoc))
-> m SrcLoc -> m (QualName VName, SrcLoc)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
nameloc)
      m (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TupLit [ExpBase Info VName]
els SrcLoc
loc) =
    [ExpBase Info VName] -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. [ExpBase f vn] -> SrcLoc -> ExpBase f vn
TupLit ([ExpBase Info VName] -> SrcLoc -> ExpBase Info VName)
-> m [ExpBase Info VName] -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ExpBase Info VName -> m (ExpBase Info VName))
-> [ExpBase Info VName] -> m [ExpBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
els m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordLit [FieldBase Info VName]
fields SrcLoc
loc) =
    [FieldBase Info VName] -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. [FieldBase f vn] -> SrcLoc -> ExpBase f vn
RecordLit ([FieldBase Info VName] -> SrcLoc -> ExpBase Info VName)
-> m [FieldBase Info VName] -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> [FieldBase Info VName] -> m [FieldBase Info VName]
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv [FieldBase Info VName]
fields m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (ArrayLit [ExpBase Info VName]
els Info PatternType
t SrcLoc
loc) =
    [ExpBase Info VName]
-> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
[ExpBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
ArrayLit ([ExpBase Info VName]
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m [ExpBase Info VName]
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ExpBase Info VName -> m (ExpBase Info VName))
-> [ExpBase Info VName] -> m [ExpBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
els m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Range ExpBase Info VName
start Maybe (ExpBase Info VName)
next Inclusiveness (ExpBase Info VName)
end (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> Maybe (ExpBase Info VName)
-> Inclusiveness (ExpBase Info VName)
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> Maybe (ExpBase f vn)
-> Inclusiveness (ExpBase f vn)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Range (ExpBase Info VName
 -> Maybe (ExpBase Info VName)
 -> Inclusiveness (ExpBase Info VName)
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Maybe (ExpBase Info VName)
      -> Inclusiveness (ExpBase Info VName)
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
start m (Maybe (ExpBase Info VName)
   -> Inclusiveness (ExpBase Info VName)
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Maybe (ExpBase Info VName))
-> m (Inclusiveness (ExpBase Info VName)
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ExpBase Info VName -> m (ExpBase Info VName))
-> Maybe (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
next
      m (Inclusiveness (ExpBase Info VName)
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Inclusiveness (ExpBase Info VName))
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ExpBase Info VName -> m (ExpBase Info VName))
-> Inclusiveness (ExpBase Info VName)
-> m (Inclusiveness (ExpBase Info VName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Inclusiveness (ExpBase Info VName)
end
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Ascript ExpBase Info VName
e TypeDeclBase Info VName
tdecl SrcLoc
loc) =
    ExpBase Info VName
-> TypeDeclBase Info VName -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn -> TypeDeclBase f vn -> SrcLoc -> ExpBase f vn
Ascript (ExpBase Info VName
 -> TypeDeclBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (TypeDeclBase Info VName -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (TypeDeclBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (TypeDeclBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m
-> TypeDeclBase Info VName -> m (TypeDeclBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeDeclBase Info VName
tdecl m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Coerce ExpBase Info VName
e TypeDeclBase Info VName
tdecl (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> TypeDeclBase Info VName
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> TypeDeclBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Coerce (ExpBase Info VName
 -> TypeDeclBase Info VName
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (TypeDeclBase Info VName
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (TypeDeclBase Info VName
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (TypeDeclBase Info VName)
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m
-> TypeDeclBase Info VName -> m (TypeDeclBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeDeclBase Info VName
tdecl
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (BinOp (QualName VName
fname, SrcLoc
fname_loc) Info PatternType
t (ExpBase Info VName
x, Info (StructType
xt, Maybe VName
xext)) (ExpBase Info VName
y, Info (StructType
yt, Maybe VName
yext)) (Info PatternType
rt) Info [VName]
ext SrcLoc
loc) =
    (QualName VName, SrcLoc)
-> Info PatternType
-> (ExpBase Info VName, Info (StructType, Maybe VName))
-> (ExpBase Info VName, Info (StructType, Maybe VName))
-> Info PatternType
-> Info [VName]
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
(QualName vn, SrcLoc)
-> f PatternType
-> (ExpBase f vn, f (StructType, Maybe VName))
-> (ExpBase f vn, f (StructType, Maybe VName))
-> f PatternType
-> f [VName]
-> SrcLoc
-> ExpBase f vn
BinOp ((QualName VName, SrcLoc)
 -> Info PatternType
 -> (ExpBase Info VName, Info (StructType, Maybe VName))
 -> (ExpBase Info VName, Info (StructType, Maybe VName))
 -> Info PatternType
 -> Info [VName]
 -> SrcLoc
 -> ExpBase Info VName)
-> m (QualName VName, SrcLoc)
-> m (Info PatternType
      -> (ExpBase Info VName, Info (StructType, Maybe VName))
      -> (ExpBase Info VName, Info (StructType, Maybe VName))
      -> Info PatternType
      -> Info [VName]
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (QualName VName -> SrcLoc -> (QualName VName, SrcLoc))
-> m (QualName VName) -> m (SrcLoc -> (QualName VName, SrcLoc))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
fname m (SrcLoc -> (QualName VName, SrcLoc))
-> m SrcLoc -> m (QualName VName, SrcLoc)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
fname_loc)
      m (Info PatternType
   -> (ExpBase Info VName, Info (StructType, Maybe VName))
   -> (ExpBase Info VName, Info (StructType, Maybe VName))
   -> Info PatternType
   -> Info [VName]
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Info PatternType)
-> m ((ExpBase Info VName, Info (StructType, Maybe VName))
      -> (ExpBase Info VName, Info (StructType, Maybe VName))
      -> Info PatternType
      -> Info [VName]
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m ((ExpBase Info VName, Info (StructType, Maybe VName))
   -> (ExpBase Info VName, Info (StructType, Maybe VName))
   -> Info PatternType
   -> Info [VName]
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName, Info (StructType, Maybe VName))
-> m ((ExpBase Info VName, Info (StructType, Maybe VName))
      -> Info PatternType
      -> Info [VName]
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,) (ExpBase Info VName
 -> Info (StructType, Maybe VName)
 -> (ExpBase Info VName, Info (StructType, Maybe VName)))
-> m (ExpBase Info VName)
-> m (Info (StructType, Maybe VName)
      -> (ExpBase Info VName, Info (StructType, Maybe VName)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
x
              m (Info (StructType, Maybe VName)
   -> (ExpBase Info VName, Info (StructType, Maybe VName)))
-> m (Info (StructType, Maybe VName))
-> m (ExpBase Info VName, Info (StructType, Maybe VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((StructType, Maybe VName) -> Info (StructType, Maybe VName)
forall a. a -> Info a
Info ((StructType, Maybe VName) -> Info (StructType, Maybe VName))
-> m (StructType, Maybe VName)
-> m (Info (StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (StructType -> Maybe VName -> (StructType, Maybe VName))
-> m StructType -> m (Maybe VName -> (StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
xt m (Maybe VName -> (StructType, Maybe VName))
-> m (Maybe VName) -> m (StructType, Maybe VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe VName -> m (Maybe VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
xext))
          )
      m ((ExpBase Info VName, Info (StructType, Maybe VName))
   -> Info PatternType
   -> Info [VName]
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName, Info (StructType, Maybe VName))
-> m (Info PatternType
      -> Info [VName] -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,) (ExpBase Info VName
 -> Info (StructType, Maybe VName)
 -> (ExpBase Info VName, Info (StructType, Maybe VName)))
-> m (ExpBase Info VName)
-> m (Info (StructType, Maybe VName)
      -> (ExpBase Info VName, Info (StructType, Maybe VName)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
y
              m (Info (StructType, Maybe VName)
   -> (ExpBase Info VName, Info (StructType, Maybe VName)))
-> m (Info (StructType, Maybe VName))
-> m (ExpBase Info VName, Info (StructType, Maybe VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((StructType, Maybe VName) -> Info (StructType, Maybe VName)
forall a. a -> Info a
Info ((StructType, Maybe VName) -> Info (StructType, Maybe VName))
-> m (StructType, Maybe VName)
-> m (Info (StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (StructType -> Maybe VName -> (StructType, Maybe VName))
-> m StructType -> m (Maybe VName -> (StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
yt m (Maybe VName -> (StructType, Maybe VName))
-> m (Maybe VName) -> m (StructType, Maybe VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe VName -> m (Maybe VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
yext))
          )
      m (Info PatternType
   -> Info [VName] -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType)
-> m (Info [VName] -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
rt)
      m (Info [VName] -> SrcLoc -> ExpBase Info VName)
-> m (Info [VName]) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Negate ExpBase Info VName
x SrcLoc
loc) =
    ExpBase Info VName -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn. ExpBase f vn -> SrcLoc -> ExpBase f vn
Negate (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
x m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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 (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> ExpBase Info VName
-> ExpBase Info VName
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
If (ExpBase Info VName
 -> ExpBase Info VName
 -> ExpBase Info VName
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> ExpBase Info VName
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
c m (ExpBase Info VName
   -> ExpBase Info VName
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
texp m (ExpBase Info VName
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
fexp
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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 (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> ExpBase Info VName
-> Info (Diet, Maybe VName)
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> f (Diet, Maybe VName)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Apply (ExpBase Info VName
 -> ExpBase Info VName
 -> Info (Diet, Maybe VName)
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> Info (Diet, Maybe VName)
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
f m (ExpBase Info VName
   -> Info (Diet, Maybe VName)
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info (Diet, Maybe VName)
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg m (Info (Diet, Maybe VName)
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Info (Diet, Maybe VName))
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info (Diet, Maybe VName) -> m (Info (Diet, Maybe VName))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info (Diet, Maybe VName)
d
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t) m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetPat PatternBase Info VName
pat ExpBase Info VName
e ExpBase Info VName
body (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    PatternBase Info VName
-> ExpBase Info VName
-> ExpBase Info VName
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
PatternBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
LetPat (PatternBase Info VName
 -> ExpBase Info VName
 -> ExpBase Info VName
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (PatternBase Info VName)
-> m (ExpBase Info VName
      -> ExpBase Info VName
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatternBase Info VName
pat m (ExpBase Info VName
   -> ExpBase Info VName
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (ExpBase Info VName
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetFun VName
name ([TypeParamBase VName]
fparams, [PatternBase Info VName]
params, Maybe (TypeExp VName)
ret, Info StructType
t, ExpBase Info VName
e) ExpBase Info VName
body Info PatternType
body_t SrcLoc
loc) =
    VName
-> ([TypeParamBase VName], [PatternBase Info VName],
    Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
-> ExpBase Info VName
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
vn
-> ([TypeParamBase vn], [PatternBase f vn], Maybe (TypeExp vn),
    f StructType, ExpBase f vn)
-> ExpBase f vn
-> f PatternType
-> SrcLoc
-> ExpBase f vn
LetFun (VName
 -> ([TypeParamBase VName], [PatternBase Info VName],
     Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
 -> ExpBase Info VName
 -> Info PatternType
 -> SrcLoc
 -> ExpBase Info VName)
-> m VName
-> m (([TypeParamBase VName], [PatternBase Info VName],
       Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
      -> ExpBase Info VName
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> VName -> m VName
forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name
      m (([TypeParamBase VName], [PatternBase Info VName],
    Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
   -> ExpBase Info VName
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m ([TypeParamBase VName], [PatternBase Info VName],
      Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
-> m (ExpBase Info VName
      -> Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,,,,) ([TypeParamBase VName]
 -> [PatternBase Info VName]
 -> Maybe (TypeExp VName)
 -> Info StructType
 -> ExpBase Info VName
 -> ([TypeParamBase VName], [PatternBase Info VName],
     Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
-> m [TypeParamBase VName]
-> m ([PatternBase Info VName]
      -> Maybe (TypeExp VName)
      -> Info StructType
      -> ExpBase Info VName
      -> ([TypeParamBase VName], [PatternBase Info VName],
          Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeParamBase VName -> m (TypeParamBase VName))
-> [TypeParamBase VName] -> m [TypeParamBase VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> TypeParamBase VName -> m (TypeParamBase VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [TypeParamBase VName]
fparams m ([PatternBase Info VName]
   -> Maybe (TypeExp VName)
   -> Info StructType
   -> ExpBase Info VName
   -> ([TypeParamBase VName], [PatternBase Info VName],
       Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
-> m [PatternBase Info VName]
-> m (Maybe (TypeExp VName)
      -> Info StructType
      -> ExpBase Info VName
      -> ([TypeParamBase VName], [PatternBase Info VName],
          Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternBase Info VName -> m (PatternBase Info VName))
-> [PatternBase Info VName] -> m [PatternBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatternBase Info VName]
params
              m (Maybe (TypeExp VName)
   -> Info StructType
   -> ExpBase Info VName
   -> ([TypeParamBase VName], [PatternBase Info VName],
       Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
-> m (Maybe (TypeExp VName))
-> m (Info StructType
      -> ExpBase Info VName
      -> ([TypeParamBase VName], [PatternBase Info VName],
          Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (TypeExp VName -> m (TypeExp VName))
-> Maybe (TypeExp VName) -> m (Maybe (TypeExp VName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) Maybe (TypeExp VName)
ret
              m (Info StructType
   -> ExpBase Info VName
   -> ([TypeParamBase VName], [PatternBase Info VName],
       Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
-> m (Info StructType)
-> m (ExpBase Info VName
      -> ([TypeParamBase VName], [PatternBase Info VName],
          Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (StructType -> m StructType)
-> Info StructType -> m (Info StructType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv) Info StructType
t
              m (ExpBase Info VName
   -> ([TypeParamBase VName], [PatternBase Info VName],
       Maybe (TypeExp VName), Info StructType, ExpBase Info VName))
-> m (ExpBase Info VName)
-> m ([TypeParamBase VName], [PatternBase Info VName],
      Maybe (TypeExp VName), Info StructType, ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e
          )
      m (ExpBase Info VName
   -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
body_t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (LetWith IdentBase Info VName
dest IdentBase Info VName
src [DimIndexBase Info VName]
idxexps ExpBase Info VName
vexp ExpBase Info VName
body Info PatternType
t SrcLoc
loc) =
    IdentBase Info VName
-> IdentBase Info VName
-> [DimIndexBase Info VName]
-> ExpBase Info VName
-> ExpBase Info VName
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
IdentBase f vn
-> IdentBase f vn
-> [DimIndexBase f vn]
-> ExpBase f vn
-> ExpBase f vn
-> f PatternType
-> SrcLoc
-> ExpBase f vn
LetWith
      (IdentBase Info VName
 -> IdentBase Info VName
 -> [DimIndexBase Info VName]
 -> ExpBase Info VName
 -> ExpBase Info VName
 -> Info PatternType
 -> SrcLoc
 -> ExpBase Info VName)
-> m (IdentBase Info VName)
-> m (IdentBase Info VName
      -> [DimIndexBase Info VName]
      -> ExpBase Info VName
      -> ExpBase Info VName
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> IdentBase Info VName -> m (IdentBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
dest
      m (IdentBase Info VName
   -> [DimIndexBase Info VName]
   -> ExpBase Info VName
   -> ExpBase Info VName
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m (IdentBase Info VName)
-> m ([DimIndexBase Info VName]
      -> ExpBase Info VName
      -> ExpBase Info VName
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> IdentBase Info VName -> m (IdentBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
src
      m ([DimIndexBase Info VName]
   -> ExpBase Info VName
   -> ExpBase Info VName
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m [DimIndexBase Info VName]
-> m (ExpBase Info VName
      -> ExpBase Info VName
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (DimIndexBase Info VName -> m (DimIndexBase Info VName))
-> [DimIndexBase Info VName] -> m [DimIndexBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [DimIndexBase Info VName]
idxexps
      m (ExpBase Info VName
   -> ExpBase Info VName
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
vexp
      m (ExpBase Info VName
   -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Update ExpBase Info VName
src [DimIndexBase Info VName]
slice ExpBase Info VName
v SrcLoc
loc) =
    ExpBase Info VName
-> [DimIndexBase Info VName]
-> ExpBase Info VName
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [DimIndexBase f vn] -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Update (ExpBase Info VName
 -> [DimIndexBase Info VName]
 -> ExpBase Info VName
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ([DimIndexBase Info VName]
      -> ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
src m ([DimIndexBase Info VName]
   -> ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m [DimIndexBase Info VName]
-> m (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (DimIndexBase Info VName -> m (DimIndexBase Info VName))
-> [DimIndexBase Info VName] -> m [DimIndexBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [DimIndexBase Info VName]
slice
      m (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
v
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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 PatternType
t) SrcLoc
loc) =
    ExpBase Info VName
-> [Name]
-> ExpBase Info VName
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [Name]
-> ExpBase f vn
-> f PatternType
-> SrcLoc
-> ExpBase f vn
RecordUpdate (ExpBase Info VName
 -> [Name]
 -> ExpBase Info VName
 -> Info PatternType
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ([Name]
      -> ExpBase Info VName
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
src m ([Name]
   -> ExpBase Info VName
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m [Name]
-> m (ExpBase Info VName
      -> Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Name] -> m [Name]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Name]
fs
      m (ExpBase Info VName
   -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
v
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Project Name
field ExpBase Info VName
e Info PatternType
t SrcLoc
loc) =
    Name
-> ExpBase Info VName
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
Name -> ExpBase f vn -> f PatternType -> SrcLoc -> ExpBase f vn
Project Name
field (ExpBase Info VName
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Index ExpBase Info VName
arr [DimIndexBase Info VName]
idxexps (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> [DimIndexBase Info VName]
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [DimIndexBase f vn]
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Index (ExpBase Info VName
 -> [DimIndexBase Info VName]
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ([DimIndexBase Info VName]
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arr m ([DimIndexBase Info VName]
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m [DimIndexBase Info VName]
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (DimIndexBase Info VName -> m (DimIndexBase Info VName))
-> [DimIndexBase Info VName] -> m [DimIndexBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [DimIndexBase Info VName]
idxexps
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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 String
desc SrcLoc
loc) =
    ExpBase Info VName
-> ExpBase Info VName
-> Info String
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn -> ExpBase f vn -> f String -> SrcLoc -> ExpBase f vn
Assert (ExpBase Info VName
 -> ExpBase Info VName
 -> Info String
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (ExpBase Info VName
      -> Info String -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e1 m (ExpBase Info VName
   -> Info String -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info String -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e2 m (Info String -> SrcLoc -> ExpBase Info VName)
-> m (Info String) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info String -> m (Info String)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info String
desc m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Lambda [PatternBase Info VName]
params ExpBase Info VName
body Maybe (TypeExp VName)
ret Info (Aliasing, StructType)
t SrcLoc
loc) =
    [PatternBase Info VName]
-> ExpBase Info VName
-> Maybe (TypeExp VName)
-> Info (Aliasing, StructType)
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
[PatternBase f vn]
-> ExpBase f vn
-> Maybe (TypeExp vn)
-> f (Aliasing, StructType)
-> SrcLoc
-> ExpBase f vn
Lambda ([PatternBase Info VName]
 -> ExpBase Info VName
 -> Maybe (TypeExp VName)
 -> Info (Aliasing, StructType)
 -> SrcLoc
 -> ExpBase Info VName)
-> m [PatternBase Info VName]
-> m (ExpBase Info VName
      -> Maybe (TypeExp VName)
      -> Info (Aliasing, StructType)
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternBase Info VName -> m (PatternBase Info VName))
-> [PatternBase Info VName] -> m [PatternBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatternBase Info VName]
params
      m (ExpBase Info VName
   -> Maybe (TypeExp VName)
   -> Info (Aliasing, StructType)
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Maybe (TypeExp VName)
      -> Info (Aliasing, StructType) -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
body
      m (Maybe (TypeExp VName)
   -> Info (Aliasing, StructType) -> SrcLoc -> ExpBase Info VName)
-> m (Maybe (TypeExp VName))
-> m (Info (Aliasing, StructType) -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (TypeExp VName -> m (TypeExp VName))
-> Maybe (TypeExp VName) -> m (Maybe (TypeExp VName))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) Maybe (TypeExp VName)
ret
      m (Info (Aliasing, StructType) -> SrcLoc -> ExpBase Info VName)
-> m (Info (Aliasing, StructType))
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((Aliasing, StructType) -> m (Aliasing, StructType))
-> Info (Aliasing, StructType) -> m (Info (Aliasing, StructType))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((StructType -> m StructType)
-> (Aliasing, StructType) -> m (Aliasing, StructType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((StructType -> m StructType)
 -> (Aliasing, StructType) -> m (Aliasing, StructType))
-> (StructType -> m StructType)
-> (Aliasing, StructType)
-> m (Aliasing, StructType)
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv) Info (Aliasing, StructType)
t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSection QualName VName
name Info PatternType
t SrcLoc
loc) =
    QualName VName -> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
QualName vn -> f PatternType -> SrcLoc -> ExpBase f vn
OpSection (QualName VName
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (QualName VName)
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
name
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSectionLeft QualName VName
name Info PatternType
t ExpBase Info VName
arg (Info (PName
pa, StructType
t1a, Maybe VName
argext), Info (PName
pb, StructType
t1b)) (Info PatternType
t2, Info [VName]
retext) SrcLoc
loc) =
    QualName VName
-> Info PatternType
-> ExpBase Info VName
-> (Info (PName, StructType, Maybe VName),
    Info (PName, StructType))
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
QualName vn
-> f PatternType
-> ExpBase f vn
-> (f (PName, StructType, Maybe VName), f (PName, StructType))
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
OpSectionLeft (QualName VName
 -> Info PatternType
 -> ExpBase Info VName
 -> (Info (PName, StructType, Maybe VName),
     Info (PName, StructType))
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (QualName VName)
-> m (Info PatternType
      -> ExpBase Info VName
      -> (Info (PName, StructType, Maybe VName),
          Info (PName, StructType))
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
name
      m (Info PatternType
   -> ExpBase Info VName
   -> (Info (PName, StructType, Maybe VName),
       Info (PName, StructType))
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Info PatternType)
-> m (ExpBase Info VName
      -> (Info (PName, StructType, Maybe VName),
          Info (PName, StructType))
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (ExpBase Info VName
   -> (Info (PName, StructType, Maybe VName),
       Info (PName, StructType))
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ((Info (PName, StructType, Maybe VName),
       Info (PName, StructType))
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg
      m ((Info (PName, StructType, Maybe VName),
    Info (PName, StructType))
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Info (PName, StructType, Maybe VName),
      Info (PName, StructType))
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              (Info (PName, StructType, Maybe VName)
 -> Info (PName, StructType)
 -> (Info (PName, StructType, Maybe VName),
     Info (PName, StructType)))
-> m (Info (PName, StructType, Maybe VName))
-> m (Info (PName, StructType)
      -> (Info (PName, StructType, Maybe VName),
          Info (PName, StructType)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName, StructType, Maybe VName)
-> Info (PName, StructType, Maybe VName)
forall a. a -> Info a
Info ((PName, StructType, Maybe VName)
 -> Info (PName, StructType, Maybe VName))
-> m (PName, StructType, Maybe VName)
-> m (Info (PName, StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pa,,) (StructType -> Maybe VName -> (PName, StructType, Maybe VName))
-> m StructType
-> m (Maybe VName -> (PName, StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1a m (Maybe VName -> (PName, StructType, Maybe VName))
-> m (Maybe VName) -> m (PName, StructType, Maybe VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe VName -> m (Maybe VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
argext))
              m (Info (PName, StructType)
   -> (Info (PName, StructType, Maybe VName),
       Info (PName, StructType)))
-> m (Info (PName, StructType))
-> m (Info (PName, StructType, Maybe VName),
      Info (PName, StructType))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((PName, StructType) -> Info (PName, StructType)
forall a. a -> Info a
Info ((PName, StructType) -> Info (PName, StructType))
-> m (PName, StructType) -> m (Info (PName, StructType))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pb,) (StructType -> (PName, StructType))
-> m StructType -> m (PName, StructType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1b))
          )
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t2 m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
retext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (OpSectionRight QualName VName
name Info PatternType
t ExpBase Info VName
arg (Info (PName
pa, StructType
t1a), Info (PName
pb, StructType
t1b, Maybe VName
argext)) Info PatternType
t2 SrcLoc
loc) =
    QualName VName
-> Info PatternType
-> ExpBase Info VName
-> (Info (PName, StructType),
    Info (PName, StructType, Maybe VName))
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
QualName vn
-> f PatternType
-> ExpBase f vn
-> (f (PName, StructType), f (PName, StructType, Maybe VName))
-> f PatternType
-> SrcLoc
-> ExpBase f vn
OpSectionRight (QualName VName
 -> Info PatternType
 -> ExpBase Info VName
 -> (Info (PName, StructType),
     Info (PName, StructType, Maybe VName))
 -> Info PatternType
 -> SrcLoc
 -> ExpBase Info VName)
-> m (QualName VName)
-> m (Info PatternType
      -> ExpBase Info VName
      -> (Info (PName, StructType),
          Info (PName, StructType, Maybe VName))
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
name
      m (Info PatternType
   -> ExpBase Info VName
   -> (Info (PName, StructType),
       Info (PName, StructType, Maybe VName))
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m (Info PatternType)
-> m (ExpBase Info VName
      -> (Info (PName, StructType),
          Info (PName, StructType, Maybe VName))
      -> Info PatternType
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (ExpBase Info VName
   -> (Info (PName, StructType),
       Info (PName, StructType, Maybe VName))
   -> Info PatternType
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m ((Info (PName, StructType),
       Info (PName, StructType, Maybe VName))
      -> Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
arg
      m ((Info (PName, StructType),
    Info (PName, StructType, Maybe VName))
   -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info (PName, StructType),
      Info (PName, StructType, Maybe VName))
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ( (,)
              (Info (PName, StructType)
 -> Info (PName, StructType, Maybe VName)
 -> (Info (PName, StructType),
     Info (PName, StructType, Maybe VName)))
-> m (Info (PName, StructType))
-> m (Info (PName, StructType, Maybe VName)
      -> (Info (PName, StructType),
          Info (PName, StructType, Maybe VName)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName, StructType) -> Info (PName, StructType)
forall a. a -> Info a
Info ((PName, StructType) -> Info (PName, StructType))
-> m (PName, StructType) -> m (Info (PName, StructType))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pa,) (StructType -> (PName, StructType))
-> m StructType -> m (PName, StructType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1a))
              m (Info (PName, StructType, Maybe VName)
   -> (Info (PName, StructType),
       Info (PName, StructType, Maybe VName)))
-> m (Info (PName, StructType, Maybe VName))
-> m (Info (PName, StructType),
      Info (PName, StructType, Maybe VName))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((PName, StructType, Maybe VName)
-> Info (PName, StructType, Maybe VName)
forall a. a -> Info a
Info ((PName, StructType, Maybe VName)
 -> Info (PName, StructType, Maybe VName))
-> m (PName, StructType, Maybe VName)
-> m (Info (PName, StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((PName
pb,,) (StructType -> Maybe VName -> (PName, StructType, Maybe VName))
-> m StructType
-> m (Maybe VName -> (PName, StructType, Maybe VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
t1b m (Maybe VName -> (PName, StructType, Maybe VName))
-> m (Maybe VName) -> m (PName, StructType, Maybe VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe VName -> m (Maybe VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe VName
argext))
          )
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t2
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (ProjectSection [Name]
fields Info PatternType
t SrcLoc
loc) =
    [Name] -> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
[Name] -> f PatternType -> SrcLoc -> ExpBase f vn
ProjectSection [Name]
fields (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (IndexSection [DimIndexBase Info VName]
idxs Info PatternType
t SrcLoc
loc) =
    [DimIndexBase Info VName]
-> Info PatternType -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
[DimIndexBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
IndexSection ([DimIndexBase Info VName]
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m [DimIndexBase Info VName]
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DimIndexBase Info VName -> m (DimIndexBase Info VName))
-> [DimIndexBase Info VName] -> m [DimIndexBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [DimIndexBase Info VName]
idxs
      m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (DoLoop [VName]
sparams PatternBase Info VName
mergepat ExpBase Info VName
mergeexp LoopFormBase Info VName
form ExpBase Info VName
loopbody (Info (PatternType
ret, [VName]
ext)) SrcLoc
loc) =
    [VName]
-> PatternBase Info VName
-> ExpBase Info VName
-> LoopFormBase Info VName
-> ExpBase Info VName
-> Info (PatternType, [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
[VName]
-> PatternBase f vn
-> ExpBase f vn
-> LoopFormBase f vn
-> ExpBase f vn
-> f (PatternType, [VName])
-> SrcLoc
-> ExpBase f vn
DoLoop ([VName]
 -> PatternBase Info VName
 -> ExpBase Info VName
 -> LoopFormBase Info VName
 -> ExpBase Info VName
 -> Info (PatternType, [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m [VName]
-> m (PatternBase Info VName
      -> ExpBase Info VName
      -> LoopFormBase Info VName
      -> ExpBase Info VName
      -> Info (PatternType, [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (VName -> m VName) -> [VName] -> m [VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> VName -> m VName
forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv) [VName]
sparams m (PatternBase Info VName
   -> ExpBase Info VName
   -> LoopFormBase Info VName
   -> ExpBase Info VName
   -> Info (PatternType, [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (PatternBase Info VName)
-> m (ExpBase Info VName
      -> LoopFormBase Info VName
      -> ExpBase Info VName
      -> Info (PatternType, [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatternBase Info VName
mergepat
      m (ExpBase Info VName
   -> LoopFormBase Info VName
   -> ExpBase Info VName
   -> Info (PatternType, [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (LoopFormBase Info VName
      -> ExpBase Info VName
      -> Info (PatternType, [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
mergeexp
      m (LoopFormBase Info VName
   -> ExpBase Info VName
   -> Info (PatternType, [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (LoopFormBase Info VName)
-> m (ExpBase Info VName
      -> Info (PatternType, [VName]) -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m
-> LoopFormBase Info VName -> m (LoopFormBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv LoopFormBase Info VName
form
      m (ExpBase Info VName
   -> Info (PatternType, [VName]) -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (Info (PatternType, [VName]) -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
loopbody
      m (Info (PatternType, [VName]) -> SrcLoc -> ExpBase Info VName)
-> m (Info (PatternType, [VName]))
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((PatternType, [VName]) -> Info (PatternType, [VName])
forall a. a -> Info a
Info ((PatternType, [VName]) -> Info (PatternType, [VName]))
-> m (PatternType, [VName]) -> m (Info (PatternType, [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (PatternType -> [VName] -> (PatternType, [VName]))
-> m PatternType -> m ([VName] -> (PatternType, [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
ret m ([VName] -> (PatternType, [VName]))
-> m [VName] -> m (PatternType, [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [VName] -> m [VName]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [VName]
ext))
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Constr Name
name [ExpBase Info VName]
es Info PatternType
ts SrcLoc
loc) =
    Name
-> [ExpBase Info VName]
-> Info PatternType
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
Name -> [ExpBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
Constr Name
name ([ExpBase Info VName]
 -> Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m [ExpBase Info VName]
-> m (Info PatternType -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ExpBase Info VName -> m (ExpBase Info VName))
-> [ExpBase Info VName] -> m [ExpBase Info VName]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) [ExpBase Info VName]
es m (Info PatternType -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
ts m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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 (Info PatternType
t, Info [VName]
ext) SrcLoc
loc) =
    ExpBase Info VName
-> NonEmpty (CaseBase Info VName)
-> (Info PatternType, Info [VName])
-> SrcLoc
-> ExpBase Info VName
forall (f :: * -> *) vn.
ExpBase f vn
-> NonEmpty (CaseBase f vn)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Match (ExpBase Info VName
 -> NonEmpty (CaseBase Info VName)
 -> (Info PatternType, Info [VName])
 -> SrcLoc
 -> ExpBase Info VName)
-> m (ExpBase Info VName)
-> m (NonEmpty (CaseBase Info VName)
      -> (Info PatternType, Info [VName])
      -> SrcLoc
      -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (NonEmpty (CaseBase Info VName)
   -> (Info PatternType, Info [VName])
   -> SrcLoc
   -> ExpBase Info VName)
-> m (NonEmpty (CaseBase Info VName))
-> m ((Info PatternType, Info [VName])
      -> SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m
-> NonEmpty (CaseBase Info VName)
-> m (NonEmpty (CaseBase Info VName))
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv NonEmpty (CaseBase Info VName)
cases
      m ((Info PatternType, Info [VName])
   -> SrcLoc -> ExpBase Info VName)
-> m (Info PatternType, Info [VName])
-> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((,) (Info PatternType
 -> Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info PatternType)
-> m (Info [VName] -> (Info PatternType, Info [VName]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> m PatternType)
-> Info PatternType -> m (Info PatternType)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv) Info PatternType
t m (Info [VName] -> (Info PatternType, Info [VName]))
-> m (Info [VName]) -> m (Info PatternType, Info [VName])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Info [VName] -> m (Info [VName])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Info [VName]
ext)
      m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Attr AttrInfo
attr ExpBase Info VName
e SrcLoc
loc) =
    AttrInfo -> ExpBase Info VName -> SrcLoc -> ExpBase Info VName
forall (f :: * -> *) vn.
AttrInfo -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Attr AttrInfo
attr (ExpBase Info VName -> SrcLoc -> ExpBase Info VName)
-> m (ExpBase Info VName) -> m (SrcLoc -> ExpBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
e m (SrcLoc -> ExpBase Info VName)
-> m SrcLoc -> m (ExpBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

instance ASTMappable (LoopFormBase Info VName) where
  astMap :: ASTMapper m
-> LoopFormBase Info VName -> m (LoopFormBase Info VName)
astMap ASTMapper m
tv (For IdentBase Info VName
i ExpBase Info VName
bound) = IdentBase Info VName
-> ExpBase Info VName -> LoopFormBase Info VName
forall (f :: * -> *) vn.
IdentBase f vn -> ExpBase f vn -> LoopFormBase f vn
For (IdentBase Info VName
 -> ExpBase Info VName -> LoopFormBase Info VName)
-> m (IdentBase Info VName)
-> m (ExpBase Info VName -> LoopFormBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> IdentBase Info VName -> m (IdentBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv IdentBase Info VName
i m (ExpBase Info VName -> LoopFormBase Info VName)
-> m (ExpBase Info VName) -> m (LoopFormBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv ExpBase Info VName
bound
  astMap ASTMapper m
tv (ForIn PatternBase Info VName
pat ExpBase Info VName
e) = PatternBase Info VName
-> ExpBase Info VName -> LoopFormBase Info VName
forall (f :: * -> *) vn.
PatternBase f vn -> ExpBase f vn -> LoopFormBase f vn
ForIn (PatternBase Info VName
 -> ExpBase Info VName -> LoopFormBase Info VName)
-> m (PatternBase Info VName)
-> m (ExpBase Info VName -> LoopFormBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatternBase Info VName
pat m (ExpBase Info VName -> LoopFormBase Info VName)
-> m (ExpBase Info VName) -> m (LoopFormBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
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) = ExpBase Info VName -> LoopFormBase Info VName
forall (f :: * -> *) vn. ExpBase f vn -> LoopFormBase f vn
While (ExpBase Info VName -> LoopFormBase Info VName)
-> m (ExpBase Info VName) -> m (LoopFormBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
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 :: ASTMapper m -> TypeExp VName -> m (TypeExp VName)
astMap ASTMapper m
tv (TEVar QualName VName
qn SrcLoc
loc) = QualName VName -> SrcLoc -> TypeExp VName
forall vn. QualName vn -> SrcLoc -> TypeExp vn
TEVar (QualName VName -> SrcLoc -> TypeExp VName)
-> m (QualName VName) -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
qn m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TETuple [TypeExp VName]
ts SrcLoc
loc) = [TypeExp VName] -> SrcLoc -> TypeExp VName
forall vn. [TypeExp vn] -> SrcLoc -> TypeExp vn
TETuple ([TypeExp VName] -> SrcLoc -> TypeExp VName)
-> m [TypeExp VName] -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeExp VName -> m (TypeExp VName))
-> [TypeExp VName] -> m [TypeExp VName]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [TypeExp VName]
ts m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TERecord [(Name, TypeExp VName)]
ts SrcLoc
loc) =
    [(Name, TypeExp VName)] -> SrcLoc -> TypeExp VName
forall vn. [(Name, TypeExp vn)] -> SrcLoc -> TypeExp vn
TERecord ([(Name, TypeExp VName)] -> SrcLoc -> TypeExp VName)
-> m [(Name, TypeExp VName)] -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, TypeExp VName) -> m (Name, TypeExp VName))
-> [(Name, TypeExp VName)] -> m [(Name, TypeExp VName)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((TypeExp VName -> m (TypeExp VName))
-> (Name, TypeExp VName) -> m (Name, TypeExp VName)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((TypeExp VName -> m (TypeExp VName))
 -> (Name, TypeExp VName) -> m (Name, TypeExp VName))
-> (TypeExp VName -> m (TypeExp VName))
-> (Name, TypeExp VName)
-> m (Name, TypeExp VName)
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, TypeExp VName)]
ts m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEArray TypeExp VName
te DimExp VName
dim SrcLoc
loc) =
    TypeExp VName -> DimExp VName -> SrcLoc -> TypeExp VName
forall vn. TypeExp vn -> DimExp vn -> SrcLoc -> TypeExp vn
TEArray (TypeExp VName -> DimExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeExp VName) -> m (DimExp VName -> SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
te m (DimExp VName -> SrcLoc -> TypeExp VName)
-> m (DimExp VName) -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> DimExp VName -> m (DimExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv DimExp VName
dim m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEUnique TypeExp VName
t SrcLoc
loc) = TypeExp VName -> SrcLoc -> TypeExp VName
forall vn. TypeExp vn -> SrcLoc -> TypeExp vn
TEUnique (TypeExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeExp VName) -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TEApply TypeExp VName
t1 TypeArgExp VName
t2 SrcLoc
loc) =
    TypeExp VName -> TypeArgExp VName -> SrcLoc -> TypeExp VName
forall vn. TypeExp vn -> TypeArgExp vn -> SrcLoc -> TypeExp vn
TEApply (TypeExp VName -> TypeArgExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeExp VName)
-> m (TypeArgExp VName -> SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t1 m (TypeArgExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeArgExp VName) -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> TypeArgExp VName -> m (TypeArgExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeArgExp VName
t2 m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
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) =
    Maybe VName
-> TypeExp VName -> TypeExp VName -> SrcLoc -> TypeExp VName
forall vn.
Maybe vn -> TypeExp vn -> TypeExp vn -> SrcLoc -> TypeExp vn
TEArrow Maybe VName
v (TypeExp VName -> TypeExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeExp VName)
-> m (TypeExp VName -> SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t1 m (TypeExp VName -> SrcLoc -> TypeExp VName)
-> m (TypeExp VName) -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
t2 m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TESum [(Name, [TypeExp VName])]
cs SrcLoc
loc) =
    [(Name, [TypeExp VName])] -> SrcLoc -> TypeExp VName
forall vn. [(Name, [TypeExp vn])] -> SrcLoc -> TypeExp vn
TESum ([(Name, [TypeExp VName])] -> SrcLoc -> TypeExp VName)
-> m [(Name, [TypeExp VName])] -> m (SrcLoc -> TypeExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, [TypeExp VName]) -> m (Name, [TypeExp VName]))
-> [(Name, [TypeExp VName])] -> m [(Name, [TypeExp VName])]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (([TypeExp VName] -> m [TypeExp VName])
-> (Name, [TypeExp VName]) -> m (Name, [TypeExp VName])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (([TypeExp VName] -> m [TypeExp VName])
 -> (Name, [TypeExp VName]) -> m (Name, [TypeExp VName]))
-> ([TypeExp VName] -> m [TypeExp VName])
-> (Name, [TypeExp VName])
-> m (Name, [TypeExp VName])
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> [TypeExp VName] -> m [TypeExp VName]
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, [TypeExp VName])]
cs m (SrcLoc -> TypeExp VName) -> m SrcLoc -> m (TypeExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

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

instance ASTMappable (DimExp VName) where
  astMap :: ASTMapper m -> DimExp VName -> m (DimExp VName)
astMap ASTMapper m
tv (DimExpNamed QualName VName
vn SrcLoc
loc) =
    QualName VName -> SrcLoc -> DimExp VName
forall vn. QualName vn -> SrcLoc -> DimExp vn
DimExpNamed (QualName VName -> SrcLoc -> DimExp VName)
-> m (QualName VName) -> m (SrcLoc -> DimExp VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
vn m (SrcLoc -> DimExp VName) -> m SrcLoc -> m (DimExp VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
_ (DimExpConst Int
k SrcLoc
loc) = DimExp VName -> m (DimExp VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DimExp VName -> m (DimExp VName))
-> DimExp VName -> m (DimExp VName)
forall a b. (a -> b) -> a -> b
$ Int -> SrcLoc -> DimExp VName
forall vn. Int -> SrcLoc -> DimExp vn
DimExpConst Int
k SrcLoc
loc
  astMap ASTMapper m
_ DimExp VName
DimExpAny = DimExp VName -> m (DimExp VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure DimExp VName
forall vn. DimExp vn
DimExpAny

instance ASTMappable (DimDecl VName) where
  astMap :: ASTMapper m -> DimDecl VName -> m (DimDecl VName)
astMap ASTMapper m
tv (NamedDim QualName VName
vn) = QualName VName -> DimDecl VName
forall vn. QualName vn -> DimDecl vn
NamedDim (QualName VName -> DimDecl VName)
-> m (QualName VName) -> m (DimDecl VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv QualName VName
vn
  astMap ASTMapper m
_ (ConstDim Int
k) = DimDecl VName -> m (DimDecl VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DimDecl VName -> m (DimDecl VName))
-> DimDecl VName -> m (DimDecl VName)
forall a b. (a -> b) -> a -> b
$ Int -> DimDecl VName
forall vn. Int -> DimDecl vn
ConstDim Int
k
  astMap ASTMapper m
_ DimDecl VName
AnyDim = DimDecl VName -> m (DimDecl VName)
forall (f :: * -> *) a. Applicative f => a -> f a
pure DimDecl VName
forall vn. DimDecl vn
AnyDim

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

instance ASTMappable (DimIndexBase Info VName) where
  astMap :: ASTMapper m
-> DimIndexBase Info VName -> m (DimIndexBase Info VName)
astMap ASTMapper m
tv (DimFix ExpBase Info VName
j) = ExpBase Info VName -> DimIndexBase Info VName
forall (f :: * -> *) vn. ExpBase f vn -> DimIndexBase f vn
DimFix (ExpBase Info VName -> DimIndexBase Info VName)
-> m (ExpBase Info VName) -> m (DimIndexBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
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) =
    Maybe (ExpBase Info VName)
-> Maybe (ExpBase Info VName)
-> Maybe (ExpBase Info VName)
-> DimIndexBase Info VName
forall (f :: * -> *) vn.
Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> Maybe (ExpBase f vn)
-> DimIndexBase f vn
DimSlice
      (Maybe (ExpBase Info VName)
 -> Maybe (ExpBase Info VName)
 -> Maybe (ExpBase Info VName)
 -> DimIndexBase Info VName)
-> m (Maybe (ExpBase Info VName))
-> m (Maybe (ExpBase Info VName)
      -> Maybe (ExpBase Info VName) -> DimIndexBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (Maybe (ExpBase Info VName))
-> (ExpBase Info VName -> m (Maybe (ExpBase Info VName)))
-> Maybe (ExpBase Info VName)
-> m (Maybe (ExpBase Info VName))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (ExpBase Info VName)
forall a. Maybe a
Nothing) ((ExpBase Info VName -> Maybe (ExpBase Info VName))
-> m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ExpBase Info VName -> Maybe (ExpBase Info VName)
forall a. a -> Maybe a
Just (m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName)))
-> (ExpBase Info VName -> m (ExpBase Info VName))
-> ExpBase Info VName
-> m (Maybe (ExpBase Info VName))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
i
      m (Maybe (ExpBase Info VName)
   -> Maybe (ExpBase Info VName) -> DimIndexBase Info VName)
-> m (Maybe (ExpBase Info VName))
-> m (Maybe (ExpBase Info VName) -> DimIndexBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (Maybe (ExpBase Info VName))
-> (ExpBase Info VName -> m (Maybe (ExpBase Info VName)))
-> Maybe (ExpBase Info VName)
-> m (Maybe (ExpBase Info VName))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (ExpBase Info VName)
forall a. Maybe a
Nothing) ((ExpBase Info VName -> Maybe (ExpBase Info VName))
-> m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ExpBase Info VName -> Maybe (ExpBase Info VName)
forall a. a -> Maybe a
Just (m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName)))
-> (ExpBase Info VName -> m (ExpBase Info VName))
-> ExpBase Info VName
-> m (Maybe (ExpBase Info VName))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
forall (m :: * -> *).
ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
mapOnExp ASTMapper m
tv) Maybe (ExpBase Info VName)
j
      m (Maybe (ExpBase Info VName) -> DimIndexBase Info VName)
-> m (Maybe (ExpBase Info VName)) -> m (DimIndexBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (Maybe (ExpBase Info VName))
-> (ExpBase Info VName -> m (Maybe (ExpBase Info VName)))
-> Maybe (ExpBase Info VName)
-> m (Maybe (ExpBase Info VName))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Maybe (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (ExpBase Info VName)
forall a. Maybe a
Nothing) ((ExpBase Info VName -> Maybe (ExpBase Info VName))
-> m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ExpBase Info VName -> Maybe (ExpBase Info VName)
forall a. a -> Maybe a
Just (m (ExpBase Info VName) -> m (Maybe (ExpBase Info VName)))
-> (ExpBase Info VName -> m (ExpBase Info VName))
-> ExpBase Info VName
-> m (Maybe (ExpBase Info VName))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASTMapper m -> ExpBase Info VName -> m (ExpBase Info VName)
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 :: ASTMapper m -> Alias -> m Alias
astMap ASTMapper m
tv (AliasBound VName
v) = VName -> Alias
AliasBound (VName -> Alias) -> m VName -> m Alias
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> VName -> m VName
forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
v
  astMap ASTMapper m
tv (AliasFree VName
v) = VName -> Alias
AliasFree (VName -> Alias) -> m VName -> m Alias
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> VName -> m VName
forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
v

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

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

traverseScalarType ::
  Applicative f =>
  TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType :: TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType TypeName -> f TypeName
_ dim1 -> f dims
_ als1 -> f als2
_ (Prim PrimType
t) = ScalarTypeBase dims als2 -> f (ScalarTypeBase dims als2)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ScalarTypeBase dims als2 -> f (ScalarTypeBase dims als2))
-> ScalarTypeBase dims als2 -> f (ScalarTypeBase dims als2)
forall a b. (a -> b) -> a -> b
$ PrimType -> ScalarTypeBase dims als2
forall dim as. PrimType -> ScalarTypeBase dim as
Prim PrimType
t
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (Record Map Name (TypeBase dim1 als1)
fs) = Map Name (TypeBase dims als2) -> ScalarTypeBase dims als2
forall dim as. Map Name (TypeBase dim as) -> ScalarTypeBase dim as
Record (Map Name (TypeBase dims als2) -> ScalarTypeBase dims als2)
-> f (Map Name (TypeBase dims als2))
-> f (ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (TypeBase dim1 als1 -> f (TypeBase dims als2))
-> Map Name (TypeBase dim1 als1)
-> f (Map Name (TypeBase dims als2))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (TypeTraverser f TypeBase dim1 als1 dims als2
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h) Map Name (TypeBase dim1 als1)
fs
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (TypeVar als1
als Uniqueness
u TypeName
t [TypeArg dim1]
args) =
  als2
-> Uniqueness
-> TypeName
-> [TypeArg dims]
-> ScalarTypeBase dims als2
forall dim as.
as
-> Uniqueness -> TypeName -> [TypeArg dim] -> ScalarTypeBase dim as
TypeVar (als2
 -> Uniqueness
 -> TypeName
 -> [TypeArg dims]
 -> ScalarTypeBase dims als2)
-> f als2
-> f (Uniqueness
      -> TypeName -> [TypeArg dims] -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als f (Uniqueness
   -> TypeName -> [TypeArg dims] -> ScalarTypeBase dims als2)
-> f Uniqueness
-> f (TypeName -> [TypeArg dims] -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Uniqueness -> f Uniqueness
forall (f :: * -> *) a. Applicative f => a -> f a
pure Uniqueness
u f (TypeName -> [TypeArg dims] -> ScalarTypeBase dims als2)
-> f TypeName -> f ([TypeArg dims] -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TypeName -> f TypeName
f TypeName
t f ([TypeArg dims] -> ScalarTypeBase dims als2)
-> f [TypeArg dims] -> f (ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (TypeArg dim1 -> f (TypeArg dims))
-> [TypeArg dim1] -> f [TypeArg dims]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((TypeName -> f TypeName)
-> (dim1 -> f dims) -> TypeArg dim1 -> f (TypeArg dims)
forall (f :: * -> *) dim1 dim2.
Applicative f =>
(TypeName -> f TypeName)
-> (dim1 -> f dim2) -> TypeArg dim1 -> f (TypeArg dim2)
traverseTypeArg TypeName -> f TypeName
f dim1 -> f dims
g) [TypeArg dim1]
args
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (Arrow als1
als PName
v TypeBase dim1 als1
t1 TypeBase dim1 als1
t2) =
  als2
-> PName
-> TypeBase dims als2
-> TypeBase dims als2
-> ScalarTypeBase dims als2
forall dim as.
as
-> PName
-> TypeBase dim as
-> TypeBase dim as
-> ScalarTypeBase dim as
Arrow (als2
 -> PName
 -> TypeBase dims als2
 -> TypeBase dims als2
 -> ScalarTypeBase dims als2)
-> f als2
-> f (PName
      -> TypeBase dims als2
      -> TypeBase dims als2
      -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als f (PName
   -> TypeBase dims als2
   -> TypeBase dims als2
   -> ScalarTypeBase dims als2)
-> f PName
-> f (TypeBase dims als2
      -> TypeBase dims als2 -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> PName -> f PName
forall (f :: * -> *) a. Applicative f => a -> f a
pure PName
v f (TypeBase dims als2
   -> TypeBase dims als2 -> ScalarTypeBase dims als2)
-> f (TypeBase dims als2)
-> f (TypeBase dims als2 -> ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TypeTraverser f TypeBase dim1 als1 dims als2
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h TypeBase dim1 als1
t1 f (TypeBase dims als2 -> ScalarTypeBase dims als2)
-> f (TypeBase dims als2) -> f (ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TypeTraverser f TypeBase dim1 als1 dims als2
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h TypeBase dim1 als1
t2
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (Sum Map Name [TypeBase dim1 als1]
cs) =
  Map Name [TypeBase dims als2] -> ScalarTypeBase dims als2
forall dim as. Map Name [TypeBase dim as] -> ScalarTypeBase dim as
Sum (Map Name [TypeBase dims als2] -> ScalarTypeBase dims als2)
-> f (Map Name [TypeBase dims als2])
-> f (ScalarTypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (([TypeBase dim1 als1] -> f [TypeBase dims als2])
-> Map Name [TypeBase dim1 als1]
-> f (Map Name [TypeBase dims als2])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (([TypeBase dim1 als1] -> f [TypeBase dims als2])
 -> Map Name [TypeBase dim1 als1]
 -> f (Map Name [TypeBase dims als2]))
-> ((TypeBase dim1 als1 -> f (TypeBase dims als2))
    -> [TypeBase dim1 als1] -> f [TypeBase dims als2])
-> (TypeBase dim1 als1 -> f (TypeBase dims als2))
-> Map Name [TypeBase dim1 als1]
-> f (Map Name [TypeBase dims als2])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeBase dim1 als1 -> f (TypeBase dims als2))
-> [TypeBase dim1 als1] -> f [TypeBase dims als2]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse) (TypeTraverser f TypeBase dim1 als1 dims als2
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> f TypeName
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 :: TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (Array als1
als Uniqueness
u ScalarTypeBase dim1 ()
et ShapeDecl dim1
shape) =
  als2
-> Uniqueness
-> ScalarTypeBase dims ()
-> ShapeDecl dims
-> TypeBase dims als2
forall dim as.
as
-> Uniqueness
-> ScalarTypeBase dim ()
-> ShapeDecl dim
-> TypeBase dim as
Array (als2
 -> Uniqueness
 -> ScalarTypeBase dims ()
 -> ShapeDecl dims
 -> TypeBase dims als2)
-> f als2
-> f (Uniqueness
      -> ScalarTypeBase dims () -> ShapeDecl dims -> TypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> als1 -> f als2
h als1
als f (Uniqueness
   -> ScalarTypeBase dims () -> ShapeDecl dims -> TypeBase dims als2)
-> f Uniqueness
-> f (ScalarTypeBase dims ()
      -> ShapeDecl dims -> TypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Uniqueness -> f Uniqueness
forall (f :: * -> *) a. Applicative f => a -> f a
pure Uniqueness
u
    f (ScalarTypeBase dims () -> ShapeDecl dims -> TypeBase dims als2)
-> f (ScalarTypeBase dims ())
-> f (ShapeDecl dims -> TypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TypeTraverser f ScalarTypeBase dim1 () dims ()
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g () -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ScalarTypeBase dim1 ()
et
    f (ShapeDecl dims -> TypeBase dims als2)
-> f (ShapeDecl dims) -> f (TypeBase dims als2)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (dim1 -> f dims) -> ShapeDecl dim1 -> f (ShapeDecl dims)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse dim1 -> f dims
g ShapeDecl dim1
shape
traverseType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h (Scalar ScalarTypeBase dim1 als1
t) =
  ScalarTypeBase dims als2 -> TypeBase dims als2
forall dim as. ScalarTypeBase dim as -> TypeBase dim as
Scalar (ScalarTypeBase dims als2 -> TypeBase dims als2)
-> f (ScalarTypeBase dims als2) -> f (TypeBase dims als2)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeTraverser f ScalarTypeBase dim1 als1 dims als2
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f ScalarTypeBase dim1 als1 dims als2
traverseScalarType TypeName -> f TypeName
f dim1 -> f dims
g als1 -> f als2
h ScalarTypeBase dim1 als1
t

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

instance ASTMappable StructType where
  astMap :: ASTMapper m -> StructType -> m StructType
astMap ASTMapper m
tv = TypeTraverser m TypeBase (DimDecl VName) () (DimDecl VName) ()
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> m TypeName
f (ASTMapper m -> DimDecl VName -> m (DimDecl VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    where
      f :: TypeName -> m TypeName
f = (QualName VName -> TypeName) -> m (QualName VName) -> m TypeName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap QualName VName -> TypeName
typeNameFromQualName (m (QualName VName) -> m TypeName)
-> (TypeName -> m (QualName VName)) -> TypeName -> m TypeName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv (QualName VName -> m (QualName VName))
-> (TypeName -> QualName VName) -> TypeName -> m (QualName VName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeName -> QualName VName
qualNameFromTypeName

instance ASTMappable PatternType where
  astMap :: ASTMapper m -> PatternType -> m PatternType
astMap ASTMapper m
tv = TypeTraverser
  m TypeBase (DimDecl VName) Aliasing (DimDecl VName) Aliasing
forall (f :: * -> *) dim1 als1 dims als2.
Applicative f =>
TypeTraverser f TypeBase dim1 als1 dims als2
traverseType TypeName -> m TypeName
f (ASTMapper m -> DimDecl VName -> m (DimDecl VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) (ASTMapper m -> Aliasing -> m Aliasing
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv)
    where
      f :: TypeName -> m TypeName
f = (QualName VName -> TypeName) -> m (QualName VName) -> m TypeName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap QualName VName -> TypeName
typeNameFromQualName (m (QualName VName) -> m TypeName)
-> (TypeName -> m (QualName VName)) -> TypeName -> m TypeName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ASTMapper m -> QualName VName -> m (QualName VName)
forall (m :: * -> *).
ASTMapper m -> QualName VName -> m (QualName VName)
mapOnQualName ASTMapper m
tv (QualName VName -> m (QualName VName))
-> (TypeName -> QualName VName) -> TypeName -> m (QualName VName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypeName -> QualName VName
qualNameFromTypeName

instance ASTMappable (TypeDeclBase Info VName) where
  astMap :: ASTMapper m
-> TypeDeclBase Info VName -> m (TypeDeclBase Info VName)
astMap ASTMapper m
tv (TypeDecl TypeExp VName
dt (Info StructType
et)) =
    TypeExp VName -> Info StructType -> TypeDeclBase Info VName
forall (f :: * -> *) vn.
TypeExp vn -> f StructType -> TypeDeclBase f vn
TypeDecl (TypeExp VName -> Info StructType -> TypeDeclBase Info VName)
-> m (TypeExp VName)
-> m (Info StructType -> TypeDeclBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> TypeExp VName -> m (TypeExp VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeExp VName
dt m (Info StructType -> TypeDeclBase Info VName)
-> m (Info StructType) -> m (TypeDeclBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (StructType -> Info StructType
forall a. a -> Info a
Info (StructType -> Info StructType)
-> m StructType -> m (Info StructType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> StructType -> m StructType
forall (m :: * -> *). ASTMapper m -> StructType -> m StructType
mapOnStructType ASTMapper m
tv StructType
et)

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

instance ASTMappable (PatternBase Info VName) where
  astMap :: ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
astMap ASTMapper m
tv (Id VName
name (Info PatternType
t) SrcLoc
loc) =
    VName -> Info PatternType -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> PatternBase f vn
Id (VName -> Info PatternType -> SrcLoc -> PatternBase Info VName)
-> m VName
-> m (Info PatternType -> SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> VName -> m VName
forall (m :: * -> *). ASTMapper m -> VName -> m VName
mapOnName ASTMapper m
tv VName
name m (Info PatternType -> SrcLoc -> PatternBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t) m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (TuplePattern [PatternBase Info VName]
pats SrcLoc
loc) =
    [PatternBase Info VName] -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
[PatternBase f vn] -> SrcLoc -> PatternBase f vn
TuplePattern ([PatternBase Info VName] -> SrcLoc -> PatternBase Info VName)
-> m [PatternBase Info VName]
-> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternBase Info VName -> m (PatternBase Info VName))
-> [PatternBase Info VName] -> m [PatternBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatternBase Info VName]
pats m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (RecordPattern [(Name, PatternBase Info VName)]
fields SrcLoc
loc) =
    [(Name, PatternBase Info VName)]
-> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
[(Name, PatternBase f vn)] -> SrcLoc -> PatternBase f vn
RecordPattern ([(Name, PatternBase Info VName)]
 -> SrcLoc -> PatternBase Info VName)
-> m [(Name, PatternBase Info VName)]
-> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, PatternBase Info VName)
 -> m (Name, PatternBase Info VName))
-> [(Name, PatternBase Info VName)]
-> m [(Name, PatternBase Info VName)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((PatternBase Info VName -> m (PatternBase Info VName))
-> (Name, PatternBase Info VName)
-> m (Name, PatternBase Info VName)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((PatternBase Info VName -> m (PatternBase Info VName))
 -> (Name, PatternBase Info VName)
 -> m (Name, PatternBase Info VName))
-> (PatternBase Info VName -> m (PatternBase Info VName))
-> (Name, PatternBase Info VName)
-> m (Name, PatternBase Info VName)
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [(Name, PatternBase Info VName)]
fields m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatternParens PatternBase Info VName
pat SrcLoc
loc) =
    PatternBase Info VName -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
PatternBase f vn -> SrcLoc -> PatternBase f vn
PatternParens (PatternBase Info VName -> SrcLoc -> PatternBase Info VName)
-> m (PatternBase Info VName)
-> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatternBase Info VName
pat m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatternAscription PatternBase Info VName
pat TypeDeclBase Info VName
t SrcLoc
loc) =
    PatternBase Info VName
-> TypeDeclBase Info VName -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
PatternBase f vn -> TypeDeclBase f vn -> SrcLoc -> PatternBase f vn
PatternAscription (PatternBase Info VName
 -> TypeDeclBase Info VName -> SrcLoc -> PatternBase Info VName)
-> m (PatternBase Info VName)
-> m (TypeDeclBase Info VName -> SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv PatternBase Info VName
pat m (TypeDeclBase Info VName -> SrcLoc -> PatternBase Info VName)
-> m (TypeDeclBase Info VName)
-> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m
-> TypeDeclBase Info VName -> m (TypeDeclBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv TypeDeclBase Info VName
t m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (Wildcard (Info PatternType
t) SrcLoc
loc) =
    Info PatternType -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
f PatternType -> SrcLoc -> PatternBase f vn
Wildcard (Info PatternType -> SrcLoc -> PatternBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t) m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatternLit PatLit
v (Info PatternType
t) SrcLoc
loc) =
    PatLit -> Info PatternType -> SrcLoc -> PatternBase Info VName
forall (f :: * -> *) vn.
PatLit -> f PatternType -> SrcLoc -> PatternBase f vn
PatternLit PatLit
v (Info PatternType -> SrcLoc -> PatternBase Info VName)
-> m (Info PatternType) -> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t) m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc
  astMap ASTMapper m
tv (PatternConstr Name
n (Info PatternType
t) [PatternBase Info VName]
ps SrcLoc
loc) =
    Name
-> Info PatternType
-> [PatternBase Info VName]
-> SrcLoc
-> PatternBase Info VName
forall (f :: * -> *) vn.
Name
-> f PatternType
-> [PatternBase f vn]
-> SrcLoc
-> PatternBase f vn
PatternConstr Name
n (Info PatternType
 -> [PatternBase Info VName] -> SrcLoc -> PatternBase Info VName)
-> m (Info PatternType)
-> m ([PatternBase Info VName] -> SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (PatternType -> Info PatternType
forall a. a -> Info a
Info (PatternType -> Info PatternType)
-> m PatternType -> m (Info PatternType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> PatternType -> m PatternType
forall (m :: * -> *). ASTMapper m -> PatternType -> m PatternType
mapOnPatternType ASTMapper m
tv PatternType
t) m ([PatternBase Info VName] -> SrcLoc -> PatternBase Info VName)
-> m [PatternBase Info VName]
-> m (SrcLoc -> PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (PatternBase Info VName -> m (PatternBase Info VName))
-> [PatternBase Info VName] -> m [PatternBase Info VName]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (ASTMapper m -> PatternBase Info VName -> m (PatternBase Info VName)
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv) [PatternBase Info VName]
ps m (SrcLoc -> PatternBase Info VName)
-> m SrcLoc -> m (PatternBase Info VName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SrcLoc -> m SrcLoc
forall (f :: * -> *) a. Applicative f => a -> f a
pure SrcLoc
loc

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

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

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

instance ASTMappable a => ASTMappable [a] where
  astMap :: ASTMapper m -> [a] -> m [a]
astMap ASTMapper m
tv = (a -> m a) -> [a] -> m [a]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((a -> m a) -> [a] -> m [a]) -> (a -> m a) -> [a] -> m [a]
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> a -> m a
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 :: ASTMapper m -> NonEmpty a -> m (NonEmpty a)
astMap ASTMapper m
tv = (a -> m a) -> NonEmpty a -> m (NonEmpty a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((a -> m a) -> NonEmpty a -> m (NonEmpty a))
-> (a -> m a) -> NonEmpty a -> m (NonEmpty a)
forall a b. (a -> b) -> a -> b
$ ASTMapper m -> a -> m a
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 :: ASTMapper m -> (a, b) -> m (a, b)
astMap ASTMapper m
tv (a
x, b
y) = (,) (a -> b -> (a, b)) -> m a -> m (b -> (a, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> a -> m a
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv a
x m (b -> (a, b)) -> m b -> m (a, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> b -> m 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 :: ASTMapper m -> (a, b, c) -> m (a, b, c)
astMap ASTMapper m
tv (a
x, b
y, c
z) = (,,) (a -> b -> c -> (a, b, c)) -> m a -> m (b -> c -> (a, b, c))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ASTMapper m -> a -> m a
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv a
x m (b -> c -> (a, b, c)) -> m b -> m (c -> (a, b, c))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> b -> m b
forall x (m :: * -> *).
(ASTMappable x, Monad m) =>
ASTMapper m -> x -> m x
astMap ASTMapper m
tv b
y m (c -> (a, b, c)) -> m c -> m (a, b, c)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ASTMapper m -> c -> m c
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.

bareTypeDecl :: TypeDeclBase Info VName -> TypeDeclBase NoInfo VName
bareTypeDecl :: TypeDeclBase Info VName -> TypeDeclBase NoInfo VName
bareTypeDecl (TypeDecl TypeExp VName
te Info StructType
_) = TypeExp VName -> NoInfo StructType -> TypeDeclBase NoInfo VName
forall (f :: * -> *) vn.
TypeExp vn -> f StructType -> TypeDeclBase f vn
TypeDecl TypeExp VName
te NoInfo StructType
forall a. NoInfo a
NoInfo

bareField :: FieldBase Info VName -> FieldBase NoInfo VName
bareField :: FieldBase Info VName -> FieldBase NoInfo VName
bareField (RecordFieldExplicit Name
name ExpBase Info VName
e SrcLoc
loc) =
  Name -> ExpBase NoInfo VName -> SrcLoc -> FieldBase NoInfo VName
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 PatternType
_ SrcLoc
loc) =
  VName -> NoInfo PatternType -> SrcLoc -> FieldBase NoInfo VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> FieldBase f vn
RecordFieldImplicit VName
name NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc

barePat :: PatternBase Info VName -> PatternBase NoInfo VName
barePat :: PatternBase Info VName -> PatternBase NoInfo VName
barePat (TuplePattern [PatternBase Info VName]
ps SrcLoc
loc) = [PatternBase NoInfo VName] -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
[PatternBase f vn] -> SrcLoc -> PatternBase f vn
TuplePattern ((PatternBase Info VName -> PatternBase NoInfo VName)
-> [PatternBase Info VName] -> [PatternBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map PatternBase Info VName -> PatternBase NoInfo VName
barePat [PatternBase Info VName]
ps) SrcLoc
loc
barePat (RecordPattern [(Name, PatternBase Info VName)]
fs SrcLoc
loc) = [(Name, PatternBase NoInfo VName)]
-> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
[(Name, PatternBase f vn)] -> SrcLoc -> PatternBase f vn
RecordPattern (((Name, PatternBase Info VName)
 -> (Name, PatternBase NoInfo VName))
-> [(Name, PatternBase Info VName)]
-> [(Name, PatternBase NoInfo VName)]
forall a b. (a -> b) -> [a] -> [b]
map ((PatternBase Info VName -> PatternBase NoInfo VName)
-> (Name, PatternBase Info VName)
-> (Name, PatternBase NoInfo VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap PatternBase Info VName -> PatternBase NoInfo VName
barePat) [(Name, PatternBase Info VName)]
fs) SrcLoc
loc
barePat (PatternParens PatternBase Info VName
p SrcLoc
loc) = PatternBase NoInfo VName -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
PatternBase f vn -> SrcLoc -> PatternBase f vn
PatternParens (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase Info VName
p) SrcLoc
loc
barePat (Id VName
v Info PatternType
_ SrcLoc
loc) = VName -> NoInfo PatternType -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> PatternBase f vn
Id VName
v NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
barePat (Wildcard Info PatternType
_ SrcLoc
loc) = NoInfo PatternType -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
f PatternType -> SrcLoc -> PatternBase f vn
Wildcard NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
barePat (PatternAscription PatternBase Info VName
pat (TypeDecl TypeExp VName
t Info StructType
_) SrcLoc
loc) =
  PatternBase NoInfo VName
-> TypeDeclBase NoInfo VName -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
PatternBase f vn -> TypeDeclBase f vn -> SrcLoc -> PatternBase f vn
PatternAscription (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase Info VName
pat) (TypeExp VName -> NoInfo StructType -> TypeDeclBase NoInfo VName
forall (f :: * -> *) vn.
TypeExp vn -> f StructType -> TypeDeclBase f vn
TypeDecl TypeExp VName
t NoInfo StructType
forall a. NoInfo a
NoInfo) SrcLoc
loc
barePat (PatternLit PatLit
v Info PatternType
_ SrcLoc
loc) = PatLit -> NoInfo PatternType -> SrcLoc -> PatternBase NoInfo VName
forall (f :: * -> *) vn.
PatLit -> f PatternType -> SrcLoc -> PatternBase f vn
PatternLit PatLit
v NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
barePat (PatternConstr Name
c Info PatternType
_ [PatternBase Info VName]
ps SrcLoc
loc) = Name
-> NoInfo PatternType
-> [PatternBase NoInfo VName]
-> SrcLoc
-> PatternBase NoInfo VName
forall (f :: * -> *) vn.
Name
-> f PatternType
-> [PatternBase f vn]
-> SrcLoc
-> PatternBase f vn
PatternConstr Name
c NoInfo PatternType
forall a. NoInfo a
NoInfo ((PatternBase Info VName -> PatternBase NoInfo VName)
-> [PatternBase Info VName] -> [PatternBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map PatternBase Info VName -> PatternBase NoInfo VName
barePat [PatternBase Info VName]
ps) SrcLoc
loc

bareDimIndex :: DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex :: DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex (DimFix ExpBase Info VName
e) =
  ExpBase NoInfo VName -> DimIndexBase NoInfo VName
forall (f :: * -> *) vn. ExpBase f vn -> DimIndexBase f vn
DimFix (ExpBase NoInfo VName -> DimIndexBase NoInfo VName)
-> ExpBase NoInfo VName -> DimIndexBase NoInfo VName
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) =
  Maybe (ExpBase NoInfo VName)
-> Maybe (ExpBase NoInfo VName)
-> Maybe (ExpBase NoInfo VName)
-> DimIndexBase NoInfo VName
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 (ExpBase Info VName -> ExpBase NoInfo VName)
-> Maybe (ExpBase Info VName) -> Maybe (ExpBase NoInfo VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ExpBase Info VName)
x) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp (ExpBase Info VName -> ExpBase NoInfo VName)
-> Maybe (ExpBase Info VName) -> Maybe (ExpBase NoInfo VName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (ExpBase Info VName)
y) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp (ExpBase Info VName -> ExpBase NoInfo VName)
-> Maybe (ExpBase Info VName) -> Maybe (ExpBase NoInfo VName)
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 PatternType
_ SrcLoc
loc) ExpBase Info VName
e) = IdentBase NoInfo VName
-> ExpBase NoInfo VName -> LoopFormBase NoInfo VName
forall (f :: * -> *) vn.
IdentBase f vn -> ExpBase f vn -> LoopFormBase f vn
For (VName -> NoInfo PatternType -> SrcLoc -> IdentBase NoInfo VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> IdentBase f vn
Ident VName
i NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e)
bareLoopForm (ForIn PatternBase Info VName
pat ExpBase Info VName
e) = PatternBase NoInfo VName
-> ExpBase NoInfo VName -> LoopFormBase NoInfo VName
forall (f :: * -> *) vn.
PatternBase f vn -> ExpBase f vn -> LoopFormBase f vn
ForIn (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase Info VName
pat) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e)
bareLoopForm (While ExpBase Info VName
e) = ExpBase NoInfo VName -> LoopFormBase NoInfo VName
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 PatternBase Info VName
pat ExpBase Info VName
e SrcLoc
loc) = PatternBase NoInfo VName
-> ExpBase NoInfo VName -> SrcLoc -> CaseBase NoInfo VName
forall (f :: * -> *) vn.
PatternBase f vn -> ExpBase f vn -> SrcLoc -> CaseBase f vn
CasePat (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase 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 PatternType
_ SrcLoc
loc) = QualName VName
-> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
QualName vn -> f PatternType -> SrcLoc -> ExpBase f vn
Var QualName VName
name NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Literal PrimValue
v SrcLoc
loc) = PrimValue -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn. PrimValue -> SrcLoc -> ExpBase f vn
Literal PrimValue
v SrcLoc
loc
bareExp (IntLit Integer
val Info PatternType
_ SrcLoc
loc) = Integer -> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
Integer -> f PatternType -> SrcLoc -> ExpBase f vn
IntLit Integer
val NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (FloatLit Double
val Info PatternType
_ SrcLoc
loc) = Double -> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
Double -> f PatternType -> SrcLoc -> ExpBase f vn
FloatLit Double
val NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Parens ExpBase Info VName
e SrcLoc
loc) = ExpBase NoInfo VName -> SrcLoc -> ExpBase NoInfo VName
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) = (QualName VName, SrcLoc)
-> ExpBase NoInfo VName -> SrcLoc -> ExpBase NoInfo VName
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) = [ExpBase NoInfo VName] -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn. [ExpBase f vn] -> SrcLoc -> ExpBase f vn
TupLit ((ExpBase Info VName -> ExpBase NoInfo VName)
-> [ExpBase Info VName] -> [ExpBase NoInfo VName]
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) = [Word8] -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn. [Word8] -> SrcLoc -> ExpBase f vn
StringLit [Word8]
vs SrcLoc
loc
bareExp (RecordLit [FieldBase Info VName]
fields SrcLoc
loc) = [FieldBase NoInfo VName] -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn. [FieldBase f vn] -> SrcLoc -> ExpBase f vn
RecordLit ((FieldBase Info VName -> FieldBase NoInfo VName)
-> [FieldBase Info VName] -> [FieldBase NoInfo VName]
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 PatternType
_ SrcLoc
loc) = [ExpBase NoInfo VName]
-> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
[ExpBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
ArrayLit ((ExpBase Info VName -> ExpBase NoInfo VName)
-> [ExpBase Info VName] -> [ExpBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map ExpBase Info VName -> ExpBase NoInfo VName
bareExp [ExpBase Info VName]
els) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Range ExpBase Info VName
start Maybe (ExpBase Info VName)
next Inclusiveness (ExpBase Info VName)
end (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> Maybe (ExpBase NoInfo VName)
-> Inclusiveness (ExpBase NoInfo VName)
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> Maybe (ExpBase f vn)
-> Inclusiveness (ExpBase f vn)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Range
    (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
start)
    ((ExpBase Info VName -> ExpBase NoInfo VName)
-> Maybe (ExpBase Info VName) -> Maybe (ExpBase NoInfo VName)
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)
    ((ExpBase Info VName -> ExpBase NoInfo VName)
-> Inclusiveness (ExpBase Info VName)
-> Inclusiveness (ExpBase NoInfo VName)
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)
    (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo)
    SrcLoc
loc
bareExp (Ascript ExpBase Info VName
e TypeDeclBase Info VName
tdecl SrcLoc
loc) =
  ExpBase NoInfo VName
-> TypeDeclBase NoInfo VName -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn -> TypeDeclBase f vn -> SrcLoc -> ExpBase f vn
Ascript (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) (TypeDeclBase Info VName -> TypeDeclBase NoInfo VName
bareTypeDecl TypeDeclBase Info VName
tdecl) SrcLoc
loc
bareExp (Coerce ExpBase Info VName
e TypeDeclBase Info VName
tdecl (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> TypeDeclBase NoInfo VName
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> TypeDeclBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Coerce (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) (TypeDeclBase Info VName -> TypeDeclBase NoInfo VName
bareTypeDecl TypeDeclBase Info VName
tdecl) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (BinOp (QualName VName, SrcLoc)
fname Info PatternType
_ (ExpBase Info VName
x, Info (StructType, Maybe VName)
_) (ExpBase Info VName
y, Info (StructType, Maybe VName)
_) Info PatternType
_ Info [VName]
_ SrcLoc
loc) =
  (QualName VName, SrcLoc)
-> NoInfo PatternType
-> (ExpBase NoInfo VName, NoInfo (StructType, Maybe VName))
-> (ExpBase NoInfo VName, NoInfo (StructType, Maybe VName))
-> NoInfo PatternType
-> NoInfo [VName]
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
(QualName vn, SrcLoc)
-> f PatternType
-> (ExpBase f vn, f (StructType, Maybe VName))
-> (ExpBase f vn, f (StructType, Maybe VName))
-> f PatternType
-> f [VName]
-> SrcLoc
-> ExpBase f vn
BinOp (QualName VName, SrcLoc)
fname NoInfo PatternType
forall a. NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
x, NoInfo (StructType, Maybe VName)
forall a. NoInfo a
NoInfo) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
y, NoInfo (StructType, Maybe VName)
forall a. NoInfo a
NoInfo) NoInfo PatternType
forall a. NoInfo a
NoInfo NoInfo [VName]
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Negate ExpBase Info VName
x SrcLoc
loc) = ExpBase NoInfo VName -> SrcLoc -> ExpBase NoInfo VName
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 (If ExpBase Info VName
c ExpBase Info VName
texp ExpBase Info VName
fexp (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase 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) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (Apply ExpBase Info VName
f ExpBase Info VName
arg Info (Diet, Maybe VName)
_ (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> NoInfo (Diet, Maybe VName)
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> ExpBase f vn
-> f (Diet, Maybe VName)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase 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) NoInfo (Diet, Maybe VName)
forall a. NoInfo a
NoInfo (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (LetPat PatternBase Info VName
pat ExpBase Info VName
e ExpBase Info VName
body (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  PatternBase NoInfo VName
-> ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
PatternBase f vn
-> ExpBase f vn
-> ExpBase f vn
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
LetPat (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase 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) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (LetFun VName
name ([TypeParamBase VName]
fparams, [PatternBase Info VName]
params, Maybe (TypeExp VName)
ret, Info StructType
_, ExpBase Info VName
e) ExpBase Info VName
body Info PatternType
_ SrcLoc
loc) =
  VName
-> ([TypeParamBase VName], [PatternBase NoInfo VName],
    Maybe (TypeExp VName), NoInfo StructType, ExpBase NoInfo VName)
-> ExpBase NoInfo VName
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
vn
-> ([TypeParamBase vn], [PatternBase f vn], Maybe (TypeExp vn),
    f StructType, ExpBase f vn)
-> ExpBase f vn
-> f PatternType
-> SrcLoc
-> ExpBase f vn
LetFun VName
name ([TypeParamBase VName]
fparams, (PatternBase Info VName -> PatternBase NoInfo VName)
-> [PatternBase Info VName] -> [PatternBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map PatternBase Info VName -> PatternBase NoInfo VName
barePat [PatternBase Info VName]
params, Maybe (TypeExp VName)
ret, NoInfo StructType
forall a. 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) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (LetWith (Ident VName
dest Info PatternType
_ SrcLoc
destloc) (Ident VName
src Info PatternType
_ SrcLoc
srcloc) [DimIndexBase Info VName]
idxexps ExpBase Info VName
vexp ExpBase Info VName
body Info PatternType
_ SrcLoc
loc) =
  IdentBase NoInfo VName
-> IdentBase NoInfo VName
-> [DimIndexBase NoInfo VName]
-> ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
IdentBase f vn
-> IdentBase f vn
-> [DimIndexBase f vn]
-> ExpBase f vn
-> ExpBase f vn
-> f PatternType
-> SrcLoc
-> ExpBase f vn
LetWith
    (VName -> NoInfo PatternType -> SrcLoc -> IdentBase NoInfo VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> IdentBase f vn
Ident VName
dest NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
destloc)
    (VName -> NoInfo PatternType -> SrcLoc -> IdentBase NoInfo VName
forall (f :: * -> *) vn.
vn -> f PatternType -> SrcLoc -> IdentBase f vn
Ident VName
src NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
srcloc)
    ((DimIndexBase Info VName -> DimIndexBase NoInfo VName)
-> [DimIndexBase Info VName] -> [DimIndexBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex [DimIndexBase 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)
    NoInfo PatternType
forall a. NoInfo a
NoInfo
    SrcLoc
loc
bareExp (Update ExpBase Info VName
src [DimIndexBase Info VName]
slice ExpBase Info VName
v SrcLoc
loc) =
  ExpBase NoInfo VName
-> [DimIndexBase NoInfo VName]
-> ExpBase NoInfo VName
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [DimIndexBase f vn] -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Update (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
src) ((DimIndexBase Info VName -> DimIndexBase NoInfo VName)
-> [DimIndexBase Info VName] -> [DimIndexBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex [DimIndexBase 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 PatternType
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> [Name]
-> ExpBase NoInfo VName
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [Name]
-> ExpBase f vn
-> f PatternType
-> 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) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Project Name
field ExpBase Info VName
e Info PatternType
_ SrcLoc
loc) = Name
-> ExpBase NoInfo VName
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
Name -> ExpBase f vn -> f PatternType -> SrcLoc -> ExpBase f vn
Project Name
field (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Index ExpBase Info VName
arr [DimIndexBase Info VName]
slice (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> [DimIndexBase NoInfo VName]
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> [DimIndexBase f vn]
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Index (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arr) ((DimIndexBase Info VName -> DimIndexBase NoInfo VName)
-> [DimIndexBase Info VName] -> [DimIndexBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex [DimIndexBase Info VName]
slice) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (Assert ExpBase Info VName
e1 ExpBase Info VName
e2 Info String
_ SrcLoc
loc) = ExpBase NoInfo VName
-> ExpBase NoInfo VName
-> NoInfo String
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn -> ExpBase f vn -> f String -> 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) NoInfo String
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Lambda [PatternBase Info VName]
params ExpBase Info VName
body Maybe (TypeExp VName)
ret Info (Aliasing, StructType)
_ SrcLoc
loc) =
  [PatternBase NoInfo VName]
-> ExpBase NoInfo VName
-> Maybe (TypeExp VName)
-> NoInfo (Aliasing, StructType)
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
[PatternBase f vn]
-> ExpBase f vn
-> Maybe (TypeExp vn)
-> f (Aliasing, StructType)
-> SrcLoc
-> ExpBase f vn
Lambda ((PatternBase Info VName -> PatternBase NoInfo VName)
-> [PatternBase Info VName] -> [PatternBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map PatternBase Info VName -> PatternBase NoInfo VName
barePat [PatternBase Info VName]
params) (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
body) Maybe (TypeExp VName)
ret NoInfo (Aliasing, StructType)
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (OpSection QualName VName
name Info PatternType
_ SrcLoc
loc) = QualName VName
-> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
QualName vn -> f PatternType -> SrcLoc -> ExpBase f vn
OpSection QualName VName
name NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (OpSectionLeft QualName VName
name Info PatternType
_ ExpBase Info VName
arg (Info (PName, StructType, Maybe VName), Info (PName, StructType))
_ (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  QualName VName
-> NoInfo PatternType
-> ExpBase NoInfo VName
-> (NoInfo (PName, StructType, Maybe VName),
    NoInfo (PName, StructType))
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
QualName vn
-> f PatternType
-> ExpBase f vn
-> (f (PName, StructType, Maybe VName), f (PName, StructType))
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
OpSectionLeft QualName VName
name NoInfo PatternType
forall a. NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arg) (NoInfo (PName, StructType, Maybe VName)
forall a. NoInfo a
NoInfo, NoInfo (PName, StructType)
forall a. NoInfo a
NoInfo) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (OpSectionRight QualName VName
name Info PatternType
_ ExpBase Info VName
arg (Info (PName, StructType), Info (PName, StructType, Maybe VName))
_ Info PatternType
_ SrcLoc
loc) =
  QualName VName
-> NoInfo PatternType
-> ExpBase NoInfo VName
-> (NoInfo (PName, StructType),
    NoInfo (PName, StructType, Maybe VName))
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
QualName vn
-> f PatternType
-> ExpBase f vn
-> (f (PName, StructType), f (PName, StructType, Maybe VName))
-> f PatternType
-> SrcLoc
-> ExpBase f vn
OpSectionRight QualName VName
name NoInfo PatternType
forall a. NoInfo a
NoInfo (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
arg) (NoInfo (PName, StructType)
forall a. NoInfo a
NoInfo, NoInfo (PName, StructType, Maybe VName)
forall a. NoInfo a
NoInfo) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (ProjectSection [Name]
fields Info PatternType
_ SrcLoc
loc) = [Name] -> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
[Name] -> f PatternType -> SrcLoc -> ExpBase f vn
ProjectSection [Name]
fields NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (IndexSection [DimIndexBase Info VName]
slice Info PatternType
_ SrcLoc
loc) =
  [DimIndexBase NoInfo VName]
-> NoInfo PatternType -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
[DimIndexBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
IndexSection ((DimIndexBase Info VName -> DimIndexBase NoInfo VName)
-> [DimIndexBase Info VName] -> [DimIndexBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map DimIndexBase Info VName -> DimIndexBase NoInfo VName
bareDimIndex [DimIndexBase Info VName]
slice) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (DoLoop [VName]
_ PatternBase Info VName
mergepat ExpBase Info VName
mergeexp LoopFormBase Info VName
form ExpBase Info VName
loopbody Info (PatternType, [VName])
_ SrcLoc
loc) =
  [VName]
-> PatternBase NoInfo VName
-> ExpBase NoInfo VName
-> LoopFormBase NoInfo VName
-> ExpBase NoInfo VName
-> NoInfo (PatternType, [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
[VName]
-> PatternBase f vn
-> ExpBase f vn
-> LoopFormBase f vn
-> ExpBase f vn
-> f (PatternType, [VName])
-> SrcLoc
-> ExpBase f vn
DoLoop
    []
    (PatternBase Info VName -> PatternBase NoInfo VName
barePat PatternBase 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)
    NoInfo (PatternType, [VName])
forall a. NoInfo a
NoInfo
    SrcLoc
loc
bareExp (Constr Name
name [ExpBase Info VName]
es Info PatternType
_ SrcLoc
loc) =
  Name
-> [ExpBase NoInfo VName]
-> NoInfo PatternType
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
Name -> [ExpBase f vn] -> f PatternType -> SrcLoc -> ExpBase f vn
Constr Name
name ((ExpBase Info VName -> ExpBase NoInfo VName)
-> [ExpBase Info VName] -> [ExpBase NoInfo VName]
forall a b. (a -> b) -> [a] -> [b]
map ExpBase Info VName -> ExpBase NoInfo VName
bareExp [ExpBase Info VName]
es) NoInfo PatternType
forall a. NoInfo a
NoInfo SrcLoc
loc
bareExp (Match ExpBase Info VName
e NonEmpty (CaseBase Info VName)
cases (Info PatternType, Info [VName])
_ SrcLoc
loc) =
  ExpBase NoInfo VName
-> NonEmpty (CaseBase NoInfo VName)
-> (NoInfo PatternType, NoInfo [VName])
-> SrcLoc
-> ExpBase NoInfo VName
forall (f :: * -> *) vn.
ExpBase f vn
-> NonEmpty (CaseBase f vn)
-> (f PatternType, f [VName])
-> SrcLoc
-> ExpBase f vn
Match (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) ((CaseBase Info VName -> CaseBase NoInfo VName)
-> NonEmpty (CaseBase Info VName)
-> NonEmpty (CaseBase NoInfo VName)
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) (NoInfo PatternType
forall a. NoInfo a
NoInfo, NoInfo [VName]
forall a. NoInfo a
NoInfo) SrcLoc
loc
bareExp (Attr AttrInfo
attr ExpBase Info VName
e SrcLoc
loc) =
  AttrInfo -> ExpBase NoInfo VName -> SrcLoc -> ExpBase NoInfo VName
forall (f :: * -> *) vn.
AttrInfo -> ExpBase f vn -> SrcLoc -> ExpBase f vn
Attr AttrInfo
attr (ExpBase Info VName -> ExpBase NoInfo VName
bareExp ExpBase Info VName
e) SrcLoc
loc