!SLIDE
monads are simple
!SLIDE
a monad is a monoid in the category of endofunctors
| (require '[sumo.client :as sumo]) | |
| (require '[clojure.pprint :as pp]) | |
| ;; make sure that allow_mult true is set on this bucket first | |
| (def client (sumo/connect-pb)) | |
| ;; make sure ping is working | |
| (sumo/ping client) | |
| ;; true |
| -module(iset). | |
| -include_lib("eqc/include/eqc.hrl"). | |
| -export([empty/0, | |
| singleton/1, | |
| union/2, | |
| member/2, | |
| to_list/1]). | |
| -compile(export_all). |
| -module(iset). | |
| -include_lib("eqc/include/eqc.hrl"). | |
| -export([empty/0, | |
| singleton/1, | |
| difference/2, | |
| union/2, | |
| member/2, | |
| to_list/1]). |
| -module(amt). | |
| -compile(export_all). | |
| -type kv() :: {Key :: integer(), Value :: term()}. | |
| -type tree() :: {tree, orddict:orddict()} | {value, kv()}. | |
| -type either(A) :: {ok, A} | {error, term()}. | |
| -spec empty() -> tree(). | |
| empty() -> |
| -module(amt). | |
| -compile(export_all). | |
| -type kv() :: {Key :: integer(), Value :: term()}. | |
| -type tree() :: {tree, orddict:orddict()} | {value, kv()}. | |
| -type either(A) :: {ok, A} | {error, term()}. | |
| -spec empty() -> tree(). | |
| empty() -> |
| -module(radix). | |
| -compile(export_all). | |
| -record(tree, {value :: maybe(), | |
| children :: children()}). | |
| -type maybe() :: error | {ok, term()}. | |
| -type tree() :: #tree{}. | |
| -type children() :: orddict:orddict(). |
| -module(amt). | |
| -compile(export_all). | |
| -type kv() :: {Key :: integer(), Value :: term()}. | |
| -type tree() :: {tree, orddict:orddict()} | {value, kv()}. | |
| -type either(A) :: {ok, A} | {error, term()}. | |
| -spec empty() -> tree(). | |
| empty() -> |
| -module(radix). | |
| -include_lib("eqc/include/eqc.hrl"). | |
| -compile(export_all). | |
| -record(tree, {value :: maybe(), | |
| children :: children()}). | |
| -type maybe() :: error | {ok, term()}. | |
| -type tree() :: #tree{}. |
I've been reading a bit about concatenative languages recently, and figured I'd compose a short reading list for others interested.
I won't explain what a concatenative language is, but I do want to quickly say a couple of the reasons I find them interesting.
I already like to write really tiny functions, and concatenative languages make it really easy to factor a function into a smaller one. Here's an example, in a made up concatenative language: