
As many people guess, I am trying to port programs from Clean 1.3 to Haskell (and also to Clean 2.2, which is easier, but not much easier). Late Professor Wellesley wrote an interesting data base manager in Clean 1.3 that I would like to see in Haskell and Clean 2.2. However, when I tried to implement the BTree algorithm, GHC compiler did not accept hSeek and other IO operations. D:\Programs\GHC-PROGS\docs\textut>ghc btree.hs --make [1 of 1] Compiling Main ( btree.hs, btree.o ) Linking btree.exe ... D:\Programs\GHC-PROGS\docs\textut>btree.exe btree.exe: teste.txt: hSeek: illegal operation (seek operations on text-mod dles are not allowed on this platform) To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files. __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com.

Hi Philippos,
The secret is there in the error message: "seek operations on
text-moddles are not allowed on this platform"
You need to set your file in to binary mode, with hSetBinaryMode
(http://haskell.org/hoogle/?hoogle=hSetBinaryMode) or openBinaryFile
(http://haskell.org/hoogle/?hoogle=openBinaryFile). After doing that
hSeek will work.
Thanks, Neil
On Sun, Nov 1, 2009 at 8:44 PM, Philippos Apolinarius
As many people guess, I am trying to port programs from Clean 1.3 to Haskell (and also to Clean 2.2, which is easier, but not much easier). Late Professor Wellesley wrote an interesting data base manager in Clean 1.3 that I would like to see in Haskell and Clean 2.2. However, when I tried to implement the BTree algorithm, GHC compiler did not accept hSeek and other IO operations.
D:\Programs\GHC-PROGS\docs\textut>ghc btree.hs --make [1 of 1] Compiling Main ( btree.hs, btree.o ) Linking btree.exe ...
D:\Programs\GHC-PROGS\docs\textut>btree.exe btree.exe: teste.txt: hSeek: illegal operation (seek operations on text-mod dles are not allowed on this platform)
To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files.
________________________________ All new Yahoo! Mail - Get a sneak peak at messages with a handy reading pane. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Sun, Nov 1, 2009 at 9:44 PM, Philippos Apolinarius
To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files.
The reason it fails to run is because, on windows, there isn't a one-to-one mapping between characters and bytes on text files. You have to use binary mode, in which case you're likely to see doubled newlines - \r\n, or the other way around, I don't remember. Which brings up the interesting question of how this works in 6.12, which has text support for modes that are 1:N on /all/ platforms; e.g. UTF-8. If hSeek works there, then chances are it'll work in text mode on windows as well. -- Svein Ove Aas
participants (3)
-
Neil Mitchell
-
Philippos Apolinarius
-
Svein Ove Aas