Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
@Heimdell
Heimdell / Context.hs
Created September 29, 2018 20:44
Attempt to create simple dependently typed type inferrer / evaluator.
module Context
( T()
, empty
, add
, extend, singleton
, assign, assignment
, apply, accumulate
)
where
@Heimdell
Heimdell / Nowsp.hs
Last active October 9, 2018 21:38
Whitespace / end line cleaner. Run `Nowsp path/to/project .hs .yml`. No warranty.
import Control.Monad (when)
import Data.Foldable (for_)
import System.Directory (doesDirectoryExist, doesFileExist, listDirectory)
import System.FilePath ((</>), takeExtension)
import System.Environment (getArgs)
inode dirAction fileAction = go
@Heimdell
Heimdell / Dawg.md
Last active September 22, 2018 16:50

Syntax

Elements

Constants

Numbers

Just regular numbers, like

@Heimdell
Heimdell / Octree.go
Last active September 6, 2018 07:37
package main
import (
"fmt"
"image/color"
)
/*
The idea is to make "better minecraft", essentially.
@Heimdell
Heimdell / tc.prolog
Last active July 20, 2018 22:21
Typecheker, backed by Prolog embedded unification and `cyclic_term/1` predicate.
% Type variable.
%
tvar(A) :- var(A).
% Type application.
%
% The `forall` is forbidden as constructor name, arglist must be non-empty.
%
tapp(FX, F, Xs) :- FX =.. [F | Xs], F \= forall, F \= prod, F \= sum, Xs \= [].
{-# language GeneralizedNewtypeDeriving #-}
{-# language DeriveFunctor #-}
{-# language LambdaCase #-}
{-# language FlexibleInstances #-}
import Control.Applicative (Alternative (..), optional)
import Control.Category ((>>>))
import Control.Monad (ap, void, guard)
{-# language NamedFieldPuns #-}
{-# language TypeSynonymInstances #-}
{-# language FlexibleInstances #-}
{-# language OverloadedStrings #-}
{-# language TypeFamilies #-}
{-# language LambdaCase #-}
import Control.Applicative (some)
import Control.Monad (guard, void)
{-# language LambdaCase #-}
{-# language TypeSynonymInstances #-}
{-# language FlexibleInstances #-}
{-# language FlexibleContexts #-}
{-# language DeriveFunctor #-}
{-# language OverloadedStrings #-}
import Control.Applicative (some)
import Control.Monad
@Heimdell
Heimdell / adt.js
Last active April 1, 2018 14:22
Partitioned CPS transfrom from there: http://matt.might.net/articles/cps-conversion/
// Object.prototype.ancestors = function () {
// let acc = []
// for (let i = this; i; i = Object.getPrototypeOf(i)) {
// acc.push(i)
// }
// return acc
// }
let automatch = function (proto) {
/*
Graph Reduction Machine, or GRiM.
Makes it possible to implement lazy language above golang in a dumb an simple (but messy) way.
The idea is a follows:
Lazy program is like a makefile - its a tree (DAG) of dependent computations.
You can freely replace each function call with its body, provided you put the arguments in places.