Skip to content

Instantly share code, notes, and snippets.

View lpil's full-sized avatar
🦦
Ahoy!

Louis Pilfold lpil

🦦
Ahoy!
View GitHub Profile
@lpil
lpil / elm.js
Last active September 2, 2018 19:34
var elm$core$Basics$never = function (_n0) {
never:
while (true) {
// Stuff here
}
};
defmodule Web do
require Logger
@behaviour :elli_handler
def handle(r, _args) do
Router.handle(:elli_request.method(r), :elli_request.path(r), r)
rescue
exception ->
Logger.error(inspect(exception))
@lpil
lpil / bind.ex
Last active October 22, 2017 17:43
Ways of handling nil
id
|> get()
|> Maybe.and_then(& &1.size)
@lpil
lpil / one.rb
Last active April 22, 2017 11:14
Examples of Ruby Result monad in use
# Given methods that return Results...
get_params
.and_then(method(:validate_params))
.and_then(method(:save_record))
.and_then(method(:send_email))
.match(ok: method(:render_success),
error: method(:render_failure))
@lpil
lpil / result.rb
Created April 13, 2017 11:21
Ruby Result Monad
require 'result/ok'
require 'result/error'
#
# A generic representation of success and failure.
#
# Styled after the Result monad of Elm and Rust
# (or the Either monad of Haskell).
#
# The `#and_then` method can be used to chain functions that

Pull Request Guidelines

Good code is tested, designed for change, easy to understand and able to cope when things go wrong.

Good pull requests are descriptive, small and short-lived.

For the Author

module Main where
import Prelude
import Control.Monad.Eff.Console
import Data.Foldable (foldl)
import Data.String as String
import Data.Char as Char
import Data.List as List
import Data.List (List(Nil), (:))
import Data.Array as Array
@lpil
lpil / oop.js
Created December 5, 2016 23:12
export function makeAnimal({ name, size }) {
const sayHello = () => `Hello, I'm ${name}`;
const isBigger = (other) => size > other.size;
return Object.freeze({
sayHello,
isBigger,
size,
});
defmodule Pattern do
@pattern quote do: {:attr, payload}
defmacro pattern do
quote do: {:macro, payload}
end
def match(unquote(@pattern) = argument) do
print(
"hello"
)
print([
1,
2,
])
vs