在Elm lang中嵌入其他模块视图

在Elm lang中嵌入其他模块视图,elm,Elm,我如何在某个地方使用此应答列表,以便正确地处理事件?我已经为此挣扎太久了:/ module AnswersList (Model, Action, update, view, Answer) where import Html exposing (..) import Html.Events exposing (onClick) import Html.Attributes exposing (class) type alias Answer = { id : Int , a

我如何在某个地方使用此应答列表,以便正确地处理事件?我已经为此挣扎太久了:/

module AnswersList (Model, Action, update, view, Answer) where

import Html exposing (..)
import Html.Events exposing (onClick)
import Html.Attributes exposing (class)

type alias Answer =
    { id : Int
    , answer : String
    , points : Int
    , visible : Bool
    }

type alias Model = List Answer

-- actions
type Action = ShowAnswer Int

update action model =
  case action of
    ShowAnswer aid ->
      let newAnswer a = if a.id == aid then { a | visible <- True } else a
      in
        List.map newAnswer model

-- view

view : Signal.Address Action -> Model -> Html
view address model =
      div [class "list-group"]
      (List.map (viewAnswer address) model)

viewAnswer : Signal.Address Action -> Answer -> Html
viewAnswer address answer =
  let answerText = if answer.visible then answer.answer else "........"
  in
    div [class "list-group-item", onClick address (ShowAnswer answer.id) ] [text answerText]

我想把事件传递给应答列表。更新会以某种方式处理它们。

好的,我真正需要的是这个例子,是的,它完全有意义:)

model = { answers: AnswerList.model }