Skip to content

Instantly share code, notes, and snippets.

View Makefile
.PHONY: all $(SOURCE_NAMES) lhs compile build-dir
### Constants ###
BUILD := build
PAPER := implicits
OUTPUT := $(BUILD)/$(PAPER).pdf
LHS := $(shell find src -type f -name '*.lhs')
SOURCES := $(shell find src -type f -name 'Main.lhs')
View shell.nix
let
_nixpkgs = import <nixpkgs> {};
in
{ nixpkgs ? import (_nixpkgs.fetchFromGitHub { owner = "NixOS"
; repo = "nixpkgs"
; rev = "e6808e30ae2b10f09e8f55e340d1b57f24027010"
; sha256 = "148gms9s3xzqnjw53v5w2c54l3vff6zd3krq9kp4arny9fm3y95i";}) {}
}:
let
pkgs = _nixpkgs; #if nixpkgs == null then _nixpkgs else nixpkgs;
@edsko
edsko / RTTI.hs
Created Jun 9, 2017
Run-time type information in Haskell
View RTTI.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
@Icelandjack
Icelandjack / Constraints.org
Last active Oct 4, 2021
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.

@nh2
nh2 / gadt-equality.hs
Last active Nov 19, 2018
Shows how to implement an `instance Eq` for a GADT wrapped in an existential type, in Haskell.
View gadt-equality.hs
-- Shows how to implement an `instance Eq` for a GADT wrapped in an existential type.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE TypeOperators #-}
import Data.Type.Equality
-- | A GADT. The example would also work if it had more than 1 type parameter.
@ahammar
ahammar / Array.hs
Created Feb 14, 2014
Mutually recursive modules using a .hs-boot file
View Array.hs
module Array where
import qualified Data.IntMap as M
import {-# SOURCE #-} Object
data Array = Array
{ _map :: M.IntMap Value
}
a ! i {- | i >= baseLength ai -} = maybe vnil id $ M.lookup i (_map a)
@pfn
pfn / build.sbt
Last active Dec 19, 2015
Simple scala android project build example. It only takes one line in build.sbt to do what's necessary. Everything else is optional.
View build.sbt
// so we can use keywords from Android, such as 'Android' and 'proguardOptions'
import android.Keys._
// load the android plugin into the build
android.Plugin.androidBuild
// project name, completely optional
name := "time-widgets"
// pick the version of scala you want to use