Skip to content

Instantly share code, notes, and snippets.

View expede's full-sized avatar
Highly caffeinated

Brooklyn Zelenka expede

Highly caffeinated
View GitHub Profile
@expede
expede / .spacemacs
Last active August 26, 2023 02:56
Spacemacs Config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@expede
expede / getSchema.graphql
Last active January 26, 2022 19:50
Get complete GraphQL schema
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
types {
...FullType
}
directives {
name
description
@expede
expede / witchcraft_monadic_do.ex
Last active May 20, 2020 15:54
Witchcraft Monadic Do Notation Primer
# ========
# NOTATION
# ========
# Control.Monad (Haskell) Bind
>>=
# Witchcraft.Chain.bind (Elixir)
>>>
Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> use Witchcraft
iex(2)> alias Algae.Maybe
# With a Just
iex(5)> monad %Maybe.Just{} do
...(5)> a <- Maybe.Just.new(1)
...(5)> b <- Maybe.Just.new(2)
...(5)> return(a + b)
@expede
expede / gist:8712eba17daa3980e352
Last active October 26, 2017 22:35
What is the Free Monad + Interpreter pattern?
-- Just the code from http://programmers.stackexchange.com/a/242803
-- ...I find it useful to type this stuff out. Weird, I know.
data DSL next = Get String (String -> next)
| Set String String next
| End
p1 :: DSL (DSL (DSL next))
p1 = Get "foo" $ \foo -> Set "bar" foo End
@expede
expede / IntegerProps.hs
Last active October 21, 2016 17:07
IntegerProps
x == x -- Reflixivity
x * 0 == 0 -- Origin
x * 0 * 0 == 0 -- Idempotence
x + 0 == x -- Additive identity
x / 1 == x -- Divisive identity
x * 1 == x -- Multiplicative identity
{-
Vectors are fixed-length data structures
They're written in this format: `Vect length type`
ex. `Vect 3 Int` could represent [1,2,3], but not [1,2] or ['a', 'b', 'c']
-}
concat : Vect lengthX a -> Vect lengthY a -> Vect (lengthX + lengthY) a
concat Nil ys = ys
concat (x :: xs) ys = x :: app xs ys
@expede
expede / MonadLaws.hs
Last active October 12, 2016 09:32
Monad laws
return a >>= f == f a -- Left Identity
m >>= return == m -- Right Identity
(m >>= f) >>= g == m >>= (\x -> f x >>= g) -- Associativity
-- ...plus all applicative functor laws
# Hypothetical rewrite of `File.read`
# Not the lack of a `OtherFile.read!` (with a bang),
# but we get the same effect with the caller via `>>>`
# Success
iex> OtherFile.read("./existing_file.txt")
"I'm a little teapot short and stout ..."
# Error
# Note that this returns an Exception struct as a value
use Exceptional
# Success case
iex> OtherFile.read("./existing_file.txt") >>> String.length
1000
# Error case
iex> OtherFile.read("./missing.file") >>> String.length
**(OtherFile.NotFoundError) File not found at ./missing.file