Skip to content

Instantly share code, notes, and snippets.

View jkachmar's full-sized avatar
🏳️‍⚧️

jkachmar jkachmar

🏳️‍⚧️
View GitHub Profile
@jkachmar
jkachmar / Example.hs
Last active October 5, 2023 21:11
UUID as Primary Key in Persistent
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Example where
@jkachmar
jkachmar / openpgp.md
Last active May 19, 2023 17:05
keyoxide proof and verification

This is an OpenPGP proof that connects my OpenPGP key to this Github account. For details check out https://keyoxide.org/guides/openpgp-proofs

[Verifying my OpenPGP key: openpgp4fpr:0107655cc20afd1a8f3f9872c1782440640bc696]

#########################
# Machine Configuration #
#########################
{ config, inputs, lib, pkgs, unstable, ... }:
{
imports = [
./primary-user-nixos.nix
./desktop-apps.nix
./desktop-kde.nix
@jkachmar
jkachmar / Main.hs
Last active May 19, 2022 13:20
"Simple" example for how to set up Servant to automatically retry its client requests
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
@jkachmar
jkachmar / package.yaml
Created October 18, 2018 21:16
Useful GHC flags
# NOTE:
# For details on warnings: https://downloads.haskell.org/~ghc/master/users-guide/using-warnings.html
#
# This list taken from https://medium.com/mercury-bank/enable-all-the-warnings-a0517bc081c3
ghc-options:
- -fwarn-tabs # Warn on tabs (spaces are better)
- -Weverything # Enable all warnings with -Weverything, then
# disable the ones we don’t care about
@jkachmar
jkachmar / 1README.md
Last active December 24, 2021 15:06
Small Docker images with Alpine, Haskell, and Stack

All actions should be performed in the root directory of a Haskell project that uses stack. The following lines should be present in the project's stack.yaml file:

docker:
  enable: true

Additionally, the BaseImage and Dockerfile files from this gist should also be present in the project's root directory.

@jkachmar
jkachmar / Example.hs
Last active October 14, 2021 17:21
Dependency-Injected Servant Client Interpreter
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
@jkachmar
jkachmar / Example.hs
Created August 17, 2021 14:34
Type alias quantification trick for semi-polymorphic effect stacks
{-# LANGUAGE AllowAmbiguousTypes, ConstraintKinds, DataKinds, FlexibleContexts,
FlexibleInstances, FunctionalDependencies, InstanceSigs,
MultiParamTypeClasses, RankNTypes, RecordWildCards, ScopedTypeVariables,
StandaloneKindSignatures, TypeApplications, TypeFamilies,
TypeFamilyDependencies #-}
import Control.Monad.Reader (MonadReader)
import Control.Monad.Trans (MonadTrans)
import Control.Monad.Trans.Except (ExceptT, runExceptT)
import Data.Kind (Constraint, Type)
@jkachmar
jkachmar / pihole-ftl.nix
Last active June 20, 2020 23:22
Pi-hole FTL derivation
{ fetchFromGitHub, gmp, nettle, sqlite, stdenv }:
let
rev = "3d7c095cb10a1b692c80dd28f6051dea91d45baa";
version = "5.0";
tag = "v${version}";
in
stdenv.mkDerivation {
pname = "pihole-ftl";
@jkachmar
jkachmar / README.md
Created June 13, 2020 16:37
Nix Haskell developPackages Demo

Quickstart

  1. Make a new directory and place the other files at their described paths relative to that directory's root
  • library.DemoLib.hs should be placed at library/DemoLib.hs, gists don't allow a naming convention of library/DemoLib.hs
  1. Run the following command:
nix-shell -E 'let pkgs = import ./pinned.nix {}; pkg =  pkgs.haskellPackages.developPackage { root = ./.; }; in pkg.overrideAttrs (attrs: { buildInputs = attrs.buildInputs ++ [ pkgs.cabal-install]; })'
  1. Run cabal update (to ensure that there's a valid $HOME/.cabal directory with relevant Hackage information, even though we're not going to use it)
  2. Run cabal build and verify that the package builds.