Skip to content

Instantly share code, notes, and snippets.

@chrisdone
chrisdone / great.md
Created September 28, 2023 19:14
My experience trying out GHC webassembly
View great.md
23-09-28 20:13:14.751 $ nix shell https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz --extra-experimental-features nix-command  --extra-experimental-features flakes
error: flake 'https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz' does not provide attribute 'packages.x86_64-linux.defaultPackage.x86_64-linux', 'legacyPackages.x86_64-linux.defaultPackage.x86_64-linux' or 'defaultPackage.x86_64-linux'
@chrisdone
chrisdone / README.md
Last active September 27, 2023 10:54
Indexed fields exploration
View README.md
@chrisdone
chrisdone / typing.md
Last active September 16, 2023 22:35
Typing Haskell in Haskell
View typing.md

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@chrisdone
chrisdone / Printf.idr
Last active September 8, 2023 21:48
Type-safe dependently-typed printf in Idris
View Printf.idr
module Printf
%default total
-- Formatting AST.
data Format
= FInt Format
| FString Format
| FOther Char Format
| FEnd
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active September 3, 2023 13:06
Build and run minimal Linux / Busybox systems in Qemu
View gist:02e165a0004be33734ac2334f215380e

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@chrisdone
chrisdone / review.md
Last active August 14, 2023 23:40
Email message parsing in Haskell in 2018
View review.md

Email message parsing in Haskell in 2018

Background: I am moving away from GMail to my own Haskell-based server (SMTP receiver/sender, web-based email client, spam filtering, etc.). All email to @chrisdone.com goes through this server (mx.chrisdone.com) as of today, and chrisdone@gmail.com forwards a copy of everything to it.

This is a summary/tracking document of my efforts to simply parse email messages in Haskell for the SMTP receiver.

@chrisdone
chrisdone / 0README.md
Last active July 17, 2023 10:32
Various type inference designs/sketches
View 0README.md

Type Inference: Various Designs

I'm exploring the right data types for writing a type inference with higher kinds and poly types.

Putting more things in the type system can force you to think about more things, but it also can make it harder and more verbose to write and read algorithms.

@chrisdone
chrisdone / shoe.el
Created July 13, 2023 16:01
shoe.el
View shoe.el
(defun shoe-write-script (script)
"Write SCRIPT to the proper place."
(let* ((script-dir (shoe-script-dir script))
(script-path (shoe-script-file-path "/" script-dir)))
(with-temp-file script-path (insert script))))
(defun shoe-script-file-path (script &optional dir)
"Produce the file path for SCRIPT."
(concat (or dir (shoe-script-dir script))
"/"
@chrisdone
chrisdone / .gitignore
Last active April 24, 2023 10:59
Linux + BusyBox + QEMU/VirtualBox/USB boot recipe
@chrisdone
chrisdone / Intro.md
Last active April 10, 2023 06:33
Statically checked overloaded strings
View Intro.md

Statically checked overloaded strings

This gist demonstrates a trick I came up with which is defining IsString for Q (TExp a), where a is lift-able. This allows you to write $$("...") and have the string parsed at compile-time.

On GHC 9, you are able to write $$"..." instead.

This offers a light-weight way to enforce compile-time constraints. It's basically OverloadedStrings with static checks. The inferred return type