Created
August 2, 2010 19:24
-
-
Save vito/505169 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 [] [])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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