traceCallAPI :: MonadIO m => String -> (Call :~> m) -> (Call :~> m)
traceCallAPI msg f = wrapNT $ \ case
  p@(CallMethod nm args) -> do
          let method = Method nm args :: Prim Value
          liftIO $ putStrLn $ msg ++ " method " ++ show method
          r <- f # p
          liftIO $ putStrLn $ msg ++ " return " ++ LT.unpack (decodeUtf8 (encode r))
          return r
  p@(CallNotification nm args) -> do
          let n = Notification nm args
          liftIO $ putStrLn $ msg ++ " notification " ++ show n
          f # p
traceCallAPI :: MonadIO m => String -> (Call :~> m) -> (Call :~> m)
traceCallAPI msg f = wrapNT $ \ case
  p@(CallMethod nm args) -> do
          let method = Method nm args :: Prim Value
          liftIO $ putStrLn $ msg ++ " method " ++ show method
          r <- f # p
          liftIO $ putStrLn $ msg ++ " return " ++ LT.unpack (decodeUtf8 (encode r))
          return r
  p@(CallNotification nm args) -> do
          let n = Notification nm args
          liftIO $ putStrLn $ msg ++ " notification " ++ show n
          f # p
traceCallAPI msg f = wrapNT $ \ case
  p@(CallMethod nm args) -> do
          let method = Method nm args :: Prim Value
          liftIO $ putStrLn $ msg ++ " method " ++ show method
          r <- f # p
          liftIO $ putStrLn $ msg ++ " return " ++ LT.unpack (decodeUtf8 (encode r))
          return r
  p@(CallNotification nm args) -> do
          let n = Notification nm args
          liftIO $ putStrLn $ msg ++ " notification " ++ show n
          f # p