Skip to content

Instantly share code, notes, and snippets.

View bitemyapp's full-sized avatar
🐺
aroo

Chris A. bitemyapp

🐺
aroo
View GitHub Profile
@nkpart
nkpart / fmap.md
Last active December 5, 2024 05:31
fmap . fmap . fmap

fmap . fmap . fmap

Functors and Traversables compose.

You might have seen this statement before. This is how you can take advantage of it.

Composing many fmap calls gives you a function that will drill down into a structure and modify it at a certain depth in that nested structure.

@aaronlevin
aaronlevin / haskell-project.nix
Last active August 29, 2015 14:13
Nix n00b templates
# This template will give you a prompt with:
# - ghc
# - cabal
# - ghc-mod
# - the libraries: free, mtl, transformers
#
# to run: nix-shell haskell-project.nix
#
# to specify specific version of haskell, you can:
# nix-shell --arg haskellPackages 'with import <nixpkgs> {}; haskellPackages_ghc783_profiling'
@andrewthad
andrewthad / natural_join.hs
Created December 19, 2014 00:21
Haskell implementation of relational algebra's natural join
{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeOperators, TypeFamilies,
MultiParamTypeClasses, FlexibleInstances, PolyKinds, FlexibleContexts,
UndecidableInstances, ConstraintKinds, OverlappingInstances, ScopedTypeVariables #-}
import GHC.TypeLits
import Data.Type.Bool
import Data.Type.Equality
import Data.Proxy
import Control.Applicative ((<$>), (<*>))
import Data.Maybe (catMaybes)
@paf31
paf31 / Arbiter.hs
Last active August 29, 2015 14:11
needs a better name
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
module Main where
import Test.QuickCheck
class Arbiter f r where
arbiter :: f -> Gen r
instance Arbiter r r where
@maurisvh
maurisvh / fcast.hs
Last active January 20, 2017 00:32
tiny terminal livestreaming server
-- to watch: telnet localhost 8887
-- to stream: script -f >( (echo hello streamname; cat -) | nc -q5 localhost 8888 > /dev/tty )
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Concurrent
import Control.Concurrent.Chan
import Control.Concurrent.MVar
import Control.Monad

Give me back my sanity

One of the many things I do for my group at work is to take care of automating as many things as possible. It usually brings me a lot of satisfaction, mostly because I get a kick out of making people's lives easier.

But sometimes, maybe too often, I end up in drawn-out struggles with machines and programs. And sometimes, these struggles bring me to the edge of despair, so much so that I regularly consider living on a computer-less island growing vegetables for a living.

This is the story of how I had to install Pandoc in a CentOS 6 Docker container. But more generally, this is the story of how I think computing is inherently broken, how programmers (myself included) tend to think that their way is the way, how we're ultimately replicating what most of us think is wrong with society, building upon layers and layers of (best-case scenario) obscure and/or weak foundations.

*I would like to extend my gratitude to Google, StackOverflow, GitHub issues but mostly, the people who make the

@chrisdone
chrisdone / typing.md
Last active August 14, 2025 17:50
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

diff --git a/apps/flake/src/flake_harness.erl b/apps/flake/src/flake_harness.erl
index 0657f03..6980cb3 100644
--- a/apps/flake/src/flake_harness.erl
+++ b/apps/flake/src/flake_harness.erl
@@ -18,33 +18,35 @@
-author ('Dietrich Featherston <[email protected]>').
-export ([
- generate/1,
- generate/2,
@paf31
paf31 / node-haskell.md
Last active May 14, 2024 03:51
Reimplementing a NodeJS Service in Haskell

Introduction

At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

{-# LANGUAGE InstanceSigs, OverloadedStrings #-}
module Text.Parser.Selmer where
import Control.Applicative
import Data.Char (isAlpha)
import Data.Map.Lazy (Map)
import qualified Data.Map.Lazy as M
import Data.Maybe (fromMaybe)
import Data.Monoid