Skip to content

Instantly share code, notes, and snippets.

Avatar
🏳️‍⚧️

jkachmar jkachmar

🏳️‍⚧️
View GitHub Profile
@jkachmar
jkachmar / Example.hs
Last active Oct 14, 2021
Dependency-Injected Servant Client Interpreter
View Example.hs
{-# 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 Aug 17, 2021
Type alias quantification trick for semi-polymorphic effect stacks
View Example.hs
{-# 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)
View default.nix
#########################
# Machine Configuration #
#########################
{ config, inputs, lib, pkgs, unstable, ... }:
{
imports = [
./primary-user-nixos.nix
./desktop-apps.nix
./desktop-kde.nix
@jkachmar
jkachmar / pihole-ftl.nix
Last active Jun 20, 2020
Pi-hole FTL derivation
View pihole-ftl.nix
{ 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 Jun 13, 2020
Nix Haskell developPackages Demo
View README.md

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.
@jkachmar
jkachmar / Total.hs
Created May 13, 2020
Total prism matching
View Total.hs
import Control.Lens hiding (from, to)
import GHC.Generics
class Empty a where
impossible :: a -> x
default impossible :: (Generic a, GEmpty (Rep a)) => a -> x
impossible = gimpossible . from
instance Empty Void where
impossible = absurd
View init.el
;;; init.el --- jkachmar's Emacs setup. -*- lexical-binding: t; -*-
;;
;;; Commentary:
;; This file loads use-package, org-mode, and compiles and executes readme.org
;;
;;; Code:
(require 'package)
(setq package-enable-at-startup nil)
View Blap.hs
newtype ClientInterpreter params m
= ClientInterpreter
( forall response
. params
-> ClientEnv
-> ClientF response
-> ExceptT ServantError m response
)
class HasClientInterpreter (context :: Type -> (Type -> Type) -> Type) where
View keybase.md

Keybase proof

I hereby claim:

  • I am jkachmar on github.
  • I am jkachmar (https://keybase.io/jkachmar) on keybase.
  • I have a public key ASDsrA8DW3FUcHdfREv4Ws2lnjzCinJTes8DTm6K72iRcQo

To claim this, I am signing this object:

@jkachmar
jkachmar / stack.yaml
Last active Jan 29, 2020
GitHub Semantic w/ Stack
View stack.yaml
resolver: lts-13.23
packages:
- '.'
- vendor/haskell-tree-sitter
- vendor/haskell-tree-sitter/languages/go
- vendor/haskell-tree-sitter/languages/haskell
- vendor/haskell-tree-sitter/languages/java
- vendor/haskell-tree-sitter/languages/json
- vendor/haskell-tree-sitter/languages/php
- vendor/haskell-tree-sitter/languages/python