This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Tested in Poly/ML. To compile: `polyc thread.ml && ./a.out` | |
* | |
* Heavily influenced by: http://pages.cs.wisc.edu/~remzi/OSTEP/threads-cv.pdf | |
* Poly/ML Thread documentation here: http://www.polyml.org/documentation/Reference/Threads.html | |
* Poly/ML Thread implementation here: https://github.com/polyml/polyml/blob/master/basis/Thread.sml | |
*) | |
val done = ref false; | |
val m = Thread.Mutex.mutex(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Poly/ML specific build tool partially reimplementing the polyc bash script in SML. | |
* Additionally, this adds a means to include files needed in the main script. | |
* Usage: | |
* $ polyc -o poly-build poly-build.sml # bootstrap the tool | |
* $ ./poly-build poly-build.sml # compile itself | |
* $ mv a.out poly-build | |
* $ ./poly-build a.sml b.sml c.sml # where needs some fun/val from b.sml and c.sml | |
*) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
prefix=/usr/local | |
exec_prefix=${prefix} | |
BINDIR=${exec_prefix}/bin | |
LINK=cc | |
LIBDIR=${exec_prefix}/lib | |
LIBS="-lpthread -lm -lgcc_s -lgcc -L/usr/local/lib -lffi " | |
CFLAGS="-O2 -pipe -fstack-protector -fno-strict-aliasing" | |
# Extra options for Windows. config.status sets these conditionals to either "" or "#". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Tested on Poly/ML. | |
* Usage: | |
* $ polyc getreq.sml | |
* $ ./a.out | |
*) | |
exception E of string | |
fun request domain path = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
structure File = Ponyo.Os.File | |
structure String = Ponyo.String | |
structure Format = Ponyo.Format | |
val f = PolyML.NameSpace.displayTypeExpression | |
val g = PolyML.globalNameSpace | |
fun parseModule (path: string) = | |
let |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
structure StringMap = Map(String) | |
let | |
val stringMap = StringMap.empty | |
val stringMap = StringMap.insert stringMap "key" "value" | |
val stringMap = StringMap.insert stringMap "key1" "value1" | |
in | |
assertEquals (StringMap.get stringMap "key1") "value1" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CHICKEN | |
(c) 2008-2015, The CHICKEN Team | |
(c) 2000-2007, Felix L. Winkelmann | |
Version 4.10.0 (rev b259631) | |
freebsd-unix-clang-x86-64 [ 64bit manyargs dload ptables ] | |
compiled 2015-08-04 on yves.more-magic.net (Linux) | |
#;1> (use match) | |
Error: (import) during expansion of (import ...) - cannot import from undefined module: match |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(provide 'sml-mode) | |
(defface sml-highlight-misc | |
'((t (:foreground "light blue"))) | |
"SML misc highlighting" | |
:group 'basic-faces) | |
(defface sml-highlight-builtin | |
'((t (:foreground "dark magenta"))) | |
"SML builtin highlighting" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MaybeMonad = struct | |
type 'a t = None | Maybe of 'a | |
let return (a: 'a) : 'a t = Maybe a | |
let (>>=) (m: 'a t) (f: 'a -> 'b t) : 'b t = match m with | |
| None -> None | |
| Maybe a -> f a | |
let get (m: 'a t) (a: 'a) = match m with |