Skip to content

Instantly share code, notes, and snippets.

View relrod's full-sized avatar

Rick Elrod relrod

View GitHub Profile
@bbarker
bbarker / unison_type_hierarchy_notes.md
Last active January 14, 2020 08:39
Extremal types in Unison

The type system of Unison is a form of predicative system F, but the intent of this article is not to discuss the type system formally, but to give some understanding for how "extremal types" function within the type system. Extremal types in this sense are types at the bottom or top of some hierarchy, and it should be noted that extremal is not a word used elsewhere in this exact sense, to our knowledge.

Unison Type Hierarchy (lattice of types)

The lattice of types in Unison has top and bottom types:

⊤ = ∃e.e -- Called Any
⊥ = ∀a.a -- Called Void
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

@yougg
yougg / proxy.md
Last active April 7, 2024 04:02
complete ways to set http/socks/ssh proxy environment variables

set http or socks proxy environment variables

# set http proxy
export http_proxy=http://PROXYHOST:PROXYPORT

# set http proxy with user and password
export http_proxy=http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT

# set http proxy with user and password (with special characters)
@tonymorris
tonymorris / free-classy-prisms.hs
Created April 28, 2017 07:35
Free monad with classy prisms on grammar
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DeriveFunctor #-}
import Control.Lens
import Prelude hiding (readFile, writeFile, print)
import qualified Prelude as Prelude(readFile, writeFile, print)
@casperbp
casperbp / turing.v
Last active March 26, 2024 23:44
Coq implementation of a Turing Machine
(*** Turing Machines in Coq *)
(** Some preliminary types we'll use *)
CoInductive CoList (A: Type) := CONS (a:A) (t:CoList A) | NIL.
Arguments CONS [A] _ _.
Arguments NIL [A].
CoInductive Delay A := HERE (a:A) | LATER (_:Delay A).
@tonymorris
tonymorris / serialisation.md
Last active September 24, 2016 18:44
20 minutes of thinking about, "a serialisation format that sucks less than JSON, XML, YAML, BLAML, BLAH BLAH FARKINELLMATE"
  • All things are either:

    • A sum, which is a hypothetical/potential (not necessarily corresponding) constructor name, followed by +, followed by one or more things.
    • A product, which is a hypothetical/potential (not necessarily corresponding) field name, followed by *, followed by exactly one thing.
  • Left + (7 + (() * ()))

    • Left 7 :: Either Int a
    • This 7 :: These Int a
    • Const 7 :: Const Int a
  • name * (Cons + (F + (() * ())) (Cons + (r + (() * ())) (Cons * (e + (() * ())) (Cons + (d + (() * ())) Nil))))

@gallais
gallais / UntypedLambda.agda
Created September 7, 2015 18:53
Interpreting the untyped lambda calculus in Agda
{-# OPTIONS --copatterns #-}
module UntypedLambda where
open import Size
open import Function
mutual
data Delay (A : Set) (i : Size) : Set where
@alpmestan
alpmestan / Files.hs
Last active August 17, 2016 23:53
File upload with servant
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Files where
import Control.Monad.IO.Class
import Control.Monad.Trans.Either
@ekmett
ekmett / fmap.markdown
Last active April 14, 2021 20:41
Proof that fmap f . fmap g = fmap (f . g) given fmap id = id, and the free theorem for fmap's signature.

##Theorem:

Given fmap id = id:

fmap f . fmap g = fmap (f . g)

To prove this we're going to need a few lemmas:

@chrisdone
chrisdone / typing.md
Last active March 22, 2024 23:24
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology