Skip to content

Instantly share code, notes, and snippets.

@aisamanra
aisamanra / jsonfs.hs
Created November 13, 2014 07:17
Quick-and-dirty program to mount JSON as a read-only file system
{-# LANGUAGE OverloadedStrings #-}
-- WARNING! This is very bad, quickly-written code, and should not be
-- trusted to do anything right! It does not support writing, and still
-- has several problems even for reading. Also it's ugly and bad.
import qualified Data.ByteString as BSS
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BS
import Data.Char (isDigit)
module Main where
import Data.List (nub)
import MonadLib
import UI.TCOD.Console
import UI.TCOD.Console.Types
import UI.TCOD.Color
type Pt = (Int, Int)
type St = (Pt, [Pt])
@aisamanra
aisamanra / untyped.rs
Last active April 10, 2018 23:45
Basic Rust implementation of an interpreter for the untyped lambda calculus
// A basic intepreter for the untyped lambda calculus
enum Term
{ Num(int)
, Var(~str)
, Lam(~str, ~Term)
, App(~Term, ~Term)
, Let(~str, ~Term, ~Term)
}
;; guile-utf8.scm
;; A quickly hacked together set of functions to turn
;; utf-8-encoded text (which Guile sees as raw bytes) into
;; ASCII-encoded HTML, with a few other functions for
;; getting the code values out of a UTF-8 string.
;; anon-let is a hacky macro to create a new scope while
;; allowing definitions within it to bind in its enclosing
;; scope. It also allows define-local which only defines
;; within that scope. It is used here to close over constants