Skip to content

Instantly share code, notes, and snippets.

Brad bradparker

Block or report user

Report or block bradparker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bradparker
bradparker / App.ts
Created Jun 16, 2019
Geneator function do notation experiment
View App.ts
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;
}
@bradparker
bradparker / prepare-commit-message
Last active May 31, 2019
Git Hook to prepend a commit message with the Jira ticket id at the start of the current branch's name
View prepare-commit-message
#!/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`
View Traversals.hs
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE FlexibleInstances #-}
module Traversals where
import Control.Applicative (Applicative(..))
import Data.Bool (Bool(True))
View LensesAndFunctionalReferences.hs
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
module LensesAndFunctionalReferences where
import Data.Char (chr, ord, toUpper)
import Data.Functor.Const (Const(Const, getConst))
import Data.Functor.Contravariant (Contravariant(contramap))
import Data.Functor.Identity (Identity(Identity, runIdentity))
View NewtypeLists.hs
{-# LANGUAGE TupleSections #-}
newtype NonEmpty a = NonEmpty { getNonEmpty :: (a, List a) }
newtype List a = List { getList :: Maybe (NonEmpty a) }
nil :: List a
nil = List Nothing
cons :: a -> List a -> List a
cons a =
@bradparker
bradparker / default.nix
Created Mar 5, 2019
Minimal Miso default nix file
View default.nix
let
overlay = self: super:
{
haskell = super.haskell // {
packages = super.haskell.packages // {
ghcjs = super.haskell.packages.ghcjs.extend (hself: hsuper: {
# Doctest fails to build with a strange error.
doctest = null;
# These require doctest to run their tests.
View the-little-typer.pie
#lang pie
(claim one
Nat)
(define one
(add1 zero))
(claim vegetables
(Pair Atom Atom))
(define vegetables
View Comonad.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveFunctor #-}
{-# OPTIONS_GHC -Wall #-}
-- $ nix-shell -p "haskellPackages.ghcWithPackages (pkgs: [ pkgs.random ])"
-- $ runhaskell Comonad.hs
module Main where
View CommonmarkJSON.hs
{-# LANGUAGE OverloadedStrings #-}
module Main
( main
) where
import CMarkGFM
( ListAttributes
, Node
, NodeType
View Mtl.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Main where
import Control.Monad
import Control.Monad.Trans.State (runState, runStateT)
import Control.Monad.Trans.Except (runExceptT, runExcept)
import Control.Monad.Error.Class
import Control.Monad.State.Class
You can’t perform that action at this time.