Skip to content

Instantly share code, notes, and snippets.

View vito's full-sized avatar

Alex Suraci vito

View GitHub Profile
(b: Block) in-scope :=
Object clone do: {
delegates-to: b
call := b scope do: b
call: vs := b scope do: b with: vs
}
import The.Haskell
load = do
"(x: Object) clone" =: do
Reference r <- getSymbol "x"
proto <- newProto $ \p -> p
{ vpDelegates = [r]
}
return (Reference proto)
@vito
vito / dict.the.hs
Created August 5, 2010 03:42
Dictionaries implementing using blocks and delicious metaprogramming.
(b: Block) key: (v: Object) := {
find = { l |
l match: {
[] -> @nothing
(e . es) ->
if: (e values head evaluate == v)
then: { @(ok: (e values (at: 1) evaluate)) }
else: { find call: [es] }
}
}
@vito
vito / html.atomo.hs
Created August 7, 2010 21:38
a little HTML DSL in Atomo (incomplete)
HTML = Object clone
Association = Object clone
a -> b := Association clone do: { from = a; to = b }
Self-Closing = ["base", "meta", "link", "hr", "br", "param", "img", "area", "input", "col", "frame"]
-- creating elements with no content
-- keyword dispatch adds attributes
@vito
vito / gist:513433
Created August 8, 2010 01:29
dispatch object + pseudo lisp-style parameterization
$ the
> foo := dispatch sender x
> foo
message not understood: (<reference> x)
> x = 0
> foo
0
> { x = 42; foo } call
42
> x
@vito
vito / 0-with-output-to.the.hs
Created August 8, 2010 17:10
file writing comparison: The, Scheme, Ruby
"writan to the terminal" print
with-output-to: "foo.txt" do: {
"writan to foo.txt" print
}
val ensuring: p do: b := {
res = b call: [val]
p call: [val]
res
} call
with-output-to: (fn: String) do: b :=
Port (new: fn) ensuring: @close do: { file |
with-input-from: file do: b
}
#title:{The}
hello!
#bold:{Hello, there. #bold:{My name is Inigo Monyoya}.}
goodbye!
#interaction:({
1 + 1
module A.AutoFlow where
import Data.Char (isSpace)
import Text.HTML.TagSoup
autoFlow :: String -> String
autoFlow = renderTags . autoFlow' False . canonicalizeTags . parseTags
where
autoFlow' open []
| open = [TagClose "p"]
import Data.Int
import Data.Time.Clock.POSIX
import LLVM.Core
import LLVM.ExecutionEngine
import System.Environment
main :: IO ()
main = do
as <- getArgs
let num =