Open DonaldScott opened 11 years ago
My understanding is, the Haskell compiler (and the Elm compiler?) may need a lot of RAM to compile the programs. But once compilation is completed, much less RAM is needed to run the programs.
Here is a snapshot of the first few lines of output from the top
command:
top - 04:12:13 up 15 min, 1 user, load average: 0.00, 0.01, 0.02
Tasks: 62 total, 3 running, 59 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.7%us, 0.0%sy, 0.0%ni, 98.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 3869704k total, 447060k used, 3422644k free, 12488k buffers
Swap: 0k total, 0k used, 0k free, 236752k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
976 root 20 0 262m 220m 58m S 1.3 5.8 0:08.93 ghc
975 root 20 0 6268 1076 848 R 0.7 0.0 0:00.94 runghc
1166 ubuntu 20 0 30280 12m 9168 R 0.3 0.3 0:01.02 elm-server
I'm not sure exactly how to interpret the output of the top
command, but it does appear that RAM usage and CPU % are quite low, which seems encouraging.
For the IE9 issue, it is because that browser disallows cross-site AJAX requests in all cases. To look up the zip codes, I call some API somewhere and IE9 does not like that. It should throw errors to that effect in the debugging console.
(0) Thank you Neil @ngunn for your helpful explanation of unzipping / modifying / zipping the package in the
.cabal
directory and then runningcabal install elm-yesod
again, here:https://github.com/tazjin/elm-yesod/pull/4#issuecomment-14325616
This allowed
elm-yesod
to compile. I suspect part of the trick is to not docabal update
before re-doingcabal install elm-yesod
, correct?Sorry for yet another lengthy post, but I wanted to test both
elm-server
(involving 4 demos) andelm-yesod
(involving 3 demos) in 3 browsers, so there was a bit of a minor "combinatorial explosion".Summary
elm-yesod
works on all routes tested (inMain.hs
) except/
.elm-yesod
did not work on any of the routes tested (inMain.hs
).elm-server
(without yesod) works (exceptZipCodes.elm
in IE 9: the field and prompt display, but the browser does not return the state/city).Full testing details below: section (1) describes testing
elm-server
(without yesod), and section (2) describes testingelm-yesod
.Next steps
elm-yesod
shows blank pages on route/
in Chrome and Firefox, and blank pages all the time in IE9.elm-server
(without yesod) doesn't work in IE9.(1) Testing
elm-server
by itself without yesodI attempted to run
elm-server
by itself without yesod (on port 8000) following the instructions here:https://github.com/evancz/Elm#using-the-elm-compiler-and-server
That worked fine.
Note: I am using nohup as follows to make sure the server doesn't "die" when I close my Putty SSH window:
nohup elm-server &
The
/
page displays a convenient directory listing (automatically generated by Elm? nice touch - reminds me of Tomcat :-), showing 4 clickable file links, which take you to the 'clock' demo, the 'mousePosition' demo, the 'ZipCodes' demo, and a slightly modified demo 'shapes3', shown below:IE9 error: ZipCodes demo doesn't work in IE9. The page displays in IE9, but when I enter a correct 5-digit zipcode, nothing happens, even after hitting Return. If I hit return a few times, the prompt text under the field disappears, and a small empty graphic box (the "waiting" icon?) appears in its place.
(2) Testing
elm-yesod
- overview of resultsI continued with the steps here:
https://github.com/evancz/Elm/wiki/Elm-with-Yesod:-Getting-Started
Examples/elm-yesod/
directory which contains the example Yesod code inMain.hs
;runhaskell Main.hs
I went through 4 testing phases, and on the 4th testing phase it finally worked (but route `/`` doesn't work in Chrome and Firefox, and none of the routes work in IE)
What got it working (mostly) was when I made a change in
Main.hs
so that it now references:https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.7.2.js
elm-yesod
in Chrome 26 and Firefox 19, only the route/
doesn't work, and the routes/mouse
,/clock
and/shapes
do work.elm-yesod
in Internet Explorer 9, all of the routes render a blank page in the browser, displaying only a Title. However, the source looks ok.Testing
elm-yesod
in Chrome and Firefox, about 20% of the time when attempting to GET a route involving graphics (eg,/mouse
or/shapes
or/clock
), a blank page renders initially, and the browser must be refreshed in order to correctly render the page. (IE9 never works withelm-yesod
: it always renders a blank page, with a Title.)Testing phases (a), (b), (c) below for
elm-yesod
are no longer the current behavior. The current behavior forelm-yesod
is described in testing phase (d) below.(2)(a) First testing phase for
elm-yesod
During this first testing phase the browser would GET the fairly short HTML source shown below, complaining about an ambiguous occurrence of 'link', and rendering a blank browser window (meaning the HTML was invalid?).
(2)(b) Second testing phase for
elm-yesod
I then did the changes suggested here https://github.com/ngunn/Elm/commit/346ff6bb5d675ff27dc3a7b11c3a48c9c650b96d which made the browser GET the much more complete HTML source (but still somehow invalid?) shown below, clearly showing a lot of Javascript which had been generated by Elm. However, the rendered page was still blank (although the Title did appear correctly in the page's tab in the browser).
It was at this point that I actually did the steps in (1) above - testing
elm-server
by itself (without yesod), which worked. Then I proceeded to testing phase (c) below.(Testing phase (c) below was the first time that the HTML source actually rendered something in the window. I wonder if this was somehow related to the fact that I did (1) launching
elm-server
(without yesod) just before doing testing phase (c) forelm-yesod
? This would not seem to make sense as I do not believe that there is any interconnection between testingelm-server
and testingelm-yesod
in different directories, on different ports.)(2)(c) Third testing phase for
elm-yesod
In this third testing phase, the browser would GET the valid HTML source shown below, mentioning "Not Found", and this rendered in the browser window, along with the (supposedly) not-found filename. This happened whether or not the file actually existed on the server.
(2)(d) Fourth testing phase for
elm-yesod
(the current behavior)I remembered reading the following:
https://github.com/evancz/Elm
An important note: When you install the elm compiler, it automatically downloads Elm's JavaScript runtime system to
~/.cabal/share/Elm-x.y.z/
. The runtime system will follow the name schemeelm-runtime-x.y.z.js
wherex.y.z
matches the version number of the compiler. If you want to serve this file from a different location, copy it from its home and always be sure that code compiled with versionx.y.z
of the compiler is served with versionx.y.z
of the runtime system.So I grabbed the link to the latest
elm-runtime-x.y.z.js
here:https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.7.2.js
and modified
Main.hs
inElm/Examples/elm-yesod
to reference this link.Now in Chrome 26 and Firefox 19 all routes work except for
/
(which incorrectly complains that I do not have a modern browser), while IE9 merely renders a blank page with a Title.The error happening in Chrome and Firefox using
elm-yesod
, renders the following for the route/
:And the HTML source says:
Recall (as mentioned in testing phase (2)(b) above) that the elm source for the
/
page (generating the HTML source above) uses the latest code modified by Neil @ngunn which can be inspected here: https://github.com/ngunn/Elm/commit/346ff6bb5d675ff27dc3a7b11c3a48c9c650b96dSo when using
elm-yesod
(runhaskell Main.hs
), for the route/
, we have the following incorrect behavior:Chrome 26: complains "do you have a modern browser?" with a "Welcome" Title in the tab
Firefox 19.0 complains "do you have a modern browser?" with a "Welcome" Title in the tab, and
IE 9.0.8112.16421 renders a blank page with a "Welcome" Title in the tab
UPDATE: The route
/
above no longer renders the text "Are you using a modern browser?" Now, for some reason, it behaves differently, rendering the following text in the browser window:Error: Ambiguous occurrence of 'link' could refer to Text.link, Graphics.link
I have no idea why the behavior of the
/
route is incorrect and inconsistent inelm-yesod
.Conclusions
I am pleased to have Elm and
elm-yesod
running, and I really appreciate the help from @ngunn Neil as well as the Elm language design itself by Evan @evancz.Elm represents a major breakthrough in how web programming is done, using concurrent FRP to permit a very high-level declarative programming style, and it is great to have it working both standalone (
elm-server
) and usingelm-yesod
(leveraging Yesod's high-performance Warp webserver).Pending minor issues
The command
elm-server
always works (including in IE9), and there only two minor issues remaining when when using elm-yesod to runrunhaskell Main.hs
inElm/Examples/elm-yesod
:Issue (i) - When using
elm-yesod
, why does the route/
:Issue (ii) - When using
elm-yesod
, why do the routes involving graphics occasionally fail to render on the first page load (about 20% of the time), requiring an addiitional page refresh in order to render?Update
I now see that Neil @ngunn has posted a fix for Issue (i) above, here:
https://github.com/ngunn/elm-yesod/commit/f95507f3862b5d56885024f022bb21ce2e1039ee
As this involves repeating step (0) above, including re-running
cabal install elm-yesod
, I will try this fix later, possibly on a different server at AWS EC2, to avoid any chance of messing up the server that is already showing mostly correct behavior.Thanks for any help or feedback!