Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: How do I marshall a pointer over SendMessage LPARAM or WPARAM? (Sylvain HENRY) 2. Re: How do I marshall a pointer over SendMessage LPARAM or WPARAM? (Simon Peter Nicholls) 3. Re: How do I marshall a pointer over SendMessage LPARAM or WPARAM? (Simon Peter Nicholls) 4. Re: haskell for system administration (Erik Johnson) ---------------------------------------------------------------------- Message: 1 Date: Wed, 18 Jul 2012 19:13:00 +0200 From: Sylvain HENRY <hsy...@gmail.com> Subject: Re: [Haskell-beginners] How do I marshall a pointer over SendMessage LPARAM or WPARAM? To: beginners@haskell.org Message-ID: <5006ee9c.5060...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed If you are doing inter-process communication, you should not send pointers as processes do not share the same address space. Use WM_COPYDATA to send a specific amount of data. http://msdn.microsoft.com/en-us/library/windows/desktop/ms649011%28v=vs.85%29.aspx I've read that SendMessage is blocking, so you can use withCWString (contrary to what I have previously written). As you have to pass the size of the data, you can even use withCWStringLen (and peekCWStringLen). Cheers Sylvain Le 18/07/2012 19:02, Simon Peter Nicholls a ?crit : > It's inter-process by design. > > I have a small "single instance " C++ program that I'm porting to > Haskell. Once the first instance launched is up and running, > subsequent launches send their command line params through to the > single instance (file names). Similar to when a media player queues > files in a play list. > > The most recent extra clue I have is that if I wrap the SendMessage > function with my own C FFI version, my C function can both re-cast and > output the CWString I have sent, and can successfully invoke the real > SendMessage by overriding the CWString with a newly created L"blah" > string. It's just a shame it can't use the original! > > My next session will involve poking around at the two strings to learn > why they are treated differently. > > On Wed, Jul 18, 2012 at 6:33 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >> Are you sending the message to a window of the same process? >> >> -Sylvain >> >> Le 18/07/2012 18:28, Simon Peter Nicholls a ?crit : >> >>> I've tried that without joy. Have reposted over at Haskell cafe, as >>> per Brent's advice. Thanks to both of you. >>> >>> On Wed, Jul 18, 2012 at 5:56 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >>>> Hi, >>>> >>>> [As I've just registered to the list, I don't have the original message. >>>> That's why I answer to Brent insted of Simon] >>>> >>>> By using "withCWString", your CWString may be freed before the message is >>>> sent. Use "newCWString" instead and "free" in your receiving code. >>>> >>>> Cheers >>>> Sylvain >>>> >>>> Le 18/07/2012 17:47, Brent Yorgey a ?crit : >>>> >>>>> Hi, >>>>> >>>>> Just a meta-comment: this doesn't seem like a beginner question to >>>>> me. =) Perhaps someone on this list will know the answer (and there's >>>>> nothing wrong with asking), but for such a specific question you may >>>>> have better luck posting to haskell-cafe or StackOverflow. >>>>> >>>>> -Brent >>>>> >>>>> On Wed, Jul 18, 2012 at 03:14:46PM +0200, Simon Peter Nicholls wrote: >>>>>> I'm new to Haskell, and have had some good success with FFI so far, >>>>>> but using Win32's sendMessage to send a pointer in LPARAM or WPARAM is >>>>>> resulting in access violations at the other end. >>>>>> >>>>>> Is there some issue with my pointer conversions? Am I hitting some >>>>>> restriction, or missing some compiler options? >>>>>> >>>>>> >>>>>> It's driving me pretty crazy, after a very nice start to using >>>>>> Haskell. >>>>>> >>>>>> Some "sending" code: >>>>>> >>>>>> Foreign.C.String.withCWString "frustrator" $ \s -> do >>>>>> let wParam = System.Win32.Types.castPtrToUINT s :: >>>>>> System.Win32.Types.WPARAM >>>>>> Graphics.Win32.sendMessage wnd Graphics.Win32.wM_APP >>>>>> wParam 0 >>>>>> >>>>>> wndProc "receiving" code: >>>>>> >>>>>> | wmsg == Graphics.Win32.wM_APP = do >>>>>> s <- peekCWString $ System.Win32.Types.castUINTToPtr wParam >>>>>> putStrLn s >>>>>> return 0 >>>>>> >>>>>> The string will not be seen. >>>>>> >>>>>> Some extra notes: >>>>>> >>>>>> I can get wndProc messages and integral data generally. >>>>>> The pointer values match textually at both ends when "shown" to stdout. >>>>>> At the sending side I can pass the CWString to a regular FFI function >>>>>> call just fine, and castUINTToPtr will give me back a functioning Ptr >>>>>> for that call. >>>>>> >>>>>> I have also tried sending to & receiving from a working C++ program, >>>>>> without success. Access violations are reported when receiving, though >>>>>> again the address matches up. Silence from Haskell as before, when C++ >>>>>> is sending. >>>>>> >>>>>> I found someone else having an issue here: >>>>>> http://osdir.com/ml/haskell-c...@haskell.org/2009-11/msg00731.html but >>>>>> no solution unfortunately. >>>>>> >>>>>> _______________________________________________ >>>>>> Beginners mailing list >>>>>> Beginners@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/beginners >>>>> _______________________________________________ >>>>> Beginners mailing list >>>>> Beginners@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/beginners >>>> >>>> >>>> >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners@haskell.org >>>> http://www.haskell.org/mailman/listinfo/beginners >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 2 Date: Wed, 18 Jul 2012 19:57:35 +0200 From: Simon Peter Nicholls <si...@mintsource.org> Subject: Re: [Haskell-beginners] How do I marshall a pointer over SendMessage LPARAM or WPARAM? To: beginners@haskell.org Message-ID: <CAEaCoJ+1jJS1j=kwdukybp1-qdoxo-yqpsra1aqypufjcv2...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Actually, I tried that first of all, using a COPYDATASTRUCT Storable. When things didn't go smoothly, I tried to narrow down the problem by direct passing of the CWString data. However, this point about address space is a good one. In the link below, it suggests that WM_COPYDATA is treated as a special case, ensuring the COPYDATASTRUCT will be available in the receiving process. http://www.go4expert.com/forums/showthread.php?t=19730 Ah yes. Same function name, but magic stuff happening based on a magic value. That ole ruse. I'll go back to WM_COPYDATA for a fresh try tomorrow. Cheers On Wed, Jul 18, 2012 at 7:13 PM, Sylvain HENRY <hsy...@gmail.com> wrote: > If you are doing inter-process communication, you should not send pointers > as processes do not share the same address space. > > Use WM_COPYDATA to send a specific amount of data. > http://msdn.microsoft.com/en-us/library/windows/desktop/ms649011%28v=vs.85%29.aspx > > I've read that SendMessage is blocking, so you can use withCWString > (contrary to what I have previously written). As you have to pass the size > of the data, you can even use withCWStringLen (and peekCWStringLen). > > Cheers > Sylvain > > Le 18/07/2012 19:02, Simon Peter Nicholls a ?crit : > >> It's inter-process by design. >> >> I have a small "single instance " C++ program that I'm porting to >> Haskell. Once the first instance launched is up and running, >> subsequent launches send their command line params through to the >> single instance (file names). Similar to when a media player queues >> files in a play list. >> >> The most recent extra clue I have is that if I wrap the SendMessage >> function with my own C FFI version, my C function can both re-cast and >> output the CWString I have sent, and can successfully invoke the real >> SendMessage by overriding the CWString with a newly created L"blah" >> string. It's just a shame it can't use the original! >> >> My next session will involve poking around at the two strings to learn >> why they are treated differently. >> >> On Wed, Jul 18, 2012 at 6:33 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >>> >>> Are you sending the message to a window of the same process? >>> >>> -Sylvain >>> >>> Le 18/07/2012 18:28, Simon Peter Nicholls a ?crit : >>> >>>> I've tried that without joy. Have reposted over at Haskell cafe, as >>>> per Brent's advice. Thanks to both of you. >>>> >>>> On Wed, Jul 18, 2012 at 5:56 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >>>>> >>>>> Hi, >>>>> >>>>> [As I've just registered to the list, I don't have the original >>>>> message. >>>>> That's why I answer to Brent insted of Simon] >>>>> >>>>> By using "withCWString", your CWString may be freed before the message >>>>> is >>>>> sent. Use "newCWString" instead and "free" in your receiving code. >>>>> >>>>> Cheers >>>>> Sylvain >>>>> >>>>> Le 18/07/2012 17:47, Brent Yorgey a ?crit : >>>>> >>>>>> Hi, >>>>>> >>>>>> Just a meta-comment: this doesn't seem like a beginner question to >>>>>> me. =) Perhaps someone on this list will know the answer (and there's >>>>>> nothing wrong with asking), but for such a specific question you may >>>>>> have better luck posting to haskell-cafe or StackOverflow. >>>>>> >>>>>> -Brent >>>>>> >>>>>> On Wed, Jul 18, 2012 at 03:14:46PM +0200, Simon Peter Nicholls wrote: >>>>>>> >>>>>>> I'm new to Haskell, and have had some good success with FFI so far, >>>>>>> but using Win32's sendMessage to send a pointer in LPARAM or WPARAM >>>>>>> is >>>>>>> resulting in access violations at the other end. >>>>>>> >>>>>>> Is there some issue with my pointer conversions? Am I hitting some >>>>>>> restriction, or missing some compiler options? >>>>>>> >>>>>>> >>>>>>> It's driving me pretty crazy, after a very nice start to using >>>>>>> Haskell. >>>>>>> >>>>>>> Some "sending" code: >>>>>>> >>>>>>> Foreign.C.String.withCWString "frustrator" $ \s -> do >>>>>>> let wParam = System.Win32.Types.castPtrToUINT s :: >>>>>>> System.Win32.Types.WPARAM >>>>>>> Graphics.Win32.sendMessage wnd >>>>>>> Graphics.Win32.wM_APP >>>>>>> wParam 0 >>>>>>> >>>>>>> wndProc "receiving" code: >>>>>>> >>>>>>> | wmsg == Graphics.Win32.wM_APP = do >>>>>>> s <- peekCWString $ System.Win32.Types.castUINTToPtr >>>>>>> wParam >>>>>>> putStrLn s >>>>>>> return 0 >>>>>>> >>>>>>> The string will not be seen. >>>>>>> >>>>>>> Some extra notes: >>>>>>> >>>>>>> I can get wndProc messages and integral data generally. >>>>>>> The pointer values match textually at both ends when "shown" to >>>>>>> stdout. >>>>>>> At the sending side I can pass the CWString to a regular FFI function >>>>>>> call just fine, and castUINTToPtr will give me back a functioning Ptr >>>>>>> for that call. >>>>>>> >>>>>>> I have also tried sending to & receiving from a working C++ >>>>>>> program, >>>>>>> without success. Access violations are reported when receiving, >>>>>>> though >>>>>>> again the address matches up. Silence from Haskell as before, when >>>>>>> C++ >>>>>>> is sending. >>>>>>> >>>>>>> I found someone else having an issue here: >>>>>>> http://osdir.com/ml/haskell-c...@haskell.org/2009-11/msg00731.html >>>>>>> but >>>>>>> no solution unfortunately. >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Beginners mailing list >>>>>>> Beginners@haskell.org >>>>>>> http://www.haskell.org/mailman/listinfo/beginners >>>>>> >>>>>> _______________________________________________ >>>>>> Beginners mailing list >>>>>> Beginners@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/beginners >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Beginners mailing list >>>>> Beginners@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/beginners >>>> >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners@haskell.org >>>> http://www.haskell.org/mailman/listinfo/beginners >>> >>> >>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 3 Date: Wed, 18 Jul 2012 21:40:51 +0200 From: Simon Peter Nicholls <si...@mintsource.org> Subject: Re: [Haskell-beginners] How do I marshall a pointer over SendMessage LPARAM or WPARAM? To: beginners@haskell.org Message-ID: <caeacoj+aadx03msp6ywdpjxeaqzh1gaym8egnd0t19mvhq+...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Wellllll, I couldn't wait until tomorrow of course. I just had to have an after-dinner hack, tried again with WM_COPYDATA / COPYDATASTRUCT, and it worked first time! Thanks again for your help! On Wed, Jul 18, 2012 at 7:13 PM, Sylvain HENRY <hsy...@gmail.com> wrote: > If you are doing inter-process communication, you should not send pointers > as processes do not share the same address space. > > Use WM_COPYDATA to send a specific amount of data. > http://msdn.microsoft.com/en-us/library/windows/desktop/ms649011%28v=vs.85%29.aspx > > I've read that SendMessage is blocking, so you can use withCWString > (contrary to what I have previously written). As you have to pass the size > of the data, you can even use withCWStringLen (and peekCWStringLen). > > Cheers > Sylvain > > Le 18/07/2012 19:02, Simon Peter Nicholls a ?crit : > >> It's inter-process by design. >> >> I have a small "single instance " C++ program that I'm porting to >> Haskell. Once the first instance launched is up and running, >> subsequent launches send their command line params through to the >> single instance (file names). Similar to when a media player queues >> files in a play list. >> >> The most recent extra clue I have is that if I wrap the SendMessage >> function with my own C FFI version, my C function can both re-cast and >> output the CWString I have sent, and can successfully invoke the real >> SendMessage by overriding the CWString with a newly created L"blah" >> string. It's just a shame it can't use the original! >> >> My next session will involve poking around at the two strings to learn >> why they are treated differently. >> >> On Wed, Jul 18, 2012 at 6:33 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >>> >>> Are you sending the message to a window of the same process? >>> >>> -Sylvain >>> >>> Le 18/07/2012 18:28, Simon Peter Nicholls a ?crit : >>> >>>> I've tried that without joy. Have reposted over at Haskell cafe, as >>>> per Brent's advice. Thanks to both of you. >>>> >>>> On Wed, Jul 18, 2012 at 5:56 PM, Sylvain HENRY <hsy...@gmail.com> wrote: >>>>> >>>>> Hi, >>>>> >>>>> [As I've just registered to the list, I don't have the original >>>>> message. >>>>> That's why I answer to Brent insted of Simon] >>>>> >>>>> By using "withCWString", your CWString may be freed before the message >>>>> is >>>>> sent. Use "newCWString" instead and "free" in your receiving code. >>>>> >>>>> Cheers >>>>> Sylvain >>>>> >>>>> Le 18/07/2012 17:47, Brent Yorgey a ?crit : >>>>> >>>>>> Hi, >>>>>> >>>>>> Just a meta-comment: this doesn't seem like a beginner question to >>>>>> me. =) Perhaps someone on this list will know the answer (and there's >>>>>> nothing wrong with asking), but for such a specific question you may >>>>>> have better luck posting to haskell-cafe or StackOverflow. >>>>>> >>>>>> -Brent >>>>>> >>>>>> On Wed, Jul 18, 2012 at 03:14:46PM +0200, Simon Peter Nicholls wrote: >>>>>>> >>>>>>> I'm new to Haskell, and have had some good success with FFI so far, >>>>>>> but using Win32's sendMessage to send a pointer in LPARAM or WPARAM >>>>>>> is >>>>>>> resulting in access violations at the other end. >>>>>>> >>>>>>> Is there some issue with my pointer conversions? Am I hitting some >>>>>>> restriction, or missing some compiler options? >>>>>>> >>>>>>> >>>>>>> It's driving me pretty crazy, after a very nice start to using >>>>>>> Haskell. >>>>>>> >>>>>>> Some "sending" code: >>>>>>> >>>>>>> Foreign.C.String.withCWString "frustrator" $ \s -> do >>>>>>> let wParam = System.Win32.Types.castPtrToUINT s :: >>>>>>> System.Win32.Types.WPARAM >>>>>>> Graphics.Win32.sendMessage wnd >>>>>>> Graphics.Win32.wM_APP >>>>>>> wParam 0 >>>>>>> >>>>>>> wndProc "receiving" code: >>>>>>> >>>>>>> | wmsg == Graphics.Win32.wM_APP = do >>>>>>> s <- peekCWString $ System.Win32.Types.castUINTToPtr >>>>>>> wParam >>>>>>> putStrLn s >>>>>>> return 0 >>>>>>> >>>>>>> The string will not be seen. >>>>>>> >>>>>>> Some extra notes: >>>>>>> >>>>>>> I can get wndProc messages and integral data generally. >>>>>>> The pointer values match textually at both ends when "shown" to >>>>>>> stdout. >>>>>>> At the sending side I can pass the CWString to a regular FFI function >>>>>>> call just fine, and castUINTToPtr will give me back a functioning Ptr >>>>>>> for that call. >>>>>>> >>>>>>> I have also tried sending to & receiving from a working C++ >>>>>>> program, >>>>>>> without success. Access violations are reported when receiving, >>>>>>> though >>>>>>> again the address matches up. Silence from Haskell as before, when >>>>>>> C++ >>>>>>> is sending. >>>>>>> >>>>>>> I found someone else having an issue here: >>>>>>> http://osdir.com/ml/haskell-c...@haskell.org/2009-11/msg00731.html >>>>>>> but >>>>>>> no solution unfortunately. >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Beginners mailing list >>>>>>> Beginners@haskell.org >>>>>>> http://www.haskell.org/mailman/listinfo/beginners >>>>>> >>>>>> _______________________________________________ >>>>>> Beginners mailing list >>>>>> Beginners@haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/beginners >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Beginners mailing list >>>>> Beginners@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/beginners >>>> >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners@haskell.org >>>> http://www.haskell.org/mailman/listinfo/beginners >>> >>> >>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners@haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > > > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 4 Date: Wed, 18 Jul 2012 12:41:49 -0700 From: Erik Johnson <cryptore...@gmail.com> Subject: Re: [Haskell-beginners] haskell for system administration To: Mike Meyer <m...@mired.org> Cc: beginners@haskell.org Message-ID: <capj1xcgqcuzgwr8jyk7ydhryacsvitsheyw1c5k2dfl0-a9...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi Mike, I'm a little late to this thread but wanted to let you know it looks like Google Code changed the location of your project (URL). I've pasted the correct location inline. Thanks for this info., it looks helpful. By the way, I like the play on the name (ie. "Eddie" + "Haskell"). Erik Date: Mon, 21 May 2012 10:28:45 -0400 From: Mike Meyer <m...@mired.org> Subject: Re: [Haskell-beginners] haskell for system administration To: Ben <benjo11...@gmail.com> Cc: beginners@haskell.org Message-ID: <20120521102845.6dc79...@bhuda.mired.org> Content-Type: text/plain; charset=US-ASCII On Mon, 21 May 2012 19:43:47 +0530 Ben <benjo11...@gmail.com> wrote: >>> I am new to HASKELL.Currently I am using shell scripting for >>> Administration tasks and all.Kindly suggest me , does HASKELL usefull >>> for Linux system administration and reporting purpose.? >>Yes, it is. I wrote "eddie" to let me leverage Haskell list processing >> from the command line. The standard Unix tools generally cover this >> kind of thing fairly well, so it's only marginally useful. Windows >> users seem to find more use for it. http://code.google.com/eddie. http://code.google.com/p/eddie/ >>> Do we use HASKELL for network programming and all? >> Yup. You can find the code I wrote to extract statistical information >> on NCAA FBS seasons from the web at >> http://blog.mired.org/2012/01/analysis-of-fbs-controversies-part-i.html. >> While doing the fetch is a bit more complicated than using fetch (or >> curl, or whatever), the ease of analysis in Haskell and having the >> data already loaded when you want to start analysis makes up for that. <mike >> -- >> Mike Meyer <m...@mired.org> http://www.mired.org/ >> Independent Software developer/SCM consultant, email for more information. >> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120718/c5bcae8a/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 49, Issue 21 *****************************************