Make sure you have installed Homebrew and (Homebrew-Cask)[http://caskroom.io/].
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebrew-cask
brew install caskroom/cask/brew-cask
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;;; Connection | |
| (defprotocol DatomicConnection | |
| (as-conn [_])) | |
| (extend-protocol DatomicConnection | |
| datomic.Connection | |
| (as-conn [c] c) | |
| datomic.db.Db |
Make sure you have installed Homebrew and (Homebrew-Cask)[http://caskroom.io/].
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebrew-cask
brew install caskroom/cask/brew-cask
| curl --include \ | |
| --no-buffer \ | |
| --header "Connection: Upgrade" \ | |
| --header "Upgrade: websocket" \ | |
| --header "Host: example.com:80" \ | |
| --header "Origin: http://example.com:80" \ | |
| --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ | |
| --header "Sec-WebSocket-Version: 13" \ | |
| http://example.com:80/ |
| ;; Re-render when Figwheel reloads. | |
| (gevents/listen js/document.body | |
| "figwheel.js-reload" | |
| (fn [] | |
| (let [root-component (om-next/app-root (compassus/get-reconciler a))] | |
| (letfn [(js-vals [o] | |
| (map #(aget o %) (js-keys o))) | |
| ;; Finds the children of a React internal instance of a component. | |
| ;; That could be a single _renderedComponent or several | |
| ;; _renderedChildren. |
| # Update: This micro-blog is now also a guide on clojurescript.org: | |
| # http://clojurescript.org/guides/native-executables | |
| # Hello! This is a micro-post about how to produce native executables | |
| # from ClojureScript source. The basic idea is to produce a | |
| # JavaScript file using the ClojureScript compiler, and then use a | |
| # Node.js tool called nexe (https://github.com/jaredallard/nexe) to | |
| # compile that into an executable. The resulting file can be run | |
| # without requiring a node install on the target machine, which can | |
| # be handy. |
NOTE: This gist uses the master branch of ClojureScript. Clone ClojureScript and from the checkout run
./script/bootstrapand./script/uberjar. This will producetarget/cljs.jarwhich you can use to follow this guide.
As client applications become larger it becomes desirable to load only the code actually
required to run a particular logical screen. Previously ClojureScript :modules compiler option
permitted such code splitting, but this feature only worked under :advanced compilation
and users would still have to manage loading these splits. :modules also required manual
| type json = Js.Json.t; | |
| let x: json = [%bs.raw {|{"a": [1, "hello", 2, {"b": {"c": [100,200, "d", [10,20,30]]}}]}|}]; | |
| let rec json_to_string json => { | |
| let array_to_string a => a |> Array.to_list |> String.concat ","; | |
| let emitObject o => | |
| "{" ^ | |
| { | |
| let emitKV (key, value) => key ^ ": " ^ json_to_string value; |
| /* Slaying a UI Anti Pattern in Reason */ | |
| type remoteData 'e 'a = | |
| | Nothing | |
| | Loading | |
| | Failure 'e | |
| | Success 'a; | |
| type item = { | |
| userId: int, |
"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType
The following write-up is intended as an introduction into using phantom types in ReasonML.
Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.
| module Store = { | |
| type action = | |
| | Increase | |
| | Decrease | |
| | SetUsername(string); | |
| type state = { | |
| count: int, | |
| username: string, | |
| }; | |
| type storeBag = { |