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 DeriveDataTypeable, QuasiQuotes, RankNTypes, StandaloneDeriving #-} | |
import Data.Typeable | |
import qualified Data.Text.Encoding as T | |
import qualified System.ZMQ as Z | |
import Atomo | |
import Atomo.Valuable | |
load :: VM () |
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
~ $ atomo | |
[0]> x = { a = 1; { a + 1 } } call | |
{ a + 1 } | |
[1]> x call | |
2 | |
[2]> a = 100 | |
100 | |
[3]> x call | |
2 | |
[4]> x context |
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
~ $ atomo | |
[0]> (y . ys) insert: x by: pred := if: (pred call: [x, y]) then: { x . y . ys } else: { y . (ys insert: x by: pred) } | |
@ok | |
[1]> [] insert: x by: _ := [x] | |
@ok | |
[2]> [] insertion-sort: _ := [] | |
@ok | |
[3]> (x . xs) insertion-sort: pred := (xs insertion-sort: pred) insert: x by: pred | |
@ok | |
[4]> [5, 3, 10] insertion-sort: @<= |
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
atomo $ atomo | |
[0]> this | |
<object (delegates to 1 object)> | |
[1]> [x, y] = [1, 2] | |
[1, 2] | |
[2]> this | |
<object (delegates to 1 object)> | |
x := 1 | |
y := 2 | |
[3]> |
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
atomo $ atomo | |
[0]> 2 repl | |
[0]> + 2 | |
4 | |
[1]> * 3 | |
6 | |
[2]> | |
really quit? (y/n) y | |
@ok | |
[3]> |
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
atomo $ rlwrap atomo repl.atomo | |
[0]> 1 + | |
------------------------------------------------------------------------------ | |
*** parse error: | |
*** "<input>" (line 1, column 3): | |
*** unexpected '+' | |
*** expecting end of input | |
restarts: | |
0: @retry |
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
test = | |
{ { res = { error: @foo } with-restarts: { @use-value -> { r | r } } | |
res .. "?" | |
} with-restarts: { | |
@use-value -> { r | r } | |
} | |
} bind: { | |
Error -> { e | restart: @use-value with: [e show .. "!"] } | |
} |
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
_ evaluate-all: [] := error: @no-expressions | |
t evaluate-all: [e] := e evaluate-in: t | |
t evaluate-all: (e . es) := | |
{ e evaluate-in: t | |
t evaluate-all: es | |
} call | |
(s: String) go: env := | |
s parse-expressions match: { | |
[] -> @ok |
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
> `(x = { a = ~(2 + 2); a . [1 + ~(42 / 5)] }) | |
<expression x = { a = 4; a . [1 + 8] }> | |
> `(x = { a = ~(2 + 2); a . [1 + ~(42 / 5)] }) evaluate | |
{ a = 4; a . [1 + 8] } | |
> x call | |
[4, 9] | |
> |
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 QuasiQuotes #-} | |
import Atomo.Environment | |
import Atomo.Haskell | |
import Atomo.Method | |
import Atomo.Valuable | |
import Text.JSON as JSON | |
load :: VM () |