Skip to content

Instantly share code, notes, and snippets.

@AndrasKovacs
AndrasKovacs / STLC.hs
Last active Aug 14, 2016
Lambda calculus on the type level with GHC 7.11.20151212.
View STLC.hs
{-# LANGUAGE
TypeInType, UndecidableInstances, TypeOperators, GADTs, TypeFamilies #-}
import Data.Kind
import GHC.Prim
import Data.Proxy
data Fun a b
type a ~> b = Fun a b -> Type
infixr 0 ~>
View stack.yaml
compiler-check: match-exact
resolver: ghc-8.0.1.20161117
setup-info:
ghc:
linux64:
8.0.1.20161117:
url: http://downloads.haskell.org/~ghc/8.0.2-rc1/ghc-8.0.1.20161117-x86_64-deb8-linux.tar.xz
content-length: 112047972
sha1: 6a6e4c9c53c71cc84b6966a9f61948542fd2f15a
macosx:
View Printf.hs
{-# LANGUAGE GADTs, TypeInType, DataKinds, TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
import GHC.TypeLits
import GHC.Types
import Data.Singletons
import Data.Singletons.Prelude
data Format = Lit Symbol | Str | Shown Type
@pchiusano
pchiusano / type-inhabitants.markdown
Last active Jan 21, 2020
Reasoning about type inhabitants in Haskell
View type-inhabitants.markdown

This is material to go along with a 2014 Boston Haskell talk.

We are going to look at a series of type signatures in Haskell and explore how parametricity (or lack thereof) lets us constrain what a function is allowed to do.

Let's start with a decidedly non-generic function signature. What are the possible implementations of this function which typecheck?

wrangle :: Int -> Int
@chrisdone
chrisdone / AnIntro.md
Last active Aug 21, 2020
Statically Typed Lisp
View AnIntro.md

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

@Icelandjack
Icelandjack / Constraints.org
Last active Sep 8, 2020
Type Classes and Constraints
View Constraints.org

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.

@george-hawkins
george-hawkins / arm64.md
Last active Oct 13, 2020
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU
View arm64.md

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key:

@smeijer
smeijer / parse-es6-template.js
Last active Oct 16, 2020
ES6 template string parser
View parse-es6-template.js
function get(path, obj, fb = `$\{${path}}`) {
return path.split('.').reduce((res, key) => res[key] || fb, obj);
}
function parseTpl(template, map, fallback) {
return template.replace(/\$\{.+?}/g, (match) => {
const path = match.substr(2, match.length - 3).trim();
return get(path, map, fallback);
});
}
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active Oct 19, 2020
Reader Macros in Common Lisp
View _reader-macros.md

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.

You can’t perform that action at this time.