Skip to content

Instantly share code, notes, and snippets.

find . -not -path '*/\.*' | entr -c -d bash -c 'stack test --fast --haddock && pkill -INT foo 2>&1 | fold -w $(tput cols) -s | head -n $(tput lines)'

bash -c 'X=$(stack exec -- which foo); while true; do $X; done'

{- | Error-accumulating traversals.
-}
{-# LANGUAGE DeriveFunctor, FunctionalDependencies #-}
module Accumulate
( Acc(..), accAp, accLiftA2, accTraverse, accSequence, accFold
) where
import Control.Applicative
{-# LANGUAGE DeriveGeneric #-}
import GHC.Generics
import Control.Category (Category)
import qualified Control.Category as Cat
-----------------------------------------------------------------------
-- Endofunctions
-----------------------------------------------------------------------
instance Bounded Float where
minBound = -1/0
maxBound = 1/0
minimum' :: [Float] -> Float
minimum' = coerce . foldMap Min
maximum' :: [Float] -> Float
maximum' = coerce . foldMap Max
trait Question[R] {
def ask(ref: ActorRef)(implicit timeout: Timeout, ct: ClassTag[R]):
Future[R] =
new AskableActorRef(ref).ask(this).mapTo[R]
def reply(r: R)(implicit context: ActorContext): Unit =
context.sender ! r
def replyWithFuture(f: Future[R])
newtype ConjList a = ConjList [a] deriving Show
instance Monoid a => Monoid (ConjList a) where
mempty = ConjList $ repeat mempty
mappend (ConjList x) (ConjList y) = ConjList $ zipWith mappend x y
λ> mappend (ConjList ["ab", "cd"]) (ConjList ["xc", "xy", "xp"])
ConjList ["abxc","cdxy"]
it :: (Monoid a, Data.String.IsString a) => ConjList a
chris@renzo ~> cat ~/.stack/config.yaml
# This file contains default non-project-specific settings for 'stack', used
# in all projects. For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration.html
#
nix:
enable: true
pure: false
shell-file: /home/chris/.stack/shell.nix

Standardized Ladder of Functional Programming

The LambdaConf Ladder of Functional Programming (LOFP) is a standardized progression of different concepts and skills that developers must master on their journey to becoming expert-level functional programmers. LOFP can be used to rank workshops, talks, presentations, books, and courseware, so that aspiring functional programmers have a better understanding of what material is appropriate for them given their current experience.

Fire Keramik

Concepts

  • Immutable Data
  • Second-order Functions

Dear Googler:

‘toJSON’ is not a (visible) method of class ‘FromJSON’

It should be parseJSON.

#!/usr/bin/env stack
-- stack --resolver lts-7.8 --install-ghc runghc --package protolude
{-# LANGUAGE NoImplicitPrelude #-}
import Protolude
merge :: (Eq a, Semigroup a) => [a] -> [a]
merge (x:y:more) | x == y = (x <> y) : more
merge (x:xs) = x : merge xs