Skip to content

Instantly share code, notes, and snippets.

View therewillbecode's full-sized avatar

Tom therewillbecode

  • Edinburgh, UK
View GitHub Profile

buffers

minibuffer helm mini (launche buffers open and recentfiles

spc b b

move buffer to window n

spc b [n]

erase buffer

spc b e

@therewillbecode
therewillbecode / post.md
Last active November 26, 2019 16:57
Modelling the World of Blade Runner with Haskell's Type System

alt text

If you are starting your Haskell journey I implore you to focus on the type system.

Types are the roots from which your Haskell knowledge grows.

Haskell has algebraic data types. This is a fancy way of saying that we can create types which are composites of other types. Intuitively we can think of types as sets of values.

let
pkgs = import <nixpkgs> {};
overridez = fetchTarball {
patchFlags = [ "--binary" ];
url = "https://github.com/adetokunbo/haskell-overridez/archive/v0.10.3.0.tar.gz";
sha256 = "1mfnjksb0n3jbbsqi7g7jd3qn0c10s5q4dg1lqx3fhqw46yvr7j7";
};
in
import overridez { inherit pkgs; }
{ system ? builtins.currentSystem, compiler ? "ghc844" } :
let
overridez = import ./nix/haskell-overridez.nix;
overlays = [
(newPkgs: oldPkgs: {
haskellPackages = oldPkgs.haskellPackages.override {
overrides = overridez.allIn ./nix;
patchFlags = [ "--binary" ];
};
setting SOURCE_DATE_EPOCH to timestamp 1465036472 of file authenticate-oauth-1.6/Web/Authenticate/OAuth/IO.hs
patching sources
Replace Cabal file with edited version from http://hackage.haskell.org/package/authenticate-oauth-1.6/revision/1.cabal.
compileBuildDriverPhase
setupCompileFlags: -package-db=/build/setup-package.conf.d -j4 -threaded
[1 of 1] Compiling Main ( Setup.lhs, /build/Main.o )
unpacking sources
unpacking source archive /nix/store/vnan6xar42hf2pabl7apwscqnd9w75zr-beam-core-0.7.2.3.tar.gz
source root is beam-core-0.7.2.3
setting SOURCE_DATE_EPOCH to timestamp 1549648350 of file beam-core-0.7.2.3/test/Database/Beam/Test/Schema.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE KindSignatures #-}
@therewillbecode
therewillbecode / Poker.hs
Last active May 13, 2019 22:05
typelevel stuff
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE KindSignatures #-}
import GHC.TypeLits (Symbol)
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
module Interpreter where
import Control.Monad
@therewillbecode
therewillbecode / array_ptr.wat
Last active April 18, 2019 17:00
Array with Pointer in Webassembly
(module
;; Requires that we have at least 1 page of memory available (64kb)
(import "env" "memory" (memory $mem 1))
;; Declare a global variable representing a pointer initalised to index 0 -
;; each element is a 32bit integer and thus 4 bytes wide
(global $ptr (mut i32) (i32.const 0))
(func $get_ptr (result i32)
get_global $ptr