Skip to content

Instantly share code, notes, and snippets.

View mheiber's full-sized avatar

Max Heiber mheiber

View GitHub Profile
" add visual indication of progress in a buffer to the status bar. To use:
" set statusline=%{ProgRock()}REST_OF_YOUR_STATUS_LINE HERE}
" for example:
" set statusline=%{ProgRock()}%{coc#status()}%{get(b:,'coc_current_function','')}
function! ProgRock()
let magic_width_number = 30
let width = winwidth(0)
let lcur = line('.')
let lend = line('$')
let full = max([width - magic_width_number, 3])

Slogans about Mainstream Dependent Types

I find it can be hard for programmers to talk about dependent types, since we don't always have the same idea of what they are and they have a reputation of being hard to understand and implement. I want to share these slogans to (hopefully) make the conversation easier.

I wrote this in a hurry and would welcome comments with examples of "mainstream dependent types" - and any relevant corrections and links.

Note: "mainstream" is a moving target

  1. "A dependent type is a type whose definition depends on a value."
Ltac dubstep_goal F :=
unfold F; fold F.
Ltac dubstep_in F H :=
unfold F in H; fold F in H.
Tactic Notation "dubstep" constr(F) := (dubstep_goal F).
Tactic Notation "dubstep" constr(F) "in" hyp(H) := (dubstep_in F H).
set nocompatible
filetype off " required for Vundle
:set suffixesadd+=.js
nnoremap <leader><space> :noh<return>
nnoremap <leader><leader> :b#<CR>
nnoremap <leader>s :source ~/.vimrc<CR>
nnoremap <leader>q :xall<CR>
nnoremap <right> <C-w>10>
nnoremap <left> <C-w>10<
nnoremap <up> :resize -5<Cr>
@mheiber
mheiber / count.erl
Created May 23, 2020 15:22
count.py, count.erl
-module(three).
-export([main/1]).
main(FileName) ->
{ok, Device} = file:open(FileName, [read]),
Cnt = device_counts(Device, maps:new()),
io:format("~p", [Cnt]).
device_counts(Device, Map) ->
case io:get_line(Device, "") of

this content has moved! link coming soon

Equality: Prior Art in Programming Languages

This document contains notes on how equality works in different programming languages, with a focus on immutable data types in functional languages.

OCaml

OCaml and Reason

OCaml has two equality primitives:

Should this error?

class Parent {
  #foo;
  copy(instance) {
    this.#foo = instance.foo;
  }
}
class Child extends Parent {}
@mheiber
mheiber / TypeScript's Type System as a Little Language.md
Last active April 28, 2019 19:16
2019 Conference Talk: TypeScript's Type System as a Little Language

TypeScript's Type System as a Little Language

Theme: Thinking of type-level TS as a programming language

It has all the pieces!

  • data:
    • objects, arrays, and tuples
  • functions
  • structured programming: