Skip to content

Instantly share code, notes, and snippets.

@codygman
codygman / vals.hs
Last active November 8, 2021 22:06
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NumericUnderscores #-}
module Main where
import Database.PostgreSQL.Simple
import Control.Monad
import qualified Data.Text as Text
import Data.Time
import qualified GHC.Clock as Clock

my presentation on “How to take smart notes”

A quote to keep in mind

Notes aren’t a record of my thinking process. They are my thinking process. – Richard Feynman

@codygman
codygman / haskell-mode-nix-emacs-issue.md
Last active May 13, 2021 21:36
haskell-mode nix emacs issue

haskell-mode-minimal.el:

(require 'use-package)
(setq eval-expression-print-length 100)
(use-package haskell-interactive-mode)
(use-package haskell-mode
  :mode "\\.hs\\'"
  :hook
  (haskell-mode . interactive-haskell-mode)
@codygman
codygman / readme.md
Last active March 13, 2021 00:37
Why isn't withResource blocking?

I get output like:

/tmp $ stack exec --resolver lts-17.5 --package resource-pool --package stm --package hslogger --package time --package concurrent-output -- ghc -O2 -threaded -fwarn-unused-imports testpool.hs && ./testpool
acquire 0 - .81428
acquire 1 - .81431
acquire 2 - .81438
acquire 3 - .81440
acquire 4 - .81448
ThreadId 8:  processing 1 - .82460
FROM haskell:8.10
RUN apt-get update && apt-get install --yes libpq-dev
ARG USER=haskell
RUN useradd --create-home "$USER"
USER $USER
@codygman
codygman / diffwaysbuildhasknix.org
Last active October 12, 2020 22:11
Different ways to build haskell projects with nix

nix for haskell development

There are numerous options for using nix with Haskell, which themselves have numerous options:

cabal2nix (Nix manual recommended)

Sadly, there aren’t instructions on adding a source override for this method and it instead switches to using developPackage

how do you override a Haskell dependency version with this method?

@codygman
codygman / diagrams-builder.nix
Created July 18, 2020 00:56
try to build diagrams-builder working with nix
# Command
# nix-build diagrams-builder.nix
# Error
#
# Setup: Encountered missing or private dependencies:
# haskell-src-exts ==1.22.*
# builder for '/nix/store/9mwklkck5gjjd0adk2jdkrm5zbhyy16b-haskell-src-exts-simple-1.22.0.0.drv' failed with exit code 1
# cannot build derivation '/nix/store/iw613czqivarhr12xbgj8rri7j4m0w8x-diagrams-builder.drv': 1 dependencies couldn't be built
# run with:
# export HOME=$(pwd)
# nix-shell --pure emacs.nix --keep HOME --run "env HOME=$HOME emacs --eval='(load \"$HOME/init.el\")'"
{ pkgs ? (builtins.fetchGit {
name = "nixpkgs-unstable-2020-04-14";
url = "https://github.com/NixOS/nixpkgs.git";
ref = "nixpkgs-unstable";
rev = "7e07846d99bed4bd7272b1626038e77a78aa36f6";
})
{ overlays = [
@codygman
codygman / foo.hs
Last active November 21, 2019 21:08
Interaction.getUserTeams :: MonadMongo p => Gluon.UserExternalId -> p [Gluon.SavedTeam]
WebInteraction.getUserTeams :: MonadMongo p => Gluon.EnterpriseGrantExternalId -> Gluon.UserExternalId -> p [Gluon.SavedTeam]
WebInteraction.getUserTeams = if hasAccess eGrantId then Interaction.getUserTeams
-- vs
Interaction.getUserTeams :: MonadMongo p => Gluon.UserExternalId -> p [Gluon.SavedTeam]
Interaction.webGetUserTeams :: MonadMongo p => Gluon.EnterpriseGrantExternalId -> Gluon.UserExternalId -> p [Gluon.SavedTeam]
WebInteraction.getUserTeams = if hasAccess eGrantId then Interaction.getUserTeams
;; Package configs
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
;; Bootstrap `use-package`
(unless (package-installed-p 'use-package)