GithubHelp home page GithubHelp logo

elm / compiler Goto Github PK

View Code? Open in Web Editor NEW
7.5K 7.5K 657.0 9.65 MB

Compiler for Elm, a functional language for reliable webapps.

Home Page: https://elm-lang.org/

License: BSD 3-Clause "New" or "Revised" License

Haskell 95.06% Elm 3.45% JavaScript 0.32% Shell 0.16% NSIS 0.53% Batchfile 0.02% CSS 0.15% Python 0.08% Rich Text Format 0.08% Dockerfile 0.08% VBScript 0.07%
compiler elm

compiler's People

Contributors

andys8 avatar apanatshka avatar avh4 avatar boshen avatar brianhicks avatar bsattelb avatar dandandan avatar deadfoxygrandpa avatar dobesv avatar evancz avatar hdgarrood avatar imeckler avatar jfmengels avatar joeyeremondi avatar johnpmayer avatar jsl avatar jvoigtlaender avatar laszlopandy avatar maxsnew avatar mgold avatar michaelbjames avatar ngunn avatar perplexes avatar process-bot avatar sheeo avatar techtangents avatar terezka avatar timthelion avatar vbychkovsky avatar xash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compiler's Issues

combo box don't fit their inner contents on some browers

bug observed long time ago, just never reported. It happens on various configuration (school, home,..).

I already saw this 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. :)

Dict fromList seems to be broken.

Running this sample code on elm 0.6.0.2:

import Dict

dict = fromList [(1,2),(2,3)]
main = asText $ values dict

gives me an error:

ReferenceError: List is not defined

Quick glance into the js console indicates that is has something to do with List namespace in Dict implementation.
I think that we need to find a way to do regression tests for Elm as fast as possible:)

Tuples are still incomparable.

In the update log for 0.6 you stated that tuples are now comperable, but this code:

main = asText $ (1,2) < (1,1)

gives an error:

Type error: (t613,t615) is not a {Char,Date,Float,Int,String} in context `(Tuple2 1) 2' in main

Installation on Mac OSX (update docs)

System properties:

  • Mac OSX Lion
  • cabal-install version 0.10.2
  • Cabal library version 1.10.2.0

I've attempted the first few steps of installing elm, and encountered the following error when running cabal install elm:

cabal: cannot configure happstack-server-7.0.2. It requires blaze-html ==0.5.*
For the dependency on blaze-html ==0.5.* there are these packages:
blaze-html-0.5.0.0. However none of them are available.
blaze-html-0.5.0.0 was excluded because Elm-0.1.0 requires blaze-html ==0.4.*

I then tried installing blaze-html directly, but that resulted in its own set of failures.

If it's not possible to solve these dependency issues, at least a note in the README for Mac OSX users would be good to have.

elm-lang.org does not work in conkeror

The website http://elm-lang.org does not work on the xulrunner based conkeror
(http://www.conkeror.org/) browser. Instead of showing the actual content the
website presents the user with the following error message:
"An Error Occured: Better Messages to come."

conkeror version: 1.0pre (commit
e4c6bf10ad882c623ebccf3937ac44bf79abc432)
xulrunner version: 1.9.2.17
OS: Ubuntu 11.10/12.04

Javascript console output:

Error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://elm-lang.org/elm-mini.js :: anonymous :: line 5" data: no]

Error: document.getElementById("widthChecker") is null
Source File: http://elm-lang.org/elm-mini.js
Line: 26

Random numbers

Can you give me an example of how to do display a random number on the screen?

(I know this is not an issue. I am just trying to understand)

-Thanks
Drew
480-840-5406

collage filled to Window.dimensions falls short

I threw together the following:

background(width, height) = collage width height [ filled black (rect width height (0, 0)) ]
main = lift background Window.dimensions

My handle on the syntax is pretty shaky, but I expected the above pair of lines to cause a solid black collage to fill the browser window. It didn't, only going to about 50% (Chromium 18.0 on Ubuntu 12.04). Apologies if this is just a mistake on my part!

Parse error with unary (-) operator.

There is no unary (-) operator in Elm. I think you are aware of this (I saw usage of (0-1) in the examples) but I think it should be in the issues list for everyone to see and remember. I'll add this to my elm caveats list.

foldr1 uses the wrong item for the base case

foldr1 uses the first item instead of the last item for the base case. For example:

main = plainText $ foldr1 (++) ["1", "2", "3", "4", "5"]

displays:

23451

This is surprising behavior, and contrary to Haskell's foldr1:

> foldr1 (++) ["1", "2", "3", "4", "5"]
"12345"

shakespeare dependency needs minimum version

I had a relatively old version of shakespeare installed, 0.10.2. Upgrading to Elm 0.4.0 failed with the following:

src/Language/Elm/Quasi.hs:93:5:
    Not in scope: `shakespeareFileReload'

