This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query IntrospectionQuery { | |
__schema { | |
queryType { name } | |
mutationType { name } | |
types { | |
...FullType | |
} | |
directives { | |
name | |
description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ======== | |
# NOTATION | |
# ======== | |
# Control.Monad (Haskell) Bind | |
>>= | |
# Witchcraft.Chain.bind (Elixir) | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder