Skip to content

Instantly share code, notes, and snippets.

View chrisdone-artificial's full-sized avatar

Chris Done chrisdone-artificial

View GitHub Profile
ghci> runReader (runParserT (do a <- local (+1) ask; b <- ask; pure (a,b)) "" "") 0
Right (1,0)
@chrisdone-artificial
chrisdone-artificial / times.el
Created May 13, 2024 13:35
parsing todoist style times in emacs lisp
(rx-define do-rx
(and word-start
(or
;; today/tomorrow
(and (group-n 1 "tom") (optional "orrow"))
(or (and (group-n 1 "tod") (optional "ay")))
;; next <thing>
(and "next "
(group-n 2 (or "week" "month" "year")))
;; in x <duration>
@chrisdone-artificial
chrisdone-artificial / hell-http.hs
Last active June 30, 2024 21:17
hell-http.hs demo
#!/usr/bin/env hell
-- How to run this:
--
-- socat TCP-LISTEN:8081,fork,reuseaddr,max-children=20 EXEC:"./handler.hell"
main = do
line <- Text.getLine
let content =
Text.concat ["<h1>Hello, World!</h1><p>This is generated by Hell.</p><pre>", line, "</pre>"]
(defcustom albero-width 30
"Width of the albero window.")
(defvar albero-expanded (make-hash-table :test 'equal))
(defun albero-win-config-hook ()
(let ((w (albero-window)))
(when w
(albero-adjust-win w))))
bash-3.2$ ghc T.hs && ./T
[1 of 2] Compiling Main             ( T.hs, T.o ) [Source file changed]
[2 of 2] Linking T [Objects changed]
(a) -> (a)
Bool
Bool
Type error
CallStack (from HasCallStack):
 error, called at T.hs:126:16 in main:Main
@chrisdone-artificial
chrisdone-artificial / 0readme.md
Last active December 12, 2023 10:55
Copy tab title + url as rich text bookmarklet

You need to enable dom.events.asyncClipboard.clipboardItem for it to work, via about:config.

(define-derived-mode shoe-mode
fundamental-mode "Shoe"
"Auto-paging shell mode..
\\{shoe-mode-map}"
(linum-mode -1))
(defconst shoe-dir "~/.shoe")
(defvar shoe-shell-program "/bin/bash")
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE UndecidableInstances #-}
module Brossa.Authorization where
-- brossa-specific
import qualified Brossa.DB.Rel8 as BrossaRel8
import qualified Brossa.DB.Hasql as BrossaHasql
@chrisdone-artificial
chrisdone-artificial / attempts to add polytypes to lambda.hs
Created December 14, 2022 16:21
attempts to add polytypes to lambda
-- original from <https://www.cs.ox.ac.uk/projects/gip/school/tc.hs> but URLs don't last long in academia
--
{-# LANGUAGE ExistentialQuantification,GADTs,TypeOperators #-}
-- This typechecker, written by Stephanie Weirich at Dagstuhl (Sept 04)
-- demonstrates that it's possible to write functions of type
-- tc :: String -> Term a
-- where Term a is our strongly-typed GADT.
-- That is, generate a typed term from an untyped source; Lennart
-- Augustsson set this as a challenge.