Upon upgrading shakespeare to 1.0.1.3, Elm installed with no fuss.

elm compiler option to embed runtime in html file?

I'm really enjoying the work you've done! Being able to sidestep the whole html/js hairball and encapsulate your app entirely in an .elm file is very cool.

One thing that caught me by surprise is the way the html file produced by elm references your local copy of the elm runtime (in my case, deep in my .cabal folder). That means you can't just throw the html file up on a server, or serve your project folder locally with something like python -m SimpleHTTPServer.

I see that there's a switch to let you specify your own path to the runtime, but it would also be nice to have a compiler switch that embeds the whole thing into the html, so it's completely self-contained. It might not be appropriate for larger apps, but for small stuff it would be very handy.

some unclear documentation stuff

1:
layers :: [Element] -> Element
Stack elements on top of each other. -> in which order ? :)

2:
please, tell us type of 'main' function: Either element or signal element, this is super annoying when you take a look at elm for the first time.

3:
Could you add in the doc that Form is actually Canvas ?
Why not to use CanvasForm?

4: can you explicit what those two first 'int' in definition are in the doc?
container :: Int -> Int -> Position -> Element -> Element
Put an element in a container.

readInt and readFloat broken in Elm 0.6

The following program does not work in Elm 0.6:

main = asText (readFloat "1")

Runtime Error in Main module:
ReferenceError: Char is not defined

readInt does not work either

hover signals / position signals

Strange thought about this request.

basically, this can't wok well :

(a, position) = withPositionEvent   (plainText "test")
main = flow down [a,a,a,a]  -- incoherent meaning of position :/, and no way to define hover signal too on previous line

but I would like to be able to write something lke this :

posOfThirdA  = SignalThatWillBeDefinedLaterWithDefault (0,0) 

a = plainText "test"
main = flow down [a,a,withPositionEvent posOfThirdA a,a, asText posOfThirdA  ] 

I wans't able to find a way to do so in the doc

elm fails to compile Pong

The Elm Compiler 0.5.0.2
Pong is at 87eaa91

Error while compiling Pong.elm: Parse error at (line 100, column 5): unexpected "U" expecting "{"

Elm 0.6.0.1 shipping with 0.6 runtime

The cabal\Elm-0.6.0.1 directory contains elm-runtime-0.6.js.
But the compiler generates the following path:
(...)\cabal\Elm-0.6.0.1\elm-runtime-0.6.0.1.js

[JsonObject JsonValue] doesn't act like a list in all instances

I was expecting the result of findArray "foo" json to act like a list. It does sometimes, but not in all instances, leading to some confusing situations.

For instance, this doesn't work:

json = extract res
children = (findArray "children" . findObject "data") json
urls = map (findString "url" . findObject "data") children

urls ends up as a list of empty lists.

It seems the only way to get at the contents of the list in children is by destructuring, as in the flickr search demo. Other list operations like head children don't work either.

Linking pandoc makes Elm "effectively" GPL

Possible solutions:

  • Call pandoc as an executable and don't depend on pandoc in Cabal
  • Use the sundown package instead which is Public Domain and ISC (BSD-like)
  • Change Elm's license to GPL
  • Keep Elm's current license but add notes about how the whole is really GPL

Quicksort explanation

Parenthesised use of infix operators is confusing for first timers. Add explanation!

middleAt is not working

Hi,

This is not working :
container 900 200 (middleAt (relative 0.5) (relative 0.5) ) (plainText "test")

but this is working;
container 900 200 (topLeftAt (relative 0.5) (relative 0.5) ) (plainText "test")

message from chrome
Uncaught ReferenceError: elem is not defined (message from chrome)

Decimal values error

main = asText 10.25

yields this error: Type error: Int is not equal to 111 -> 112

and

