Skip to content

Instantly share code, notes, and snippets.

@tkob
tkob / boot.sml
Last active September 23, 2018 01:08
SML Socket.select example
val _ = main ()
type_of(return(Values), _, [Arity]) :- length(Values, Arity).
type_of(if(Then, Else), Env, T) :-
type_of(Then, Env, T1),
type_of(Else, Env, T2),
union(T1, T2, T).
type_of(fun([]), _, [] -> []).
type_of(fun([Args->Body|Cdr]), Env, TArity->TBody) :-
length(Args, TArityCar),
@tkob
tkob / yokohamaunitintro.md
Last active October 1, 2016 11:57
単体テストのための外部DSL (第十七回 #渋谷java)

単体テストのための外部DSL

tkob

JUnit 4 の assertThat の典型的な説明

tal: parse.sml scan.ulex.sml tal.sml boot.sml
mlton \
-output 'tal' \
tal.mlb
scan.ulex.sml: scan.ulex
ml-ulex scan.ulex
parse.sml: parse.cf
proglr < parse.cf > parse.sml
@tkob
tkob / build.gradle
Created May 3, 2015 08:11
Jasmin task for Gradle
task compileJasmin(type:Exec) {
ext.classesDir = sourceSets.main.output.classesDir
ext.srcDir = "$projectDir/src/main/jasmin"
ext.sourceSet = fileTree(dir: ext.srcDir, include: '**/*.j')
ext.command = [
'jasmin',
'-d', ext.classesDir,
]
ext.command += ext.sourceSet.getFiles()
import org.gicentre.handy.*;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.image.BufferedImage;
import java.awt.geom.PathIterator;
PathIterator createOutline(String name, int size, String text, float x, float y) {
FontRenderContext frc =
new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)
.createGraphics()
val smlnj poly mosml smlsharp aliceml
ArraySlice.length yes yes yes yes yes
ArraySlice.sub yes yes yes yes yes
ArraySlice.update yes yes yes yes yes
ArraySlice.full yes yes yes yes yes
ArraySlice.slice yes yes yes yes yes
ArraySlice.subslice yes yes yes yes yes
ArraySlice.base yes yes yes yes yes
ArraySlice.vector yes yes yes yes yes
sml_comparison.md: comparison.txt
perl -alne 'print map {"|".$$_} @F; if($$.==1) {print "|---" x @F}' \
< comparison.txt > sml_comparison.md
comparison.txt: smlnj.txt poly.txt mosml.txt smlsharp.txt aliceml.txt
ruby compare.rb val.txt smlnj.txt poly.txt mosml.txt smlsharp.txt aliceml.txt > comparison.txt
smlnj.txt: val.txt
expect -f check.tcl smlnj
@tkob
tkob / AbsPeyton.ml
Created March 12, 2014 14:23
An OCaml implementation of "Parsing distfix operators" (Simon Peyton Jones 1986) http://dl.acm.org/citation.cfm?id=5659
type var = string
type exp =
LetExp of var * exp * exp
| IfExp of exp * exp * exp
| FunExp of var * exp
| AppExp of exp * exp
| IntExp of int
| VarExp of string
| PrimAdd | PrimSub | PrimMul | PrimDiv