user
Let's add an example.main namespace in src, which just has a main function that prints hello world.
assistant
I'll create a new Clojure namespace with a main function in the src directory.
(ns example.main)
Follow these steps when translating code to Kotlin: | |
1. Analyze the source code to understand its structure and functionality. | |
2. Identify language-specific constructs or idioms in the source language that may need special attention when translating to Kotlin. | |
3. Translate the code to Kotlin, ensuring that you: | |
a. Use Kotlin's syntax and language features appropriately. | |
b. Maintain the original code's functionality and logic. | |
c. Apply Kotlin best practices and idioms where applicable. | |
d. Preserve the overall structure and organization of the code when possible. | |
4. Add comments to explain any significant changes or decisions made during the translation process. |
user
Let's add an example.main namespace in src, which just has a main function that prints hello world.
assistant
I'll create a new Clojure namespace with a main function in the src directory.
(ns example.main)
(ns nodes | |
(:refer-clojure :exclude [format]) | |
(:require [malli.core :as m] | |
[malli.dev.virhe :as v] | |
[malli.error :as me])) | |
(defn node [params & children] | |
(tagged-literal 'cursive/node | |
(assoc params :children (remove nil? children)))) |
(ns cursive.llm.api.malli-repro | |
(:require [clojure.data.json :as json] | |
[clojure.string :as str] | |
[malli.core :as m] | |
[malli.transform :as mt])) | |
(defn decode-type | |
"This is required for decoding :type fields, otherwise they are not | |
converted and don't dispatch properly." | |
[x] |
Loading src/nrepl_tests/src.clj... done | |
(let [server (start-server :port 7888)] | |
(try | |
(test-on 7888) | |
(finally | |
(stop-server server)))) | |
; These are responses from the CLJ version |
Classfile /Users/colin/dev/cursive-2099/classes/cursive_2099/core$_main.class | |
Last modified 18/01/2019; size 1271 bytes | |
MD5 checksum f74ca1f9fccde176d30524a628eaa1ee | |
Compiled from "core.clj" | |
public final class cursive_2099.core$_main extends clojure.lang.RestFn | |
minor version: 0 | |
major version: 52 | |
flags: ACC_PUBLIC, ACC_FINAL, ACC_SUPER | |
Constant pool: | |
#1 = Utf8 cursive_2099/core$_main |
; Before | |
(defn light-keys [symbol language] | |
(let [states (light.resolve/resolve-states (psi/containing-file symbol) language)] | |
(loop [current (psi/parent symbol)] ; <- infinite loop if current is nil | |
(if-let [state (get states current)] ; because psi/parent nil puns | |
(light.resolve/resolve-keys symbol state) | |
(if (psi/file? (psi/parent current)) | |
(recur (first (filter psi/significant? (psi/prev-siblings current)))) ; <- first can return nil | |
(recur (psi/parent current))))))) |
~/d/c/jitpack> lein deps :tree | |
Retrieving com/github/SquidPony/SquidLib/squidlib/-v3.0.0-b3-g386143b-39/squidlib--v3.0.0-b3-g386143b-39.pom from jitpack | |
Retrieving com/github/SquidPony/SquidLib/squidlib-parent/-v3.0.0-b3-g386143b-39/squidlib-parent--v3.0.0-b3-g386143b-39.pom from jitpack | |
Retrieving com/github/SquidPony/SquidLib/squidlib-util/-v3.0.0-b3-g386143b-39/squidlib-util--v3.0.0-b3-g386143b-39.pom from jitpack | |
Retrieving com/badlogicgames/gdx/gdx/1.9.2/gdx-1.9.2.pom from central | |
Retrieving com/badlogicgames/gdx/gdx-parent/1.9.2/gdx-parent-1.9.2.pom from central | |
Retrieving com/github/SquidPony/SquidLib/squidlib/-v3.0.0-b3-g386143b-39/squidlib--v3.0.0-b3-g386143b-39.jar from jitpack | |
Retrieving com/github/SquidPony/SquidLib/squidlib-util/-v3.0.0-b3-g386143b-39/squidlib-util--v3.0.0-b3-g386143b-39.jar from jitpack | |
Retrieving com/badlogicgames/gdx/gdx/1.9.2/gdx-1.9.2.jar from central | |
[clojure-complete "0.2.4" :exclusions [[org.clojure/clojure]]] |
The other new feature is an interactive macroexpander. It requires a REPL to perform | |
the actual expansion, with the current namespace loaded into it. Start by executing | |
Tools->REPL->View Macro Expansion. This will select the nearest surrounding macro | |
form and display it in a popup window. You can move the cursor anywhere within the | |
form and either click the right arrow in the toolbar or use Ctrl/Cmd-right - this | |
will expand the nearest surrounding macro form and all forms above it up to the | |
top displayed form - the cursor will be left at the start of the innermost form | |
that was actually expanded. Give it a try, it’s less confusing than it sounds! | |
There are also various controls in the toolbar for various sorts of prettification - | |
you can show and hide metadata, tidy up referred vars and imported classes etc. This |
; Parsers are defined like this - this this for the core.typed defprotocol | |
(defn binder [] | |
(vector (alt (symbol :into :bindings) | |
(vector (symbol :into :bindings))))) | |
(defn type-decl [] | |
(all (keyword :matching :-) | |
(any :into :types) | |
(opt (alt (symbol :matching '* | |
:into :no-resolve) |