Skip to content

Instantly share code, notes, and snippets.

I am attesting that this GitHub handle txus is linked to the Tezos account tz1TSCo7tDXgCEySkrVyyNov7GBLSQPpL2ev for tzprofiles
txus / Playground.hs
Last active July 16, 2020 14:10
Plutus Playground Smart Contract (should adapt from
-- This is a starter contract, based on the Game contract,
-- containing the bare minimum required scaffolding.
-- What you should change to something more suitable for
-- your use case:
-- * The DataScript type
-- * The Redeemer type
-- And add function implementations (and rename them to

Keybase proof

I hereby claim:

  • I am txus on github.
  • I am txus ( on keybase.
  • I have a public key ASAbZcf0hjvViWF-qloQU5qxKk4thtbvBjzXBtKRWAeU9wo

To claim this, I am signing this object:

txus / sessions.clj
Created February 20, 2017 17:07
Compile-time verification of session-type-like programs in Clojure
(require '[clojure.string :as str])
(defn parse [s]
(->> s
(map (fn [line]
(let [[action source destination alternative]
(str/split (str/trim line) #" +")]
{:source source
txus / adts.clj
Created August 1, 2016 20:10
ADTs with compile-time arity / type checking in Clojure --wip!
(ns adts
(:require [clojure.string :as str]))
(defn type->kw [ty]
(keyword (str *ns* "/" ty)))
(defn capitalized? [s]
(= (str s) (str/capitalize s)))
(defn adt? [s]
txus / small_town.cljs
Created July 18, 2016 17:03
Small Town
;; person
(def genders #{:male :female})
(defn make-person [age]
{:age age
:gender (rand-nth (vec genders))
:dead false})
txus / incidental_complexity.go
Created May 4, 2016 14:29
Getting a random subset of size (N * percentage) of a slice of size N.
func RandomSubset(containers []*docker.Container, percentage float64) []*docker.Container {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
length := len(containers)
numberOfElementsWeWant := int64(percentage * float64(length))
randomIndices := r.Perm(length)[0:numberOfElementsWeWant]
var selected []*docker.Container
for _, idx := range randomIndices {
selected = append(selected, containers[idx])
txus /
Last active March 15, 2016 13:42
Is there a way to have enum branches that introduce their own type parameters?
trait Hey {
fn ha(&self) -> u32;
enum Foo<A> {
Bar<X: Hey>(Box<Fn(X) -> Foo<A>>)
fn test() -> Foo<u32> {
txus /
Last active July 30, 2018 20:54
Memory as a dependently-typed effect (scroll down for examples!)

Memory as an effect

What if we treated memory as a side-effect?

Idris lets us track lots of things in the type system, in order to get errors at compile-time rather than at runtime. One of the tools that lets us do this in Idris is called Effects, and they're used to keep track of state, to manage file handlers, and lots more.

In barely 40 lines of Idris (which could be less if I had any idea what I'm

txus /
Created January 5, 2016 11:10
Python is crazy


You'll need dbus running. In a console:


In another console: