Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar

Stephen Diehl sdiehl

View GitHub Profile
@sdiehl
sdiehl / setup.py
Created May 12, 2025 06:34
Setup.py for mlir-python-bindings
from setuptools import setup, find_packages
import os
import platform
import sys
# Ensure we're using Python 3.10 or later
if sys.version_info < (3, 10):
raise RuntimeError("Python 3.10 or later required")
# Get platform-specific extension
@sdiehl
sdiehl / church.py
Created February 15, 2021 14:07
Pathological Python Programs
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 March 17, 2020 10:50
2019 Reading List
  • 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
@sdiehl
sdiehl / Main.hs
Last active February 24, 2020 15:09
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE GHCForeignImportPrim #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnliftedFFITypes #-}
module Main where
import GHC.Prim
import GHC.Word

Install Stack.

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

Install Unison from source.

@sdiehl
sdiehl / fails.hs
Created August 13, 2019 12:07
QuantifiedConstraints Weirdness
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE QuantifiedConstraints #-}
module Test where
{-# 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))
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