Skip to content

Instantly share code, notes, and snippets.

The following code
(defn do-stuff [msg]
(hmatch msg
[:dog age name] (println "got a dog with age " age " and name " name)
[:cat cute? legs] (println "got a cat that is " cute? " cute and has " legs "legs")
[other] (println "got an unrecognized animal of type " other ))
becomes:
PROJECT = websocket
DEPS = cowboy erldn
dep_cowboy = pkg://cowboy master
dep_erldn = https://github.com/txrev319/erldn.git master
{application, hello_erlang, [
{description, "Hello world with Cowboy!"},
{vsn, "0.1.0"},
{modules, []},
{registered, [hello_erlang_sup]},
{applications, [
kernel,
stdlib,
cowboy
]},
Erlang/OTP 17 [RELEASE CANDIDATE 2] [erts-6.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V6.0 (abort with ^G)
(websocket_example@127.0.0.1)1> application:stop(websocket).
=INFO REPORT==== 8-Mar-2014::02:51:11 ===
application: websocket
exited: stopped
type: permanent
ok
=INFO REPORT==== 9-Mar-2014::03:03:41 ===
application: websocket
exited: {bad_return,
{{websocket_app,start,[normal,[]]},
{'EXIT',
{{badmatch,{error,{already_started,<0.53.0>}}},
[{websocket_app,start,2,
[{file,"src/websocket_app.erl"},{line,26}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,272}]}]}}}}
## websocket_app.erl
-module(websocket_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
-module(websocket_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
-export([public_router/0]).
public_router() ->
websocket_handle({text, Msg}, Req, State) ->
try _X = lists:flatten(io_lib:format("~p", [erldn:parse_str(Msg)])) of
_ -> {reply, {text, <<"That's what she said! ", Msg/binary >>}, Req, State}
catch
_ -> {reply, {text, <<"ERROR Parsing", Msg/binary >>}, Req, State}
end;
websocket_handle(_Data, Req, State) ->
{ok, Req, State}.
(ns doc.doc-diff
#+clj (:require [clojure.core.typed :as t])
#+cljs (:require-macros [cljs.core.typed :as t]))
(t/defalias Cmd (U Set-Attrs Set-Order Update-Child Swap-Child))
(t/defalias Cmds (t/Seq Cmd))
(ns cljs.core.typed
"Macros for Clojurescript type checking"
(:refer-clojure :exclude [type defprotocol #_letfn fn loop dotimes let for doseq
#_def #_filter #_remove])
(:require [clojure.core.typed :as t]
[clojure.core.typed.current-impl :as impl :refer [v]]
[clojure.core.typed.util-cljs :as u]
[cljs.analyzer :as ana]
[cljs.compiler :as comp]
[cljs.core :as core]