bind :: MonadSubst a b m
     => AST a
     -> AST b
     -> a
     -> (a -> m c)
     -> m c
bind wa wb v kont = do
    old_phi   <- getsTheta wa wb phi
    old_theta <- getsTheta wa wb theta
    a <- if v `Set.member` old_phi
         then do  let v' = uniqBinder v old_phi
                  modifyTheta wa wb $ \s -> s { phi   = Set.insert v' old_phi
                                              , theta = Map.insert v (binderOcc v') old_theta
                                              }
                  kont v'
         else do  modifyTheta wa wb $ \s -> s { phi   = Set.insert v (phi s)
                                              , theta = Map.delete v old_theta
                                              }
                  kont v
    modifyTheta wa wb $ \s -> s { phi   = old_phi
                                , theta = old_theta
                                }
    return a
bind :: MonadSubst a b m
     => AST a
     -> AST b
     -> a
     -> (a -> m c)
     -> m c
bind wa wb v kont = do
    old_phi   <- getsTheta wa wb phi
    old_theta <- getsTheta wa wb theta
    a <- if v `Set.member` old_phi
         then do  let v' = uniqBinder v old_phi
                  modifyTheta wa wb $ \s -> s { phi   = Set.insert v' old_phi
                                              , theta = Map.insert v (binderOcc v') old_theta
                                              }
                  kont v'
         else do  modifyTheta wa wb $ \s -> s { phi   = Set.insert v (phi s)
                                              , theta = Map.delete v old_theta
                                              }
                  kont v
    modifyTheta wa wb $ \s -> s { phi   = old_phi
                                , theta = old_theta
                                }
    return a
bind wa wb v kont = do
    old_phi   <- getsTheta wa wb phi
    old_theta <- getsTheta wa wb theta
    a <- if v `Set.member` old_phi
         then do  let v' = uniqBinder v old_phi
                  modifyTheta wa wb $ \s -> s { phi   = Set.insert v' old_phi
                                              , theta = Map.insert v (binderOcc v') old_theta
                                              }
                  kont v'
         else do  modifyTheta wa wb $ \s -> s { phi   = Set.insert v (phi s)
                                              , theta = Map.delete v old_theta
                                              }
                  kont v
    modifyTheta wa wb $ \s -> s { phi   = old_phi
                                , theta = old_theta
                                }
    return a