Long story short...
Uncaught TypeError: Cannot read property
TypeError: ‘undefined’ is not an object (evaluating
TypeError: null is not an object
(unknown): Script error
TypeError: Object doesn’t support property
TypeError: ‘undefined’ is not a function
Uncaught RangeError
TypeError: Cannot read property ‘length’
Uncaught TypeError: Cannot set property
ReferenceError: event is not defined
Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice", made possible by the Elm compiler's static type checking.
-
They say it just won't catch fire like the javascript forest does.
-
They say it will get you fired because it allows only bug free code and the application will never have a runtime exception.
just as easy as everything else if you used npm before: npm install -g elm
ext install sbrink.elm
Then, in .vscode/settings.json
, add the following:
"elm.compiler": "./node_modules/.bin/elm",
"elm.makeCommand": "./node_modules/.bin/elm-make"
lists useful commands for elm development..
$ elm
Hi, thank you for trying out Elm 0.19.0. I hope you like it!
-------------------------------------------------------------------------------
I highly recommend working through <https://guide.elm-lang.org> to get started.
It teaches many important concepts, including how to use `elm` in the terminal.
-------------------------------------------------------------------------------
The most common commands are:
elm repl
Open up an interactive programming session. Type in Elm expressions like
(2 + 2) or (String.length "test") and see if they equal four!
elm init
Start an Elm project. It creates a starter elm.json file and provides a
link explaining what to do from there.
elm reactor
Compile code with a click. It opens a file viewer in your browser, and
when you click on an Elm file, it compiles and you see the result.
There are a bunch of other commands as well though. Here is a full list:
elm repl --help
elm init --help
elm reactor --help
elm make --help
elm install --help
elm bump --help
elm diff --help
elm publish --help
Adding the --help flag gives a bunch of additional details about each one.
Be sure to ask on the Elm slack if you run into trouble! Folks are friendly and
happy to help out. They hang out there because it is fun, so be kind to get the
best results!
in terminal type elm repl
---- Elm 0.19.0 ----------------------------------------------------------------
Read <https://elm-lang.org/0.19.0/repl> to learn more: exit, help, imports, etc.
--------------------------------------------------------------------------------
>
Information on elm version and a link to the appears, all very helpful so far so good!
by simply adding two numbers > 1+1
we get 2 : number
with a type inference, amazing!
typing 1.5
gives us 1.5 : Float
and > 1.5 +0.5
gives us 2 : Float
so the number 2
may look like an int
but in elm there is no implicit type casting, meaning elm will never do implicit casts.
you are welcome to read more on Elm Implicit Casts in the official documentation.
All strings are in double quotes "a"
> "a"
"a" : String
char can be represented with single quotes 'a'
> 'a'
'a' : Char
>
'a' ++"bb"
-- TYPE MISMATCH ----------------------------------------------------------- elm
The (++) operator cannot append this type of value:
5| 'a' ++"bb"
^^^
I am seeing a character of type:
Char
But the (++) operator is only for appending List and String values. Maybe put
this value in [] to make it a list?
Hint: Only strings and lists are appendable.
> "a"++"pple"
"apple" : String
> "a"+"pple"
-- TYPE MISMATCH ----------------------------------------------------------- elm
I cannot do addition with String values like this one:
4| "a"+"pple"
^^^
The (+) operator only works with Int and Float values.
Hint: Switch to the (++) operator to append strings!
just write a name for it add
followed by arguments a b
and after the =
sign what it will do a + b
it is so simple.
> add a b = a+b
<function> : number -> number -> number
> add 12 8
20 : number