Skip to content

Instantly share code, notes, and snippets.

@eldesh
eldesh / dup_structure
Created February 26, 2014 14:43
[ (name evaluation CP-600) Provide check fails (structure replication): Top.S ] is occured from SML#1.2.0
(* .smi *)
_require "basis.smi"
structure S =
struct
val id : 'a -> 'a
end
structure Top =
struct
@eldesh
eldesh / cygwin-fault.c
Created March 3, 2014 01:39
SML/NJ110.76 を cygwin1.7.28-2 でビルドするために書いた怪しげなヘッダ(cygwin-fault.h)とパッチ
/* base/runtime/mach-dep/cygwin-fault.c */
$ diff base/runtime/mach-dep/cygwin-fault.c base/runtime/mach-dep/cygwin-fault.new.c
20,21c20
< #include <windows.h>
< #include <exceptions.h> /* Cygwin stuff */
---
> #include "cygwin-fault.h" /* Cygwin stuff */
@eldesh
eldesh / body.smi
Created May 1, 2014 04:35
SML#1.2.0 でウソのシグネチャ(型注釈)がコンパイルを通るバグ。(SML#2.0.0では修正済み)
_require "basis.smi"
structure B =
struct
val g : {dir:string, name:string} -> unit
end
@eldesh
eldesh / dynlink.sml
Last active August 29, 2015 14:10
use Win32 API with MLton FFI
@eldesh
eldesh / qcheck_sample.cm
Created June 14, 2012 17:34
QCheck sample solution
library
structure Sample
is
$/basis.cm
$/qcheck.cm
qcheck_sample.sml
@eldesh
eldesh / array_unfold.sml
Created September 7, 2012 06:37
Unfolding on Array(fixed size memory block)
(***
* Array, Vector 等の固定長データ構造を生成するために状態を持ちたい。
* unfold すればよいが、要素を一つずつ連結するのはイヤ(重すぎる)なので 配列用unfold 作ってみた
* ***)
infixr 1 $
fun f $ a = f a
structure Array =
@eldesh
eldesh / sopath.c
Created November 18, 2015 11:19
実行した環境で、指定された名前で共有ライブラリがリンクされるとどのパスのライブラリがリンクされるかを標準出力に書き出す。
/**
* 動的リンクされたライブラリのパスを表示する
*
* **Linux specific program**
*
* build:
* $ gcc -Wall -pedantic-errors -std=c99 -DNDEBUG -o sopath sopath.c -ldl
*/
#define _GNU_SOURCE
#include <stdio.h>
@eldesh
eldesh / demo.sml
Last active December 16, 2015 11:19
demonstrate datatype replication declarations of SML'97
(**
* datatype replication declarations(specifications)のサンプル
*)
(** monomorphic version *)
structure S =
struct
datatype either = L | R
end
@eldesh
eldesh / gist:5714388
Last active December 18, 2015 02:58
De Bruijn変換をStandardMLで実装
(*
* (* debruijn.cm *)
* Group
* is
* $/basis.cm
* debrujn.sml
*)
(**
* De Bruijn変換
@eldesh
eldesh / sendmoremoney.sml
Created June 29, 2013 20:59
https://gist.github.com/yonta/5851577#file-sendmoremoney2-sml に触発されて書いてみた。力ずくで解く例。
(**
* SEND
* + MORE
* ------
* MONEY
*
* S,E,N,D,M,O,R,Y
*
* run:
* - Option.app (print o pp) (search ())