Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Stephen Diehl sdiehl

💭
I may be slow to respond.
View GitHub Profile
@sdiehl
sdiehl / church.py
Created Feb 15, 2021
Pathological Python Programs
View church.py
TRUE = lambda x: lambda y: x
FALSE = lambda x: lambda y: y
Product = lambda x: lambda y: lambda z: (z)(x)(y)
And = lambda x: lambda y: (x)(y)(x)
Not = lambda x: lambda y: lambda z: (x)(z)(y)
Boolean = (Product)(True)(False)
Succ = lambda x: lambda y: lambda z: (y)((x)(y)(z))
Pred = lambda x: lambda y: lambda z: x(lambda i: lambda j: j(i(y))) (lambda k: z) (lambda k: k)
Y = lambda g: (lambda z:z(z)) (lambda f: g(lambda arg: f(f)(arg)))
Nth = Y(lambda f: lambda n: Succ(f(n-1)) if n else Zero)
@sdiehl
sdiehl / diehl_2019.md
Created Mar 17, 2020
2019 Reading List
View diehl_2019.md
  • Absolution Gap - Alastair Reynolds
  • Abundance - Peter H Diamandis
  • Advances in Active Portfolio Management - Richard Grinold
  • Advances in Unconventional Computing - Andrew Adamatzky
  • Creating Modern Capitalism - Thomas Mccraw
  • Exhalation - Ted Chiang
  • From Bacteria to Bach and Back - Daniel C. Dennett
  • Human Compatible - Russell Stuart
  • Look To Windward - Iain M. Banks
  • Lost in Math - Sabine Hossenfelder
View Main.hs
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE GHCForeignImportPrim #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnliftedFFITypes #-}
module Main where
import GHC.Prim
import GHC.Word
View installing_unison.md

Install Stack.

$ curl -sSL https://get.haskellstack.org/ | sh
$ stack setup

Install Unison from source.

@sdiehl
sdiehl / fails.hs
Created Aug 13, 2019
QuantifiedConstraints Weirdness
View fails.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE QuantifiedConstraints #-}
module Test where
View DataTypeName.hs
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
module Test where
import GHC.Generics
import Data.Proxy
typeName :: forall a. (Generic a, GTypeName (Rep a)) => Proxy a -> String
typeName Proxy = gtypename (from (undefined :: a))
View dict.sh
rivendell% stack ghci not sandboxed
Configuring GHCi with the following packages:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/sdiehl/.ghci
Loaded GHCi configuration from /tmp/ghci18272/ghci-script
λ> class Foo a where { foo :: a -> Int }
λ> instance Foo () where { foo _ = 3 }
λ> bar = foo ()
λ> bar
3
View list_combinator.hs
list :: [b] -> (a -> b) -> [a] -> [b]
list def f xs = case xs of
[] -> def
_ -> fmap f xs
example :: [String]
example = list ["a"] show [1,2,3]
View Test.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
module Data.HdrHistogram.Config.Test where
import Data.Proxy
import GHC.TypeLits (Nat, type (<=))