Bug by Nestor Ferraro / CC BY 2.0
Once it compiles, it just works!
Speed by snapp3r / CC BY-ND 2.0
import Html
main = Html.text "Hello Stuttgart!"
import Html
greet str = Html.text str
main =
greet "Hello Stuttgart!"
import Html exposing (Html)
greet : String -> Html
greet str =
Html.text str
main : Html
main =
greet "Hello Stuttgart!"
import Html exposing (Html)
import String
greet : Int -> String -> Html
greet number string =
Html.text
(String.repeat number string)
main : Html
main =
greet 3 "Hello Stuttgart! "
greet : Int -> String -> Html
greet number string =
string
|> String.repeat number
|> Html.text
main : Html
main =
greet 3 "Hello Stuttgart! "
import Html exposing (Html)
import Mouse
toHtml : Int -> Html
toHtml x =
Html.text (toString x)
main : Signal Html
main =
Signal.map toHtml Mouse.x
merge
multiple signalsmap
signals (transform each value)filter
signals (drop events)
myFunction str =
String.repeat 3 str
main : Html
main =
Html.text (myFunctino "Elm")
-- NAMING ERROR ----------------------- errors/Spelling.elm
Cannot find variable `myFunctino`
9│ Html.text (myFunctino "Elm")
^^^^^^^^^^
Maybe you want one of the following?
myFunction
subMismatch =
{ name = "Alice", age = 24 } == { name = "Bob", age = "30" }
-- TYPE MISMATCH --------------------- errors/SubMismatch.elm
The right argument of (==) is causing a type mismatch.
2│ { name = "Alice", age = 24 } == { name = "Bob", age = "30" }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(==) is expecting the right argument to be a:
{ ..., age : number }
But the right argument is:
{ ..., age : String }
type Colour = Red | Green | Blue
colourToHex : Colour -> String
colourToHex colour =
case colour of
Red -> "#f00"
Green -> "#0f0"
-- MISSING PATTERNS --------------- errors/ForgottenCase.elm
This `case` does not have branches for all possibilities.
5│> case colour of
6│> Red -> "#f00"
7│> Green -> "#0f0"
You need to account for the following values:
Main.Blue
Add a branch to cover this pattern!
function repeatFirst(list) {
var repeated = list[0].repeat(3);
alert(repeated);
}
var list1 =
[ 'hip', 'hop', 'hooray!' ];
...
repeatFirst(list1);
var list2 = [];
...
repeatFirst(list2);
repeatFirst list =
let elem = List.head list
in String.repeat 3 elem
> elm-make RepeatFirst.elm --output repeat-first.html
-- TYPE MISMATCH -------------------------- RepeatFirst.elm
The 2nd argument to function repeat is causing a mismatch.
8│ String.repeat 3 elem
^^^^
Function `repeat` is expecting the 2nd argument to be:
String
But it is:
Maybe a
Hint: I always figure out the type of arguments from left
to right. If an argument is acceptable when I check it, I
assume it is "correct" in subsequent checks. So the problem
may actually be in how previous arguments interact with the
2nd.
repeatFirst list =
let elem = List.head list |> Maybe.withDefault ""
in String.repeat 3 elem
> elm-make RepeatFirst.elm --output repeat-first.html
Success! Compiled 1 modules.
Successfully generated repeat-first.html
clickCount : Signal Int
clickCount =
let
foldFn : () -> Int -> Int
foldFn click total = total + 1
in
Signal.foldp foldFn 0 Mouse.clicks
main : Signal Html.Html
main =
Signal.map toHtml clickCount