Skip to content

Instantly share code, notes, and snippets.

@vito
Created August 2, 2010 19:24
Show Gist options
  • Save vito/505169 to your computer and use it in GitHub Desktop.
Save vito/505169 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.State
import qualified Data.ByteString as BS
import The.Environment
import The.Parser
import The.Types
load = do
"Expression" =: exec "Object clone"
"Expression Block" =: exec "Object clone"
"(Expression Block) new: (es: List)" =: do
let toExpr (Expression e) = e
toExpr x = Primitive x
List es <- top "es"
return (Expression (EBlock [] (map toExpr es)))
"(Expression Block) new" =: return (Expression (EBlock [] []))
> import: "prelude/expression.hs"
> Expression Block new
{}
> Expression Block new: []
{}
> Expression Block new: [1]
{1}
> Expression Block new: [1, 2]
{1; 2}
> Expression Block new: { a = 1; a + 2 } contents
{a = 1; (a + 2)}
> (Expression Block new: { a = 1; a + 2 } contents) evaluate
{a = 1; (a + 2)} -- sending "evaluate" returns a block value with the current scope
> (Expression Block new: { a = 1; a + 2 } contents) evaluate do
3
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment