elm - Looping over a list to create elements -


this seems set correct, not , cannot see it's going wrong. i'm trying loop on "list of objects" , create ul lis each item in list , put inside of div. ignore involving id. have feeling i'm not entirely sure how list.map returns.

type alias product =   { : string   , b : string   , c : int   , d : string   , e : string   }  type alias model =   { id : string   , products : list product}  view : model -> html msg view model =   div []     [ input [ type' "text", oninput updatetext ] []     , button [ type' "button", onclick getproduct ] [ text "search" ]     , br [] []     , code [] [ text (tostring model.products) ]     , div [] [ renderproducts model.products ]     ]  renderproduct product =   let     children =       [ li [] [ text product.a ]        , li [] [ text product.b ]        , li [] [ text (tostring product.c) ]        , li [] [ text product.d ]        , li [] [ text product.e ] ]   in     ul [] children  renderproducts products =   list.map renderproduct products 

the error follows:

the 2nd argument function `div` causing mismatch.    78|       div [] [ renderproducts model.products ]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `div` expecting 2nd argument be:    list (virtualdom.node a)  is:    list (list (html a)) 

renderproducts returns list of elements. second parameter of div takes list of elements. enclosing second parameter in brackets, creating list containing single list of elements. that's why error message says

but is:      list (list (html a)) 

you should instead this:

div [] (renderproducts model.products) 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -