Skip to content

Instantly share code, notes, and snippets.

View vito's full-sized avatar

Alex Suraci vito

View GitHub Profile
@vito
vito / 0-source.atomo.hs
Created October 15, 2010 02:25
quick-and-dirty JSON
JSON = Object clone
(s: String) as: JSON := s show
(d: Double) as: JSON := d show
(i: Integer) as: JSON := i show
(l: List) as: (j: JSON) :=
"[" .. l (map: @(as: j)) (join: ", ") .. "]"
(b: Block) as: (j: JSON) :=
Object clone (do: b) (as: j)
@vito
vito / @methods
Created October 15, 2010 01:29
object inspection
atomo $ atomo
> Object clone (do: { a = 1; b = "hi" }) methods
<object (delegates to 1 object)>
keywords := []
singles := [[<slot (a)>], [<slot (b)>]]
> Object clone (do: { a = 1; b = "hi" }) methods singles
[[<slot (a)>], [<slot (b)>]]
> Object clone (do: { a = 1; b = "hi" }) methods singles (map: @(map: @value))
[[1], ["hi"]]
> Object clone (do: { a = 1; b = "hi" }) methods singles (map: @(map: @value)) concat
@vito
vito / process.hs
Created October 11, 2010 17:58
atomo command-line stuff
{-# LANGUAGE QuasiQuotes, StandaloneDeriving, DeriveDataTypeable #-}
import Atomo.Environment
import Atomo.Haskell
import Data.Typeable
import System.Exit
import System.Process
deriving instance Typeable ProcessHandle
Generator = Object clone
(g: Generator) yield: v := g yielder = { cc |
g control-state =! cc
g yielder yield: v
} call/cc
(b: Block) generator :=
Generator clone do: {
next := control-state _? call/cc
if: a?
then: { a }
else: {
if: b?
then: { b }
else: { c }
}
["foo",
"bar",
"baz"] print
[
"foo"
"bar"
"baz"
] print
@vito
vito / parameterization.atomo.hs
Created September 12, 2010 14:46
parameters
Parameter = Object clone
Parameter new: v := Parameter clone do: {
value: (self) = v
value: _ = v
}
(p: Parameter) _? := p value: self
(p: Parameter) set: v :=
(p) value: (self) = v
@vito
vito / Directory
Created September 12, 2010 00:14
> File
<object (delegates to 1 object)>
canonicalize-path: (fn: <object>) := ...
rename: (from: <object>) to: (to: <object>) := ...
delete: (fn: <object>) := ...
new: (fn: <object>) := Port new: fn
CSS new (do: {
body: {
font-family: "Georgia"
}
header: {
font-family: "Arial"
h1.red: {
color: "red"
load: "examples/html.atomo"
load: "examples/web.hs"
Association = Object clone
a -> b := Association clone do: { from = a; to = b }
Demo = Website clone do: {
routes = [
"/" -> @index,