Skip to content

Instantly share code, notes, and snippets.

View darach's full-sized avatar

Darach Ennis darach

  • Squircle Systems Ltd
  • London, UK
View GitHub Profile
@darach
darach / ex1.pony
Created November 11, 2015 00:30
Random pony examples
use "collections"
actor Main
fun pass[A : Any #read](ln: A): List[A] =>
List[A].push(consume ln)
new create(env : Env) =>
try
env.out.print("Got: " + pass[String]("hello")(0) as String)
end
@darach
darach / f.pony
Created November 14, 2015 20:30
ref -> val
actor Main
new create(env : Env) =>
var a : Array[String] ref = [ "a", "b", "c" ]
var b : Array[String] trn = recover Array[String] end
b.push("foo") ; b.push("bar") ; b.push("baz")
for i in a.values() do
b.push(i)
end
let c : Array[String] val = consume b
for i in c.values() do
@darach
darach / instructions.md
Last active February 13, 2016 22:37
Pony on the Raspberry Pi v2

Instructions

The following instructions assume a debian jessie based distribution

0. Prerequisites

Install dependent tools and libraries

$ sudo apt-get update
#--------
# Dockerfile to configure salt minion
FROM debian:jessie
MAINTAINER [email protected]
RUN apt-get update
RUN apt-get install -y curl
RUN curl -o - https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub |
apt-key add -
@darach
darach / getifaddr.pony
Created February 23, 2016 23:25
A minimal example of mapping a native C structure to pony struct using FFI - Shows usage of Maybe, FFI and structs working together
// Use Pony struct's, FFI, and Maybe to map native structures to C
// Thanks to sclebsch for a little help with the embedded sa_data
// structure for which details are well hidden in sockaddr_in and sockaddr_in6
//
struct SockAddr
var sa_len: U8 = 0
var sa_family: U8 = 0
var sa_port: U16 = 0
var sa_data_1: U32 = 0
@darach
darach / Pony on MIPS [ Work in Progress ]
Last active May 17, 2016 19:21
Pony on MIPS - C and RT test results
root@mylinkit:/tmp/run/mountd/sda2/current/bin# ./ponyc --pic --debug -V=4 foo
Building builtin -> /tmp/run/mountd/sda2/current/packages/builtin
Building foo -> /tmp/run/mountd/sda2/current/bin/foo
Generating
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
use "collections"
use "time"
primitive Factorial
""" Factorial
"""
fun fac(n:U64): U64 =>
var f : U64 = 1
var i : U64 = 1
if n == 0 then