Skip to content

Instantly share code, notes, and snippets.

View doublec's full-sized avatar

Chris doublec

  • Perth, Australia
View GitHub Profile
@doublec
doublec / Makefile
Created August 30, 2012 04:23
ATS FFI example
all: base64
base64: base64.dats
atscc -o base64 base64.dats
@doublec
doublec / fact_z3_threaded.dats
Created October 6, 2019 12:01
ATS proofs about factorial using threaded Z3 proofs
// ATS factorial proof examples, based on F* tutorial examples at:
// https://www.fstar-lang.org/tutorial/
//
// patsopt -tc --constraint-export -d fact_z3_threaded.dats |patsolve_z3 -i
//
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
stacst fact: int -> int
@doublec
doublec / fact_prop.dats
Created October 6, 2019 11:59
ATS proofs about factorial using dataprop
// ATS factorial proof examples, based on F* tutorial examples at:
// https://www.fstar-lang.org/tutorial/
//
// patsopt -tc --constraint-export -d fact_prop.dats |patsolve_z3 -i
//
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
dataprop FACT (int, int) =
| FACTzero (0, 1)
@doublec
doublec / build-urweb.txt
Created November 23, 2018 10:23
Building a static urweb executable
# Build musl libc
$ git clone git://git.musl-libc.org/musl
$ cd musl
$ ./configure
$ make
$ sudo make install
$ export PATH=$PATH:/usr/local/musl/bin/
# build libz for musl
$ wget https://zlib.net/zlib-1.2.11.tar.gz
@doublec
doublec / build.txt
Last active August 12, 2018 06:37
Building SWI-Prolog statically with musl libc
# Build musl libc
$ git clone git://git.musl-libc.org/musl
$ cd musl
$ ./configure
$ make
$ sudo make install
$ export PATH=$PATH:/usr/local/musl/bin/
# build libz for musl
$ wget https://zlib.net/zlib-1.2.11.tar.gz
@doublec
doublec / json.behavior.self
Created October 24, 2013 06:10
JSON parser in Self using the mango parser library
( |
"_" parent* = traits oddball.
object = (| eval = ( |dict = dictionary copy|
members elements do: [|:v. :k|
dict at: v string eval Put: v value eval
].
dict
)
|).
@doublec
doublec / gist:d4598ce955172306fef733f6e860b97f
Created February 16, 2018 01:07
Building terralang from source
# Building Terralang (http://terralang.org/) from source
$ export BUILD_ROOT=`pwd`
# Build LLVM 3.9
$ git clone https://github.com/llvm-mirror/llvm --branch release_39
$ cd $(BUILD_ROOT)/llvm/tools
$ git clone https://github.com/llvm-mirror/clang --branch release_39
$ cd $(BUILD_ROOT)/llvm
$ mkdir build
@doublec
doublec / gadt.dats
Created January 3, 2018 11:14
GADT example in ATS2
(*
$ patscc -o gadt gadt.dats
$ ./gadt
res1=true and res2=8
*)
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
datatype Expr (t@ype) =
| I(int) of int
@doublec
doublec / gist:c2e3c0ab05d622de4de9fa389b0f9d78
Created August 28, 2017 06:30
Static binaries in ATS using musl-libc
$ cat hello.dats
implement main0() = print!("Hello World\n")
$ patscc -atsccomp "/usr/local/musl/bin/musl-gcc" -static -I$PATSHOME/ccomp/runtime -I$PATSHOME hello.dats
$ ./a.out
Hello World
$ ldd ./a.out
not a dynamic executable
$ strip ./a.out
$ ls -l ./a.out
-rwxr-xr-x 1 user user 18080 Aug 28 18:29 a.out
@doublec
doublec / Makefile
Created October 3, 2012 11:26
ATS stack example
all: stack1 stack2 stack3 stack4 stack5
stack1: stack1.dats
atscc -o stack1 stack1.dats
stack2: stack2.dats
atscc -o stack2 stack2.dats
stack3: stack3.dats
atscc -tc stack3.dats