Skip to content

Instantly share code, notes, and snippets.

@vito
Created August 4, 2010 03:17
Show Gist options
  • Save vito/507581 to your computer and use it in GitHub Desktop.
Save vito/507581 to your computer and use it in GitHub Desktop.
import The.Haskell
load = do
"(x: Object) clone" =: do
Reference r <- getSymbol "x"
proto <- newProto $ \p -> p
{ vpDelegates = [r]
}
return (Reference proto)
"(x: Object) dump" =: do
x <- getSymbol "x"
liftIO (print x)
return x
"(x: Object) print" =: do
x <- getSymbol "x"
printVM x
return x
"(s: String) write" =: do
List cs <- getSymbol "s"
if all isChar cs
then do
liftIO (putStrLn (map (\(Char c) -> c) cs))
return (List cs)
else throwError $ ErrorMsg "@write applied to non-String"
"(b: Block) apply" =: do
Block s as es <- getSymbol "b"
if length as > 0
then throwError . ErrorMsg $ "block expects " ++ show (length as) ++ ", given 0"
else doBlock [] s es
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment