runCodeGen name gen = J.generated $ execState go J.emptyGState
  where
    go = do
      x <- tryEMT (J.runGenerate $ runStateT (unJvm gen) (emptyGCState name))
      case x of
        Right result -> return result
        Left  err    -> fail $ "code generator: " ++ show err
runCodeGen name gen = J.generated $ execState go J.emptyGState
  where
    go = do
      x <- tryEMT (J.runGenerate $ runStateT (unJvm gen) (emptyGCState name))
      case x of
        Right result -> return result
        Left  err    -> fail $ "code generator: " ++ show err
runCodeGen name gen = J.generated $ execState go J.emptyGState
  where
    go = do
      x <- tryEMT (J.runGenerate $ runStateT (unJvm gen) (emptyGCState name))
      case x of
        Right result -> return result
        Left  err    -> fail $ "code generator: " ++ show err