2

I have a strange error with Haskell and Gtk2Hs.

I try to set the cursor position in a text entry with

set entree [entryCursorPosition := 5 ]

which correspond to the Type

entryCursorPosition :: EntryClass self => ReadAttr self Int

and I have the following error :

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

Do you think it's a bug ? Do you know how to solve it?

I'm using Gtk2Hs 0.12.3 on my Debian Wheezy with GHC 7.4.1.

Best Regards.

JeanJouX
  • 2,555
  • 1
  • 25
  • 37

2 Answers2

6

As you state yourself, entryCursorPosition is a ReadAttr, which means it cannot be written. Internally,

type ReadAttr o a = ReadWriteAttr o a ()

So a ReadAttr is implemented as an attribute that has "read type" a, and "write type" (). This explains the error message you see, because you try to set it to an Int instead of a ().

kosmikus
  • 19,549
  • 3
  • 51
  • 66
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

JeanJouX
  • 2,555
  • 1
  • 25
  • 37