相关疑难解决方法(0)

混合 Threepenny-Gui 和 StateT

我有一个关于 Threepenny-Gui 与 StateT 交互的问题。考虑这个玩具程序,每次单击按钮时,都会在列表中添加一个“Hi”项:

import           Control.Monad
import           Control.Monad.State

import qualified Graphics.UI.Threepenny      as UI
import           Graphics.UI.Threepenny.Core hiding (get)

main :: IO ()
main = startGUI defaultConfig setup

setup :: Window -> UI ()
setup w = void $ do
  return w # set title "Ciao"
  buttonAndList <- mkButtonAndList
  getBody w #+ map element buttonAndList

mkButtonAndList :: UI [Element]
mkButtonAndList = do
  myButton <- UI.button # set text "Click me!"
  myList <- UI.ul
  on UI.click myButton $ \_ -> element myList …
Run Code Online (Sandbox Code Playgroud)

haskell state-monad monad-transformers threepenny-gui

2
推荐指数
1
解决办法
292
查看次数