Haskell 尝试测试三便士gui时出错

Haskell 尝试测试三便士gui时出错,haskell,threepenny-gui,Haskell,Threepenny Gui,我想为haskell试用三便士gui软件包。 所以我跑了 。。。没有任何问题 因此,我尝试了以下示例: module Main where import qualified Graphics.UI.Threepenny as UI import Graphics.UI.Threepenny.Core main :: IO () main = do startGUI defaultConfig setup setup :: Window ->

我想为haskell试用三便士gui软件包。 所以我跑了

。。。没有任何问题

因此,我尝试了以下示例:

module Main where

import qualified Graphics.UI.Threepenny as UI
import                  Graphics.UI.Threepenny.Core

main :: IO ()
main = do
    startGUI defaultConfig setup

setup :: Window -> IO ()
setup window = do
    return window # set UI.title "Hello World!" 

    button <- UI.button # set UI.text "Click me!"
    getBody window #+ [element button]

    on UI.click button $ const $ do
        element button # set UI.text "I have been clicked!"
但是我得到一个关于类型的错误:

threePennyHelloWorld.hs:8:28:
    Couldn't match type `IO ()' with `UI ()'
    Expected type: Window -> UI ()
      Actual type: Window -> IO ()
    In the second argument of `startGUI', namely `setup'
    In a stmt of a 'do' block: startGUI defaultConfig setup

threePennyHelloWorld.hs:12:25:
    Couldn't match type `UI Window' with `IO a0'
    Expected type: UI Window -> IO a0
      Actual type: UI Window -> UI Window
    In the second argument of `(#)', namely `set title "Hello World!"'
    In a stmt of a 'do' block: return window # set title "Hello World!"

threePennyHelloWorld.hs:14:31:
    Couldn't match type `UI Element' with `IO Element'
    Expected type: UI Element -> IO Element
      Actual type: UI Element -> UI Element
    In the second argument of `(#)', namely `set text "Click me!"'
    In a stmt of a 'do' block:
      button <- UI.button # set text "Click me!"

threePennyHelloWorld.hs:15:9:
    Couldn't match type `UI' with `IO'
    Expected type: IO Element
      Actual type: UI Element
    In a stmt of a 'do' block: getBody window #+ [element button]
    In the expression:
      do { return window # set title "Hello World!";
           button <- UI.button # set text "Click me!";
           getBody window #+ [element button];
           on UI.click button
           $ const $ do { element button # set text "I have been clicked!" } }
    In an equation for `setup':
        setup window
          = do { return window # set title "Hello World!";
                 button <- UI.button # set text "Click me!";
                 getBody window #+ [element button];
                 .... }

threePennyHelloWorld.hs:17:9:
    Couldn't match type `UI' with `IO'
    Expected type: IO ()
      Actual type: UI ()
    In a stmt of a 'do' block:
      on UI.click button
      $ const $ do { element button # set text "I have been clicked!" }
    In the expression:
      do { return window # set title "Hello World!";
           button <- UI.button # set text "Click me!";
           getBody window #+ [element button];
           on UI.click button
           $ const $ do { element button # set text "I have been clicked!" } }
    In an equation for `setup':
        setup window
          = do { return window # set title "Hello World!";
                 button <- UI.button # set text "Click me!";
                 getBody window #+ [element button];
                 .... }
即使当我试图运行一个示例文件时,我也会遇到同样的错误


有人知道我做错了什么吗?

安装程序在UI monad中,而不是IO中,因此更改类型声明:

setup :: Window -> UI()

例如在

中,整个错误只是说您编写了IO,但您指的是UI。非常感谢。。。我现在觉得有点傻。我本应该看到这一点,但因为我是在一个教程之后写的,所以我有点困惑。
setup :: Window -> UI()