Skip to content

Instantly share code, notes, and snippets.

View jozefg's full-sized avatar

daniel gratzer jozefg

View GitHub Profile
@jozefg
jozefg / intrinsic.agda
Last active January 12, 2018 20:47
Another formalization of "The intrinsic topology of a Martin-Lof Universe"
module intrinsic where
open import Function using (_∘_; id)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Data.Empty
open import Data.Unit
open import Data.Product
open import Data.Sum as S
open import Data.Bool as B
open import Data.Nat as N
open Cmdliner
module type Config_t =
sig
type opt_level = O1 | O2 | O3
val int_of_opt : opt_level -> int
type config =
{ line_width : int
@jozefg
jozefg / pftools.sty
Created October 12, 2017 15:45
A handy package called pftools for LaTex.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pftools}
\@ifundefined{basedir}{%
\RequirePackage{locallabel}
}{%
\RequirePackage{\basedir locallabel}
}%
\RequirePackage{Tabbing} % Avoid the standard tabbing environment. Its \< conflicts with the semantic package.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternGuards #-}
module Unification where
import Control.Monad
import Control.Monad.Gen
import Control.Monad.Trans
import qualified Data.Map.Strict as M
import Data.Foldable
import Data.Monoid
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternGuards #-}
module Unification where
import Control.Monad
import Control.Monad.Gen
import Control.Monad.Trans
import qualified Data.Map.Strict as M
import Data.Foldable
import Data.List (foldl')
module Main where
import Criterion.Main
f1 :: [(Int, b)] -> [Int] -> Bool
f1 ps qs = all (\q -> all (\p -> fst p /= q) ps) qs
f2 :: [(Int, b)] -> [Int] -> Bool
f2 ps qs = all (flip all ps . flip ((/=) . fst)) qs
main :: IO ()
module simple-bracket where
open import Data.Nat
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
record PCA : Set₁ where
constructor mk-pca
field
A : Set
_≈_ : A → A → Set
module howe where
open import Data.Nat
open import Data.Vec
open import Data.List
open import Data.Product
import Data.Fin as F
import Relation.Binary as B
open import Relation.Binary.PropositionalEquality hiding (subst)
open import Relation.Nullary
@jozefg
jozefg / out.s
Created November 23, 2016 03:38
.global _c0_main
.text
_c0_main:
push %rbx
subq $0, %rsp
movl $5, %eax
imull %eax, %eax
push %rbp
movl %eax, %ebp
movl %eax, %edi
@jozefg
jozefg / RegAlloc.hs
Created April 30, 2016 04:36
A simple register allocator which performs liveness analysis at the basic block level and properly handles spilling. Doesn't do coalescing though for brevity.
{-# LANGUAGE FlexibleContexts, ConstraintKinds, RecordWildCards #-}
module RegAlloc where
import Control.Applicative
import Control.Monad
import Data.Set (Set)
import Data.Map (Map)
import Control.Monad.Writer.Strict
import Control.Monad.State.Strict
import qualified Data.Set as S
import qualified Data.Map as M