Model -> html Model

i try to learn ELM and I code program which do this operation :
12 : 1+2+12 = 15
15 : 1+5+15 = 21
i try to add a function to do iteration, for exemple for :
output = 12, iteration = 2
12: 1+2+12 = 15 / 15 : 1+5 + 15 = 21
output =21

I have problem with my view Model β†’ html Model
this is code in ELLIE :

thank you

lets go step by step:

the type of your view function is:

view : Model -> Html Msg

This means that it takes a Model type as the input and outputs a Html Msg type

I cannot find a `input` variable

the compiler is telling you it can’t find input - that is because you did not import it! You have 2 possibilities:

-- inport the html input element
import Html exposing (Html, button, div, text, input)


-- use it strait from the module
Html.input [] []

Notice above that Html.input is a function that takes 2 arguments, its signature is:

input : List (Attribute msg) -> List (Html msg) -> Html msg

it takes a list of attributes Attribute msg and a list of Html nodes Html msg, notice that the msg starts with a small letter - this means that it could be anything - any message!

You are also using placeholder, id attributes without importing them, I would suggest you use Attr.placeholder since you did this at the top:

import Html.Attributes as Attr

From the code I suggest you go thru the elm guide and also open the main packages like:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.