main = asText [ 11.5, 20, 21.1 ]

yields this error: Type error: Int is not equal to 125 -> 126

elm-lang.org shows a blank page on IE8 and IE9

Sript debugging screenshot on IE9:

Screenshot

Later the script is stopped at this breakpoint:

catch (e) {Elm.main=function() {var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' 
+ '<br/><span style="color:grey">Runtime Error in Main module:<br/>' + e 
+ '<br/><br/>The problem may stem from an improper usage of:<br/>skeleton</span>');document.body.innerHTML 
= Text.monospace(msg);throw e;};}</script><script type="text/javascript">Dispatcher.initialize()<

elm-lang.org brought down by infinite loop in compiler

I was playing around in elm-lang.org's interactive IDE, trying to make a draggable circle. In particular, I was going for something like this:

dragCircle :: Number -> (Number, Number) -> DragCircle
type DragCircle = (Form, (Number, Number) -> Bool -> DragCircle)
    -- note the infinite type

Then, use foldp and lift2 (,) position isDown to feed the DragCircle automaton.

I ended up crashing the server. I compiled elm-server locally and reproduced the hang and leak. Here's a minimal code sample triggering the leak:

move pos down = rest
rest pos down = if down then move else rest

I suppose such hangs could be avoided using System.Timeout in elm-server, e.g.:

  mhtml <- liftIO . timeout 10000000 . evaluate $ Elm.toHtml libLoc (pageTitle filePath) content

I don't know if happstack-server does anything to time out response generation or not.

Another thing you could do is set the maximum amount of memory the runtime system may allocate, by adding this to the .cabal file:

ghc-options: -rtsopts -with-rtsopts=-M512m

This way, if elm-server blows up again, it doesn't bring the whole system to a crawl.

Installing Elm on Fedora 17

Please help me with installing Elm on Fedora 17. I'm not very familiar with ghc and cabal. I tried installing the ghc and cabal packages provided by the Fedora repositories. Unfortunately they seem to be too old, it seems to be 2011.4.0.0-6.

Is there any way to update my ghc installation?
Are there any Fedora users here?

Module system bugs when using elm --make

I ran into some show-stopping bugs in the module system of Elm 0.4.0.1:

  • Modules do not export anything by default, contrary to the Elm 0.3 announcement. Saying module Foo where does not export any functions, whereas module Foo (foo) where does.

  • The module Foo (ADT(..)) syntax is not supported. Instead, one must say module Foo (ADT, A, B), where A and B are the data constructors. This is unintuitive for someone used to Haskell.

  • Importing some system modules doesn't work when building with --make. If I import Graphics.Element, I get:

    elm: Graphics/Element.elm: openFile: does not exist (No such file or directory)
    

    However, import Signal.Mouse does work.

The first two issues are annoying, but make the module system unusable to one who doesn't know the workarounds. The third issue is more serious, since it means an application divided into modules loses access to a lot of good functionality (unless there's some tricky command to import Graphics/Element.js directly)

These issues should be easy to reproduce using elm --make. If they aren't, let me know.

cabal refuses to install elm package

$ cabal install elm
Warning: Falling back to topdown solver for GHC < 7.
Resolving dependencies...
cabal: dependencies conflict: base-3.0.3.2 requires an installed instance of
syb ==0.1.0.2 however:

The output is truncated, so maybe this is actually a cabal bug?

If Elm needs a newer GHC it should mention it on the installation page.

Elm lacks String -> Number (and Number -> String) functions

Elm does not seem to have a built-in function for converting a string to a number. I don't think it has a function for converting a number to a string, either (e.g. plainText $ show n ++ " bottles of beer on the wall").

To address the former, we could add the following functions, perhaps to Prelude, Foreign.JavaScript, or even a new "Numeric" module.

parseInt     :: String -> Maybe Int
parseIntBase :: Int -> String -> Maybe Int
parseFloat   :: String -> Maybe Float

Here is the corresponding JavaScript. We must be careful not to shadow the system parseInt and parseFloat when defining our functions.

function parseIntBase(base) {
    return function(str) {
        var n = parseInt(castStringToJSString(str), base);
        return isNaN(n) ? Nothing : Just(n);
    };
}

...

