Skip to content

Instantly share code, notes, and snippets.

View rizo's full-sized avatar

Rizo I rizo

  • London, UK
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Document Outline Test</title>
</head>
<body>
<div class="content">
<h1>Module Order</h1>
<p>Functionality for comparison and ordering of OCaml values.</p>
<section>
@rizo
rizo / my_prelude.hs
Created September 19, 2017 23:36 — forked from gatlin/my_prelude.hs
{- * Foundational functions -}
id :: a -> a
id x = x
const :: a -> b -> a
const x y = x
fix :: (a -> a) -> a
fix f = f (fix f)
@rizo
rizo / list.lhs
Created September 19, 2017 23:28 — forked from gatlin/list.lhs
"Church-encoded" lists and their interesting properties
===
*This is a literate Haskell program which you can run in ghci.*
*Also, I already corrected a glaring problem. Let us speak no more of it.*
One of the beautiful things about computer science is that, fundamentally,
**data is code** and **code is data**. But what does that mean? And how is it
useful?
@rizo
rizo / Dockerfile
Last active January 19, 2023 20:14
Alpine (3.6) based docker image with Protocol Buffers compiler supporting Go.
# Protobuf Builder
# ================
#
# This image builds protocol buffers library from source with Go generation
# support. The builder and runner images are produced.
# Builder Image
# -------------
FROM golang:1.8.3-alpine3.6 as builder
(*
* Work-in-progress implementation of a simple parser combinator library.
*)
type input = char list
(** Parser input is a list of characters. *)
module type Parser = sig
@rizo
rizo / monads.c++
Last active December 3, 2018 02:53
Quick and dirty demonstration of monads in C++.
#include <iostream>
#include <assert.h>
#include <forward_list>
#include <functional>
template <typename T>
struct option {
public:
class no_value { };
@rizo
rizo / gen.ml
Created April 24, 2017 09:22 — forked from dbuenzli/gen.ml
OCaml simple generators
(*---------------------------------------------------------------------------
Copyright (c) 2015 Daniel C. Bünzli. All rights reserved.
Distributed under the BSD3 license, see license at the end of the file.
%%NAME%% release %%VERSION%%
---------------------------------------------------------------------------*)
(* Simple generators according to:
Kiselyov, Peyton-Jones, Sabry
Lazy v. Yield: Incremental, Linear Pretty-printing
@rizo
rizo / pipes.ml
Last active September 26, 2018 13:30
Coroutine pipes in OCaml. Slides: <http://odis.io/talks/ocaml-coro.pdf>
type void
(* Core pipe type *)
type ('a, 'b, 'r) pipe =
| Yield of ('b * (unit -> ('a, 'b, 'r) pipe))
| Await of ('a -> ('a, 'b, 'r) pipe)
| Ready of 'r
@rizo
rizo / fold-overview.elm
Last active August 2, 2017 12:06
A quick overview of Fold programming language (https://github.com/fold-lang)
-- This is a single line comment
{- This is a multi-line comment,
it can span multiple lines -}
{- Multi-line comments can be {- nested -} -}
-- This is a value binding.
val answer = 42
@rizo
rizo / generic_contains.go
Created February 27, 2017 16:11
Generic implementation of the `contains` function without runtime cost. No dependencies, runs on any unix machine with a go compiler!
// Generic implementation of the `contains` function.
// No dependencies, runs on any unix machine with a go compiler!
//
// Build instruction:
//
// $ go generate
// $ go run gen.go
//
package main