Discussion:
[Ur] Error compiling "Anonymous function remains at code generation"
Fabrice Leal
2018-09-18 22:01:57 UTC
Permalink
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.

Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)

That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.

Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
Fabrice Leal
2018-09-18 22:04:23 UTC
Permalink
Post by Fabrice Leal
while trying to compile urweb
I didnt mean that, I meant while compiling a project of mine. Sorry, long
day.
Post by Fabrice Leal
that page
The page which uses a regex call
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
Fabrice Leal
2018-09-19 20:05:20 UTC
Permalink
ok so this was itching me so I decided to try to isolate whatever is at
fault. and I think I created the simplest sample to reproduce the problem:

https://github.com/fabriceleal/urweb-test

so I'm assuming the problem is not at my end and will try to do the parsing
on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
Adam Chlipala
2018-09-19 20:21:27 UTC
Permalink
Short answer before I can investigate in more detail: it is expected
that the Ur/Web compiler give that kind of terrible error message in
many cases that don't nest server-side and client-side code properly. 
Some day it should be enforced with a type system, yielding better error
messages, but that day is not yet upon us!
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is
at fault. and I think I created the simplest sample to reproduce the
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
On Tue, Sep 18, 2018 at 11:01 PM Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it
compiles fine (even though I seem unable to access that page from
the browser), so I assume I'm doing something wrong in my
helloworld.ur file.
Would appreciate some pointers; Source file is this one
(https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource
(https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705)
That FFI maybe_onload is particularly suspicious ... is the call
to parsePgn being "lifted" to javascript code? Some time ago I had
some errors while trying to use the rpc function in the loadPost
page because i was mixing it with code that uses my canvas library
which has a bunch of clientOnly FFI calls; I reorganized my code
and eventually made it work nicely
(https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not
lead anywhere.
Sorry for the wall of text and thanks in advance :)
Aistis Raulinaitis
2018-09-19 23:27:05 UTC
Permalink
Adam is exactly correct here. You're trying to call server code in a web
view. Try this:

`val r = rpc (testRe "test 123")`
Short answer before I can investigate in more detail: it is expected that
the Ur/Web compiler give that kind of terrible error message in many cases
that don't nest server-side and client-side code properly. Some day it
should be enforced with a type system, yielding better error messages, but
that day is not yet upon us!
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
_______________________________________________
Ur mailing list
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Fabrice Leal
2018-09-20 21:53:03 UTC
Permalink
@Aistis
Just doing your snippet won't typecheck for me;

I tried like this

...
fun testReR s = return (testRe s)

fun index () =
r <- rpc (testReR "test 123");
return <xml>
...

and the error is "Anonymous function remains at code generation" and on top
I get "RPC in server-side code"

and I tried like this
...
fun testReR s = return (testRe s)

fun index () =
r <- testReR "test 123";
return <xml>
....

and the error is the same "Anonymous function remains at code generation"

==

btw, I started another toy project and I seem unable to use curried
functions due to them resulting in the same error
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
Aistis Raulinaitis
2018-09-20 22:17:06 UTC
Permalink
I'll download your toy and I'll try to get it to work
Post by Fabrice Leal
@Aistis
Just doing your snippet won't typecheck for me;
I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- rpc (testReR "test 123");
return <xml>
...
and the error is "Anonymous function remains at code generation" and on
top I get "RPC in server-side code"
and I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- testReR "test 123";
return <xml>
....
and the error is the same "Anonymous function remains at code generation"
==
btw, I started another toy project and I seem unable to use curried
functions due to them resulting in the same error
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
_______________________________________________
Ur mailing list
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Fabrice Leal
2018-09-20 23:29:59 UTC
Permalink
@Aistis
Thanks :)

Check the toy here https://github.com/fabriceleal/urweb-nregex

I tried to coerce my match function to work on the server side my calling
it via rpc and giving the value back to the page using a <dyn>
I tried 4 ways of coding the predicates to eval chars but to no good

https://github.com/fabriceleal/urweb-nregex/commit/57eac6de87fe755ab0a0ce2cf03132c99ef92dd1#diff-28f969b3b5e13b5a7230a77f7d879e2eR95

