Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View GrafBlutwurst's full-sized avatar

Dominic Egger GrafBlutwurst

View GitHub Profile
import cats._
import cats.data.Const
import cats.tagless._
import cats.tagless.implicits._
trait GadtEncoded[Trait[_[_]], GADTRepresentation[_]] {
def gadtInstance: Trait[GADTRepresentation]
def gadtEval[F[_]](against: Trait[F]): GADTRepresentation ~> F
final def partialOverride[F[_]](base: Trait[F])(
package tech.rivero.core.util.monocle
import monocle.AppliedIso
import monocle.AppliedLens
import monocle.AppliedOptional
import monocle.AppliedPrism
import monocle.AppliedTraversal
import monocle.syntax._
object Syntax {
@GrafBlutwurst
GrafBlutwurst / types.nix
Created February 8, 2022 16:15
A hacky fix for the either submodule problem
{ lib }: with lib; with lib.types; let
addTag = typeTag: module:
let
tagModule = {
_tpe = mkOption {
type = types.enum [ typeTag ];
description = ''Type Tag (${typeTag})'';
};
};
imports = if module ? imports then { inherit (module) imports; } else { };
@GrafBlutwurst
GrafBlutwurst / miniexample.nix
Last active February 8, 2022 13:42
Example of how lists type merge breaks
let
pkgs = import <nixpkgs> { };
in
with pkgs.lib; with pkgs.lib.types; let
leftType = submodule {
options.foo = mkOption {
type = int;
description = "left.foo";
};
// YOINKED from scala docs https://dotty.epfl.ch/docs/reference/contextual/derivation.html
// this is just so we have something derivable here to see it doesn't break with the stuff below
import scala.deriving.*
import scala.compiletime.{erasedValue, summonInline}
inline def summonAll[T <: Tuple]: List[Eq[_]] =
inline erasedValue[T] match
case _: EmptyTuple => Nil
case _: (t *: ts) => summonInline[Eq[t]] :: summonAll[ts]
let Environment = < Staging | Preprod | Prod >
let TenantsPerEnvironment =
{ Staging = < Tenant1 >
, Preprod = < Tenant1 | Tenant2 >
, Prod = < Tenant2 >
}
let tenantOf
: Environment -> Type
{ pkgs ? import <nixpkgs> {} }:
let
sbt = pkgs.sbt.override { jre = pkgs.jre8;};
in
pkgs.mkShell {
buildInputs = [
sbt
];
}
package example
import zio.RIO
import zio.ZIO
import zio.duration._
import zio.interop.catz._
import okhttp3.OkHttpClient
import org.http4s.client.okhttp.OkHttpBuilder
import cats.effect.Blocker
import cats.implicits._

Shell scripts

This is the literate programming notebook for /shell/scripts. Because this is a ton of arcane bash I thought it’d be nice if it was thoroughly documented. For the readers sake, do not assume that they read previous entries. They might only be interested in one particular script. If you find yourself documenting something over and over put a reference.

Construct the shebang-line. If you want to tangle this file from within emacs, put your cursor on the codeblock and press `C-c C-c` “` (defconst shebang-line (concat “#!” (locate-file “bash” exec-path exec-suffixes 1))) “`

Workspace Tooling & Utility scripts

Tangling Org Files

private def memLoadResponse(
response: Response[RIO[Clock, *]]
): RIO[Clock, (Response[RIO[Clock, *]], Response[RIO[Clock, *]])] =
response.body.compile
.to(fs2.Chunk)
.map(bodyBytes =>
(
response.copy(
body = fs2.Stream.chunk(bodyBytes)
),