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

Embeding other module view in Elm lang

如何在某处使用此 AnswerList 以便正确处理事件?我已经为此苦苦挣扎了太久:/

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]

现在在其他模块视图中,我想简单地添加一些 AnswersList 来查看,但我不知道如何实现它:/ 你能帮我吗?

我还有一些其他模块

model = { answers: AnswerList.model }

我想将事件传递给 AnswerList.update 将以某种方式处理它们。

好的,我真正需要的是这个例子 https://github.com/evancz/elm-architecture-tutorial/blob/master/examples/2/CounterPair.elm from https://github.com/evancz/elm-architecture-tutorial 是的,它完全有道理 :)