Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bitmappergit's full-sized avatar

Bram Wyllie bitmappergit

View GitHub Profile
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
@bitmappergit
bitmappergit / Huggable.hs
Created November 9, 2021 19:02
huggable optics
module Huggable where
swap :: (a, b) -> (b, a)
swap (a, b) = (b, a)
newtype Star f a b = Star { runStar :: a -> f b }
newtype Forget r a b = Forget { runForget :: a -> r }
class Profunctor p where
dimap :: (a -> b) -> (c -> d) -> p b c -> p a d
{-# LANGUAGE RankNTypes
, BlockArguments
, GADTs
, MultiParamTypeClasses
, OverloadedLabels
, DataKinds
, PolyKinds
, FunctionalDependencies
, AllowAmbiguousTypes
, TypeApplications
@bitmappergit
bitmappergit / ski.c
Last active September 30, 2021 16:07
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <gc.h>
typedef enum {
APP,
CON,
COMB,
} tag_t;
module 📕 where
open import Agda.Primitive
renaming (Set to 💯; lsuc to 👆; lzero to 🔴; Level to 🏢)
data _🤝_ {🤣 : 🏢} {🇦 : 💯 🤣} (🇽 : 🇦) : 🇦 → 💯 🤣 where
✅ : 🇽 🤝 🇽
infix 4 _🤝_
@bitmappergit
bitmappergit / Lens.hs
Created September 6, 2021 05:13
my personal lens library
{-# LANGUAGE RankNTypes, BlockArguments #-}
module Lens
( Lens
, MonoLens
, view
, (...)
, over
, set
, lens
use std::convert::TryInto;
use std::io::{BufRead, Read, Write};
use std::process::exit;
const IMAGE_SIZE: usize = 242000;
const NUM_DEVICES: usize = 2;
const TIB: usize = 1471;
type Cell = i32;
module Glue
import StdEnv
:: Name :== String
:: Term
= Loc Name
| Top Name
| App Term Term
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <gc.h>
typedef enum {
APP,
CON,
COMB,
} tag_t;
(* based on https://gist.github.com/AndrasKovacs/a0e0938113b193d6b9c1c0620d853784 *)
type name = string
datatype term
= Loc of name
| Top of name
| App of term * term
| Let of name * term * term
| Lam of name * term