Skip to content

Instantly share code, notes, and snippets.

@cdepillabout
cdepillabout / shell.nix
Last active April 29, 2024 08:32
shell.nix for Python development using virtualenv and pip
let
nixpkgs-src = builtins.fetchTarball {
# master of 2021-01-05.
url = "https://github.com/NixOS/nixpkgs/archive/1a57d96edd156958b12782e8c8b6a374142a7248.tar.gz";
sha256 = "1qdh457apmw2yxbpi1biwl5x5ygaw158ppff4al8rx7gncgl10rd";
};
pkgs = import nixpkgs-src {
config = {
# allowUnfree may be necessary for some packages, but in general you should not need it.
@cdepillabout
cdepillabout / example.nix
Last active February 7, 2023 03:52
Example of overriding a GHC core Haskell package with Nix
# This file is an example of overriding a GHC core Haskell library (like
# bytestring, containers, text, unix, etc) when building a Haskell package.
let default-nixpkgs =
builtins.fetchTarball {
# nixpkgs haskell-updates branch as of 2019/09/15.
url = "https://github.com/NixOS/nixpkgs/archive/a51b3367ab6acc72630da0bad50ce14fa86996d0.tar.gz";
sha256 = "05d3jxxk5dxzs9b3nan16lhkrjnzf0bjd4xy66az86fsafnrr9rd";
};
in
@cdepillabout
cdepillabout / FizzBuzzOne.hs
Last active December 28, 2022 00:55
type-level fizzbuzz in Haskell with singletons
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}

Haskell DB Library Comparison

We will be comparing the following DB libraries:

  • HRR
  • Opaleye
  • Persistent + Esqueleto
  • Groundhog
  • postgresql-simple (and postgresql-transactional)
@cdepillabout
cdepillabout / nix-build-output.md
Last active December 16, 2021 05:31
pkgsMusl.postgresql test fail
$ nix build -L .#pkgsMusl.postgresql
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/j76apgvazybh6fhiif7yj67xnfj6x7fr-postgresql-13.4.tar.bz2
source root is postgresql-13.4
setting SOURCE_DATE_EPOCH to timestamp 1628543016 of file postgresql-13.4/INSTALL
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/zv4waczq5k45138d2sdy7dyidas90lhh-disable-resolve_symlinks-94.patch
@cdepillabout
cdepillabout / fetch-dhall-as-binary.nix
Created September 14, 2021 06:23
demonstrate how to fetch URL imports in Dhall by turning the integrity checks into Nix fixed-output-derivations
with import <nixpkgs> {};
let
packageSet = fetchurl {
url = "https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20210905/packages.dhall";
# The hash below is a base64-encoded version of the base-16 hash that is
# specified in our local packages.dhall file:
# ```
# $ cat packages.dhall
# let upstream =
@cdepillabout
cdepillabout / existential-vs-sigma.hs
Last active June 11, 2021 11:53
This file shows how similar existential types are vs. sigma types (dependent pairs).
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
@cdepillabout
cdepillabout / transformers-tests.hs
Last active January 24, 2021 03:24
examples of output of various monadic functions with different monad transformer orders
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.Except
import Control.Monad.State
import Control.Monad.Writer
import Data.Functor.Identity
import Data.Text (Text)
@cdepillabout
cdepillabout / continuations.hs
Created January 5, 2021 05:38
Examples of playing around with continuations in Haskell
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Example where
import Control.Concurrent.MVar
import Control.Monad.IO.Class
import Control.Monad.Trans.Cont
import Data.Foldable
import Data.Monoid
@cdepillabout
cdepillabout / README.md
Created April 22, 2020 02:02
shell.nix to enable training ML models remotely with the GCP AI Platform