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. gtk2hs and threadDelay (ga...@caesar.elte.hu) 2. Getting the current system date outside the IO Monad (AbdulSattar Mohammed) 3. Re: Getting the current system date outside the IO Monad (Chadda? Fouch?) ---------------------------------------------------------------------- Message: 1 Date: Mon, 26 Dec 2011 14:24:52 +0100 From: ga...@caesar.elte.hu Subject: [Haskell-beginners] gtk2hs and threadDelay To: beginners@haskell.org Message-ID: <20111226142452.10493mg6jdffn...@webmail.caesar.elte.hu> Content-Type: text/plain; charset=ISO-8859-2; DelSp="Yes"; format="flowed" Hello! I managed to do it with timeoutAdd: --code below is the onClicked function: drawProgram gui preprocPrg = do let drArea = (drawWin gui) drw <- widgetGetDrawWindow drArea -- let list = compileToList preprocPrg -- renderWithDrawable drw (drawFromList list) renderWithDrawable drw (myDraw 200 200) -- drawWindowProcessUpdates drw True timeoutAdd ((\_ -> do renderWithDrawable drw (myDraw2 200 200) return False) 5) 500 return () But "sometimes" it gives the following error: (<interactive>:23929): Gdk-WARNING **: Using Cairo rendering requires the drawable argument to have a specified colormap. All windows have a colormap, however, pixmaps only have colormap by default if they were created with a non-NULL window argument. Otherwise a colormap must be set on them with gdk_drawable_set_colormap (<interactive>:23929): Gdk-CRITICAL **: IA__gdk_cairo_region: assertion `region != NULL' failed <interactive>: user error (NULL pointer) <interactive>: interrupted <interactive>: warning: too many hs_exit()s What can cause this? I think the other parts of my program are correct, and I cant understand, how can ghci "randomly give" this error. (every 5. try) To be honest, my goal is to make a "turtle graphics" program, so I ll have to write a function, which draws a line on the GUI in slow motion: there will be even more problems with timing, because I ll have to draw the line pixel by pixel. ------------------------------ Message: 2 Date: Tue, 27 Dec 2011 14:11:34 +0530 From: AbdulSattar Mohammed <codingta...@gmail.com> Subject: [Haskell-beginners] Getting the current system date outside the IO Monad To: beginners@haskell.org Message-ID: <ca+mxqh_oofa7u5dgg_let6cwfncmqpaonudiy9di63x+6dg...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I'm still learning Haskell and I've started learning Yesod. I pretty much built a blog before I came this silly roadblock. Whenever I create a new post, I want it take the current system time as its creation time. I understand it's an impure operation and it must go into the IO Monad to be performed. But, in Yesod, your handler is of the type Handler RepHtml. I don't get how you could get the impure value into a pure function without main playing any part. Here's the link for my blog: http://hpaste.org/55757#line85 -- Warm Regards, AbdulSattar Mohammed -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111227/807de9dd/attachment-0001.htm> ------------------------------ Message: 3 Date: Tue, 27 Dec 2011 09:53:08 +0100 From: Chadda? Fouch? <chaddai.fou...@gmail.com> Subject: Re: [Haskell-beginners] Getting the current system date outside the IO Monad To: AbdulSattar Mohammed <codingta...@gmail.com> Cc: beginners@haskell.org Message-ID: <canfjzryn-vkzxji_st5p2j_wbo-alafq4ha9k49-fkubj8p...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Tue, Dec 27, 2011 at 9:41 AM, AbdulSattar Mohammed <codingta...@gmail.com> wrote: > I'm still learning Haskell and I've started learning Yesod. I pretty much > built a blog before I came this silly roadblock. > > Whenever I create a new post, I want it take the current system time as its > creation time. I understand it's an impure operation and it must go into the > IO Monad to be performed. But, in Yesod, your handler is of the type Handler > RepHtml. I don't get how you could get the impure value into a pure function > without main playing any part. > Thankfully, we can build monad "stacks" that contains several capacities, this is a standard way to design libraries in Haskell. Yesod use Handler and not IO because it needs to convey more informations than just the IO monad but Handler normally contains IO and is as such a MonadIO instance. In other words, you can use any IO action with the "liftIO" function. -- Jeda? ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 42, Issue 29 *****************************************