elm / elm-lang.org Goto Github PK
View Code? Open in Web Editor NEWServer and client code for the Elm website.
Home Page: http://elm-lang.org/
License: BSD 3-Clause "New" or "Revised" License
Server and client code for the Elm website.
Home Page: http://elm-lang.org/
License: BSD 3-Clause "New" or "Revised" License
Consider the following:
import Graphics.Input as Input
data Event = Nop | Create | Change Int String
fields = Input.fields Nop
buttons = Input.buttons Nop
events = merge fields.events buttons.events
btn = buttons.button Create "Create"
view : [(Element, String)] -> Element
view lst =
let f (e,s) = e `beside` plainText s
in flow down (btn :: map f lst)
change : Int -> (a -> a) -> [a] -> [a]
change i f l =
case l of [] -> []
x::xs -> if i == 0 then f x :: xs
else x :: change (i-1) f xs
update : Event -> [(Element,String)] -> [(Element,String)]
update evt x =
case evt of
Nop -> x
Create -> x ++ [(fields.field (\fs -> Change (length x) fs.string)
"write here"
Input.emptyFieldState,
"")]
Change i s -> change i (\(e,_) -> (e,s)) x
main = view <~ foldp update [] events
It should create a new text field whenever the "Create" button is pressed, but leaves the old text fields alone (rather than re-creating them, as a naive implementation based on counting button-presses might do).
However, when I run it under Elm 0.11, pressing the Create button actually blanks all other text fields. The text beside the field stays the same, though, until you select the text field in question, whereupon that becomes blank, too.
This behavior makes it very difficult to create a dynamic list of items containing text fields (dynamic meaning the list can be added to and removed from at runtime) that behaves properly.
JavaScript has an atan2 function, which can be used to find the angle of a vector given its y and x components (in that order). Using Math.atan(y/x)
, you have to deal with ugly edge cases:
x
is zero, meaning the angle is π/2 or -π/2 (that is, unless y
is zero too, in which case the angle can be anything).y/x
eliminates the distinction between Q1/Q4 and Q3/Q2, meaning you have to see what quadrant the coordinate is in and add/subtract accordingly.Math.atan2(y, x)
will take care of this for you. I think we should add this to Elm's Prelude next to atan
(I don't have time to put together a patch at the moment). By the way, Haskell has an atan2
function, too, and it works the same way.
Also, we can simplify part of the insideShape
function. Here is the current code:
var angle = 2 * Math.PI * theta;
var t = x === 0 ? (y > 0 ? Math.PI/2 : -Math.PI/2) - angle
: (Math.atan(y/x) + (x > 0 ? 0 : Math.PI)) - angle;
var r = Math.sqrt(x*x + y*y);
x = r * Math.cos(t);
y = r * Math.sin(t);
This appears to rotate x
and y
by -2π * theta
. It turns out there is a much nicer way to rotate vectors: apply a rotation matrix. We don't need atan
at all. The following formula rotates a vector "counter-clockwise" by θ:
x' = x*cos(θ) - y*sin(θ)
y' = x*sin(θ) + y*cos(θ)
When I say "counter-clockwise", I assume a coordinate system where x+ is right and y+ is up. On a computer screen, y+ is down, meaning this will actually rotate clockwise.
In general, when you have foo(bar¯¹(x)) (where foo and bar are trig functions), there's a good chance they cancel into something much nicer.
In the current version of elm-0.9.x Graphics.Collage.rect : Float -> Float -> Shape, however the docs state that it's type is rect : number -> number -> Shape http://elm-lang.org/docs/Graphics/Collage.elm
I've noticed that each touch propagated by Touch.touches
yields a Touch
with ID 1 less than the previous one. How come they don't increment instead?
I can't read the end of this article:
http://elm-lang.org/learn/Records.elm
I use Safari Version 7.0.3 (9537.75.14) on OS X 10.9.2
A lot of web site code uses the FFI so needs to be updated to use ports. I encountered while trying to profile some compilation slowness.
It's kinda tedious though. You could probably tell the mailing list it needs doing and someone will do it to get experience with the Ports syntax.
Unless I missed something obvious, this is very misleading, as I was trying to change the text in the Skeleton.elm file and it would not update, and I was stuck until I grepped the whole source to find other references of "About", "Docs", etc.
As an aside, I don't see the License on the repository. I want to use it as a base to a little website and I'm not sure if I can do that for commercial purposes, and if my resulting website should be open source as well. As Jeff Atwood said, "Experienced developers won't touch unlicensed code because they have no legal right to use it."
The announcement page 0.12.3.elm loads some text and images, then instantly kills Firefox.
0.12.2.elm does the same. 0.12.1.elm and 0.12.elm are fine and do NOT crash.
Browser: 29.0.1 with HTTPS Everywhere, Ghostery, FlashBlock, Privacy Badger.
System: 3.10.39-1-MANJARO x86_64 using NVidia driver 331.67 on a GTX 660.
using Firefox 16.0.2, ubuntu 12.04.1, it is broken: slideshow appears at the bottom of the page
http://elm-lang.org/edit/examples/Intermediate/SlideShow.elm
only 20% of the picture (upper part) is visible (at the very bottom of the page)
Every month or so, the server goes down with this message:
Server error: public/build/Elm.elm: openBinaryFile: resource exhausted (Too many open files)
I assume this has to do with lazy IO in the server. Sometimes you need to artificially read to the end of a file to make sure it gets closed properly. I find things like (length content seq
...) is sometimes necessary... This may be something in HAppStack as well.
http://elm-lang.org/learn/Escape-from-Callback-Hell.elm
On page load, in Chrome js Console I get:
Uncaught RangeError: Maximum call stack size exceeded elm-runtime.js?v0.10:1480
None of the examples run.
OS X Mavericks, Chrom 31.0.1650.57
Update: after refreshing the page, it's not rendering and errors:
Server error: public/build/learn/Escape-from-Callback-Hell.elm: openBinaryFile: resource exhausted (Too many open files)
When trying to send JS events to the same Elm worker - but on different channels, only one event goes through.
In this example only signal_a is updated in TestModule:
var worker = Elm.worker(Elm.TestModule);
example.addEventListener("click", function () {
worker.send("signal_a", "a");
worker.send("signal_b", "b");
});
But if I postpone one event to the next event loop "tick" then both signals get updated:
...
works.send("signal_a", "a");
setTimeout(function() { worker.send("signal_b", "b"); }, 0);
...
Hi Evan,
I have noticed that this error shows up in the javascript console 4~5 secs after page load.
ReferenceError: JavaScript is not defined - Navigation.elm:19
I just wanted to mention it - I haven't seen any direct implecations from this.
Mads
http://elm-lang.org/edit/examples/Intermediate/Form.elm
Error on line 12, column 3 to 14
Could not find variable 'Maybe.justs'.
Apparently other examples are in the Intermediate folder are broken, It seems they
are not accessible thru normal navigation. This may be deliberate. In this case, this
issue is a reminder these files are bitrotted
If you take a poke at http://elm-lang.org/blog/announce/version-0.6.elm you can get this result:
1/1/2035 11:00 pm
-> Sun Dec 31 2034 23:00:00 GMT-0500 (EST)
This doesn’t seem to happen before 2035.
I like the sites content but the navigation can be improved.
Navigational links should be present and identical across all elm sites.
They should be no more than ten (if more, we will need menus) with
one word labels (good so far).
Instead of
learn examples docs install
They should be
about try learn examples syntax operators libraries discuss
I have tried to pick the landing pages I go often and I have sometimes
trouble to find.
In the main page, the following laius is unneeded, so are the button that are too low,
so may be under the fold anyway.
"See the examples and learning resources to learn more. Join the elm-discuss list for questions, announcements, and discussion. Press a huge button to get started!"
Probably, the operator pages can be improved. I have no specific suggestion
so far.
list : [Int]
list = 0 :: list -- the compiler allows to write this line
hd = head list -- 0
tl = tail list -- <internal structure>
main = asText (length list) -- Runtime error: Cannot read property 'ctor' of undefined
I've found this bug here: http://elm-lang.org/try
Avoiding forking the whole repo, but on the syntax reference page:
Very minor, fix whenever.
Piling on another distraction, come back when you've got time to kill.
The Escape from Callback Hell article interactive components do not react. The console says that dropTil
is blowing the stack, which is reasonable since it's recursively peeling off a letter. I can't get the page to run locally, hence the absence of a pull request. It will probably take some finagling to get working again, but for starters,
dropTil' str = case String.indexes "[" str of
(i::_) -> String.dropLeft (i+1) str
[] -> str
Also, the libraries link in the second-to-last paragraph 404s. And it says Elm is only in 0.5; your call if you want to try to keep that updated.
http://elm-lang.org/docs/Signal/Signal.elm
http://elm-lang.org/docs/Signal/Time.elm
Your browser may not be supported. Are you using a modern browser?
Runtime Error in Main module:
TypeError: number is not a function
The problem may stem from an improper usage of:
createDocs2
It looks like the Elm compiler is embedding \ue2 into the output, which isn't a valid escape sequence in HTML. As a result, the JavaScript doesn't run.
$ more Main.elm
import Mouse
main = lift asText Mouse.position
$ elm Main.elm
Generating HTML ... Done
$ tail build/Main.html
var Text = Elm.Text.make(_elm);
var Time = Elm.Time.make(_elm);
var _op = {};
var main = A2(Signal\u2elift,
Text\u2easText,
Mouse\u2eposition);
_elm.Main.values = {_op: _op
,main: main};
return _elm.Main.values;
};</script><script type="text/javascript">Elm.fullscreen(Elm.Main)</script>
$ elm --version
0.11
it is just a probelm with my ubuntu..
In the Infix.elm comments, cons is listed as (:) rather than (::).
http://elm-lang.org/edit/examples/Functional/Infix.elm
Overview:
Sometimes it is useful to use an infix operator such as
addition (+) or cons (:) as a function.
When running compile.sh on Mac OS X 10.8, I get the following error:
mv: rename Server to ../Server: Is a directory
and it looks like the executable Server
is clashing with the directory server
. The executable still works from the server directory, but it should probably be changed so it installs cleanly.
In the FAQ, it says
The order of arguments for foldl is deliberately different from Haskell's to improve composability.
However, it's the same:
~ elm-repl
> foldl (+) 0 [1,2,3]
6 : number
>
~ ghci
oλ foldl (+) 0 [1,2,3]
6
λ
Affected page:
http://elm-lang.org/Libraries.elm
Broken links that I noticed:
Dict, Set, Maybe, Either, Http, WebSocket, Window
Originally I was only looking for the docs for Either but then I noticed that several other links were broken as well.
http://library.elm-lang.org/catalog/elm-lang-Elm/0.12.1/Either
says:
'undefined' is not an object (evaluating 'fun.arity')
I cloned the repository and built the project.
On running command,
./run-elm-website
I get the following error.
Initializing Server
run-elm-website: build: getDirectoryContents: does not exist (No such file or directory)
Am I missing something?
This is how new repl announcement page looks in Chrome on my Win8:
Hello! I just downloaded Elm-Platform-0.12.3.pkg from the install page, and installed.
(As a side note: for some reason /usr/local/bin, which I believe did not exist prior since only Elm things are currently in /usr/local, was created without any access for non-superusers. I was able to fix /usr/local/bin's permissions, but it should be created with the right permissions if it doesn't exist and needs to be created.)
With permissions fixed, I tried running the executables, but get errors for all of them.
MacBook-Pro:CODE user$ elm-server
/usr/local/bin/elm-server: line 6: 999 Segmentation fault: 11 /usr/local/bin/elm-server-unwrapped $*
MacBook-Pro:CODE user$ elm HelloWorld.elm
/usr/local/bin/elm: line 6: 1002 Segmentation fault: 11 /usr/local/bin/elm-unwrapped $*
MacBook-Pro:CODE user$ elm-doc
/usr/local/bin/elm-doc: line 6: 1004 Segmentation fault: 11 /usr/local/bin/elm-doc-unwrapped $*
MacBook-Pro:CODE user$ elm-repl
/usr/local/bin/elm-repl: line 6: 1006 Segmentation fault: 11 /usr/local/bin/elm-repl-unwrapped $*
MacBook-Pro:CODE user$ elm-get
/usr/local/bin/elm-get: line 6: 1008 Segmentation fault: 11 /usr/local/bin/elm-get-unwrapped $*
The system is Mac OSX 10.7.3.
The Graphics.Input page says:
"See the walkthrough on Graphics.Input to get a better understanding of how this library works and why it is designed this way."
and the contained link on "the walkthrough on Graphics.Input" just points to:
http://elm-lang.org/
Edit: sorry, didn't realize this isn't the Elm compiler. Please close it.
Consider the following example that consists of two files:
module A where
import B(g)
main = asText g
and
module B(f) where
f = "asdf"
g = "jkl;"
Here the import of identifier g from module B by A should be illegal because B only exports f, but Elm fails to report the error and happily compiles with elm --make
The generated page, however, does not load properly: in this case I've got a page that only reads
<internal structure>
and in other cases I've seen the error
Cannot read property 'arity' of undefined
Open the developer console for more details.
The produced error is, in my opinion, however irrelevant: it is Elm that should detect, report and refuse to compile module A because it tries to import an unexported identifier.
The code lives here. Just need to think of an example that'll work after String
stops being a [Char]
.
Link "A skeleton for making games" in http://elm-lang.org/About.elm is broke
I asked the same basic question on the elm subreddit (link), but that place seems dead, so I'm asking here.
I just build elm-lang.org server on Windows and tried to run it, but the server serves only a blank page. The elm core stylesheets, scripts etc. are there, but content div is empty. Interesting part is that there's normal content inside the tag. I can go to /edit/Elm.elm url and use the editor, but there's no result in the left pane. I get same behaviour for elm-server.
The documentation at Catalog/Elm/Text says that link
has a type signature of String -> Text -> Text
, but my (just-updated) elm-repl
disagrees:
$ elm-repl
Elm REPL 0.2.2.1 <https://github.com/elm-lang/elm-repl#elm-repl>
Type :help for help, :exit to exit
> link
<function> : String -> Element -> Element
Actually attempting to compile with 0.12.1.3 seems to bear out elm-repl
's side of the story. String -> Element -> Element
, if correct, is more sensible anyway!
When looking at simple examples like
http://elm-lang.org/edit/examples/Reactive/TextField.elm
The main source of mystery mights come from the lifting operators (<~) and the .s and $s
Neither of them are mentioned in http://elm-lang.org/learn/Syntax.elm which is where I would expect to find the explanation.
No definitions are listed here:
http://library.elm-lang.org/catalog/evancz-Elm/0.12/Debug
Possibly related to elm/compiler#632?
After following the README instructions:
$ ./dist/build/run-elm-website/run-elm-website
Initializing Server
Unknown flag: --runtime
Unknown flag: --runtime
...
^CUnknown flag: --runtime
run-elm-website: build: getDirectoryContents: does not exist (No such file or directory)
Thanks!
Hi
I have tried to write a new slideshow example:
slideShow (w,h) list =
color black . container w h middle . image 472 315 $ head list
nextImage input list = (tail list) ++ [(head list)]
img = [ "book.jpg", "shells.jpg", "stack.jpg", "car.jpg", "pipe.jpg" ]
imageList = foldp nextImage img (every (4 * second))
main = lift2 slideShow Window.dimensions imageList
I believe that it is a simplified version of the current slideshow example
Br.
Runje
For example in the Password.elm you have "import Graphics.Input.Field as Field" the editor will then not show the docs for things such as Field.password which should be interpreted as Graphics.Input.Field.password.
bug observed long time ago, just never reported. It happened on various configuration (school, home,..).
I already saw it on an other project (not elm-related) where someone fixed it by I don't know which trick (yeah, cool story). The point is that there should be a way to deal with this problem which is visible in a fairly large number of pc.
As usual, thanks very much for making elm. :)
The following code causes an overflow when run by using elm-server (v 0.11).
import Mouse
import WebSocket
import Window
import Keyboard
struct = {word = ""}
update dir table = {table | word = "wtf"} -- notice mistake here: '=' instead of '<-'
main = asText <~ (foldp update struct Keyboard.arrows)
Steps to reproduce:
Parse error at (line 1, column 1):
unexpected end of input
expecting reserved word 'module', reserved word 'import' or at least one datatype or variable definition
It should probably return a 404 status code (instead of 200 OK), and a different message.
I spent some time trying to learn Elm this weekend, and I got stuck trying to understand what the types are supposed to be. For example, I still don't know what type main
is expecting.
Could you please add type signatures to all of the examples, especially the complex examples like Mario.
Thank you.
There is a limitation on how much data can be URL encoded and sent to /compile?input=
The URL is silently truncated and will usually result in a compilation error. Changing Editor.hs to use multipart/form-data for the input might help.
When I press right-click on the demo [1], the context-menu pops up and the boolean value stays 'True' until the next left mouse-click. Chrome Version 27.0.1453.81 beta on 32-bit Ubuntu 12.10.
Line 102:
description = [markdown|See [the walkthrough on `Graphics.Input`](/) to get a better understanding of how this library works and why it is designed this way.|]
In public/docs/Graphics/Input.elm is linking to a (as far as I can tell!) non-existing walkthrough. If I knew where the walkthrough was I would fix the link, but I can't seem to find it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.