Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use monads with clojurescript?

I know monads are available in clojure, but has anyone verified that they work in clojurescript?

like image 200
yazz.com Avatar asked Jul 06 '12 19:07

yazz.com


1 Answers

Monads work in clojurescript. The only thing is the way you reference macros in clojurescript [1].

What I did is copy all tools/macro.clj and all the monads.clj code into a big file which I then reference from clojurescript.

It's perhaps not the most elegant way but it works.

You can find the file in https://github.com/cotarmanach/clojurescript-monad-macros (I copy it in my project and change the namespace to be the one of my project)

[1] See https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure

ClojureScript's macros are written in Clojure, and are referenced via the require-macros keyword in namespace declarations:

(ns my.namespace (:require-macros [my.macros :as my])) The :as prefix selector is required in :require-macros. One point of note is that the code generated by ClojureScript macros must target the capabilities in ClojureScript.

like image 99
cotarmanach Avatar answered Sep 24 '22 05:09

cotarmanach