Skip to content

Instantly share code, notes, and snippets.

View reiddraper's full-sized avatar
🍹

Reid Draper reiddraper

🍹
View GitHub Profile
{
"props": {
"allow_mult": true,
"basic_quorum": false,
"big_vclock": 50,
"chash_keyfun": {
"fun": "chash_std_keyfun",
"mod": "riak_core_util"
},
"dw": "quorum",
(require '[simple-check.core :as sc])
(require '[simple-check.generators :as gen])
(require '[simple-check.properties :as prop])
(use 'byte-transforms)
(def compression-type (gen/elements ["lz4" "snappy" "gzip" "zlib"]))
;; a simple round-trip compression property...
;; for all byte-arrays `b`, compressiong with
{-# LANGUAGE TemplateHaskell #-}
module Main
where
import System.Environment (getArgs)
import Data.ByteString.Char8 (pack)
import Control.Distributed.Process (say, Process, spawnLink, RemoteTable)
import Control.Distributed.Process.Node (newLocalNode, initRemoteTable, runProcess, localNodeId, LocalNode(..))
import Control.Distributed.Process.Internal.Types (NodeId(..))
{-# LANGUAGE TemplateHaskell #-}
module Main
where
import System.Environment (getArgs)
import Data.ByteString.Char8 (pack)
import Control.Distributed.Process (say, Process(..), spawn, RemoteTable(..))
import Control.Distributed.Process.Node (newLocalNode, initRemoteTable, runProcess, localNodeId, LocalNode(..))
import Control.Distributed.Process.Internal.Types (NodeId(..))
@reiddraper
reiddraper / convenience.clj
Last active December 17, 2015 23:09
nested properties in simple-check
(defn gen-creator
[{:arbitrary arbitrary-fun :shrink shrink-fun}]
(reify Generator
(arbitrary [this]
(arbitrary-fun this)
(shrink [this value]
(shrink-fun this value)))
git tag --contains 6f144b9208b8d5dc12cd75a2e5f9fcd1574ce670
1.2.0
1.3.0
1.3.3
1.3.3slf
1.4.0.1
1.4.0.2
Java-1.2.1-release
Python-1.2.1-release

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.

Refactoring

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:

-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{}.
-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().