Skip to content

Instantly share code, notes, and snippets.

View m-renaud's full-sized avatar

Matt Renaud m-renaud

  • Google Inc.
  • San Francisco, CA
View GitHub Profile
@m-renaud
m-renaud / pretty-haskell-operators.el
Last active November 28, 2018 07:54
Pretty Haskell operators
;; Prefix variable name with mrenaud/ in case haskell-mode adds
;; a 'haskell-prettify-alist in a future release.
(defvar mrenaud/haskell-prettify-alist
'(("\\" . ?λ)
("->>" . (?\s (Br . Bl) ?\s (Br . Bl) ?\s
(Bl . Bl) ?- (Bc . Br) ?- (Bc . Bc) ?>
(Bc . Bl) ?- (Br . Br) ?>))
(">>=" . (?\s (Br . Bl) ?\s (Br . Bl) ?\s
@m-renaud
m-renaud / Lib.hs
Last active November 21, 2018 07:05
Default project template for `cabal init`
-- File: src/Lib.hs
module Lib (greeting) where
greeting :: String
greeting = "Hello, world!"
@m-renaud
m-renaud / ElegantFizzBuzz.hs
Last active December 11, 2017 04:21
Elegant fizzbuzz implementation based on Monoids. Inspired by http://www.parsonsmatt.org/2016/02/27/an_elegant_fizzbuzz.html.
module Main where
import Data.Foldable (fold)
import Data.Maybe (fromMaybe, listToMaybe)
fizzBuzz :: Functor f => f Int -> f String
fizzBuzz =
fmap (fromMaybe <$> show <*> fold rules)
where
rules = [fizz, buzz]
data Entry = Entry
{ entryState :: EntryState
, entryPayload :: Maybe Payload
}
data EntryState = NO_ENTRY | IN_PROGRESS | HAS_ENTRY
data Cache = ...
lookup :: Cache -> Key -> Entry
# control-left control-right nav
set-window-option -g xterm-keys on
setw -g mode-keys emacs
bind-key q confirm-before kill-session
bind-key Q confirm-before kill-server
# remap prefix from 'C-b' to 'C-o'
unbind C-b
set-option -g prefix C-o
these derivations will be built:
/nix/store/lxk22wmjmwf2xadrw7pm37k80m9lcnql-project1-1.0.0.drv
building path(s) ‘/nix/store/81gy6a8m1iin193507qyr580i2mj6n77-project1-1.0.0’
setupCompilerEnvironmentPhase
Build with /nix/store/qijwxnz9s8gas6pc6n5qfv976w523xyb-ghc-8.0.2.
unpacking sources
unpacking source archive /nix/store/cp5d14hvbpkhhv6r0yw6a1520nyr326v-project1
source root is project1
patching sources
compileBuildDriverPhase
@m-renaud
m-renaud / mrenaud-helm.el
Last active January 12, 2017 00:02
Helm config
(require 'helm-config)
(require 'helm-ls-git)
(require 'helm-swoop)
(helm-mode)
;; Interactive buffer rebindings.
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action)
(define-key helm-map (kbd "C-z") 'helm-select-action)
@m-renaud
m-renaud / custom-decoder.elm
Created November 15, 2016 18:11
Custom decoder in elm 0.18
customDecoder decoder toResult =
Json.andThen
(\a ->
case toResult a of
Ok b -> Json.succeed b
Err err -> Json.fail err
)
decoder
@m-renaud
m-renaud / git-codegen-in-branch.bash
Last active November 4, 2016 00:44
Git commands for building generated files on another branch and pulling them in temporarily for a build
#!/bin/bash
# Save the current branch.
previous_branch=`git rev-parse --abbrev-ref HEAD`
# Switch to generated code branch and pull in any changes from the working branch.
git checkout generated-code
git merge --no-edit $previous_branch
# <Build generated files>
@m-renaud
m-renaud / GenericGraph.hs
Last active February 27, 2016 19:50
Generic graphs with type families instead of functional dependencies.
{- | Based on http://www.osl.iu.edu/publications/prints/2005/garcia05:_extended_comparing05.pdf -}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Array
----------------------------------------
-- Typeclass definitions.