Skip to content

Instantly share code, notes, and snippets.

:- tpp(
type Colour = 'MkColour'!(int,int,int);
type Point = 'MkPoint'!(float,float);
type CPoint = 'MkCPoint'!(float,float,Colour);
val 'MkColour' : (int->int->int->Colour);
val c1 : (Colour->int);
val c2 : (Colour->int);
val c3 : (Colour->int);
val 'MkPoint' : (float->float->Point);
val pt1 : (Point->float);
@hsk
hsk / file1.txt
Last active December 4, 2017 21:44
日本語で言語を作ろう ref: https://qiita.com/h_sakurai/items/701b1ca926b5e2176a83
$ swipl test.pl
7
@hsk
hsk / Makefile
Created December 4, 2017 19:29
prolog test sample
test: test1 test2
test1:
swipl funtest.pl
test2:
swipl funtest.pl fun2
@hsk
hsk / dependent.pl
Created November 11, 2017 07:35
An algorithm for type-checking dependent types
% An algorithm for type-checking dependent types
:- op(650,xfy,$).
:- op(900,xfy,[=>,->,⇓]).
:- op(920,xfx,[⊢]).
failwith(A,L) :- format(A,L),halt.
% Syntax
id(Id) :- atom(Id). % Identify
/*
Algorithm W
*/
object poly extends App {
type X = String
type U = Int
type Assump = Map[X, Scheme]
type Subst = Map[U, T]
type FTV = Set[U]
@hsk
hsk / poly.ml
Last active October 27, 2017 07:48
type x = string
type e =
| EInt of int
| EBool of bool
| EVar of x
| EApp of e * e
| EAbs of x * e
| ELet of x * e * e
let rec show_e = function
@hsk
hsk / poly.rs
Last active October 27, 2017 07:44
Algorithm W on Rust
/*
Algorithm W
*/
use std::collections::BTreeMap;
use std::collections::BTreeSet;
type X = String;
type U = i32;
type Assump = BTreeMap<X, Scheme>;
type Subst = BTreeMap<U, T>;
class MatchError
attr_accessor :r
def initialize(a)
@r = self
@match = a
end
def >>(a)
self
end
def >=(a)
@hsk
hsk / index.html
Last active March 22, 2017 13:42
smartlog.js hispeed big log data view
<html>
<title>SmartLogJs Example</title>
<script src="smartlog.js"></script>
<script>
window.onload = function () {
var counter = 0
var log = new SmartLog({
el:document.getElementById("log"),
buildRow:function(){return {
head:"",text:"",
@hsk
hsk / arith.pl
Created March 7, 2017 08:17
define syntax on prolog
:- op(1200, xfx, ['--', where, ::=]).
:- op(920, xfx, ['==>', '==>>']).
term_expansion((A where B), (A :- B)).
% 構文
zip([], [], []).
zip([L|Ls], [R|Rs], [(L,R)|Ps]) :- zip(Ls, Rs, Ps).