Docstrings and metadata on protocol method signatures
Hello, I tried adding :doc and :added metadata on a protocol method signature but found it hard to do: ;; defn-like, docstring then metadata map -> nope (defprotocol P (foo "mydoc" {:added "1.0"} [_])) ; => CompilerException java.lang.IllegalArgumentException: Parameter declaration missing, compiling:(/tmp/form-init3901889500037802283.clj:1:1) ;; defn-like, docstring in the metadata map -> nope (defprotocol P (foo {:doc "mydoc" :added "1.0"} [_])) ; => CompilerException java.lang.IllegalArgumentException: Parameter declaration missing, compiling:(/tmp/form-init3901889500037802283.clj:1:1) ;; Maybe after the arguments? -> ok for the doc (defprotocol P (foo [_] "mydoc")) (select-keys (meta #'foo) [:doc :added]) ; => {:doc "mydoc"} ;; Let's add the :added bit -> nope (defprotocol P (foo [_] "mydoc" {:added "1.0"})) (select-keys (meta #'foo) [:doc :added]) ; => {:doc "mydoc"} ;; Maybe both in the same map? -> nope (defprotocol P (foo [_] {:doc "mydoc" :added "1.0"})) (select-keys (meta #'foo) [:doc :added]) ; => {:doc {:doc "mydoc" :added "1.0"}} ;; Not really. ^{} -style? -> nope (defprotocol P (^{:doc "mydoc" :added "1.0"} foo [_])) (select-keys (meta #'foo) [:doc :added]) ; => {:doc nil :added "1.0"} ;; ^{} + after the args -> yeah! (defprotocol P (^{:added "1.0"} foo [_] "mydoc")) (select-keys (meta #'foo) [:doc :added]) ; => {:doc "mydoc" :added "1.0"} Is there a reason for this? I’m quite surprised using ^{:doc "..."} doesn’t work. Thanks, -- Baptiste Fontaine -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[?] How to alias the ClojureScript namespaces in macros
Refer to https://groups.google.com/forum/#!topic/clojurescript/oP4qFdPRm2Q or https://gist.github.com/philoskim/496a01dc8d71b83c678c866874310871 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[TIP] How to alias the ClojureScript namespaces in macros
Refer to https://groups.google.com/forum/#!topic/clojurescript/oP4qFdPRm2Q or https://gist.github.com/philoskim/496a01dc8d71b83c678c866874310871 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Complete Web Development Setup Using Clojure CLI Tools
Howdy Clojurians, I recently started developing a new Clojure+Clojurescript web application, and I wanted to see if I could set up my development environment using just the Clojure CLI tools. After a good deal of digging around through tutorials on a number of different websites and a fair amount of experimenting, I've managed to create a very simple (IMHO) configuration that provides me with both development and production mode CLJS->JS compilation, development and production mode ring handlers, and the always delightful FIgwheel development environment all from just the simple "clojure" command. Since I haven't seen this before, I thought I'd share it with all of you in case it helps someone else out there who doesn't need (or want) all of leiningen or boot to develop a simple web app. Here goes: Step 1: Create your project structure like so: ├── cljsbuild.edn ├── deps.edn ├── figwheel.edn ├── resources │ └── public │ ├── cljs │ ├── css │ │ ├── style.css │ ├── images │ └── js ├── src │ ├── clj │ │ └── my_project │ │ ├── handler.clj │ │ ├── server.clj │ │ ├── views.clj │ └── cljs │ └── my_project │ ├── client.cljs Step 2: Make the deps.edn file (replace :deps and my-project.server namespace as necessary for your project) {:paths ["src/clj" "resources"] :deps {org.clojure/clojure {:mvn/version "1.9.0"} org.clojure/clojurescript {:mvn/version "1.10.312"} ring {:mvn/version "1.7.0-RC1"} ring/ring-defaults{:mvn/version "0.3.2"} prone {:mvn/version "1.6.0"} compojure {:mvn/version "1.6.1"} hiccup{:mvn/version "1.0.5"} reagent {:mvn/version "0.8.1"}} :aliases {:run{:main-opts ["-m" "my-project.server"]} :cljsbuild {:extra-paths ["src/cljs"] :main-opts ["-m" "cljs.main" "-co" "cljsbuild.edn" "-c"]} :figwheel {:extra-deps {org.clojure/tools.nrepl {:mvn/version "0.2.13"} cider/cider-nrepl {:mvn/version "0.17.0"} com.cemerick/piggieback {:mvn/version "0.2.2"} figwheel-sidecar{:mvn/version "0.5.14"}} :main-opts ["-e" "(use,'figwheel-sidecar.repl-api),(start-figwheel!)"]}}} Step 3: Make the cljsbuild.edn file (replace :main for your project) {:main "my-project.client" :output-dir"resources/public/cljs" :output-to "resources/public/cljs/app.js" :source-map"resources/public/cljs/app.js.map" :optimizations :advanced :pretty-print false} Step 4: Make the figwheel.edn file (replace :ring-handler, :on-jsload, and :main for your project) {:nrepl-port 7000 :nrepl-middleware ["cider.nrepl/cider-middleware" "cemerick.piggieback/wrap-cljs-repl"] :server-port 3000 :ring-handler my-project.handler/development-app :http-server-root "public" :css-dirs ["resources/public/css"] :builds [{:id "dev" :source-paths ["src/cljs"] :figwheel {:on-jsload "my-project.client/mount-root"} :compiler {:main "my-project.client" :output-dir"resources/public/cljs/out" :output-to "resources/public/cljs/app.js" :asset-path"/cljs/out" :source-maptrue :optimizations :none :pretty-print true}}]} Step 5: Write server.clj (ns my-project.server (:require [ring.adapter.jetty :refer [run-jetty]] [my-project.handler :refer [development-app production-app]]) (:gen-class)) (defonce server (atom nil)) (defn start-server! [& [port mode]] (reset! server (run-jetty (case mode "dev" #'development-app "prod" #'production-app #'production-app) {:port (if port (Integer/parseInt port) 3000) :join? false}))) (defn stop-server! [] (when @server (.stop @server) (reset! server nil))) (def -main start-server!) Step 6: Write handler.clj (ns my-project.handler (:require [ring.middleware.defaults :refer [wrap-defaults site-defaults]] [ring.middleware.reload :refer [wrap-reload]] [prone.middleware :refer [wrap-exceptions]] [compojure.core :refer [defroutes GET]] [compojure.route :refer [not-found]] [my-project.views :refer [render-page]])) (defroutes routes (GET "/" [] (render-page)) (not-found "Not Found")) (def development-app (wrap-reload (wrap-exceptions (wrap-defaults #'routes site-defaults (def production-app (wrap-defaults #'routes site-defaults)) Step 7:
Re: Complete Web Development Setup Using Clojure CLI Tools
Hi again, folks. Just to make it easier for everyone to use this template right away, I put all these files into a public git repository on Gitlab. Here's the URL: https://gitlab.com/lambdatronic/clojure-webapp-template Happy hacking! ~Gary -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: What is the minimal Emacs config for practical Clojure development?
Not sure what you mean by minimum but here's instruction on setting up a dev environment that works for me http://lambdakids.stigmergy.systems/2018/6/6/hello-world.blog my emacs init.el is at https://bit.ly/2z3gtyi On Monday, July 2, 2018 at 6:41:23 AM UTC+3, Austin Haas wrote: > > I don't want to use a package manager with Emacs. > > Should I launch a REPL outside of Emacs, then connect to it? Using the CLI > tools (i.e., from the command line: clojure -J-Dclojure.server.repl="{:port > :accept clojure.core.server/repl}")? > > Can I launch a REPL from within Emacs? > > I've been using inf-clojure and clojure-mode with the following elisp in > my .emacs: > > (add-to-list 'load-path "~/.emacs.d/site-lisp/third-party/clojure-mode/") > (require 'clojure-mode) > (add-to-list 'load-path "~/.emacs.d/site-lisp/third-party/inf-clojure/") > (load-file "~/.emacs.d/site-lisp/third-party/inf-clojure/inf-clojure.el") > (add-hook 'clojure-mode-hook #'inf-clojure-minor-mode) > (setf inf-clojure-lein-cmd "lein run -m clojure.main") > > and C-c C-z to start a REPL, but I get noise in the REPL, including > repeated prompts, and (seemingly) random linebreaks in large output. > > What's the state of the art for a simple, practical Emacs setup for > Clojure? > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: group rows on basis of value in a column in CSV with clojure
You may want to take a look at my library semantic-csv, which lets you cast rows as maps instead of vectors, so that you can group-by a column name instead of a positional index. https://github.com/metasoarous/semantic-csv On Saturday, July 7, 2018 at 11:07:50 PM UTC-7, Varun J.P wrote: > > Hi All, > Thanks for the tip to use (group-by last …) > It was working fine until my csv file got updated. Now i am not sure abt > the number of columns in my csv. It could change in every row, but I still > need to group it with Heading 3 itself. > > Example of my updated CSV is as below > > Heading1 Heading 2 Heading 3 Heading 4 Heading 5 >> abc 123 Value1 newValue >> def 234 Value1 anotherValue oneMoreValue >> ghi dfgew Value1 aValue >> jkl 456 Value5 >> pqr 567 Value5 >> stu 678 value3 >> vwx sdf value4 >> yza 900 value4 > > > Now i cant use (group-by last ...) instead i tried using > > (group-by (nth (nth testvector 0) 2) testvector) where testvector is a > vector of vector but is throwing an error > >> "ClassCastException java.lang.String cannot be cast to clojure.lang.IFn >> clojure.core/group-by/fn--7011 >> (core.clj:6870)" > > > Can someone suggest a different approch > > > > > > On Tuesday, July 3, 2018 at 10:42:08 PM UTC+5:30, Philipp Neumann wrote: >> >> Hi. >> >> This is a job for (group-by last ...) >> >> Regards >> >> Varun J.P schrieb am Di., 3. Juli 2018, 19:05: >> >>> My CSV file is something like the attached file which could have 'n' >>> number of line. I need to group by the values in the last column. >>> Current I believe the below code will return me a vector of vector. >>> >>> (defn read-csv-file >>> >>> [path] >>> >>> (try >>> >>>(with-open [input-file (io/reader path)] >>> >>> (let [a_list (doall (map (comp first clojure-csv.core/parse-csv) ( >>> line-seq input-file)))] >>> >>>(rest (into [] a_list >>> >>>(catch Exception exception (throw exception >>> >>> >>> i need to iterate through this vector of vector and create a new vector >>> of vector containing only elements of the first group, then in next >>> iteration i need the second set and so on. >>> >>> Example CSV >>> Heading1 Heading 2 Heading 3 abc 123 Value1 def 234 Value1 ghi dfgew Value1 jkl 456 Value5 pqr 567 Value5 stu 678 value3 vwx sdf value4 yza 900 value4 >>> >>> >>> >>> so when this CSV is parsed i will have something like >>> [ >>> [abc 123 Value1] >>> [def 234 Value1] >>> [ghi dfgew Value1] >>> [jkl 456 Value5] >>> [pqr 567 Value5] >>> [stu 678 value3] >>> [vwx sdf value4] >>> [yza 900 value4]] >>> So when i iterate through this i need to group the vector of vector by >>> the last column >>> so my first iteration output should be something like >>> >>> [ >>> [abc 123 Value1] >>> [def 234 Value1] >>> [ghi dfgew Value1]] >>> 2nd iteration should be >>> [ >>> [jkl 456 Value5] >>> [pqr 567 Value5]] >>> 3rd should be >>> >>> [ >>> [stu 678 value3]] >>> and so on. >>> >>> How would i achieve this in clojure. is there any build in csv parsing >>> function >>> >>> Regards >>> JP >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@googlegroups.com >>> Note that posts from new members are moderated - please be patient with >>> your first post. >>> To unsubscribe from this group, send email to >>> clojure+u...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/clojure?hl=en >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to clojure+u...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.