This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-27
Channels
- # aleph (2)
- # announcements (7)
- # beginners (74)
- # clj-kondo (23)
- # cljdoc (3)
- # cljsrn (3)
- # clojure (42)
- # clojure-android (1)
- # clojure-uk (4)
- # clojuredesign-podcast (10)
- # clojurescript (4)
- # figwheel-main (19)
- # fulcro (19)
- # hoplon (4)
- # jobs (5)
- # juxt (8)
- # off-topic (5)
- # pathom (40)
- # perun (3)
- # shadow-cljs (56)
hi! I'm noob to clojure. I am using luminus for creating webserver for routing. I want to pass data using route like the url is "http://localhost:3600/test?data=“xxx” " want to get the data which will be dynamically changed.
(defn testing-func
[{:keys [path-params query-params body-params]}]
{:status 200
:body (str "path params: " path-params
"\nquery params: " query-params
"\nbody params: " body-params)}
(prn "id details:" query-params))
(defroutes home-routes
(POST "/test/:id" [id] (testing-func id))
)
here is my code. I know there is lots of mistakes. Can anyone tell me how to get data from routes? Thanks in advance!(defn testing-func [{:keys [path-params query-params body-params] :as request}] ... )
it matches http://server:port/test/some-id-here?...
to match the URL you are using it would be (POST "/test" request (testing-func request))
@UKH2HDSQH thanks a lot ❤️
I have been coding with Clojure since a few years (professionally since a 1 year thanks to CLJS). I read this article https://purelyfunctional.tv/guide/5-hurdles-of-hirability/ from Eric Normand and I wondered what it meant to be coding in the functional paradigm? I use pure function, function composition, immutable data (except for atoms) and focus on declaration more than imperative. Do I miss anything in my toolbox?
(I am really happy to code with Clojure that being said).
@darioszr I can’t read the first part of your message haha
1st part: IO handling and states, composition, declaritive code and data thinking is the key to be in the functional club
Thanks :).
For sure you can improve things, but to me with also immutable data, this all are key factors to be in functional paradigm. But maybe others could express their pov
The functional thinking is imho when you think how to manipulate your data in pipelines or transducers and immutability is also something that Oop people dont get it
Ok, by that definition I am for sure a FP member lol. I still can’t understand why python does not have -> in their language
Thanks a lot. I really thought I was missing something.
Yw, but IMHO we are speaking on the functional low level of things. To me the functional level can be also improved, like how is à functional system, how components interact in a functional way. Eg understanding persistent data structures, message passing applications this is imho what is interesting on more larger view.
How to achieve this with Clojure? Suppose I am getting a string from console. “A B C”. Now I am splitting this string using split function. And trying map each of the sub string to a particular key in map. {:first-name A , :last-name B , :middxlename C}. Now, if I get another console input. I want to append that entry into the existing map. If second console input is “D E F”. Then, resulting map I am expecting is :- { {:first-name A , :last-name B , :middlename C} {:first-name D , :last-name E , :middlename F} } I’have just started getting into Clojure. Any help would be great.
You can right a fn that parses the string into a map like this:
(defn parse [s]
(->> (clojure.string/split s #" ")
(zipmap [:first :last :middle])))
(parse "A B C")
will return {:first "A", :last "B", :middle "C"}
You can then just maintain a vector and use conj
to append to it for each input received.
But I feel like I misunderstood what you want? Does this make sense @parth.12282?
How I see: it is you can a mutable state but the functions that processes the input should be pure
(From my experience of re-frame)
(The funniest piece of documentation)
@jaihindhreddy vector wont let me mutate the state.If i am doing conj
with another map as input. I need to store that output somewhere. (As per my limited knowledge)
Is what your working on an interactive cli in Clojure?
Save the state in a global atom
yup, you'd use an atom. I don't know if the app at hand is an interactive thing where user enters these string, which is when atoms would be right, or if it is possible to get all the inputs at the same time in which case its a simple (map parse strs)
@darioszr Do you know where I could read about functional systems? What are the guidelines? My understanding is we should apply the same principle as in low level: avoid states, (pure systems? Same input yields the same output)?
The book clojure Applied from @alexmiller discuss it in some chapters. A part of that book, i recommend you the talk of rich https://m.youtube.com/watch?v=ROor6_NGIWU&feature=youtu.be Unfortunately I think our industry isnt that mature, to build f systems' I think building functional systems is our challenge for nowadays. I mean building functional style programs, is for developers sanity of mind 😁
But we should not stop on the micro level, we should extend this in the system level, e.g persistent data structures, channels etc. I'm just starting researching the topic. But this is imho what business people, Users, care 😁
A part of that, we don't have like functional architecture books yet, I don't know if somebody has such book feel free to share
But they are free online. I think it is a cool book, discussing architectures of OOp mostly software but one can extrapolate some principles... There is also the Haskell compiler there afaik
@darioszr I think the book Domain-driven design is very interesting for functional programming, it’s not really about any specific programming paradigm but the books talks about a lot of concepts which go very well together with functional programming
it’s worth your while! 🙂 I especially like that it’s not preachy like a lot of other software books, instead it’s like “use this when you think that it makes sense, if it doesn’t, do something else”
HugSQL
Hi all, I'm searching in the web on a document between data serialization formats différence
I know that Rich and Stuart talked a little on the subjects. If anyone know a good line where it is somehow explained in deep, feel free to share
(I'm referring to talk of language of system video) where data formats are described
Check out Stuart Halloway's talk on Fressian.
I'm interested in this too. Will post in this thread when I find something interesting.
About system found out also this great talk, it talk about great things (link: https://youtu.be/Tb823aqgX_0) http://youtu.be/Tb823aqgX_0