return {
    parseInt:     parseIntBase(10),
    parseIntBase: parseIntBase,
    parseFloat: function(str) {
        var n = parseFloat(castStringToJSString(str));
        return isNaN(n) ? Nothing : Just(n);
    }
};

Would something like this be good? Or did you have bigger plans, like a read function whose return type determines behavior.

implementation of fittedImage prevents animated gifs from working

I think redrawing the image in canvas is what causes it.

Maybe a good solution would be to add a third function to go along with image and fittedImage. It would resize the image to fit within a bounding box while preserving aspect ratio, but not do any cropping (removing the need to redraw the image).

Support type classes

As a driving example, the Dict class doesn't make sense without typeclasses. Right now, it's unclear how exactly the Dict implementation gets the "compare" function - it looks like duck typing.

Without type classes, passing in an Ord instance is preferable to duck typing.

e.g.
instead of:
singleton :: k -> v -> Dict k v

do this:
data Ordering = LT | EQ | GT
data Ord a = Ord (a -> Ordering)
singleton :: Ord k -> k -> v -> Dict k v

Alternatives include generalised implicit parameters.

I think, given Elm's Haskell heritage, Haskell-style type classes would be nice.

bug with texFields

import Input
import Color
(a,b) = textField "trololo"
main = flow down [plainText "test", color red a,a,a,a,a,plainText "test"]

gives a surprising result

String.fromCharCode is missing in Elm.Char.fromCode

The issue is that the String.js code creates a var String, which is captured by Elm.Char in place of the builtin String. I first noticed this because the Key Presses example is broken.

I have fixed it by capturing String by reference, before it is replaced, as below, but this will not work if code is reordered.

Elm.Char = function(String) {
    // Elm.Char
}(String);

Other solutions might be Elm's namespacing String or adding fromCharCode to it, but since I've been looking at Elm for all of half an hour, I'll leave you without a recommendation.

Support custom line thickness

Elm currently does not let you set the thickness of a line. Actually, you can make thick lines using scale, but you have to tweak your coordinates.

I suppose the API could be this:

thickness :: Number -> Form -> Form

This would set the thickness of lines, both for polygon edges (coming from Shape) and line paths (coming from Line).

While we're at it, it would be nice if line and segment returned a Form instead of a Line. It's annoying to have to specify the style and color of a line just to get it on the page:

main = collage 500 500
   [ solid black $ segment (0,0) (100, 100)
   ]

I'd rather just say:

main = collage 500 500
   [ segment (0,0) (100, 100)
   ]

and have it default to a solid black line.

I would tackle this, but Element.js looks like it came from a code generator. Do you have the original Elm source, or do you just tweak the generated code now?

[cabal hell] Elm is incompatible with current Yesod version

Since 0.5.0.2 Elm.cabal has introduced an upper version limit on pandoc (<=1.9.4.2)
The commit: 3bbb984

The problem is you can't install both Elm-0.5.0.2 (which requires base64-bytestring-0.1.2.0)
and elm-yesod-0.1.3 + yesod-platform-1.1.5 (requires base64-bytestring-1.0.0.0)

p.s.
As a workaround i stick to Elm-0.5.0.1 which doesn't limit the pandoc's upper version.
(Still elm-yesod-0.1.3 won't compile, but this is a topic for another issue: tazjin/elm-yesod#2)

toForm is not documented (and a bit illogical I think)

toForm :: (Number,Number) -> Element -> Form
Turn any Element into a Form

There is no way to find out that the middle of the element will be placed at Number, Number
except trial and error or examples.

also, wouldn't it be better to put the corner at (Number, Number) ?

elm-server

Running the server gives an error when I load up a .elm page:

Elm Server 0.3.5: running at <http://localhost:8000>
HTTP request failed with: shutdown: invalid argument (Socket is not connected)

Parse error with function composition operator.

I wanted to use some point-free style in Elm and I wrote this little function:

cell = ((filled (rgb 64 64 64) .) .) . rect

Unfortunately running this code results in a parsing error.

I made a few additional tests to learn more about what is happening:

comp f g = \x -> f (g x)
cell = ((filled (rgb 64 64 64) `comp`) `comp`) . rect

This still doesn't work, but the one below is fine:

cell = (comp (comp (filled (rgb 64 64 64)))) `comp` rect

I think there's a little syntax issue here involving infix operators.

On a side note - is there any documentation on Elm syntax?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.