Hi there,

I'm pretty new to elm and I'm facing an issue I can't resolve by myself...

I would like to display a text entered in a textbox by clicking on a 
button. But elm detects an error with the definition of view. It says :

---------

Detected errors in 1 module.


-- TYPE MISMATCH 
---------------------------------------------------------------

The type annotation for `view` does not match its definition.

26| view: String -> Html a
          ^^^^^^^^^^^^^^^^
The type annotation is saying:

    String -> Html a

But I am inferring that the definition has this type:

    String -> Html (String -> Msg)

Hint: A type annotation is too generic. You can probably just switch to the 
type
I inferred. These issues can be subtle though, so read more about it.
<https://github.com/elm-lang/elm-compiler/blob/0.17.0/hints/type-annotations.md>

-----------

I really don't know what to do. If you can please explain how to resolve 
this, because I can't find anything that helps... Thanks for your time!

Here is the code I wrote in http://elm-lang.org/try :

import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)

main =
  App.beginnerProgram {
    model = init "",
    update = update,
    view = view
  }

init : String -> String
init str =
  str

type Msg = UpdateModel String

update: Msg -> String -> String
update action model =
  case action of
    UpdateModel newModel ->
      newModel
      
view: String -> Html a
view model =
  div[]
  [
    input[type' "text", placeholder "Please enter a name..."][]
   ,button [onClick UpdateModel][text "Ajouter"] 
   ,div[][text model]
  ]

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to