This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # admin-announcements (4)
- # boot (93)
- # cider (4)
- # cljsrn (61)
- # clojure (137)
- # clojure-austin (2)
- # clojure-brasil (2)
- # clojure-dev (11)
- # clojure-dusseldorf (10)
- # clojure-greece (245)
- # clojure-russia (37)
- # clojure-spec (60)
- # clojure-taiwan (1)
- # clojure-uk (24)
- # clojurescript (36)
- # cursive (18)
- # datomic (20)
- # emacs (20)
- # funcool (1)
- # hoplon (29)
- # jobs (1)
- # keechma (1)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (3)
- # om (10)
- # om-next (1)
- # onyx (60)
- # other-languages (14)
- # planck (26)
- # random (3)
- # re-frame (21)
- # ring (2)
- # spacemacs (8)
- # specter (56)
- # spirituality-ethics (2)
- # uncomplicate (1)
- # untangled (68)
- # yada (3)
If I didn't have
def as an option for assigning the result of a function to something, what would an alternative method be? For example, if I was using
map to run some functionality against a list, and I wanted to store the result of the applied
map, but I wasn't allowed to use
How would I alter this to include the
let for later reference within the top level
let has two parts, a vector where u can create bindings, and other where can use those bindings
i want to have a command prompt with multiple autovompletes like "lin<tab> goo<tab>" -> "link http://google.de"
Spending Friday afternoons in work re implementing a Java Microservice in Clojure. Then I'm presenting it to whole Dev team in about 6 weeks. It's a thin service running Cassandra queries but it also needs to run with Dropwizard and Smartstack and include Prometheus health metrics. If anyone has any pointers or experience in integrating these in a Clojure Microservice, I'd love to get some advice, thanks!
@mpenet Yep, I've been using both Hayt and Alia and they are amazing! Thanks a million! I love just specifying my cassandra queries as maps 🙂
glad it's working for you, feel free to privmsg if you need some info or have suggestions
I'd like to deploy a Clojure app to my server, but as with any JVM project, the uberjar I generate for this is far too large for me to upload, as my upstream speed is awful.
Is there any clever solution to work around this? What I found to work with Gradle is that I could have it build a "distribution" that has a handy shell script to start the app, along with a directory containing the app's jar and its dependencies. This would let me rsync it over without having to copy all the dependencies over and over again, which makes updating my remote app a lot more manageable.
That's an option, too, but it's kind of time consuming and messy... prone to issues, too, due to varying system dependency versions.
I've got Drone CI running, but sadly, that only supports pulling from a single source per instance - either GitHub, Bitbucket or GitLab. I do have public projects on GitHub, and while I could set up a GitLab instance for private projects (I don't need private GitHub repos), I'd need to set up another Drone instance.
And that's ultimately what my problem is: My app's dependencies are huge, and I don't wanna push them over my tiny pipe to the server every time I want to deploy.
@meowy: the point of creating a jar is that you put your dependencies on your server once and pass a classpath option when running your jar
@rauh That sounds like a viable option, though I'd have to create a script or something to parse the classpath and transfer stuff over (likely via rsync).
The run script then takes the output of
lein classpath and runs the jar with it. If you update a dependency you only need to rsync over the new jars, and the (new) run script will also use the new ones.
did I get the idea:
3. start app with
java -jar <jarname> —classpath <output from second step>
@rmuslimov: You'd have to copy the deps somewhere else and fix the classpath, I think. When you're running your app remotely, which is what I want to do.
A really wacky idea would be deploying the JAR to a private Maven repo on the server and using a Boot script to run it.
As far as I'm aware, this should pull in the current deps automatically, so I don't even have to transfer them to the server in the first place.
The Boot script would be trivial, like this one: https://github.com/boot-clj/boot/wiki/Scripts
I actually think this might be the neatest slash least hackiest solution because it doesn't require mucking around with copying dependencies.
Pull in my app as dependency from the local repo (using LATEST as version), then require its entrypoint function and bam.
@meowy: If you want to avoid rsyncing the dependency jars you can also just copy over the
project.clj and run the
lein deps on the server. Or create a
lein pom locally and download them with maven on the server. Lots of ways to get it done.
I'm trying to use https://github.com/weavejester/environ but I can't get it to stop overwriting my .lein-env file
there are lots of ways to do things, doing builds on the server is one, but I cannot say I am a fan
and I can't easily put it in environment variables (I think?) because I'm running from Cursive
you will end up with a different guava jar on your classpath from the one the build was tested with
Well, yeah, but that's a matter of not forgetting to extract your deps before deploying.
ah ha, I missed this part of Environ docs: "The most common way during development is to use a local profiles.clj file in your project directory. ..."
what I've done in the past is have the ci node push built artifacts to s3, and then the nodes pull new releases from s3, but I haven't tried that in some kind of bandwidth constrained environment, and of course that assumes you have access to s3
may be a noob question, so I runned
lein libdir which copied all jar to
lib folder. Now I’m calling:
$ java -classpath ./lib -jar target/specd-0.1.0-SNAPSHOT.jar
Error: Could not find or load main class clojure.main
only about 10 minutes into checking out spec; is there already a helper function equivalent to
conforming-fn here that will take a value-returning "spec" function and wrap it in a Spec impl so conform will return the value it returns? https://gist.github.com/cemerick/fd824dea77c9736225531a5cc97affee
you can also use the clojure main class and tell it to run a function from a namespace if you don't want to aot compile a main
if I have a :dev profile in my project.clj, and a :dev profile in profiles.clj, will they be merged?
because I already have a :dev profile in my project.clj, the example in the environ readme is not going to work for me
Alright, I installed Artifactory on my server and uploaded a dep, let's try running this dep via a Boot script...
The neat thing is, I don't even need to make the Artifactory instance accessible from the web, I can just port-forward via SSH on my dev machine and use localhost:8081 on the server. Might change when I deploy to a VPS, but there's always options.
Alright, it works. Guess it's a bit of a hackish way to get things done, but, hey, can't beat only having to upload a few kilobytes.
How can i get Algebraic Data Types in clojure, a la haskell:
data List a = Empty | Cons a (List a)
I'm trying to do this with protocols, and multimethods, but I'm not sure how 😞
What are you trying to do? ADTs are mostly useful for static type checking and pattern matching. If you want pattern matching, check out
@exupero: it is for static type checks and pattern matching. I'm trying to implement so different monads, and it's awkward building my own types via maps. Just curious if there's a way to use ADTs. Oh, and can
core.match match on things like types (ie instances of
It seems like it should be possible to have that using multimethods, or protocols, no?
@exupero: I see from searching around that ADTs were talked about for clojure quite a bit in 2009, but not much since. Is there a better way of accomplishing what I need?
I don’t know much about Clojure’s static typing offerings, but there’s core.typed, Schema, and now clojure.spec.
If you can find a hard way to pull off what you're wanting, you can always wrap it in macros to make it more Haskell-like.
josh.freckleton: Clojure doesn’t have dispatch on return, so implementing monads is a little tricky.
josh.freckleton: You might want to take a look at https://github.com/funcool/cats
@weavejester: ah, interesting you should mention
cats, I'm trying to build the Free Monad in
cats, and trying to port haskell code, but stumped because I can't see a clean way around ADT's, namely for:
data Free f r = Free (f (Free f r)) | Pure r
@josh.freckleton: I’m afraid I don’t really see the problem. Even without a type signature, there shouldn’t be anything stopping you from creating a data structure that resembles the type.
@weavejester: I'm admittedly new to clojure, and monads in general, so maybe I bit off a bit much.
If you look at https://github.com/funcool/cats/blob/master/src/cats/monad/maybe.cljc it has
(deftype nothing ...) and
(deftype just ...), so I've been looking to them for inspiration, but they're not recursive types like Free needs to be. Can I make a Free recursive type, that can be either Free or Pure?
Also, Free needs a functor (the
f in the haskell data type), and I can create types that extend
p/Functor protocol, but it's not clear to me how to utilize that within a
The recursiveness of the types is just a compile-time definition. Any type can be recursive. You could easily write
(just (just (just (just … ad infinitum.
@weavejester: that makes sense. And how do I convey a functor into the
Free type? Or in other words, how can I ad hoc build a type
Free X, or
Free List, or
Free String, etc.?
Just give the record arguments. In the constructor function, perhaps add a precondition.
ok, this is starting to make sense. and then if, say,
List has an
fmap, how could I use
fmap from an instance of
Free List? Would it just be
It looks like you need to create a context for your Free monad, and then have that context implement the Functor protocol.
ahh, I had been assuming the
fmap would come from the
Free List type definition. But the
fmap you mention is probably
cats/fmap, yes? If so, I think I've got it!
@weavejester: Thanks for this! So, I totally respect you for
hiccup, and I'd be curious your recommendation here. Is trying to use monads outside of a strong static type system more effort than it's worth? I want to use a Free monad for implementing DSLs and interpreters, and I know that Haskell would be more comfortable to write this in. But I want the DSL to output code and i like how in clojure, programs are data, and you can easily manipulate the AST. I don't care at all about performance (since it generates textual code). Just, non-bugginess, decreased programmer-time, and being relatively easy to extend/modular. Or is there a DSL "pattern" you would recommend instead of monads?
I’ve never actually found a need for monads outside Haskell. The cats implementation seems reasonably good, but monads wouldn’t be the first tool I’d reach for.
more macros, so embedded DSLs. I find that in writing web/mobile apps, so many problem-solution pairs are "shaped" the same, and yet it still takes a long time to "stitch" everything together. For example, if I have a mongodb with certain-shaped data, and I want to expose it through a REST API using
compojure, and then the frontend needs to consume it, and then the frontend needs to lay it out. I think an embedded DSL would take me a long way in speeding that up by requiring me to only define a data model, and then interpret it through, eg, a Mongo interpreter, a REST interpreter, a REST consumer interpreter, etc.
I think you need to be a little careful approaching this problem as you might in Haskell. While both Clojure and Haskell are functional, Haskell has a very different way of thinking about problems. In Haskell, you build up a “skeleton” of types, and then construct the solution around that. Clojure doesn’t have a static type system, so problems are solved differently, and IMO, more directly.
If you’re just transforming data, then my guess is that you need functions, rather than macros.
Unfortunately I can’t talk anymore, as I need to get to bed! But good luck regardless 🙂
@weavejester: thanks so much weavejester, you're a huge help and inspiration!
Picking up on that discussion, I’d agree that trying to write Haskell in Clojure is probably going to get you into a world of hurt...
…whilst Clojure does have
defrecord etc, they’re really designed to let you do ad hoc polymorphism rather than being a "type system" so they’re not intended to support some of the stuff you’d naturally do in Haskell.