Monad syntax bug
raimohanska opened this issue · 3 comments
raimohanska commented
As in https://gist.github.com/4150252#comments
This works:
let main = do ioMonad
_ <- putStrLn "a"
putStrLn "b"
This does not:
let main = do ioMonad
putStrLn "a"
putStrLn "b"
raimohanska commented
So I made a fix, but I gotta admit I don't understand the compiler thorougly enough to be totally convinced it works under all circumstances. I added a new testcase (callbackmonad.roy) an existing test case to also include a line where there's just a side effect and no assignment.
raimohanska commented
Works in Turtle Roy: http://turtle-roy.herokuapp.com/?turtle=2FTJWA37ZP
joneshf commented
Hmm, There still seems to be a bug about this as of 0.2.2. It seems to still have to bind something in order for it to compile.
So something like:
let main = do someMonad
someFunc 37
Gives this traceback:
/usr/lib/node_modules/roy/src/compile.js:152
var result = n.accept({
^
TypeError: Cannot call method 'accept' of undefined
at compileNodeWithEnvToJsAST (/usr/lib/node_modules/roy/src/compile.js:152:20)
at compileNode (/usr/lib/node_modules/roy/src/compile.js:150:16)
at Object.n.accept.visitBind (/usr/lib/node_modules/roy/src/compile.js:317:27)
at accept (/usr/lib/node_modules/roy/src/nodes.js:146:26)
at compileNodeWithEnvToJsAST (/usr/lib/node_modules/roy/src/compile.js:152:20)
at compileNode (/usr/lib/node_modules/roy/src/compile.js:150:16)
at Object.n.accept.visitDo (/usr/lib/node_modules/roy/src/compile.js:388:27)
at accept (/usr/lib/node_modules/roy/src/nodes.js:156:26)
at compileNodeWithEnvToJsAST (/usr/lib/node_modules/roy/src/compile.js:152:20)
at compileNode (/usr/lib/node_modules/roy/src/compile.js:150:16)