{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE EmptyCase, TypeOperators, FlexibleContexts #-}
module Text.LLVM.Labels where

import Text.LLVM.AST
import Text.LLVM.Labels.TH

class Functor f => HasLabel f where
  -- | Given a function for resolving labels, where the presence of a symbol
  -- denotes a label in a different function, rename all labels in a function.
  relabel :: Applicative m => (Maybe Symbol -> a -> m b) -> f a -> m (f b)

instance HasLabel Instr' where
  relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Instr' a -> m (Instr' b)
relabel Maybe Symbol -> a -> m b
_ Instr' a
RetVoid               = Instr' b -> m (Instr' b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure  Instr' b
forall lab. Instr' lab
RetVoid
  relabel Maybe Symbol -> a -> m b
_ Instr' a
Unreachable           = Instr' b -> m (Instr' b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure  Instr' b
forall lab. Instr' lab
Unreachable
  relabel Maybe Symbol -> a -> m b
_ Instr' a
Unwind                = Instr' b -> m (Instr' b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure  Instr' b
forall lab. Instr' lab
Unwind
  relabel Maybe Symbol -> a -> m b
_ (Comment String
str)         = Instr' b -> m (Instr' b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> Instr' b
forall lab. String -> Instr' lab
Comment String
str)
  relabel Maybe Symbol -> a -> m b
