2

我对 Haskell 和 Gtk2Hs 有一个奇怪的错误。

我尝试在文本条目中设置光标位置

set entree [entryCursorPosition := 5 ]

对应于类型

entryCursorPosition :: EntryClass self => ReadAttr self Int

我有以下错误:

Couldn't match expected type `()' with actual type `Int'

你认为这是一个错误吗?你知道怎么解决吗?

我在我的 Debian Wheezy 上使用 Gtk2Hs 0.12.3 和 GHC 7.4.1。

此致。

4

2 回答 2

6

正如您所说,entryCursorPositionis a ReadAttr,这意味着它不能被写入。在内部,

type ReadAttr o a = ReadWriteAttr o a ()

因此 aReadAttr被实现为具有 "read type"a和 "write type"的属性()。这解释了您看到的错误消息,因为您尝试将其设置为 aInt而不是 a ()

于 2015-02-03T21:43:59.917 回答
0

I made a mistake entryCursorPosition is a read only attribut and can't be set.

The correct function to set the cursor position in a entry is :

editableSetPosition entry (-1)

Hoping it will be helpfull

于 2015-02-04T19:06:12.957 回答