| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Seems to work. Fixes purescript#174
|
Ah, this behaves oddly if you give the module a name of an existing module in the package set. For example, if I call the current module Data.Semiring and try to use + within it, then I get a "ReferenceError: $foreign is not defined". Perhaps I should rewrite the module name to Main to ensure that it doesn't clash with any module name in the package set? |
Sorry, something went wrong.
|
This now seems to work even if I try to redefine an existing module. I haven't been able to think of a way that rewriting the module name like this would be an issue, it seems like a slightly nicer UX for what is essentially the same idea (only modules with a specific module name are allowed). |
Sorry, something went wrong.
There was a problem hiding this comment.
A nice improvement. We’ll have to revisit this if Try PureScript ever supports multiple files / modules but that’s a faraway future.
Sorry, something went wrong.
| -- Rewrite the module name to "$Main" in order to ensure that the | ||
| -- module name doesn't clash with any existing module names in | ||
| -- the package set. | ||
| let rewriteModuleName (P.Module ss coms _ decls refs) = P.Module ss coms (P.moduleNameFromString "$Main") decls refs |
There was a problem hiding this comment.
If someone attempts to play with module export syntax this might be cause problems with:
module Foo (module Bar, module Foo) where ...
Sorry, something went wrong.
There was a problem hiding this comment.
I'll wager this is by far an edge case, however 😆
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, good point. I think re-exporting main from elsewhere seems plausible to want to do, so perhaps this isn't the best approach. Maybe we should assemble a set of used module names from the externs files, and then instead of rewriting, just check that the given module name is not included in that set?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Seems to work. Fixes #174