Haskell 图表Gtk呈现失败

Haskell 图表Gtk呈现失败,haskell,plot,charts,Haskell,Plot,Charts,我正在使用Haskell和Chart模块。 在活动GTK窗口中没有用于渲染的文档。所以我自己试着: import Graphics.Rendering.Chart.Easy import Graphics.Rendering.Chart.Gtk signal :: [Double] -> [(Double,Double)] signal xs = [ (x,(sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))) | x <- xs ]

我正在使用
Haskell
Chart
模块。 在活动
GTK
窗口中没有用于渲染的文档。所以我自己试着:

import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Gtk

signal :: [Double] -> [(Double,Double)]
signal xs = [ (x,(sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))) | x <- xs ]

main = renderableToWindow def 300 300 $ do
    layout_title .= "Amplitude Modulation"
    setColors [opaque blue, opaque red]
    plot (line "am" [signal [0,(0.5)..400]])
    plot (points "am points" (signal [0,7..400]))

现在我的问题是:如何进行正确的GTK渲染?

renderableToWindow
具有类型

renderableToWindow :: Renderable a -> Int -> Int -> IO ()
。。。因此,它不会将您试图传递的
EC
计算作为最后一个参数。我认为最简单的解决方案是使用,它将以默认状态运行
EC
计算,将其结果转换为
Renderable
,并将其传递给
renderableToWindow

toWindow::(默认r,可读取r)=>Int->Int->EC r()->IO()


谢谢完美的解决方案。
renderableToWindow :: Renderable a -> Int -> Int -> IO ()
main = toWindow 300 300 $ do
    layout_title .= "Amplitude Modulation"
    setColors [opaque blue, opaque red]
    plot (line "am" [signal [0,(0.5)..400]])
    plot (points "am points" (signal [0,7..400]))