previous commit compiles, but uses plain list char and "hardcoded" function
calls instead of char -> bool
Post by Fabrice Leal
@Aistis
Just doing your snippet won't typecheck for me;
I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- rpc (testReR "test 123");
return <xml>
...
and the error is "Anonymous function remains at code generation" and on
top I get "RPC in server-side code"
and I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- testReR "test 123";
return <xml>
....
and the error is the same "Anonymous function remains at code generation"
==
btw, I started another toy project and I seem unable to use curried
functions due to them resulting in the same error
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
Aistis Raulinaitis
2018-09-27 21:56:53 UTC
Permalink
After downloading your toy and playing around with it, I realized I was
wrong to assume Regex.match is server side, reading the source it seems to
use the JSFFI..

My guess now is that some of the compiler heuristics changed since that
library was written.
You're probably going to either want to use the new library you wrote or
attempt to resurrect this old one..
Post by Fabrice Leal
@Aistis
Thanks :)
Check the toy here https://github.com/fabriceleal/urweb-nregex
I tried to coerce my match function to work on the server side my calling
it via rpc and giving the value back to the page using a <dyn>
I tried 4 ways of coding the predicates to eval chars but to no good
https://github.com/fabriceleal/urweb-nregex/commit/57eac6de87fe755ab0a0ce2cf03132c99ef92dd1#diff-28f969b3b5e13b5a7230a77f7d879e2eR95
previous commit compiles, but uses plain list char and "hardcoded"
function calls instead of char -> bool
Post by Fabrice Leal
@Aistis
Just doing your snippet won't typecheck for me;
I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- rpc (testReR "test 123");
return <xml>
...
and the error is "Anonymous function remains at code generation" and on
top I get "RPC in server-side code"
and I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- testReR "test 123";
return <xml>
....
and the error is the same "Anonymous function remains at code generation"
==
btw, I started another toy project and I seem unable to use curried
functions due to them resulting in the same error
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
_______________________________________________
Ur mailing list
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
Fabrice Leal
2018-09-29 18:23:53 UTC
Permalink
Thanks for having a look :)

Yeah I got this working good enough for me in another branch, will try to
code my way around this for the time being
Post by Fabrice Leal
@Aistis
Thanks :)
Check the toy here https://github.com/fabriceleal/urweb-nregex
I tried to coerce my match function to work on the server side my calling
it via rpc and giving the value back to the page using a <dyn>
I tried 4 ways of coding the predicates to eval chars but to no good
https://github.com/fabriceleal/urweb-nregex/commit/57eac6de87fe755ab0a0ce2cf03132c99ef92dd1#diff-28f969b3b5e13b5a7230a77f7d879e2eR95
previous commit compiles, but uses plain list char and "hardcoded"
function calls instead of char -> bool
Post by Fabrice Leal
@Aistis
Just doing your snippet won't typecheck for me;
I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- rpc (testReR "test 123");
return <xml>
...
and the error is "Anonymous function remains at code generation" and on
top I get "RPC in server-side code"
and I tried like this
...
fun testReR s = return (testRe s)
fun index () =
r <- testReR "test 123";
return <xml>
....
and the error is the same "Anonymous function remains at code generation"
==
btw, I started another toy project and I seem unable to use curried
functions due to them resulting in the same error
Post by Fabrice Leal
ok so this was itching me so I decided to try to isolate whatever is at
https://github.com/fabriceleal/urweb-test
so I'm assuming the problem is not at my end and will try to do the
parsing on my own until the urweb-regex lib gets updated
Post by Fabrice Leal
I'm having this weird error while trying to compile urweb using
urweb-regex; if I isolate that page in a separate module, it compiles fine
(even though I seem unable to access that page from the browser), so I
assume I'm doing something wrong in my helloworld.ur file.
Would appreciate some pointers; Source file is this one (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/helloworld.ur#L869)
and I also included the result of -dumpVerboseSource (
https://github.com/fabriceleal/urweb-experiments/blob/doesnt_compile/dumpVerboseSource.txt#L7705
)
That FFI maybe_onload is particularly suspicious ... is the call to
parsePgn being "lifted" to javascript code? Some time ago I had some errors
while trying to use the rpc function in the loadPost page because i was
mixing it with code that uses my canvas library which has a bunch of
clientOnly FFI calls; I reorganized my code and eventually made it work
nicely (
https://github.com/fabriceleal/urweb-experiments/commit/503da7e28f1a05be6e69e9f60c9cd321bfa252ce
IIRC). I tried to isolate the testParse function but seems to not lead
anywhere.
Sorry for the wall of text and thanks in advance :)
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
--
---
Fabrice Leal
Continue reading on narkive:
Loading...