Skip to content

Instantly share code, notes, and snippets.

@typeswitch-dev
typeswitch-dev / Test.idr
Last active March 9, 2020 02:13
Minimalistic unit testing framework for Idris.
||| Minimalistic unit testing framework for idris.
module Test
%access public export
%default total
data Test : Type where
Check : (x: Type) -> {auto p: x} -> Test
Forall : (t: Type) -> (t -> Test) -> Test
(>>=) : Test -> (() -> Test) -> Test
@Dierk
Dierk / Main.purs
Created November 14, 2016 20:11
Monoidal Fizzbuzz in Purescript
module Main where
import Control.Monad.Eff.Console (log)
import Data.List.Lazy (take, zipWith, fromFoldable, cycle, iterate, foldr)
import Data.Monoid (mempty, (<>))
import Data.Maybe (Maybe(..), fromMaybe)
import Prelude ( show, map, ($), (+))
main = do
@jdegoes
jdegoes / die-flags-die.md
Created October 8, 2014 17:20
Death to Boolean Flags

Refactoring Booleans to Functions

Boolean parameters are a plague, responsible for non-composable, monolithic functions that never quite do enough, and countless programming bugs:

  • "Oops, meant to pass that as the 2nd boolean flag, not the 1st!"
  • "Oops, accidentally inverted the meaning of that boolean in the implementation!"
  • "Oops, the function isn't flexible enough for my use case, let's add a 6th boolean flag!"
  • "Oops, got the meaning of that boolean flag wrong, time to dig into the source code!"

All boolean parameters should be refactored into functions that effect the change otherwise encoded in the parameter.