Re: [Haskell-cafe] pure Haskell database
On Thu, Sep 25, 2008 at 11:09 AM, Manlio Perillo [EMAIL PROTECTED]wrote: Rich Neswold ha scritto: On Wed, Sep 24, 2008 at 4:17 PM, Manlio Perillo [EMAIL PROTECTED]mailto: [EMAIL PROTECTED] wrote: I need a simple, concurrent safe, database, written in Haskell. A database with the interface of Data.Map would be great, since what I need to to is atomically increment some integer values, and I would like to avoid to use SQLite. How about MVar (Map k Int)? or even Map k (MVar Int)? Yes, it is a solution; and I can run a thread that every N seconds writes the database to a file. But this works only if the database is used by only one process. Ah. When you said concurrent safe, I thought you meant within the application. You're looking for something like thishttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/anydbm . -- Rich LOI: https://www.google.com/reader/shared/00900594587109808626 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pure Haskell database
On Wed, Sep 24, 2008 at 4:17 PM, Manlio Perillo [EMAIL PROTECTED]wrote: I need a simple, concurrent safe, database, written in Haskell. A database with the interface of Data.Map would be great, since what I need to to is atomically increment some integer values, and I would like to avoid to use SQLite. How about MVar (Map k Int)? or even Map k (MVar Int)? -- Rich LOI: https://www.google.com/reader/shared/00900594587109808626 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MonadPlus
On Fri, May 9, 2008 at 2:39 PM, Andrew Coppin [EMAIL PROTECTED] wrote: [In a somewhat unrelated question... I saw some code the other day that used Either as if it were a monad. And yet, I don't see an instance given in the standard libraries - even though there should be one. I can see Functor (Either a), but not Monad (Either a) or even Monad (Either String)...] It's used in the Error Monad. -- Rich JID: [EMAIL PROTECTED] LOI: https://www.google.com/reader/shared/00900594587109808626 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help using CGIT
On 8/24/07, Bjorn Bringert [EMAIL PROTECTED] wrote: On Aug 23, 2007, at 3:34 , Rich Neswold wrote: Bingo! Method #3 works beautifully! I missed the using-lift-with- the-constructor permutation. Thanks for your help! I started writing a tutorial for Haskell web programming with the cgi package a while back, but haven't worked on it for a while, see http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell I haven't added it to the list of tutorials yet, since it's still rather incomplete. The section on using CGIT is just a stub, perhaps you would like to contribute to it? See http://www.haskell.org/haskellwiki/ Practical_web_programming_in_Haskell#Extending_the_CGI_monad_with_monad_ transformers Done. As I learn more about using CGIT, I'll try to remember to add more content. Any suggestions to improve it are welcome! -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Help using CGIT
Hello! I've been having a tough time trying to use the CGI monad transformer (CGIT). Hopefully someone can show me my misstep(s). I have a CGI script that's evolving. Early on, it needed a single database access. Now it's doing two accesses (and it looks like I'll be adding more.) Rather than making a connection for each access, the script needs to connect once. To do this, I want to combine the CGI monad with the Reader monad. This version compiles cleanly: module AppMonad (App (..), runApp) where import Control.Exception (bracket) import Control.Monad.Reader import Network.CGI.Monad import Network.CGI.Protocol import System.IO (stdin, stdout) import Database.HSQL.PostgreSQL newtype App a = App (ReaderT Connection (CGIT IO) a) deriving (Monad, MonadIO, MonadReader Connection) runApp :: App CGIResult - IO () runApp (App a) = bracket (connect host dbname user password) disconnect (\c - do { env - getCGIVars ; hRunCGI env stdin stdout (runCGIT (runReaderT a c)) ; return () } ) Unfortunately, when another module tries to actually use the monad, I get warnings about No instance for (MonadCGI App). I tried making an instance: instance MonadCGI App where cgiAddHeader = ? cgiGet = ? But I don't know how to define these functions. I tried various 'lift'ing combinations, but couldn't come up with a solution that would compile. I'm also disappointed that I had to break apart 'runCGI' (by cut-and-pasting its source) because I couldn't make it believe my monad looked enough like MonadCGI. My previous experiment with monad transformers was successful. It didn't use CGIT, however, so the 'run*' functions were simpler. Does anyone have an example of using CGIT (I didn't find any from Google)? Shouldn't I be able to use 'runCGI' with my monad? CGIT users shouldn't be required to re-implement 'runCGI, right? Any help or ideas is appreciated! -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help using CGIT
On 8/22/07, Ian Lynagh [EMAIL PROTECTED] wrote: On Wed, Aug 22, 2007 at 01:27:00PM -0500, Rich Neswold wrote: newtype App a = App (ReaderT Connection (CGIT IO) a) deriving (Monad, MonadIO, MonadReader Connection) Unfortunately, when another module tries to actually use the monad, I get warnings about No instance for (MonadCGI App). I tried making an instance: instance MonadCGI App where cgiAddHeader = ? cgiGet = ? You have three choices: 1: 2: 3: Provide a single instance for App that does the whole thing: instance MonadCGI App where cgiAddHeader n v = App $ lift $ cgiAddHeader n v cgiGet x = App $ lift $ cgiGet x This one you would obviously have to change if you added a StateT. Bingo! Method #3 works beautifully! I missed the using-lift-with-the-constructor permutation. Thanks for your help! -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Bi-directional Maps
On 8/20/07, apfelmus [EMAIL PROTECTED] wrote: Andrew Wagner wrote: It occurred to me that it would be useful to explicitly have a Bi-directional Map, which does the maintenance of keeping the Maps synchronized behind the scenes. Thus, Bimap was born! ... most of the map functions (including update above) probably won't work anyway, what should left_insertWith (\new old - new) 'a' 1 (fromList [('a',2),('b',1)]) do? I can't yield fromList [('a',1),('b',1)] since 1 has two keys now. Exactly. For this to work there needs to be the constraint that there's a one-to-one mapping in each direction. The Bimap should have the uniqueness promise that Set (k, v) gives. Yet you should be able to search on either tuple value. -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] interrupting an accept()ing thread
On 7/7/07, Lukas Mai [EMAIL PROTECTED] wrote: If I understand this correctly, spin should be written as: spin = do block $ do (t, _) - accept s unblock (forkIO $ doStuff t) `finally` sClose t spin I think the `finally` portion should be done in the forked process context. Otherwise once the process is forked, the socket gets closed by the parent process. Something more along the lines of: unblock (forkIO $ doStuff t `finally` sClose t) -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] interrupting an accept()ing thread
On 7/5/07, Lukas Mai [EMAIL PROTECTED] wrote: Hello, cafe! I have the following code (paraphrased): ... forkIO spin ... spin = do (t, _) - accept s -- (*) forkIO $ dealWith t -- (**) spin My problem is that I want to stop spin from another thread. The obvious solution would be to throw it an exception. However, that leaks a socket (t) if the exception arrives between (*) and (**). I could wrap the whole thing in block, but from looking at the source of Network.Socket it seems that accept itself is not exception safe; so no matter what I do, I can't use asynchronous exceptions to make spin exit. What about using bracketOnError? nextClient s = bracketOnError (fst . accept s) sClose spin = do nextClient s (\s' - forkIO $ dealWith s') spin If bracketOnError leaks the resource in the event of an exception, then it needs to be fixed. -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Telling the time
On 6/21/07, Andrew Coppin [EMAIL PROTECTED] wrote: Is there a standard library function anywhere which will parse a string into some kind of date/time representation? In Data.Time.Format, there's parseTime. parseTime takes a format string that describes the layout. Since you have varying layouts in your files (hopefully consistent in the same file!), you simply change the format string for each file. -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Darcs on Solaris x86
It was a problem with the linking for ghc. I hacked LD_LIBRARY_PATH for my user account and it worked. You might want to add /opt/csw/ lib/ when compiling ghc. Also, I am a new Solaris user (this is on a Joyent Accelerator) so this might be entirely the wrong advice ;) On Jun 15, 2007, at 3:40 AM, Christian Maeder wrote: Rich Collins schrieb: I was able to install the ghc binary for solaris x86, but darcs fails on configure: It's not a darcs problem. configure:2718: ghc -o conftest conftest.hs ld: fatal: symbol `GHC_ZCCReturnable_static_info' in file /opt/local/lib/ghc-6.6.1/libHSrts.a(PrimOps.o): section [1] .text: size 8212: symbol (address 0x2014, size 4) lies o This bug has recently been fixed. http://hackage.haskell.org/trac/ghc/ticket/1421 Download the new binary dist: http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/ CoFI/hets/pc-solaris/versions/new-ghc-6.6.1-i386-unknown- solaris2.tar.bz2 Ian, could you replace http://www.haskell.org/ghc/dist/6.6.1/ghc-6.6.1-i386-unknown- solaris2.tar.bz2 ? utside of containing section ld: fatal: library -lgmp: not found ld: fatal: File processing errors. No output written to conftest collect2: ld returned 1 exit status You need to install gmp (libgmp.so). (I don't know where you can get it.) HTH Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Darcs on Solaris x86
I was able to install the ghc binary for solaris x86, but darcs fails on configure: configure:2718: ghc -o conftest conftest.hs ld: fatal: symbol `GHC_ZCCReturnable_static_info' in file /opt/local/ lib/ghc-6.6.1/libHSrts.a(PrimOps.o): section [1] .text: size 8212: symbol (address 0x2014, size 4) lies o utside of containing section ld: fatal: library -lgmp: not found ld: fatal: File processing errors. No output written to conftest collect2: ld returned 1 exit status ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Locating shared libraries
On 6/13/07, Stefan O'Rear [EMAIL PROTECTED] wrote: Did I understand that correctly that you don't want to see binaries with rpath's pointing to install directories such as /usr/lib/gcc-6.6? So, this forces us to use a wrapper in all cases. Please think seriously about mangling the names of Haskell libraries to include version information and dropping them in $PREFIX/lib with every other language's libraries. Haskell is not special, and users expect libraries to be in /usr/lib. No wrapper needed, no RPATH needed, as far as I can see no fanciness at all. Actually, Haskell libraries ought to be placed in /usr/local/lib (or /usr/pkg/lib for systems that use the Package System: http://www.pkgsrc.org). Haskell libraries shouldn't mingle with the base OS libraries. But it shouldn't be separate from the other third-party libraries, either. -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Locating shared libraries
On 6/12/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote: Let's see how libtool handles this situation. I would recommend against following libtool's lead in this area. Libtool's fondness for cooking RPATH into binaries makes it very difficult to deal with, because it's quite common for those binaries to get installed and distributed, RPATH and all. RPATH should only be used by a user who knows they have a large-calibre weapon pointed at their foot. The NetBSD Project has a different opinion and strongly encourages the use of RPATHs. Letting the user alter the lookup path for installed binaries is seen as a security problem. Since every NetBSD system has its libraries in one directory and third-party libraries are in /usr/pkg/lib, there's no problem in hardcoding the paths. Just another data point... -- Rich JID: [EMAIL PROTECTED] AIM: rnezzy ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] [IO Int] - IO [Int]
On 5/4/07, Phlex [EMAIL PROTECTED] wrote: Hello all, I'm trying to learn haskell, so here's is my first newbie question. I hope this list is appropriate for such help requests. I'm trying to write a function with the signature [IO Int] - IO [Int] Control.Monad has a function (called sequence) that does this for you. In fact, sequence is a more generic solution since its signature is (Monadhttp://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#t%3AMonadm = [m a] - m [a]). As a newbie, I found it educational to peruse the various modules in http://haskell.org/ghc/docs/latest/html/libraries/;. Just start looking at modules that sound interesting and see what has already been defined. Some modules at first may be too advanced, but if you go back to them in a few days (weeks?), they'll start making more sense, too. -- Rich AIM : rnezzy ICQ : 174908475 Jabber: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] What's with Network.Socket?
On 4/7/07, ROBERT DOUGLAS HOELZ [EMAIL PROTECTED] wrote: Is Network.Socket buggy/incomplete? I'm trying to implement an NNTP module in Haskell, but it seems the Network.Socket module doesn't convert the native byte order to network byte order, so the connection gets denied. When I reverse the bytes in the address by hand and try to connect, it locks up. What's wrong? There was a discussion on it: http://www.mail-archive.com/glasgow-haskell-users@haskell.org/msg11292.html One answer (use Network.Socket.inet_addr) works, but isn't very satisfactory. Another recommendation pulls the htons(), et al. functions into Haskell using FFI. This is better, but more initial work. But I believe both answers aren't correct. The binary serialization module should replace 99% of the need of htonl(), etc. For socket addresses, the Network library needs to do the endianness conversion, like the PortNum type does. -- Rich AIM : rnezzy ICQ : 174908475 Jabber: [EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: Re[2]: [Haskell-cafe] Tracking characters and a timestamp ?
On 4/5/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: you definitely should read http://haskell.org/haskellwiki/IO_inside Thanks for mentioning this link -- I wasn't aware of it. I wish it existed when I first started learning Haskell... -- Rich AIM : rnezzy ICQ : 174908475 Jabber: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Network.Socket endian problem?
On 12/14/06, Tomasz Zielonka [EMAIL PROTECTED] wrote: On Thu, Dec 14, 2006 at 05:22:43PM +0100, Ferenc Wagner wrote: Tomasz Zielonka [EMAIL PROTECTED] writes: Who agrees with me that it would be nice if network libraries used host byte order in their interface? Or at least they could use an abstract data type, whose byte order would be unobservable. Why is this trapdoor present in the C library? I don't know. Maybe for efficiency? The only mention I could find related to this is in W. Richards Stevens' Unix Network Programming: In theory an implementation could store the fields in a socket address structure in host byte order and then convert to and from the network byte order when moving the fields to and from the protocol headers, saving us from having to worry about this detail. But both history and Posix.1g specify that certain fields in the socket address structures be maintained in network byte order. Not very satisfactory. But even if the socket address details were hidden, the data itself may require a certain endianness. The htonl(), et al. functions assist in this detail for C programmers. I didn't see any functions in the Haskell Network or Marshall libraries that help Haskell programmers write out network byte order values. I didn't check any third party libraries yet. -- Rich AIM : rnezzy ICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Network.Socket endian problem?
On 12/13/06, Sigbjorn Finne [EMAIL PROTECTED] wrote: as you've time-consumingly discovered, Network.Socket.HostAddress is represented in network byte order (something that's not well documented, and a potential trap.) You may want to consider using Network.Socket.inet_addr as a constructor. Thanks to everyone for their help and suggestions. I agree, however, with Tomasz that the address should be in host byte order to the application. At the very least, the port value and the address should use the same byte ordering. For now, I'll use inet_addr as a constructor. Thanks again. -- Rich AIM : rnezzy ICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Network.Socket endian problem?
Hello, I've written a program that uses UDP as its communication with other processes. It was built with GHC 6.4.1 on MacOS 10.4 (PowerPC) and works fine. When I moved the code to a Linux box (i386) and built it with GHC 6.6, it didn't work. The problems turns out to be, apparently, an endian problem. The socket is created with the following snippet: allocSocket :: IO Socket allocSocket = do { s - socket AF_INET Datagram 0 ; handle (\e - sClose s throwIO e) $ do { connect s (SockAddrInet 6802 0x7f01) ; return s } } On the Macintosh, the socket only receives packets from 127.0.0.1:6802, which is correct (and works). On the Linux machine, the socket only accepts packets from 1.0.0.127:6802. The data constructor SockAddrInet doesn't swap the bytes of the address (although it correctly swaps the bytes of the port number!) Changing the data constructor call to (SockAddrInet 6802 0x017f) makes it work on Linux, but not on MacOS 10.4. (You can see what the socket is bound to, on Linux, with netstat -aun.) I don't have access to GHC 6.4.1 on a Linux box to determine whether this is a regression in 6.6 or simply an overlooked detail. Should I file a PR? Am I doing something wrong? -- Rich AIM : rnezzy ICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Network.Socket endian problem?
On 12/13/06, Thorkil Naur [EMAIL PROTECTED] wrote: I am not an expert on sockets, but I have both a Linux installation and a PPC Mac OS X 10.4 with both ghc-6.4.1 and ghc-6.6. So if you allow me some additional details (such as complete program texts), perhaps I can perform some useful experiments under your conductance. I can reproduce it with the following: module Main where import Control.Exception import Network.Socket import System.IO allocSocket :: IO Socket allocSocket = do { s - socket AF_INET Datagram 0 ; handle (\e - sClose s throwIO e) $ do { connect s (SockAddrInet 6802 0x7f01) ; return s } } main :: IO () main = withSocketsDo $ do { s - allocSocket ; getChar ; sClose s } If you run the program on OSX, you can check the bound address while it's waiting for a keystroke. Type netstat -an -f inet | grep 6802 to see. I get: udp4 0 0 127.0.0.1.61704127.0.0.1.6802 which is correct. When I run this program on Linux/i386, I get: udp0 0 (anonymized):334121.0.0.127:6802 ESTABLISHED (I removed my IP address.) The second bound address, however, is wrong: the octets are in the wrong order. Notice, though, that the port number is correct! Thanks for looking into this! -- Rich AIM : rnezzy ICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] split string into n parts
On 10/23/06, jim burton [EMAIL PROTECTED] wrote: I want to split a string into 5 parts of equal length, with the last fifth padded if necessary, but can't get it right I got this:fifths :: String - Stringfifths xs = let len = (length xs + 4) `div` 5 padded = take (len * 5) (xs ++ ) in unwords $ nth len padded where nth _ [] = [] nth n xs = (take n xs) : (nth n $ drop n xs) *Main fifths IDOLIKETOBEBESIDETHESEASIDE IDOLI KETOBE BESIDE THESEA SIDEXX *Main fifths 12345 1 23 45This gives the following results:IDOLIK ETOBEB ESIDET HESEAS IDE and1 2 3 4 5But it also gives this result, which may or may not be correct for your problem: *Main fifths 12345612 34 56 -- RichAIM : rnezzyICQ : 174908475 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
threadDelay not ending
I've got some unit test code that forks off test processes using the 'system' function and then delays using 'threadDelay' to synchronize with the test process. This has worked fine until I upgraded to 6.4.2, now some of the 'threadDelay' calls never return - it's like they are stuck in limbo. Any ideas? What would have changed between 6.4 and 6.4.2 that would cause this behavior? Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: threadDelay not ending
I am running on Red Hat Enterprise Linux with the latest RH 2.6 kernel. This is very bizarre and I am having a hard time figuring out what is going on. I don't see any issues in the project code itself, just my unit tests. Rich Seth Kurtzberg wrote: What is your environment? My project (which is about 70% Haskell) makes extensive use of threadDelay. I've not seen this behavior with 6.4.2. My environment is Linux using a recent 2.6 kernel. For obvious reasons I need to know whether there is a threadDelay issue here that is preparing to bite me. Seth Kurtzberg On Mon, September 18, 2006 7:23 am, Rich Fought wrote: I've got some unit test code that forks off test processes using the 'system' function and then delays using 'threadDelay' to synchronize with the test process. This has worked fine until I upgraded to 6.4.2, now some of the 'threadDelay' calls never return - it's like they are stuck in limbo. Any ideas? What would have changed between 6.4 and 6.4.2 that would cause this behavior? Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: getMBlocks
Did you try GHC's heap profiler? Or simply running your program with +RTS -Sstderr will give you a clue about the shape of the heap usage - each line is a single GC, and it includes the amount of live data at that point. If your program has a flat heap profile and yet is still grabbing more memory, then something else is going on. Cheers, Simon Well the profile is definitely not flat. I'm using the profiling tools and Network.accept is apparently the major offender using both -hc and -hr profiles. I take it this implies that the products of this function are being retained elsewhere. I do pass the handle off to another thread via forking - this shouldn't be an issue should it? Another retainer involves SYSTEM and Network.accept - what exactly does SYSTEM mean? Regards, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: getMBlocks
Simon Marlow wrote: What tool(s) did you use to obtain this figure? This particular figure was gathered using perfmon logs collecting once per second from my application, while running in WinDbg to break on getMBlocks(). The particular memory variables tracked are Private Bytes and Working Set. Did you try GHC's heap profiler? Or simply running your program with +RTS -Sstderr will give you a clue about the shape of the heap usage - each line is a single GC, and it includes the amount of live data at that point. If your program has a flat heap profile and yet is still grabbing more memory, then something else is going on. Yes I did try the profiler, but I couldn't really garner any useful information from it. Most likely because I don't understand how to use it correctly. :) I should revisit this however, as I have since discovered and fixed some leaks. It should at least look different. Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
getMBlocks
Hello, I'm still chasing down a memory leak in my server application written in Haskell using GHC 6.4.x under MinGW/MSYS. In the scenario described below, I am repeating the same server request once per second continuously. After utilizing some memory monitoring tools I've discovered that memory usage fluctuates within in a range of approximately 850 KB (I assume as garbage is collected), but at regular intervals the range gets bumped up by ~ 1 MB. So in effect I get a stair-stepping of memory usage that keeps repeating until memory runs out. WinDbg has revealed that this stepping coincides with the GHC runtime function getMBlocks(). My question is: what conditions affect when the runtime determines that it needs more memory? Is it a pure no more room trigger or is there some sort of algorithm behind it? I assume that this behavior means I still have a space leak somewhere in my Haskell code, though none of leak check tools I utilize indicate such. Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Chasing a memory leak
Thanks, you are absolutely right. There is an offset between the function addresses defined in the link map and the addresses that show up in gdb. I've rolled up my Jump to Conclusions mat. Rich Simon Marlow wrote: Rich Fought wrote: I'm getting into the weeds of a GHC-compiled program, and need a little help. I'm trying to chase down a memory leak and Valgrind gives me the following: ==24390== 54,844 bytes in 639 blocks are definitely lost in loss record 69 of 69 ==24390==at 0x400446D: malloc (vg_replace_malloc.c:149) ==24390==by 0x826337E: (within myprog) From the link map of my program this address is in the function GHCziBase_zdszddmmin_info It's unlikely this is right. This symbol is the code for the function GHC.Base.$s$dmin, which is a specialised version ($s) of the default method ($d) for min, in class Ord. I very much doubt that min calls malloc()! So it probably means that there are some symbols missing in your program binary. Try asking gdb what lies at that address, maybe? Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Chasing a memory leak
I'm getting into the weeds of a GHC-compiled program, and need a little help. I'm trying to chase down a memory leak and Valgrind gives me the following: ==24390== 54,844 bytes in 639 blocks are definitely lost in loss record 69 of 69 ==24390==at 0x400446D: malloc (vg_replace_malloc.c:149) ==24390==by 0x826337E: (within myprog) From the link map of my program this address is in the function GHCziBase_zdszddmmin_info I can't seem to find any similar reference in the GHC source or in any of my assembly files, so I'm assuming it's something the compiler puts together internally for the GHC runtime. What does this function do, or how can I find out what it does? Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Heap Profiling Question
Simon Marlow wrote: That's right - the general idea is to make the profile insensitive to other loading on the machine. I can see there might be an argument for making this tweakable, though. This would be nice to have if one is trying to correlate behavior with specific I/O events in time (i.e. messages coming into a server). AllocCollectLiveGCGC TOT TOT Page Flts bytes bytes bytes user elapuserelap 264424262144 20592 0.00 0.000.030.0100 (Gen: 1) 311540270336 63732 0.00 0.003.845.2500 (Gen: 0) So between these first two GCs, your program spent nearly 4 seconds doing something, but only allocated 300k. What was it doing? If I'm not mistaken, it's negotiating a TLS session. I think I tracked down the bizarre timetag issue, it is already in Trac: http://hackage.haskell.org/trac/ghc/ticket/769 So the out of order timetag of 3.100 in my original e-mail should really be 4.0. Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Heap Profiling Question
3.985.3900 (Gen: 0) 262128266240968636 0.00 0.003.985.3900 (Gen: 0) 262128266240 1060608 0.00 0.003.985.4000 (Gen: 0) 262128 1290240194316 0.00 0.003.985.4000 (Gen: 1) 263232266240201176 0.00 0.003.985.4000 (Gen: 0) 262128266240207568 0.00 0.003.985.4000 (Gen: 0) 262128266240214472 0.00 0.003.985.4000 (Gen: 0) 262128266240221944 0.00 0.003.985.4000 (Gen: 0) 262128266240230156 0.00 0.003.985.4000 (Gen: 0) 262128266240239628 0.00 0.004.005.4100 (Gen: 0) 262128266240251036 0.00 0.004.005.4100 (Gen: 0) 26212826624020 0.00 0.004.005.4100 (Gen: 0) 262160266240289928 0.00 0.004.005.4100 (Gen: 0) 267908266240363816 0.00 0.004.035.4500 (Gen: 0) 269488339968379412 0.00 0.004.115.5300 (Gen: 0) 271056311296407972 0.00 0.004.115.5300 (Gen: 0) 267520270336416420 0.00 0.004.125.5400 (Gen: 0) 264136274432464492 0.00 0.004.125.5400 (Gen: 0) 304612319488460256 0.00 0.004.175.6000 (Gen: 0) 268912286720470944 0.00 0.004.185.6100 (Gen: 0) 304308282624492792 0.00 0.004.215.6400 (Gen: 0) 268136286720499576 0.01 0.014.225.6500 (Gen: 0) 181052 0.00 0.00 20,883,096 bytes allocated in the heap 1,971,016 bytes copied during GC 194,316 bytes maximum residency (2 sample(s)) 78 collections in generation 0 ( 0.03s) 2 collections in generation 1 ( 0.00s) 2 Mb total memory in use INIT time0.02s ( 0.00s elapsed) MUT time4.17s ( 5.62s elapsed) GCtime0.03s ( 0.03s elapsed) RPtime0.00s ( 0.00s elapsed) PROF time0.00s ( 0.00s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time4.22s ( 5.65s elapsed) %GC time 0.7% (0.5% elapsed) Alloc rate4,988,795 bytes per MUT second Productivity 98.8% of total user, 73.8% of total elapsed Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Heap Profiling Question
On a separate issue, I can't seem to get the -hcname or -hmname options to work. For instance, profiling with just -hm yields an entry for module Network.HTTP, yet when I try to profile again with -hmNetwork.HTTP, I do not get a heap dump. Is there some special formatting I am missing? Thanks, Rich Rich Fought wrote: I'm trying to use heap profiling with +RTS -hc -i1 options and running my program for about 30 seconds. However, I only get around 7 samples with seemingly bogus timetags (i.e. 0.00, 3.69, 3.73, 3.10, 4.05, 4.12). What's going on? I'm running GHC 6.4.2 on Windows (MSYS/MinGW). Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
regex.h included with GHC 6.4.2
Am I crazy or is there an error in regex.h included with GHC? On line 110 there appears to be an extraneous or unterminated 'extern C {' Regards, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Heap Profiling Question
I'm trying to use heap profiling with +RTS -hc -i1 options and running my program for about 30 seconds. However, I only get around 7 samples with seemingly bogus timetags (i.e. 0.00, 3.69, 3.73, 3.10, 4.05, 4.12). What's going on? I'm running GHC 6.4.2 on Windows (MSYS/MinGW). Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Text.Regex.Posix regcomp
Thanks, upgrading to 6.4.2 seems to have done the trick. I've obviously put it off too long! Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Text.Regex.Posix regcomp
Hello, I have a server application that I am building using GHC 6.4 (yes, an update to 6.4.2 is on the horizon, but not in the immediate future - unless it fixes this problem :) ) under MSYS/MinGW. Things work pretty well, but under stress testing the app eventually throws a Windows memory access violation (c005) exception out of the exact same location in the regcomp function every time. When it occurs is not deterministic - it could be after 20 requests or 2000 (usually higher, though). Various Windows debuggers shows it as a memory read error. regcomp is called several times with each incoming request. I'm pretty sure it's not a multi-threading issue, as there is only one client sending requests over and over again. Can anyone suggest some ideas or debugging tips? TIA, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Receiving multicasts
Hello, Has anyone figured out a way to receive multicasts in a Haskell program? It doesn't appear that Network.Socket.setSocketOption provides enough information to join a multicast address. Any information would be appreciated. -- Rich AIM : rnezzy ICQ : 174908475 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
solutions for errors installing ghc-6.4.1 (Mac OS X 10.4.6, Xcode 2.2.1)
I got ghc-6.4.1 running on my G4 Mac. I'm sending this to the glasgow-haskell-bugs list in case others have had the same problems (one of these problems was previously posted to this list in Dec 2005 but received no reply). Why 6.4.1? Because I'm not interested in building ghc-6.4.2 at this time, just in having a running haskell compiler, and a ghc-6.4.2 binary isn't yet available for OS X. I downloaded ghc-6.4.1dyn-powerpc-apple-darwin.tar and tried to install it. Everything seemed to go fine with ./configure and make install (except for the missing *.ps files others have commented on). Then I tried to run ghci - Problem 1: Try to run ghci and get this error: dyld: Library not loaded: /usr/local/lib/libreadline.5.0.dylib Referenced from: /usr/local/lib/ghc-6.4.1/ghc-6.4.1 Reason: image not found My machine already has several versions of readline installed but not the version 5.0 that ghc wants. Installing from the GNU source doesn't get me the dynamic library that gnc wants but using Fink to install readline 5.0 gets me the correct library in /usr/lib and a symbolic link in /usr/local/lib pointing to that library makes gchi happy. Problem 2: Now ghci gives me a new 'Library not loaded' error complaining about not being able to find 'GMP.framework/Versions/A/GMP' I downloaded the disk image for AquaCurry from http://danae.uni-muenster.de/~lux/curry/aqua.html which has a GMP.framework folder which I dragged and dropped into /Library/frameworks (This was the problem that was posted to this list in Dec 2005 and received no reply.) Problem 3: Now ghci runs OK so I proceed to test the compiler installation with a 'Hello World' program as described in the Users Guide. I get 'table of contents for archive: xxx out of date; rerun ranlib(1) (can't load from it)' for these archives: libHShaskell98.a libHSbase.a libHSbase_cbits.a libHSrts.a so I use ranlib to bring them up to date. Now I finally have a working Haskell interpreter and compiler. Now I can get some work done. I already know Scheme is cool; now I'll find out if Haskell is cooler. (BTW, if you want to run ghc-6.4.1 on a recent version of OS X which uses gcc 4.0 as default you'll need to run gcc_select to set gcc 3.3 as the default since that's what ghc_6.4.1 is compatible with.) Rich Talley ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC and Cygwin/MinGW
Hello, I'm trying to port a linux-based Haskell application over to Win32. I am fiddling with both MinGW and Cygwin with varying degrees of bafflement. This is a server app that utilizes secure connections with the GnuTLS libraries. From what I understand, the Win32 version of GHC targets MinGW. Does this mean that the GnuTLS libraries must be compiled for MinGW as well, or is it possible to link in cygwin libraries via the cygwin.dll somehow? Also, any ideas how difficult a Cygwin port of GHC would be? Tips would be much appreciated. Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Full Release Notes for GHC 6.4.1?
Hello, I'm wondering if there exists a full description of bug fixes between GHC 6.4 and 6.4.1. The short one on the GHC web site only details new features. Specifically, I'm interested to know if there were any changes to the concurrency/threading portion of GHC? I'm encountering some nasty FFI/threading issues that are causing GHC 6.4 to crash. Thanks, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Cross-Compiling with GHC?
Hi there - GHC noob here, trying to compile a small app for a Linux/PPC target from a Linux/x86 host. I take it this must be doable, since it is possible to build GHC for new platforms and GHC itself is written in Haskell. I'm just trying to find out if anyone has formulated a guide to this already, before I jump in (and I did try Google without much luck). I'm afraid building GHC for the target is not an option. My first thought to try is to build an unregisterised GHC on x86 from scratch and use it to compile my app to C code, which I can then cross-compile to PPC. Something tells me however that this C code still may have some x86 specific stuff in it. Regards, Rich ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Constructor constraints
Hello,I've looked through the two tutorials and the Report, but couldn't find help on this topic. My question is whether you can place constraints on new data types. For instance, I want to make a new type that is a 4 element tuple where each element is greater than or equal to the previous entry. Is this possible? i.e.data Category = Membership a a a aI'd like to be able to prevent invalid Category data from being created. Any information would be appreciated. -- RichAIM : rnezzyICQ : 174908475 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Constructor constraints
On 9/20/05, Malcolm Wallace [EMAIL PROTECTED] wrote: You can make a 'smart' constructor function, and hide the real dataconstructor so that it cannot be used:Thanks! I'll give your solution a try.-- RichAIM : rnezzy ICQ : 174908475 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: FFI: calling Haskell from C++?
On 9/14/05, Simon Peyton-Jones [EMAIL PROTECTED] wrote: There's been a bit of traffic about calling Haskell from C++ recently, and I know that calling C++ from Haskell is a frequently asked question. Would someone like to write up a description of how to successfully call out from Haskell to C++ and vice versa, using GHC? If you did, we'd gladly include the result in the user manual, and save others a lot of head scratching. Maybe there are simple things we could do to GHC to make the process simpler. But what it needs is someone who knows C++ well to write a coherent story. Please! I'm flattered that you quoted my message, but I'm not familiar with the foreign language interface; I started looking at Haskell only a few weeks ago. I was able to fix the first problem, since the name-mangler is always a problem when mixing other languages with C++. The second error I may or may not have got right. The other solution recommended that the C++ library be linked which fixes the undefined exception handling symbols. I'm curious what would happen if Haskell called down into C++ code and then an exception was thrown... Anyways, I think your suggestion is a good one and I would be willing to answer any C++ questions that anyone has when writing such a document. -- RichAIM : rnezzyICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: FFI: calling Haskell from C++?
On 9/13/05, Felix Breuer [EMAIL PROTECTED] wrote: $ ghc -fffi Foo.o Foo_stub.o main.cppmain.o(.text+0x22): In function `main':main.cpp: undefined reference to `__stginit_Foo()'main.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'collect2: ld returned 1 exit status In main.cpp, you need to define __stginit_Foo(void) like this: extern C void __stginit_Foo(void); Specifying the C linkage with prevent the compiler from looking for a name-mangled version of the function. To fix the second problem, you need to shut off exception handling (specifying the -fno-exceptions option ought to do this. I don't know how to pass compiler option via ghc, though. -- RichAIM : rnezzyICQ : 174908475 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
order of computation in 'do' notation
Hi, I have to hand in my final project for my degree next week. I've been running my program through hugs most of the time, and I wanted to compile it to an executable, so I used ghc. Unfortunately ghc makes the program behave in a different, undesirable way. The code where the problem lies is shown below. Basically, in hugs, the prompt is displayed and then it waits for a command to be entered (getCommand) - which is what I want, but when I put the same code through ghc, it waits for a command first, and then when the command has been entered it displays the prompt, which is just silly. Surely the 'do' notation was designed to sequence computations, but it obviously isn't behaving quite right here! I'd be very grateful for any suggestions as to how to fix this. thanks, Rich. mainLoop :: IO TRS - IO () mainLoop t = do putStr \n (c,a) - getCommand 0 case c of help - do putStr help mainLoop t load - do trs - load a putStr mainLoop (return trs) show - ...and so on... And then the getCommand function is as follows: -- gets a command from the standard input getCommand :: Int - IO (String,String) getCommand _ = do com - getLine return (splitComm com) -- splits a command into the main command and arguments splitComm :: String - (String,String) splitComm [] = (,) splitComm (' ':cs) = (,cs) splitComm (c:cs) = ((c:rest),rem) where (rest,rem) = splitComm cs ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: order of computation in 'do' notation
Thanks very much everyone! I added the line hFlush stdout to the code and it works fine now - thanks for your help! Rich. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
a more practical version of getLine???
Hi, I'm writing a program for my final project at uni and I've come across the following annoying bug in my program. Basically, I have an interactive text prompt and I wish to be able to write commands into the prompt. I am currently using the function 'getLine', which as it's name suggests reads a line of text from the prompt. Unfortunately, when the delete key is used while writing to the prompt, the output differs (so typing loaf then 'delete' and then d does not seem to produce the same output as typing load). Also, the left and right arrow keys don't work, as they do in any normal text prompt. Any suggestins as to an alternative method to read the input??? (I'm by no means a Haskell expert btw, so I may have to be spoon fed!) thanks for your help, Rich. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe