Skip to content

Instantly share code, notes, and snippets.

View freddie-freeloader's full-sized avatar

Jonas Benn freddie-freeloader

View GitHub Profile
@Azeirah
Azeirah / setup-gitlab-for-magit-in-doom-emacs.md
Last active May 22, 2024 15:35
Setting up magit forge for gitlab in Doom Emacs

Magit forge for Gitlab in Doom Emacs

This guide assumes you're working on a Unix-like environment. I'm using Linux Mint (Ubuntu). It should work on Macs, and might on Windows.

These are the four steps you can use as a checklist, see the headings below for the details on each step.

  • Enable forge support
  • Create a Gitlab API key
  • Add your gitlab credentials to ~/.authinfo.gpg
  • Set-up forge in emacs
@itod
itod / split_keyboards.md
Last active June 12, 2024 12:08
Every "split" mechanical keyboard currently being sold that I know of
@rcalsaverini
rcalsaverini / maybe.hs
Last active January 14, 2018 11:05
Boehm-Berarducci encodings.
{-# LANGUAGE RankNTypes #-}
import Prelude hiding (Maybe, Just, Nothing, maybe)
data Maybe a = Maybe {maybe :: forall r . r -> (a -> r) -> r}
nothing = Maybe (\nothing' just' -> nothing')
just x = Maybe (\nothing' just' -> just' x)
instance (Show a) => (Show (Maybe a)) where

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@norswap
norswap / ObjectAlgebra.kt
Created January 18, 2016 16:30
Object Algebras in Kotlin
// Basic setup
interface Exp
data class Lit(val x: Int): Exp
data class Add(val x: Exp, val y: Exp): Exp
interface IntAlg<A>
{
fun lit(x: Int): A
fun add(x: A, y: A): A
@sebfisch
sebfisch / gist:2235780
Created March 29, 2012 10:47
Laymans explanation of delimited continuations with examples of using them for exception handling and nondeterministic programming.

Delimited Continuations

Delimited continuations manipulate the control flow of programs. Similar to control structures like conditionals or loops they allow to deviate from a sequential flow of control.

We use exception handling as another example for control flow manipulation and later show how to implement it using delimited continuations. Finally, we show that nondeterminism can also be expressed using delimited continuations.

Exception Handling