Skip to content

Instantly share code, notes, and snippets.

View RyanGlScott's full-sized avatar

Ryan Scott RyanGlScott

View GitHub Profile
@ahammar
ahammar / Array.hs
Created February 14, 2014 08:48
Mutually recursive modules using a .hs-boot file
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 December 19, 2015 00:59
Simple scala android project build example. It only takes one line in build.sbt to do what's necessary. Everything else is optional.
// 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
@nh2
nh2 / gadt-equality.hs
Last active November 19, 2018 13:02
Shows how to implement an `instance Eq` for a GADT wrapped in an existential type, in Haskell.
-- 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.
@edsko
edsko / RTTI.hs
Created June 9, 2017 17:54
Run-time type information in Haskell
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
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;
.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')
@Icelandjack
Icelandjack / Constraints.org
Last active February 21, 2024 08:43
Type Classes and Constraints

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.

@jerome-pouiller
jerome-pouiller / cross-compile-ldd
Last active February 26, 2024 03:03
ldd drop-in replacement for cross-compilation toolchains.
#!/bin/bash
# ldd drop-in replacement for cross-compilation toolchains.
# This file is a slightly modified version of xldd.in from
# crosstool-ng 1.22.0
# In order to use it, copy it in same directory than other
# toolchain binaries and rename it with same tuple.
# (i.e. /opt/arm-sysmic-linux-gnueabihf/bin/arm-sysmic-linux-gnueabihf-ldd)