我在 miso 示例应用程序中添加了单选按钮:https ://gist.github.com/razvan-flavius-panda/913c1e1c2a12ebd33eb33e6efb55dafe#file-main-hs-L46-L49
-- | Haskell language pragma
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
-- | Haskell module declaration
module Main where
-- | Miso framework import
import Miso
import Miso.String
import Language.Javascript.JSaddle.Warp as JSaddle
import Control.Monad.IO.Class (liftIO)
-- | Type synonym for an application model
type Model = Int
-- | Sum type for application events
data Action
= NoOp
| Install
deriving (Show, Eq)
-- | Entry point for a miso application
main :: IO ()
main = JSaddle.run 8080 $ startApp App {..}
where
initialAction = NoOp -- initial action to be executed on application load
model = 0 -- initial model
update = updateModel -- update function
view = viewModel -- view function
events = defaultEvents -- default delegated events
subs = [] -- empty subscription list
mountPoint = Nothing -- mount point for application (Nothing defaults to 'body')
-- | Updates model, optionally introduces side effects
updateModel :: Action -> Model -> Effect Action Model
updateModel NoOp m = noEff m
updateModel Install m = m <# do
liftIO (putStrLn "Hello World") >> pure NoOp
-- | Constructs a virtual DOM from a model
viewModel :: Model -> View Action
viewModel x = div_ [] [
label_ [] [ text "Editor / IDE" ]
, br_ []
, label_ [] [ text "Atom" ]
, input_ [ type_ "radio", name_ "editor", value_ "Atom" ]
, label_ [] [ text "Visual Studio Code" ]
, input_ [ type_ "radio", name_ "editor", value_ "VSCode", disabled_ True ]
, br_ []
, text (ms x)
, button_ [ onClick Install ] [ text "Install" ]
]
我需要进行哪些更改才能读取updateModel Install m
函数内所选单选按钮的状态?