This file contains hidden or 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
export const Identity = (x) => ({ | |
chain: (f) => f(x), | |
unwrap: () => x, | |
map: (f) => Identity(f(x)), | |
inspect: () => `Identity(${x})`, | |
}) |
This file contains hidden or 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
// a Haskell-like lazy-list | |
// adapted from this awesome gist: https://gist.github.com/gvergnaud/6e9de8e06ef65e65f18dbd05523c7ca9 | |
export class List { | |
constructor(generator, length) { | |
this[Symbol.iterator] = generator | |
this.length = length | |
} | |
// should be private |
This file contains hidden or 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
type CallbackFunction<T = unknown> = (...params: unknown[]) => T | |
export class Maybe<T> { | |
private constructor(private value: T | null) {} | |
static just<T>(a: any): Maybe<T> | |
static nothing<T>(): Maybe<T> | |
static fromValue<T>(value: T | undefined | null): Maybe<T> | |
isJust(): boolean | |
isNothing(): boolean | |
toString(): string |
This file contains hidden or 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
type NotNullOrUndefined = string | number | boolean | symbol | object | |
interface IMaybe<T> { | |
type: symbol | |
has(): boolean | |
isJust(): boolean | |
isNothing(): boolean | |
unwrap(): T | never | |
map<U>(fn: (value: T) => U): IMaybe<U> | |
flatMap<U>(fn: (value: T) => U): T |
This file contains hidden or 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
# @hoxlux/bash | |
# 🗂 💡 🔑 🔐 🚨 🐙 🌴 🔥 🌈 🥥 🥚 ⏱ 🧰 🧪 🛍 🇬🇧 🇧🇷 | |
alias ga="git add ." | |
alias gc1="git commit -m 'commit inicial'" | |
alias gmaster="git switch master" | |
alias gnext="git switch next" | |
alias gprod="git switch production" | |
function parse_git_branch { |
NewerOlder