Mat*_*att 20 gtk haskell cabal c2hs
我正在尝试通过cabal安装gtk,但是,在构建它时我遇到了以下类型错误
[ 22 of 209] Compiling Graphics.UI.Gtk.Embedding.Plug ( dist/build/Graphics/UI/Gtk/Embedding/Plug.hs, dist/build/Graphics/UI/Gtk/Embedding/Plug.o )
Graphics/UI/Gtk/Embedding/Plug.chs:120:6: error:
Couldn't match expected type ‘Ptr ()’
with actual type ‘Maybe DrawWindow’
In the first argument of ‘gtk_plug_new’, namely
‘(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
In the second argument of ‘($)’, namely
‘gtk_plug_new
(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
Graphics/UI/Gtk/Embedding/Plug.chs:137:6: error:
Couldn't match expected type ‘Ptr ()’
with actual type ‘Maybe DrawWindow’
In the second argument of ‘\ (Display arg1) arg2
-> withForeignPtr arg1
$ \ argPtr1 -> gtk_plug_new_for_display argPtr1 arg2’, namely
‘(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
In the second argument of ‘($)’, namely
‘(\ (Display arg1) arg2
-> withForeignPtr arg1
$ \ argPtr1 -> gtk_plug_new_for_display argPtr1 arg2)
display
(fromNativeWindowId (fromMaybe nativeWindowIdNone socketId))’
Graphics/UI/Gtk/Embedding/Plug.chs:151:3: error:
Couldn't match type ‘Ptr ()’ with ‘Maybe DrawWindow’
Expected type: IO (Maybe DrawWindow)
Actual type: IO (Ptr ())
In the second argument of ‘($)’, namely
‘(\ (Plug arg1)
-> withForeignPtr arg1 $ \ argPtr1 -> gtk_plug_get_id argPtr1)
(toPlug self)’
In the expression:
liftM toNativeWindowId
$ (\ (Plug arg1)
-> withForeignPtr arg1 $ \ argPtr1 -> gtk_plug_get_id argPtr1)
(toPlug self)
Failed to install gtk-0.13.9
cabal: Error: some packages failed to install:
gtk-0.13.9 failed during the building phase. The exception was:
ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
要安装此软件包,您需要"gtk2hsC2hs",类型错误在.chs文件中,大概是从gtk2hsC2hs工具生成的.这是gtk2hsC2hs的已知问题吗?有没有其他人能够建立这个包?有人知道解决方案吗?
我在Mac OS X Yosemite上(10.10.4)
$ gtk2hsC2hs --version
C->Haskell Compiler, version 0.13.13 (gtk2hs branch) "Bin IO", 27 May 2012
$ cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library
Run Code Online (Sandbox Code Playgroud)
我做了一个cabal update,所以我的所有包看起来都是最新的.我也试过构建hackage提供的一些旧版本,但是我遇到了同样的错误.
编辑
生成的文件中的错误似乎都处理由gtk2hsC2hs生成的FFI导入.在文件的底部,我得到了
foreign import ccall unsafe "gtk_plug_new"
gtk_plug_new :: ((Ptr ()) -> (IO (Ptr Widget)))
Run Code Online (Sandbox Code Playgroud)
它似乎始终Ptr()与之混淆Maybe DrawWindow.那么生成的类型是Ptr()不正确的,还是使用它不正确?
Mat*_*att 21
这有一个非常简单的解决方案.
cabal install gtk -fhave-quartz-gtk
Run Code Online (Sandbox Code Playgroud)
如果记录得更好,那将是很好的,但希望这将有助于其他任何最终处于类似情况的人