Add support for the use of "debugger;" in FFI
bitemyapp opened this issue · 7 comments
Currently get: unexpected reserved word "debugger" for an otherwise valid lambda :(
Thanks for the reminder! This is a restriction in language-ecmascript, i have been meaning to ask them if it's possible to allow it. I'll open an issue in their repo.
For now, you can do
function f(%1) { debugger; ... }
foo :: X
foo = ffi "f(%1)"
@bergmark this sounds very helpful but I'm a little confused as to what is meant here. It wasn't clear to me that I could inline JavaScript functions without being inside an ffi string into Fay code. Is that what your example is illustrating?
Forgot to reply to this, sorry!
No it's not valid to inline JS outside the FFI, I meant that you can have a normal JS function that's included which calls debugger. For instance
Debug.js:
function debug(f) { debugger; return f(); }
FayProgram.hs:
foo :: Int -> Int
foo = ffi "debug(function () { return %1; })"
Usually I just add break points in the browser or modify the produced js instead of doing this.
Would it be possible to do something like this? I don't have a lot of experience with Fay (or Haskell, for that matter).
debugBreak :: a -> a
debugBreak = ffi "(function(a){debugger;return a})(%1)"
@IMPinball We parse the ffi string as a javascript expression using the language-ecmascript package and it doesn't allow debugger
at all.
IIRC this will be supported in language-ecmascript-1.0 but I'm not sure when that will be released.
Oh. It seems odd that it's not even supported.