hGetContents bug?
If I open a file using "openFile" from the IO module (x <- openFile "foo.txt" ReadMode) and convert it to a String via hGetContents (y <- hGetContents x) and finally try to print the file on the screen (putStrLn y) I'll get a strange result if the file contains the character 1A-hexadecimal (or 26-decimal): all characters beyond this point won't be printed on the screen. If I use openFileEx (from IOExts module) rather than openFile, some characters will be printed after the 1A/26, but not all of them. I know this special character is related to EOF or something like that in Windows platforms, but is this the expected behavior of function hGetContents? (please reply to both the list AND me) Thanks, -- Andre Furtado ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: No type lib generated by hdirect
Hi Patrick. This is probably because you need to build HDirect in two stages - once without typelibrary support, and once with. Here is the process I used to build HDirect 0.17 with ghc 4.08 under NT (much is probably irrelevant as I think some of these problems have been sorted by Sigbjorne): Building HDIrect 0.17 - Uninstall previous versions of HDirect including "lib/imports/com" and associated libraries, which don't work very well with GHC 4.08.2. - Get the source from the HDirect web site and untar it somewhere. - You may need to edit "lib/WideStringSrc.c" if you use the latest Cygwin distribution to remove a clashing definition and declaration of wcslen(). - Build per the instructions in the INSTALL file. - This gives you a bare bones ihc.exe which cannot handle type libraries. - Install the freshly built lib/*.hi files in a new ghc "lib/imports/com" directory and also the libraries (libHScom.a, libhdirect.a) into ghc's "lib" directory. - Do "make clean", deleting "src/ihc.exe" by hand. - Set SUPPORT_TYPELIBS=YES in "src/Makefile" - "make boot", "make", then "make lib" as before. - You now have version 0.17 of HDirect for Windows. Regards Mike Thomas. - Original Message - From: "Lehti, Patrick " <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 10, 2001 7:47 PM Subject: No type lib generated by hdirect > I am trying to build a Haskell COM component with HDirect (from > http://www.galconn.com/~sof/hdirect-0.18-src.tar.gz) and "ghc 5.02". I have > problems generating the type library: it is simply not created. Even the > comserv example is not working because of the same problem. Could that be a > bug in that HDirect version? > > Patrick > > ___ > Glasgow-haskell-users mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: No type lib generated by hdirect
Hi Patrick. This is probably because you need to build HDirect in two stages - once without typelibrary support, and once with. Here is the process I used to build HDirect 0.17 with ghc 4.08 under NT (much is probably irrelevant as I think some of these problems have been sorted by Sigbjorne): Building HDIrect 0.17 - Uninstall previous versions of HDirect including "lib/imports/com" and associated libraries, which don't work very well with GHC 4.08.2. - Get the source from the HDirect web site and untar it somewhere. - You may need to edit "lib/WideStringSrc.c" if you use the latest Cygwin distribution to remove a clashing definition and declaration of wcslen(). - Build per the instructions in the INSTALL file. - This gives you a bare bones ihc.exe which cannot handle type libraries. - Install the freshly built lib/*.hi files in a new ghc "lib/imports/com" directory and also the libraries (libHScom.a, libhdirect.a) into ghc's "lib" directory. - Do "make clean", deleting "src/ihc.exe" by hand. - Set SUPPORT_TYPELIBS=YES in "src/Makefile" - "make boot", "make", then "make lib" as before. - You now have version 0.17 of HDirect for Windows. Regards Mike Thomas. - Original Message - From: "Lehti, Patrick " <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 10, 2001 7:47 PM Subject: No type lib generated by hdirect > I am trying to build a Haskell COM component with HDirect (from > http://www.galconn.com/~sof/hdirect-0.18-src.tar.gz) and "ghc 5.02". I have > problems generating the type library: it is simply not created. Even the > comserv example is not working because of the same problem. Could that be a > bug in that HDirect version? > > Patrick > > ___ > Glasgow-haskell-users mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
posix library for Windows?
Is the posix library (-package posix) supposed to be supported on Windows? If not (as I expect to have confirmed), what are the alternatives for process control on Windows? Dean ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
No type lib generated by hdirect
I am trying to build a Haskell COM component with HDirect (from http://www.galconn.com/~sof/hdirect-0.18-src.tar.gz) and "ghc 5.02". I have problems generating the type library: it is simply not created. Even the comserv example is not working because of the same problem. Could that be a bug in that HDirect version? Patrick ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Ptr and ForeignPtr Questions
At 2001-10-10 01:19, I wrote: >foreign import "foo" raw_foo :: Ptr () -> IO (Ptr ()); > >foo :: Ptr SomeLinkedList -> IO (ConstPtr Char); >foo = importFunction raw_foo; Actually I don't need to convert the pointers, do I? If I have (Storable SomeLinkedList), I can just declare foreign import "foo" foo :: Ptr SomeLinkedList -> IO (Ptr Char); and it should work. The only thing that's missing is a ConstPtr type... -- Ashley Yakeley, Seattle WA ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Ptr and ForeignPtr Questions
At 2001-09-23 23:54, I wrote: >As you point out, there are restrictions >on just what existing C functions you can bind to. If your function looks >like this: > > const char* foo (struct SomeLinkedList*); > >...you have no choice but to write 'impedance-matching' code for that >function. On second thought, I wonder if this is really true? It seems possible to declare a "raw" import and then use Haskell to adapt: foreign import "foo" raw_foo :: Ptr () -> IO (Ptr ()); foo :: Ptr SomeLinkedList -> IO (ConstPtr Char); foo = importFunction raw_foo; instance Storable SomeLinkedList where { ... }; Of course you'd need a suitable definition of importFunction: class ConvertValueToRaw t r | t -> r where { importValue :: r -> t; exportValue :: t -> r; }; class ConvertFunctionToRaw t r | t -> r where { importFunction :: r -> t; }; instance (ConvertValueToRaw tv rv) => ConvertFunctionToRaw (IO tv) (IO rv) where { importFunction rawF = do { rv <- rawF; return (importValue rv); }; }; instance (ConvertFunctionToRaw tb rb,ConvertValueToRaw ta ra) => ConvertFunctionToRaw (ta -> tb) (ra -> rb) where { importFunction rawF ta = importFunction (rawF (exportValue ta)); }; instance ConvertValueToRaw (Ptr a) (Ptr ()) where { importValue = castPtr; exportValue = castPtr; }; instance ConvertValueToRaw Word8 Word8 where { importValue = id; exportValue = id; }; etc. -- Ashley Yakeley, Seattle WA ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users