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
{-# LANGUAGE RankNTypes #-} | |
-- Prelude> :set -XTypeApplications | |
-- Prelude> :t id | |
-- id :: a -> a | |
-- Prelude> :t const | |
-- const :: a -> b -> a | |
-- Prelude> :t (<*>) @((->) _) | |
-- (<*>) @((->) _) :: (w -> a -> b) -> (w -> a) -> w -> 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
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# OPTIONS_GHC -Wall #-} | |
module Main where |
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
const testItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
const limit = 2; | |
const getBatch = (cursor = null) => { | |
const currentCursor = cursor || 0; | |
const nextPotentialCursor = currentCursor + limit; | |
const nextCursor = nextPotentialCursor > 10 ? null : nextPotentialCursor; | |
return new Promise(resolve => | |
setTimeout(() => resolve({ |
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# OPTIONS_GHC -Wall #-} |
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
interface Refinement<A> { | |
tag: string; | |
value: A; | |
} | |
interface Refined<A, R> { | |
value: A; | |
refinement: R; | |
} |
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
import Control.Monad.State | |
import Data.Traversable | |
import Data.Tuple | |
toByteBits :: Integral n => n -> [n] | |
toByteBits = | |
evalState (for [1..8] (\_ -> state (\s -> swap (divMod s 2)))) | |
main = do | |
print $ toByteBits 1 |
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
{-# OPTIONS_GHC -Wall #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Byte where | |
import Data.Bool (bool) | |
import Data.Functor.Const (Const(Const, getConst)) | |
import Data.Bits ((.&.), (.|.), xor) | |
import Prelude hiding (sum) |
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
interface Person { | |
name: string; | |
age: number; | |
} | |
const people: Person[] = [{ name: "Bob", age: 100 }, { name: "Jane", age: 50 }]; | |
const findPeople = (candidate: string): Promise<Person[]> => { | |
return new Promise(resolve => { | |
const timeout = Math.floor(Math.random() * 100); |
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
import * as Either from "./Either"; | |
type Action<I, E, A> = (input: I) => Promise<Either.Either<E, A>>; | |
export class App<I, E, A> { | |
public run: Action<I, E, A>; | |
public constructor(action: Action<I, E, A>) { | |
this.run = action; | |
} |
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
#!/usr/bin/env bash | |
branchname=$(git branch | grep ^* | sed 's/\* //g') | |
regex="([A-Z]*-[0-9]*)" | |
if [[ $branchname =~ $regex ]] | |
then | |
ticket_id="${BASH_REMATCH[1]}" | |
message=`cat $1` |