Welcome to another issue of Clojure weekly, my small routine blog contribution to the Clojure sphere! These are just a few links, normally 4/5 urls, pointing at articles, documentation, screencasts, podcasts or anything else that attracts my attention. I add a small comment so you can decide if you want to look at the whole thing or not. That’s it, enjoy!
ClojureScript 101 A simple and clear tutorial that explains the impact of core.async for clojurescript development. Clicking on a button generated an event you have to listen to to act upon, providing a function that should execute when that button is pressed. Since the place in the code where the callback is declared is not the same context in which some action should be taken on the event, what used to happen was that you had to pass down the callback some piece of global visible state. The click event is instead placed on a channel without any knowledge about what happens on the other side. Responding to an event looks sequential when instead it is not. No state flying around required. Much more difficult to explain than to go through this tutorial (30 mins).
Refactoring to Functional–Why Class? | Hadi Hariri’s Blog This is a parody of a refactoring where an OO model is transformed gradually toward a mere container of functions without a state. Indeed this is the case for many scenarios we attempted to constraint business logic in the past using one paradigm only. Also have a look at the related discussion on HackerNews https://news.ycombinator.com/item?id=6790392 where the argument is made that there are very good cases for OO as well as for FP. As always, best tool for the job FTW.
clojure.core map-indexed · sdegutis/clojuredocs Wiki map-indexed is totally useful when you need to act on a specific repeating item on a list. When the item repeats in the collection, but the processing you need to do is not trivial (ie is not on all of the same items or is not the first occurence of the item) map-indexed offers you a way to know all the indexes in which something occurs in a collection. For string as sequences, you can use map-indexed to process the last char occurrence on a string or other non trivial occurrences in the list.
let-caribou-in - Powered By Caribou Another interesting web framework called Caribou. But this time we are midway between a CMS, CRUD model editor and a web framework which makes it compelling in all those situation where you need to open a “window” to your data in a somehow automatic way. Creation of a project thanks to lein and migrations seem to be Rails inspired, as well as the overall project structure. Will give it a go.
Parametrize fact? - Midje Here’s a clear example of an old-school mindset (me) thinking that something like a parametrized fact should be something difficult to achieve, maybe with a macro or some obscure Midje extension. Let me back up a second: this is the problem where one of your fact contains many checkers and the list is growing long and full of repetition. Wouldn’t be nice to have some syntax sugar on top of => to remove part of the duplication? Can I “override” => in Midje? It is much simpler than that. I never realized that what’s coming after => in a Midje fact is a function taking what is on the left of the arrow and returning a boolean! So anything in the form of “response => 200” can be also written as “response => ok” with (defn ok [response] (= 200 response)). Do you need the custom checker to take a param? Use defchecker macro.2 weeks ago