f (Ret Typed (Value' a)
tv)              = Typed (Value' b) -> Instr' b
forall lab. Typed (Value' lab) -> Instr' lab
Ret (Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b)) -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
tv
  relabel Maybe Symbol -> a -> m b
f (Arith ArithOp
op Typed (Value' a)
l Value' a
r)        = ArithOp -> Typed (Value' b) -> Value' b -> Instr' b
forall lab.
ArithOp -> Typed (Value' lab) -> Value' lab -> Instr' lab
Arith ArithOp
op
                                (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
r
  relabel Maybe Symbol -> a -> m b
f (UnaryArith UnaryArithOp
op Typed (Value' a)
a)     = UnaryArithOp -> Typed (Value' b) -> Instr' b
forall lab. UnaryArithOp -> Typed (Value' lab) -> Instr' lab
UnaryArith UnaryArithOp
op
                                (Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b)) -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
  relabel Maybe Symbol -> a -> m b
f (Bit BitOp
op Typed (Value' a)
l Value' a
r)          = BitOp -> Typed (Value' b) -> Value' b -> Instr' b
forall lab. BitOp -> Typed (Value' lab) -> Value' lab -> Instr' lab
Bit BitOp
op
                                (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
r
  relabel Maybe Symbol -> a -> m b
f (Conv ConvOp
op Typed (Value' a)
l Type
r)         = ConvOp -> Typed (Value' b) -> Type -> Instr' b
forall lab. ConvOp -> Typed (Value' lab) -> Type -> Instr' lab
Conv ConvOp
op (Typed (Value' b) -> Type -> Instr' b)
-> m (Typed (Value' b)) -> m (Type -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l m (Type -> Instr' b) -> m Type -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> m Type
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
r
  relabel Maybe Symbol -> a -> m b
f (Call Bool
t Type
r Value' a
n [Typed (Value' a)]
as)       = Bool -> Type -> Value' b -> [Typed (Value' b)] -> Instr' b
forall lab.
Bool -> Type -> Value' lab -> [Typed (Value' lab)] -> Instr' lab
Call Bool
t Type
r
                                (Value' b -> [Typed (Value' b)] -> Instr' b)
-> m (Value' b) -> m ([Typed (Value' b)] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
n
                                m ([Typed (Value' b)] -> Instr' b)
-> m [Typed (Value' b)] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Typed (Value' a) -> m (Typed (Value' b)))
-> [Typed (Value' a)] -> m [Typed (Value' b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) [Typed (Value' a)]
as
  relabel Maybe Symbol -> a -> m b
f (CallBr Type
r Value' a
n [Typed (Value' a)]
as a
u [a]
es)  = Type -> Value' b -> [Typed (Value' b)] -> b -> [b] -> Instr' b
forall lab.
Type
-> Value' lab -> [Typed (Value' lab)] -> lab -> [lab] -> Instr' lab
CallBr Type
r
                                (Value' b -> [Typed (Value' b)] -> b -> [b] -> Instr' b)
-> m (Value' b) -> m ([Typed (Value' b)] -> b -> [b] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
n
                                m ([Typed (Value' b)] -> b -> [b] -> Instr' b)
-> m [Typed (Value' b)] -> m (b -> [b] -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Typed (Value' a) -> m (Typed (Value' b)))
-> [Typed (Value' a)] -> m [Typed (Value' b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) [Typed (Value' a)]
as
                                m (b -> [b] -> Instr' b) -> m b -> m ([b] -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
u
                                m ([b] -> Instr' b) -> m [b] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> m b) -> [a] -> m [b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing) [a]
es
  relabel Maybe Symbol -> a -> m b
f (Alloca Type
t Maybe (Typed (Value' a))
n Maybe Int
a)        = Type -> Maybe (Typed (Value' b)) -> Maybe Int -> Instr' b
forall lab.
Type -> Maybe (Typed (Value' lab)) -> Maybe Int -> Instr' lab
Alloca Type
t
                                (Maybe (Typed (Value' b)) -> Maybe Int -> Instr' b)
-> m (Maybe (Typed (Value' b))) -> m (Maybe Int -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Typed (Value' a) -> m (Typed (Value' b)))
-> Maybe (Typed (Value' a)) -> m (Maybe (Typed (Value' b)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) Maybe (Typed (Value' a))
n
                                m (Maybe Int -> Instr' b) -> m (Maybe Int) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Int -> m (Maybe Int)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
a
  relabel Maybe Symbol -> a -> m b
f (Load Type
t Typed (Value' a)
a Maybe AtomicOrdering
mo Maybe Int
ma)      = Type
-> Typed (Value' b)
-> Maybe AtomicOrdering
-> Maybe Int
-> Instr' b
forall lab.
Type
-> Typed (Value' lab)
-> Maybe AtomicOrdering
-> Maybe Int
-> Instr' lab
Load Type
t
                                (Typed (Value' b) -> Maybe AtomicOrdering -> Maybe Int -> Instr' b)
-> m (Typed (Value' b))
-> m (Maybe AtomicOrdering -> Maybe Int -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m (Maybe AtomicOrdering -> Maybe Int -> Instr' b)
-> m (Maybe AtomicOrdering) -> m (Maybe Int -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe AtomicOrdering -> m (Maybe AtomicOrdering)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe AtomicOrdering
mo
                                m (Maybe Int -> Instr' b) -> m (Maybe Int) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Int -> m (Maybe Int)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
ma
  relabel Maybe Symbol -> a -> m b
f (Store Typed (Value' a)
d Typed (Value' a)
v Maybe AtomicOrdering
mo Maybe Int
ma)     = Typed (Value' b)
-> Typed (Value' b)
-> Maybe AtomicOrdering
-> Maybe Int
-> Instr' b
forall lab.
Typed (Value' lab)
-> Typed (Value' lab)
-> Maybe AtomicOrdering
-> Maybe Int
-> Instr' lab
Store
                                (Typed (Value' b)
 -> Typed (Value' b)
 -> Maybe AtomicOrdering
 -> Maybe Int
 -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b)
      -> Maybe AtomicOrdering -> Maybe Int -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
d
                                m (Typed (Value' b)
   -> Maybe AtomicOrdering -> Maybe Int -> Instr' b)
-> m (Typed (Value' b))
-> m (Maybe AtomicOrdering -> Maybe Int -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
v
                                m (Maybe AtomicOrdering -> Maybe Int -> Instr' b)
-> m (Maybe AtomicOrdering) -> m (Maybe Int -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe AtomicOrdering -> m (Maybe AtomicOrdering)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe AtomicOrdering
mo
                                m (Maybe Int -> Instr' b) -> m (Maybe Int) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Int -> m (Maybe Int)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Int
ma
  relabel Maybe Symbol -> a -> m b
_ (Fence Maybe String
s AtomicOrdering
o)           = Instr' b -> m (Instr' b)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe String -> AtomicOrdering -> Instr' b
forall lab. Maybe String -> AtomicOrdering -> Instr' lab
Fence Maybe String
s AtomicOrdering
o)
  relabel Maybe Symbol -> a -> m b
f (CmpXchg Bool
w Bool
v Typed (Value' a)
p Typed (Value' a)
a Typed (Value' a)
n Maybe String
s AtomicOrdering
o AtomicOrdering
o')
                                  = Bool
-> Bool
-> Typed (Value' b)
-> Typed (Value' b)
-> Typed (Value' b)
-> Maybe String
-> AtomicOrdering
-> AtomicOrdering
-> Instr' b
forall lab.
Bool
-> Bool
-> Typed (Value' lab)
-> Typed (Value' lab)
-> Typed (Value' lab)
-> Maybe String
-> AtomicOrdering
-> AtomicOrdering
-> Instr' lab
CmpXchg Bool
w Bool
v
                                (Typed (Value' b)
 -> Typed (Value' b)
 -> Typed (Value' b)
 -> Maybe String
 -> AtomicOrdering
 -> AtomicOrdering
 -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b)
      -> Typed (Value' b)
      -> Maybe String
      -> AtomicOrdering
      -> AtomicOrdering
      -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
p
                                m (Typed (Value' b)
   -> Typed (Value' b)
   -> Maybe String
   -> AtomicOrdering
   -> AtomicOrdering
   -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b)
      -> Maybe String -> AtomicOrdering -> AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m (Typed (Value' b)
   -> Maybe String -> AtomicOrdering -> AtomicOrdering -> Instr' b)
-> m (Typed (Value' b))
-> m (Maybe String -> AtomicOrdering -> AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
n
                                m (Maybe String -> AtomicOrdering -> AtomicOrdering -> Instr' b)
-> m (Maybe String)
-> m (AtomicOrdering -> AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe String -> m (Maybe String)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe String
s
                                m (AtomicOrdering -> AtomicOrdering -> Instr' b)
-> m AtomicOrdering -> m (AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AtomicOrdering -> m AtomicOrdering
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AtomicOrdering
o
                                m (AtomicOrdering -> Instr' b) -> m AtomicOrdering -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AtomicOrdering -> m AtomicOrdering
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AtomicOrdering
o'
  relabel Maybe Symbol -> a -> m b
f (AtomicRW Bool
v AtomicRWOp
op Typed (Value' a)
p Typed (Value' a)
a Maybe String
s AtomicOrdering
o)
                                  = Bool
-> AtomicRWOp
-> Typed (Value' b)
-> Typed (Value' b)
-> Maybe String
-> AtomicOrdering
-> Instr' b
forall lab.
Bool
-> AtomicRWOp
-> Typed (Value' lab)
-> Typed (Value' lab)
-> Maybe String
-> AtomicOrdering
-> Instr' lab
AtomicRW Bool
v AtomicRWOp
op
                                (Typed (Value' b)
 -> Typed (Value' b) -> Maybe String -> AtomicOrdering -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b)
      -> Maybe String -> AtomicOrdering -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
p
                                m (Typed (Value' b) -> Maybe String -> AtomicOrdering -> Instr' b)
-> m (Typed (Value' b))
-> m (Maybe String -> AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m (Maybe String -> AtomicOrdering -> Instr' b)
-> m (Maybe String) -> m (AtomicOrdering -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe String -> m (Maybe String)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe String
s
                                m (AtomicOrdering -> Instr' b) -> m AtomicOrdering -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> AtomicOrdering -> m AtomicOrdering
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AtomicOrdering
o
  relabel Maybe Symbol -> a -> m b
f (ICmp ICmpOp
op Typed (Value' a)
l Value' a
r)         = ICmpOp -> Typed (Value' b) -> Value' b -> Instr' b
forall lab.
ICmpOp -> Typed (Value' lab) -> Value' lab -> Instr' lab
ICmp ICmpOp
op
                                (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
r
  relabel Maybe Symbol -> a -> m b
f (FCmp FCmpOp
op Typed (Value' a)
l Value' a
r)         = FCmpOp -> Typed (Value' b) -> Value' b -> Instr' b
forall lab.
FCmpOp -> Typed (Value' lab) -> Value' lab -> Instr' lab
FCmp FCmpOp
op
                                (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
r
  relabel Maybe Symbol -> a -> m b
f (GEP Bool
ib Type
t Typed (Value' a)
a [Typed (Value' a)]
is)       = Bool -> Type -> Typed (Value' b) -> [Typed (Value' b)] -> Instr' b
forall lab.
Bool
-> Type -> Typed (Value' lab) -> [Typed (Value' lab)] -> Instr' lab
GEP Bool
ib Type
t
                                (Typed (Value' b) -> [Typed (Value' b)] -> Instr' b)
-> m (Typed (Value' b)) -> m ([Typed (Value' b)] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m ([Typed (Value' b)] -> Instr' b)
-> m [Typed (Value' b)] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Typed (Value' a) -> m (Typed (Value' b)))
-> [Typed (Value' a)] -> m [Typed (Value' b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) [Typed (Value' a)]
is
  relabel Maybe Symbol -> a -> m b
f (Select Typed (Value' a)
c Typed (Value' a)
l Value' a
r)        = Typed (Value' b) -> Typed (Value' b) -> Value' b -> Instr' b
forall lab.
Typed (Value' lab)
-> Typed (Value' lab) -> Value' lab -> Instr' lab
Select
                                (Typed (Value' b) -> Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b) -> Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
c
                                m (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
l m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
r
  relabel Maybe Symbol -> a -> m b
f (ExtractValue Typed (Value' a)
a [Int32]
is)   = Typed (Value' b) -> [Int32] -> Instr' b
forall lab. Typed (Value' lab) -> [Int32] -> Instr' lab
ExtractValue
                                (Typed (Value' b) -> [Int32] -> Instr' b)
-> m (Typed (Value' b)) -> m ([Int32] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m ([Int32] -> Instr' b) -> m [Int32] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Int32] -> m [Int32]
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Int32]
is
  relabel Maybe Symbol -> a -> m b
f (InsertValue Typed (Value' a)
a Typed (Value' a)
i [Int32]
is)  = Typed (Value' b) -> Typed (Value' b) -> [Int32] -> Instr' b
forall lab.
Typed (Value' lab) -> Typed (Value' lab) -> [Int32] -> Instr' lab
InsertValue
                                (Typed (Value' b) -> Typed (Value' b) -> [Int32] -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b) -> [Int32] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m (Typed (Value' b) -> [Int32] -> Instr' b)
-> m (Typed (Value' b)) -> m ([Int32] -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
i
                                m ([Int32] -> Instr' b) -> m [Int32] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Int32] -> m [Int32]
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Int32]
is
  relabel Maybe Symbol -> a -> m b
f (ShuffleVector Typed (Value' a)
a Value' a
b Typed (Value' a)
m) = Typed (Value' b) -> Value' b -> Typed (Value' b) -> Instr' b
forall lab.
Typed (Value' lab)
-> Value' lab -> Typed (Value' lab) -> Instr' lab
ShuffleVector
                                (Typed (Value' b) -> Value' b -> Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b))
-> m (Value' b -> Typed (Value' b) -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
a
                                m (Value' b -> Typed (Value' b) -> Instr' b)
-> m (Value' b) -> m (Typed (Value' b) -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
b
                                m (Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b)) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
m
  relabel Maybe Symbol -> a -> m b
f (Jump a
lab)            = b -> Instr' b
forall lab. lab -> Instr' lab
Jump (b -> Instr' b) -> m b -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
lab
  relabel Maybe Symbol -> a -> m b
f (Br Typed (Value' a)
c a
l a
r)            = Typed (Value' b) -> b -> b -> Instr' b
forall lab. Typed (Value' lab) -> lab -> lab -> Instr' lab
Br
                                (Typed (Value' b) -> b -> b -> Instr' b)
-> m (Typed (Value' b)) -> m (b -> b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
c
                                m (b -> b -> Instr' b) -> m b -> m (b -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
l
                                m (b -> Instr' b) -> m b -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
r
  relabel Maybe Symbol -> a -> m b
f (Invoke Type
r Value' a
s [Typed (Value' a)]
as a
u a
e)   = Type -> Value' b -> [Typed (Value' b)] -> b -> b -> Instr' b
forall lab.
Type
-> Value' lab -> [Typed (Value' lab)] -> lab -> lab -> Instr' lab
Invoke Type
r
                                (Value' b -> [Typed (Value' b)] -> b -> b -> Instr' b)
-> m (Value' b) -> m ([Typed (Value' b)] -> b -> b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
s
                                m ([Typed (Value' b)] -> b -> b -> Instr' b)
-> m [Typed (Value' b)] -> m (b -> b -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Typed (Value' a) -> m (Typed (Value' b)))
-> [Typed (Value' a)] -> m [Typed (Value' b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) [Typed (Value' a)]
as
                                m (b -> b -> Instr' b) -> m b -> m (b -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
u
                                m (b -> Instr' b) -> m b -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
e
  relabel Maybe Symbol -> a -> m b
f (VaArg Typed (Value' a)
al Type
t)          = Typed (Value' b) -> Type -> Instr' b
forall lab. Typed (Value' lab) -> Type -> Instr' lab
VaArg
                                (Typed (Value' b) -> Type -> Instr' b)
-> m (Typed (Value' b)) -> m (Type -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
al
                                m (Type -> Instr' b) -> m Type -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> m Type
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type
t
  relabel Maybe Symbol -> a -> m b
f (ExtractElt Typed (Value' a)
v Value' a
i)      = Typed (Value' b) -> Value' b -> Instr' b
forall lab. Typed (Value' lab) -> Value' lab -> Instr' lab
ExtractElt
                                (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
v
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
i
  relabel Maybe Symbol -> a -> m b
f (InsertElt Typed (Value' a)
v Typed (Value' a)
e Value' a
i)     = Typed (Value' b) -> Typed (Value' b) -> Value' b -> Instr' b
forall lab.
Typed (Value' lab)
-> Typed (Value' lab) -> Value' lab -> Instr' lab
InsertElt
                                (Typed (Value' b) -> Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b))
-> m (Typed (Value' b) -> Value' b -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
v
                                m (Typed (Value' b) -> Value' b -> Instr' b)
-> m (Typed (Value' b)) -> m (Value' b -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
e
                                m (Value' b -> Instr' b) -> m (Value' b) -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f Value' a
i
  relabel Maybe Symbol -> a -> m b
f (IndirectBr Typed (Value' a)
d [a]
ls)     = Typed (Value' b) -> [b] -> Instr' b
forall lab. Typed (Value' lab) -> [lab] -> Instr' lab
IndirectBr
                                (Typed (Value' b) -> [b] -> Instr' b)
-> m (Typed (Value' b)) -> m ([b] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
d
                                m ([b] -> Instr' b) -> m [b] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> m b) -> [a] -> m [b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing) [a]
ls
  relabel Maybe Symbol -> a -> m b
f (Switch Typed (Value' a)
c a
d [(Integer, a)]
ls)       =
    let step :: (a, a) -> m (a, b)
step (a
n,a
i) = (\b
l -> (a
n,b
l)) (b -> (a, b)) -> m b -> m (a, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
i
     in Typed (Value' b) -> b -> [(Integer, b)] -> Instr' b
forall lab.
Typed (Value' lab) -> lab -> [(Integer, lab)] -> Instr' lab
Switch (Typed (Value' b) -> b -> [(Integer, b)] -> Instr' b)
-> m (Typed (Value' b)) -> m (b -> [(Integer, b)] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
c m (b -> [(Integer, b)] -> Instr' b)
-> m b -> m ([(Integer, b)] -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
d m ([(Integer, b)] -> Instr' b) -> m [(Integer, b)] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((Integer, a) -> m (Integer, b))
-> [(Integer, a)] -> m [(Integer, b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Integer, a) -> m (Integer, b)
forall {a}. (a, a) -> m (a, b)
step [(Integer, a)]
ls
  relabel Maybe Symbol -> a -> m b
f (Phi Type
t [(Value' a, a)]
ls)            =
    let step :: (f a, a) -> m (f b, b)
step (f a
a,a
l) = (,) (f b -> b -> (f b, b)) -> m (f b) -> m (b -> (f b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
relabel Maybe Symbol -> a -> m b
f f a
a m (b -> (f b, b)) -> m b -> m (f b, b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f Maybe Symbol
forall a. Maybe a
Nothing a
l
     in Type -> [(Value' b, b)] -> Instr' b
forall lab. Type -> [(Value' lab, lab)] -> Instr' lab
Phi Type
t ([(Value' b, b)] -> Instr' b) -> m [(Value' b, b)] -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Value' a, a) -> m (Value' b, b))
-> [(Value' a, a)] -> m [(Value' b, b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Value' a, a) -> m (Value' b, b)
forall {f :: * -> *}. HasLabel f => (f a, a) -> m (f b, b)
step [(Value' a, a)]
ls

  relabel Maybe Symbol -> a -> m b
f (LandingPad Type
ty Maybe (Typed (Value' a))
fn Bool
c [Clause' a]
cs) = Type -> Maybe (Typed (Value' b)) -> Bool -> [Clause' b] -> Instr' b
forall lab.
Type
-> Maybe (Typed (Value' lab))
-> Bool
-> [Clause' lab]
-> Instr' lab
LandingPad Type
ty
                                  (Maybe (Typed (Value' b)) -> Bool -> [Clause' b] -> Instr' b)
-> m (Maybe (Typed (Value' b)))
-> m (Bool -> [Clause' b] -> Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Typed (Value' a) -> m (Typed (Value' b)))
-> Maybe (Typed (Value' a)) -> m (Maybe (Typed (Value' b)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ((Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f)) Maybe (Typed (Value' a))
fn
                                  m (Bool -> [Clause' b] -> Instr' b)
-> m Bool -> m ([Clause' b] -> Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> m Bool
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
c
                                  m ([Clause' b] -> Instr' b) -> m [Clause' b] -> m (Instr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Clause' a -> m (Clause' b)) -> [Clause' a] -> m [Clause' b]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Maybe Symbol -> a -> m b) -> Clause' a -> m (Clause' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Clause' a -> m (Clause' b)
relabel Maybe Symbol -> a -> m b
f) [Clause' a]
cs

  relabel Maybe Symbol -> a -> m b
f (Resume Typed (Value' a)
tv)           = Typed (Value' b) -> Instr' b
forall lab. Typed (Value' lab) -> Instr' lab
Resume (Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b)) -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
tv
  relabel Maybe Symbol -> a -> m b
f (Freeze Typed (Value' a)
tv)           = Typed (Value' b) -> Instr' b
forall lab. Typed (Value' lab) -> Instr' lab
Freeze (Typed (Value' b) -> Instr' b)
-> m (Typed (Value' b)) -> m (Instr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
tv

instance HasLabel Stmt'                       where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Stmt' a -> m (Stmt' b)
relabel = $(generateRelabel 'relabel ''Stmt')
instance HasLabel Clause'                     where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Clause' a -> m (Clause' b)
relabel = $(generateRelabel 'relabel ''Clause')
instance HasLabel Value'                      where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel = $(generateRelabel 'relabel ''Value')
instance HasLabel ValMd'                      where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> ValMd' a -> m (ValMd' b)
relabel = $(generateRelabel 'relabel ''ValMd')
instance HasLabel DILabel'                    where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DILabel' a -> m (DILabel' b)
relabel = $(generateRelabel 'relabel ''DILabel')
instance HasLabel DebugLoc'                   where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DebugLoc' a -> m (DebugLoc' b)
relabel = $(generateRelabel 'relabel ''DebugLoc')
instance HasLabel DebugInfo'                  where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DebugInfo' a -> m (DebugInfo' b)
relabel = $(generateRelabel 'relabel ''DebugInfo')
instance HasLabel DIDerivedType'              where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DIDerivedType' a -> m (DIDerivedType' b)
relabel = $(generateRelabel 'relabel ''DIDerivedType')
instance HasLabel DISubroutineType'           where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DISubroutineType' a -> m (DISubroutineType' b)
relabel = $(generateRelabel 'relabel ''DISubroutineType')
instance HasLabel DISubrange'                 where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DISubrange' a -> m (DISubrange' b)
relabel = $(generateRelabel 'relabel ''DISubrange')
instance HasLabel DIGlobalVariable'           where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DIGlobalVariable' a -> m (DIGlobalVariable' b)
relabel = $(generateRelabel 'relabel ''DIGlobalVariable')
instance HasLabel DIGlobalVariableExpression' where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DIGlobalVariableExpression' a
-> m (DIGlobalVariableExpression' b)
relabel = $(generateRelabel 'relabel ''DIGlobalVariableExpression')
instance HasLabel DILocalVariable'            where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DILocalVariable' a -> m (DILocalVariable' b)
relabel = $(generateRelabel 'relabel ''DILocalVariable')
instance HasLabel DISubprogram'               where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DISubprogram' a -> m (DISubprogram' b)
relabel = $(generateRelabel 'relabel ''DISubprogram')
instance HasLabel DICompositeType'            where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DICompositeType' a -> m (DICompositeType' b)
relabel = $(generateRelabel 'relabel ''DICompositeType')
instance HasLabel DILexicalBlock'             where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DILexicalBlock' a -> m (DILexicalBlock' b)
relabel = $(generateRelabel 'relabel ''DILexicalBlock')
instance HasLabel DICompileUnit'              where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DICompileUnit' a -> m (DICompileUnit' b)
relabel = $(generateRelabel 'relabel ''DICompileUnit')
instance HasLabel DILexicalBlockFile'         where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DILexicalBlockFile' a -> m (DILexicalBlockFile' b)
relabel = $(generateRelabel 'relabel ''DILexicalBlockFile')
instance HasLabel DINameSpace'                where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DINameSpace' a -> m (DINameSpace' b)
relabel = $(generateRelabel 'relabel ''DINameSpace')
instance HasLabel DITemplateTypeParameter'    where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DITemplateTypeParameter' a -> m (DITemplateTypeParameter' b)
relabel = $(generateRelabel 'relabel ''DITemplateTypeParameter')
instance HasLabel DITemplateValueParameter'   where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DITemplateValueParameter' a -> m (DITemplateValueParameter' b)
relabel = $(generateRelabel 'relabel ''DITemplateValueParameter')
instance HasLabel DIImportedEntity'           where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b)
-> DIImportedEntity' a -> m (DIImportedEntity' b)
relabel = $(generateRelabel 'relabel ''DIImportedEntity')
instance HasLabel DIArgList'                  where relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> DIArgList' a -> m (DIArgList' b)
relabel = $(generateRelabel 'relabel ''DIArgList')

-- | Clever instance that actually uses the block name
instance HasLabel ConstExpr' where
  relabel :: forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> ConstExpr' a -> m (ConstExpr' b)
relabel Maybe Symbol -> a -> m b
f (ConstBlockAddr t :: Typed (Value' a)
t@(Typed { typedValue :: forall a. Typed a -> a
typedValue = ValSymbol Symbol
s }) a
l) =
    Typed (Value' b) -> b -> ConstExpr' b
forall lab. Typed (Value' lab) -> lab -> ConstExpr' lab
ConstBlockAddr (Typed (Value' b) -> b -> ConstExpr' b)
-> m (Typed (Value' b)) -> m (b -> ConstExpr' b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' a -> m (Value' b))
-> Typed (Value' a) -> m (Typed (Value' b))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Typed a -> f (Typed b)
traverse ((Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
forall (f :: * -> *) (m :: * -> *) a b.
(HasLabel f, Applicative m) =>
(Maybe Symbol -> a -> m b) -> f a -> m (f b)
forall (m :: * -> *) a b.
Applicative m =>
(Maybe Symbol -> a -> m b) -> Value' a -> m (Value' b)
relabel Maybe Symbol -> a -> m b
f) Typed (Value' a)
t m (b -> ConstExpr' b) -> m b -> m (ConstExpr' b)
forall a b. m (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Symbol -> a -> m b
f (Symbol -> Maybe Symbol
forall a. a -> Maybe a
Just Symbol
s) a
l
  relabel Maybe Symbol -> a -> m b
f ConstExpr' a
x = $(generateRelabel 'relabel ''ConstExpr') Maybe Symbol -> a -> m b
f ConstExpr' a
x