Skip to content

Instantly share code, notes, and snippets.

View aturon's full-sized avatar

Aaron Turon aturon

View GitHub Profile
implicit def str2toInt(s: String): { def toInt: Int } = new {
def toInt: Int = java.lang.Integer.parseInt(s)
}
@aturon
aturon / gist:1207265
Created September 9, 2011 20:34
The Burke-Fisher functor
signature PARSER =
sig
type token
val exampleToks: token list
type span = (int * int)
type 'stream lexer = 'stream -> token * span * 'stream
type result
exception ParseError of span
val parse: 'stream lexer -> 'stream -> result
@aturon
aturon / aca-unique.txt
Created April 29, 2012 16:07
unique words in ACA
abbreviated
abnormality
abrogate
absent
absolute
abusive
academically
accommodate
accompany
accompanying
@aturon
aturon / escape.rkt
Created May 4, 2012 20:12
racket's escape analysis
; when compiled, does this code ...
(define (abs x)
(define (f)
(if (> x 0) x (g))
(define (g)
(- 0 x))
(f))
; ... turn into this code?
@aturon
aturon / gist:2630073
Created May 7, 2012 20:08
early reagent code generation
(define-reagent (push s x)
(read-match s
[xs (update-to! (cons x xs))]))
; --generates->
(define (push s x)
(let retry40 ()
(let ([b41 (atomic-ref-box s)]
[ov42 (unsafe-unbox* b41)])
@aturon
aturon / ProcessBuilder.rs
Created April 30, 2014 00:03
draft ProcessBuilder implementation
/// This process builder type provides fine-grained control over how a new
/// process should be spawned. A default configuration can be generated using
/// `ProcessBuilder::new(program)`, where `program` gives a path to the program
/// to be executed. Additional builder methods allow the configuration to be
/// changed (for example, by adding arguments) prior to spawning:
///
/// ```
/// use std:io::ProcessBuilder;
///
/// let mut process = match ProcessBuilder.new("sh").arg("-c").arg("echo hello").spawn() {
@aturon
aturon / mut-for-immutable.rs
Last active August 29, 2015 14:01
can add mut to self in trait impl
// The trait itself says the method takes self as immutable
trait ImmutableOp {
fn do_immutable(self);
}
impl ImmutableOp for Vec<u8> {
// FAILS TO COMPILE, AS IT SHOULD:
// fn do_immutable(self) {
// self.push(0);
// }
---- [run-pass] run-pass/while-cont.rs stdout ----
error: compilation failed!
status: exit code: 101
command: x86_64-apple-darwin/stage2/bin/rustc /Users/aturon/moz/working/issue-11650/src/test/run-pass/while-cont.rs -L x86_64-apple-darwin/test/run-pass --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/run-pass/while-cont.stage2-x86_64-apple-darwin.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/run-pass/while-cont.stage2-x86_64-apple-darwin --cfg rtopt --cfg debug -L x86_64-apple-darwin/rt
stdout:
------------------------------------------
task 'rustc' failed at 'needs a temp dir', /Users/aturon/moz/working/issue-11650/src/libstd/option.rs:245
---- [run-pass] run-pass/vec-matching.rs stdout ----
error: compilation failed!
status: exit code: 101
command: x86_64-apple-darwin/stage1/bin/rustc /Users/aturon/moz/working/issue-11650/src/test/run-pass/vec-matching.rs -L x86_64-apple-darwin/test/run-pass --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/run-pass/vec-matching.stage1-x86_64-apple-darwin.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/run-pass/vec-matching.stage1-x86_64-apple-darwin --cfg rtopt --cfg debug -L x86_64-apple-darwin/rt
stdout:
------------------------------------------
task 'rustc' failed at 'needs a temp dir', /Users/aturon/moz/working/issue-11650/src/libstd/option.rs:245
task 'rustc' failed at 'needs a temp dir', /Users/aturon/moz/working/issue-11650/src/libstd/option.rs:245
stack backtrace:
1: 0x10c408f74 - rt::backtrace::imp::write::h5987cfa6d2cce788D5a::v0.11.pre
2: 0x10c35bcce - rt::unwind::begin_unwind_inner::hb4e6b4562dd8b47fHFa::v0.11.pre
3: 0x1096dc708 - rt::unwind::begin_unwind::h15535554073126010795::v0.11.pre
4: 0x109e0ebde - back::link::link_natively::ha20464d71015abc59B4::v0.11.pre
5: 0x109e08d4f - back::link::link_binary::h76c69827ffab817bDg4::v0.11.pre
6: 0x109f00209 - driver::driver::phase_6_link_output::h1b1589e6399fb3f7v7h::v0.11.pre
7: 0x109f0311a - driver::driver::compile_input::h3b5586ed143875c55mi::v0.11.pre
8: 0x109f29007 - run_compiler::h483ea1bd82c3ef35HQp::v0.11.pre