Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓

Isaac Elliott LightAndLight

🤓
View GitHub Profile
View Env.hs
{-# options_ghc -Wall -Werror #-}
module Env where
import Data.Maybe (fromMaybe)
import qualified System.Environment
data LogLevel = DEBUG | INFO | WARN | ERROR
deriving (Show, Read)
newtype Parser a = Parser { parse :: String -> IO a }
View Printer.hs
import Data.Semigroup (stimes)
import qualified Data.List as List
import Prelude hiding (words)
data Layout a = Space | Content a
deriving (Eq, Show)
layout :: b -> (a -> b) -> Layout a -> b
layout space f c =
View Plugins.hs
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstraintKinds #-}
View neuron.md

Suppose I have two zettels, A and B:

A.md        B.md

Then I link from B to A with something like, "[[A]] provides a good summary of topic blah".

I now have a graph like this:

View cryptohash-sha1-base.patch
--- a/cryptohash-sha1.cabal
+++ b/cryptohash-sha1.cabal
@@ -66,7 +66,7 @@
library
default-language: Haskell2010
- build-depends: base >= 4.5 && < 4.15
+ build-depends: base >= 4.5 && < 5
, bytestring >= 0.9.2 && < 0.11
@LightAndLight
LightAndLight / Json.hs
Created Aug 19, 2020
typed json access with paths
View Json.hs
{-# language GADTs, KindSignatures, StandaloneDeriving #-}
module Json
( JsonType(..), SomeJsonType(..)
, Segment(..)
, prettySegment
, Path(..)
, append
, prettyPath
, JsonError(..)
, typeOf
View stuff.sh
command {
name = "ls",
options = [
Flag{ name = "long", short = 'l' },
Flag{ name = "recursive", short = 'R', long = "recursive" },
Option{ name = "block-size", long = "block-size", type = Int, default = None },
Option{
name = "color",
long = "color",
@LightAndLight
LightAndLight / Rename.hs
Last active Jun 28, 2020
Injective renamings and well-typed, staged metaprogramming
View Rename.hs
{- | Calculating injective renamings
Say you have typing environment like [x : Int, y : Bool]. In your AST,
variables are represented by natural numbers that index into the environment.
So under this environment, `x` is represented by `0` and `y` is represented
by `1`. During type checking, information about a variable can be found by
indexing into that environment. Similarly, the environment of a
closure can be compiled to array, with the variable lookup being compiled to
array indexing. This approach is known as 'de bruijn indices'.
@LightAndLight
LightAndLight / RPC.hs
Created Mar 11, 2020
Sketch of well-typed RPC
View RPC.hs
{-# language DataKinds, GADTs, ScopedTypeVariables #-}
{-# language RankNTypes, TypeApplications #-}
{-# language LambdaCase #-}
{-# language ImplicitParams #-}
module Server where
import Data.Bifunctor (first)
import Data.ByteString (ByteString)
import Data.Proxy
import Data.Serialize
@LightAndLight
LightAndLight / Reactive.hs
Last active Mar 1, 2020
Patterns for building fine-grained reactive datatypes
View Reactive.hs
data Triple f a b c
= Triple1 (f a) (f b) (f c)
| Triple2 (f a) (f b) (f c)
data TripleAction a b c where
Triple1Fst :: (a -> a) -> TripleAction a b c
Triple1Snd :: (b -> b) -> TripleAction a b c
Triple1Thd :: (c -> c) -> TripleAction a b c