Skip to content

Instantly share code, notes, and snippets.

@Hirrolot
Hirrolot / CoC.ml
Last active July 16, 2024 18:56
Barebones lambda cube in OCaml
(* The syntax of our calculus. Notice that types are represented in the same way
as terms, which is the essence of CoC. *)
type term =
| Var of string
| Appl of term * term
| Binder of binder * string * term * term
| Star
| Box
and binder = Lam | Pi
@gelisam
gelisam / CouldBe.hs
Last active February 21, 2022 13:16
Keeping track of which errors have and haven't been handled
-- in response to https://www.parsonsmatt.org/2018/11/03/trouble_with_typed_errors.html
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
module CouldBe where
import Control.Monad
import Data.Void
-- Here is an alternate, much simpler solution to the problem of keeping track of which errors have
-- and haven't been handled. It doesn't use prisms nor generics, it simply uses the monad
@gvolpe
gvolpe / di-in-fp.md
Last active September 16, 2024 07:18
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
@rust-play
rust-play / playground.rs
Created May 22, 2018 01:12
Code shared from the Rust Playground
use std::collections::BTreeMap;
use std::io::{self, Write};
pub struct Todo {
name: String,
checked: bool,
priority: i32,
}
impl Todo {
@3noch
3noch / .ghci
Last active October 29, 2018 09:49
Reflex-DOM Auto Reload Development with ghcid
:set prompt "> "
:set -isrc
:load Main
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active September 12, 2024 16:16
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.