Skip to content

Instantly share code, notes, and snippets.

@jproyo
jproyo / a.md
Created Mar 8, 2020 — forked from monadplus/a.md
Profiling in Haskell
View a.md

You'll generally want to look at:

  • heap
  • stack
  • gc profiles

Do not get bogged down in microoptimizations before you've assessed any macro optimizations that are available. IO and the choice of algorithm dominate any low level changes you may make. In the end you have to think hard about your code!

Topos> For example, if i see that a particular pure function is taking a  long time relative to the rest of the code, and that it's Text, and I'm seeing ARR_WORDS rise linearly in the heap, I probably have a thunk-based memory leak. This is knowledge you build up over time.
@jproyo
jproyo / haskell_spacemacs_tips.md
Last active Jun 14, 2019
Tips for working with Emacs in Haskell. Usefull commands
View haskell_spacemacs_tips.md

Tips for Spacemacs with Haskell

  • C-c C-l => Load ghci in place with the current buffer
  • <SPC> C-r => Reformat region hindent
  • , F => Format imports
  • , f => hindent
  • , r b => hlint refactor buffer
  • , r s => suggestions
  • , r r => refactor at point
  • , h i => info at point
@jproyo
jproyo / .stylish-haskell.yaml
Last active Jun 14, 2019
My Haskell Stylish custom config
View .stylish-haskell.yaml
# stylish-haskell configuration file
# ==================================
# The stylish-haskell tool is mainly configured by specifying steps. These steps
# are a list, so they have an order, and one specific step may appear more than
# once (if needed). Each file is processed by these steps in the given order.
steps:
# Convert some ASCII sequences to their Unicode equivalents. This is disabled
# by default.
# - unicode_syntax:
@jproyo
jproyo / deps.sh
Created May 20, 2019
Install deps for spacemacs
View deps.sh
#!/bin/bash
stack install apply-refact hlint stylish-haskell hasktags hoogle intero hindent ispell
brew install ispell
@jproyo
jproyo / Data.hs
Last active Jan 2, 2020
Tagless Final Encoding in Haskell Example
View Data.hs
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Data where
type UserName = String
data DataResult = DataResult String
deriving (Eq, Show)
class Monad m => Cache m where
@jproyo
jproyo / ghci.conf
Last active Jan 20, 2019
Local Ghci configuration
View ghci.conf
:set prompt "λx.x> "
:set prompt-cont " > "
:set -XNoStarIsType
:set -XGADTSyntax
:set -XGeneralizedNewtypeDeriving
:set -XInstanceSigs
:set -XLambdaCase
:set -XPartialTypeSignatures
:set -XScopedTypeVariables
:set -XTypeApplications
@jproyo
jproyo / cats_syntax.scala
Created Dec 6, 2018
Add syntactic sugar to Cats Scala Type Classes combinators - Syntax
View cats_syntax.scala
import cats.syntax.apply._
IO.shift *> task
// equivalent to
implicitly[ContextShift[IO]].shift *> task
@jproyo
jproyo / gist:28faf139bad26517f45755db21b59f6b
Created Jul 5, 2016 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
View gist:28faf139bad26517f45755db21b59f6b
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
@jproyo
jproyo / prepare-commit-msg
Created May 28, 2013
Prepare Commit Message with Prepend Branch named for Git
View prepare-commit-msg
#!/bin/sh
NAME=$(git branch | grep '*' | sed 's/* //')
echo "[#$NAME"': '$(cat "$1")"]" > "$1"
@jproyo
jproyo / git_move.sh
Created Nov 16, 2012
moves a folder from one git repo into another repo with history intact
View git_move.sh
#!/usr/bash
# Usage:
# ./git_move.sh git@repo_site.com:/my_repo.git origin/folder/path/ /destination/repo/path/ new/folder/path/
repo=$1
folder=$2
dest_repo=$3
dest_folder=$4
clone_folder='__git_clone_repo__'
You can’t perform that action at this time.