Re: [Haskell-cafe] XCode Dependency for HP on Mac
Tom Murphy amindfv at gmail.com writes: Is there a way to install HP without XCode? Could there be in the future? I'm tired of dealing with Apple's constant upgrade requirements, registration requirements, etc., and it seems like a small function that XCode actually performs in the Haskell development toolchain. Again, I'm ignorant of the details and I'm sorry if this is ranty, but I'd love to hear your reactions. Thanks! Tom Hi, I know this is an old thread, but it came up on Google when I was searching around for an answer to this. So maybe I can still help someone. 10.6 users can use this installer on GitHub https://github.com/kennethreitz/osx-gcc-installer. It installs gcc and a few other bits and pieces (less than a GB to install). Then you can install the Haskell Platform. It's worked for me so far! Enjoy! Thanks, Andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
Mark Lentczner mark.lentczner at gmail.com writes: As the README at that repository states, For 10.7 and later Apple now distributes a Command Line Tools package on the developer site. When I build and release the Haskell Platform, I confirm that works when just this package is installed (rather than all of Xcode). [Message continues] - Mark (HP release manager) ___ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Hi Mark, I will keep you updated, the issue is that I refuse to upgrade to 10.7 or later, many of the brilliant features from Snow Leopard were entirely ruined and I still see people complaining about having trouble with it on my model of MacBook. So for 10.6 users, this 3rd part installer is the only option I could find! Thanks, Andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Online haskell course
There is also the Haskell course (21 videos) given by Philip Wadler (one or the creators of Haskell) at University of Edinburgh in 2011. The first video is available at http://www.youtube.com/watch?v=AOl2y5uW0mAfeature=relmfu . Course materials (lecture notes, exercises, solutions, references, etc.) can be found at http://www.inf.ed.ac.uk/teaching/courses/inf1/fp/ . Joao H de A Franco 2012/10/24 Richard Wallace rwall...@thewallacepack.net In case you haven't seen it, there is an intro to Haskell video series by Erik Meijer on Channel9. There aren't any graded assignments or anything like that, but I found it to be excellent without those. [1] http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1 On Wed, Oct 24, 2012 at 10:59 AM, gra...@fatlazycat.com wrote: Anyone know of a similar course to the coursera scala one for haskell ? https://www.coursera.org/course/progfun Quite interesting online course that has graded assignments. Anything similar or anyone considering doing something similar for haskell ? Thanks Graham ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Threads and hGetLine
Hello, The simplified problem: There are two threads, one which is waits on input via hGetLine and another, which should terminate this thread or close this handle. hClose as well as killThread doesn't seem to work, caused by the fact, that the thread is blocked until input is availiable. Hopefully you have some solution how to kill the thread and/or close the handle and/or have some other idea to get the lined input in the other thread. -- Thanks in advance H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Data.Number.BigFloat/Fixed
Hello, With ghc-6.10.4 the following results are produced with numbers 2009.8.9: (7e-3 :: BigFloat Prec50) (6e-4 :: BigFloat Prec50) False (7e-3 :: BigFloat Prec50) (8e-4 :: BigFloat Prec50) True where in the sourecode is written: data BigFloat e = BF (Fixed e) Integer deriving (Eq, Ord) and import Data.Ratio newtype Fixed e = F Rational deriving (Eq, Ord, Enum, Real, RealFrac) H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Data.Number.BigFloat/Fixed
Ivan Lazar Miljenovic ivan.miljenovic at gmail.com writes: I'm sorry, but is there a question in there? H. h._h._h._ at hotmail.com writes: (7e-3 :: BigFloat Prec50) (6e-4 :: BigFloat Prec50) False (7e-3 :: BigFloat Prec50) (8e-4 :: BigFloat Prec50) True 7e-3 8e-4 The result should be False, but it's True. Basically I don't know where to report this bug. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Data.Number.BigFloat/Fixed
Antoine Latter aslatter at gmail.com writes: On Sun, Mar 21, 2010 at 4:49 PM, H. h._h._h._ at hotmail.com wrote: 7e-3 8e-4 The result should be False, but it's True. Basically I don't know where to report this bug. Sending to the maintainer of the package, as listed on hackage. Antoine This was my first idea as well, but there's no email: http://hackage.haskell.org/package/numbers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Howto start a bigger project
Why not just create a wiki? - S On 17.11.2009 01:54, Günther Schmidt wrote: Hi James, it's still very very far away from even a single line of code. I'd need a medium to lay this out first and discuss the idea. I'd normaly use this list, but I think it's a bit too volatile a medium for that. Most of the time I'm unable to find the threads I was interested in ever again, or with a great deal of pain. The *project* at this stage is academic / R D in nature. Günther Am 17.11.2009, 00:58 Uhr, schrieb James Britt ja...@neurogami.com: Günther Schmidt wrote: Hi all, I'm stuck with a problem where I need serious help from other haskellers, in particular those that participate here on this list. It's a rather big project and I will need to set it up in an organized way, something with a blog, web page or other means. I tried to solve it by myself while asking the occasional question here but that turned out to be ineefective. The problem as such is certainly of interest for just about any programmer who is using Haskell for real world programming too. In short, to get started I'd appreciate some tips how to set this up. Create a project on github.com. It makes it dead easy for people to try out code and submit patches. Do enough work so that the code is useful, even if the implementation is crap. In fact, a crappy implementation may be a good thing; it makes it easier for people to find something to contribute. And then they feel a part of the project. Version 0.0.1 has to work right out of the box, be easy to install, be stupid obvious to use, and have non-zero value. Promises mean nothing. So, in practice, you need to start a really small project that could maybe become big but doesn't have to in order to be valuable right now. I've ended up as a committer on more than a few projects because the code solved a real problem in a simple and good enough way that I did not feel the need to go roll my own. And when I encountered a bug or wanted a feature, it was easy to contribute. But, key to all this, is getting people to feel they have a vested interest in the project succeeding, and that can be tricky. James ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] rotate image
Hello, Nobody any idea? I want to paint in some widget, but this will be in front of some background, so the bg should be transparent. -- best regards h. -- View this message in context: http://www.nabble.com/rotate-image-tp25122912p25198054.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] rotate image
Hello, Thanks for your answers and your time, but I fear that I didn't described the problem accurately enough. The background is in the window created with gtk2hs (windowNew). It's just a fixed layout (fixedNew): bg - imageNewFromFile bg.jpg fixedPut fBox bg (0,0) If I now create the new image (with imageNewFromFile my.png) with it's alpha values, I can put it somewhere via fixedPut, and the other image is just covered where it should be, but I can't rotate the image. So cairo and the surface come into play. This works as well, the surface has it's alpha values where it should, but a drawingArea created with drawingAreaNew has a rectangular shape and a color. This is the problem. -- best regards h. -- View this message in context: http://www.nabble.com/rotate-image-tp25122912p25199462.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] rotate image
Hello, I already studied the references of gtk2hs for hours, as well as searched in the web, but didn't found any working solution. The problem is to load an image, a png with alpha channel, rotate it e.g. 10 degree, and show it on the screen, basically as when it would be shown with imageNewFromFile with transparency. Thanks in advance for your help. -- Best regards H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] rotate image
Hello, You could use Cairo. Load the image to a surface, then rotate the surface 10 degrees and paint it. The first steps aren’t problematic, but how can I paint it - in which widget - so that the background is transparent, with drawingArea it doesn’t seem to work. -- best regards H. -- View this message in context: http://www.nabble.com/rotate-image-tp25122912p25123653.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: rotate image
Hello, You could use Cairo. Load the image to a surface, then rotate the surface 10 degrees and paint it. The first steps aren’t problematic, but how can I paint it - in which widget - so that the background is transparent, with drawingArea it doesn't seem to work. -- best regards H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: rotate image
Hello, I want to paint in some widget, but this will be in front of some background, so the bg should be transparent. At the moment it looks something like this (where it isn't the case): -- drawA - drawingAreaNew widgetSetSizeRequest drawA 30 30 fixedPut fBox drawA (400,400) imgAt - imageSurfaceCreateFromPNG some.png let drawC = do dw - widgetGetDrawWindow drawA drawWindowClear dw renderWithDrawable dw $ do translate 9 9 rotate 0.3 translate (-9) (-9) setSourceSurface imgAt 0 0 paint onExpose drawA (const $ drawC return True) -- -- best regards H. From: jefferson.r.he...@gmail.com Date: Mon, 24 Aug 2009 19:40:46 -0400 Subject: Re: [Haskell-cafe] Re: rotate image To: h._h._...@hotmail.com CC: haskell-cafe@haskell.org ahh, you want to paint against the desktop, then, yes? That requires compositing, and I'm not sure there's a way to do that with Gtk directly. Probably easier with X and OpenGL. Needs more of a Gnome expert than me. _ Hol dir 30 kostenlose Emoticons für deinen Windows Live Messenger http://www.livemessenger-emoticons.com/funfamily/de-at/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Escape Codes
Hi, It would be nice if you could package this and release it on hackage. http://hackage.haskell.org/packages/hackage.html I packaged it, perhaps you can have a look at it, if it is, what you thought... When I get a username, I'll put it on hackage :) -- H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Escape Codes
Hello, Some days ago I needed escape codes on Win32. I didn't find any library for that, so I wrote a simple one. I thought, perhaps someone else will have the same problem, so I put it on my website:http://0hc.net/?what=downloads_sup_AWin32Console I've tested it with the ghc 6.6.1, and everything works as I expected it. I would be happy if someone else could test it and/or report if some important escape codes are missing. --Sincerely H. _ Erweitere dein digitales Leben. Hol dir jetzt gratis das neue Windows Live. http://get.live.com___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Licenses and Libraries
Hello, I have some questions connected more with the licenses and libraries as the language itself: Is it possible to: - publish Haskell source code under the BSD3 license - provide an executable binary together with the code including (compiled e.g. with 'ghc --make') standard (in the ghc compiler download) libraries of the base and/or other packages - publish Haskell source code under the BSD3 license which will work with GTK2HS - provide an executable binary together with the code compiled with 'ghc -- make' - does there have to be any special flags set to do so - does there have to be included further notes about the libraries and/or there license -- Thanks in advance, H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: tail recursion ?
Simon Brenner simbr843 at student.liu.se writes: listOfIndices' ubound = concat [ [i,(2*i) .. ubound] | i - [1..ubound] ] calc ubound = accumArray (const.not) False (1,ubound) $ [(x,False) | x - listOfIndices ubound] Thanks a lot! Your solution works fine as long as there are not to much modifications (you mentioned the memory...) -- accumArray --- 20 Mb total memory in use INIT time0.02s ( 0.00s elapsed) MUT time1.73s ( 1.81s elapsed) GCtime2.83s ( 2.86s elapsed) EXIT time0.00s ( 0.01s elapsed) Total time4.59s ( 4.68s elapsed) So I tried another possibility, STUArrays, which are significantly faster and use less memory: - main = mapM_ print $ filter snd $ runST calc x = 10 :: Int calc = do arr - newArray (1,x) False :: ST s (STUArray s Int Bool) calc' arr d - getAssocs arr return (d) where calc' arr = f 1 where f a | a x = g a f (a+1) | otherwise = g a where g b | b = x= readArray arr b = \i- writeArray arr b (not i) g (b+a) | otherwise = return () - (it is the first time I'm using this Type) -- STUArray - 8 Mb total memory in use INIT time0.01s ( 0.00s elapsed) MUT time0.21s ( 0.28s elapsed) GCtime0.21s ( 0.21s elapsed) EXIT time0.00s ( 0.01s elapsed) Total time0.43s ( 0.49s elapsed) But 8MB seems still too much, how can it be further optimised? -- Best Regards and thanks for you answers in advance H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] tail recursion ?
Hello @ all, Sometimes one has an imperative algorithm, and wants to write a program in Haskell which do has the same effect... So the question is - how a construct as the following can efficiently be written? -- Pseudo code: n[1..1] = false for (1..1) |i| for (i,2*i..1) |j| n[j] = not n[j] -- Certainly it is in this special case equivalent to (True where the index is): map (^2) [1..100] But I mean the destructive updates in the imperative code in Haskell without filling the (many times more than in imperative languages) memory with recursively called functions... The idea, I thought, is tail recursion, so perhaps I just have a big bug in my code, caused by the fact, that it needs even for 5000 approximately 100MB memory: -- import Data.Array main :: IO () main = putStr $! unlines $! map show $! filter snd $! zip [1..] $! elems $! calc $! la 5000 where la x = array (1,x) [(y,False)|y-[1..x]] calc :: Array Int Bool - Array Int Bool calc x = f 1 x where k :: Int k = snd $ bounds x f :: Int - Array Int Bool - Array Int Bool f !a !x | a k = f (a+1) $! g a x | otherwise = g a x g !a !x = x//[(j,not (x!j))|j-[a,a*2..k]] -- -- Thanks for you answers in advance H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: tail recursion ?
Jon Fairbairn jon.fairbairn at cl.cam.ac.uk writes: The idea in Haskell is not to think of stepping through the array. Look at accumArray and ixmap. Thanks for your answer. But I can't really see how the calc-function can be written more efficiently with accumArray or ixmap, perhaps you can write it as an example? -- Regards, H. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: splitting strings
Thanks a lot. I hope I can learn from your lines and ideas used here to improve future code in quality. -- Best regards h. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: process
I have in mind something as connections via pipes to the chils's stdin, stdout and stderr, but the stream library just supports internal pipes, and posix require Unix. By this means it's not possible to request, receive and than respond,... with the process. Does there exist an alternative way? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: process
Jules Bean jules at jellybean.co.uk writes: Well that depends entirely what your program is supposed to do. Your email doesn't tell us (a) what your program was supposed to do or (b) what goes wrong. Therefore we are forced to guess! The following slight variation of your program works fine for me. I don't have anything called 'prog1' on my system, so I used 'bc' which is a calculator program standard on unixes, which works by line-by-line interaction. I varied your program just a tiny bit to get some interesting output: module Main where import System.Process import System.IO main :: IO () main = do putStrLn Running BC (inp,out,err,pid) - runInteractiveProcess bc [] Nothing Nothing hSetBuffering inp LineBuffering hSetBuffering out LineBuffering hSetBuffering err LineBuffering hPutStrLn inp 1+3 a - hGetLine out hPutStrLn inp a a - hGetLine out hPutStrLn inp quit waitForProcess pid putStrLn a This program asks 'bc' to calculate 1+3. The reply is stored in 'a'. Then the program sends 'a' back to bc, effectively asking bc to calculate 4. Since the 4 evaluates just to 4, 'a' gets the value 4 once more. Then I have to send quit to bc. That is the command that bc interprets as an instruction to quit; without that command, 'waitForProcess pid' will wait forever (it's waiting for bc to quit). Finally my program outputs 4 the result of the last calculation. Is this close to what you're trying to do? Jules Thanks, but I still puzzle over the same problem. I wrote the following lines to test exactely your code: module Main where main :: IO () main = f where f = do a - getLine if a == quit then return () else putStrLn a f running the program in the console works without any problems (1+3 is the result :) ), but with runInteractiveProcess I do not get any output except Running BC, and every IO action after the first hPutStrLn inp 1+3 is never reached (the program hang-up there - no error is thrown) - thats my problem... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: process
Albert Y. C. Lai trebla at vex.net writes: h. wrote: module Main where main :: IO () main = f where f = do a - getLine if a == quit then return () else putStrLn a f This one also needs to switch to line buffering. Add/Change: import System.IO(stdout, hSetBuffering, BufferMode(LineBuffering)) main = hSetBuffering stdout LineBuffering f Thanks a lot, now it does work! This means just the proc1 program has to be changed and everything will work properly (hopefully - at least the haskell part works :) ). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] process
Hello, I need to interact with some other program, and wrote the following code: module Main where import System.Process import System.IO main :: IO () main = do putStrLn Running proc9... (inp,out,err,pid) - runInteractiveProcess prog1 [] Nothing Nothing hSetBuffering inp LineBuffering hSetBuffering out LineBuffering hSetBuffering err LineBuffering hPutStrLn inp 1 a - hGetLine out hPutStrLn inp a a - hGetLine out waitForProcess pid putStrLn a But it does not work as I expected. As long as there is no need to put some input after having received some output it is no problem, but real interaction seems not possible. Is there a solution to work with the Handles as with stdin,... ? using ghc 6.6 on Windows Thanks in advance for your help. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why is $ right associative instead of leftassociative?
These lineages are more or less right, except that there is a bit of incest: LML is certainly one of the progenitors of Haskell. (more semantically than syntactically, though) Cheers, --Joe [EMAIL PROTECTED] said: G'day all. Quoting Paul Hudak [EMAIL PROTECTED]: Actually, one of the main reasons that we chose (:) is that that's what Miranda used. So, at the time at least, it was not entirely clear what the de facto universal inter-language standard was. Exactly. One point that's often not appreciated is that Haskell is not a descendent of ML. The ML lineage is, roughly: Lisp - ISWIM - ML - SML, LML, O'Caml etc And the Haskell lineage is: Lisp - ISWIM - SASL - KRC - Miranda - Haskell ML is much more like an older cousin than an ancestor. This point is important because Turner languages already had a list syntax at the time that they adopted an ML-like type system. Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Joseph H. Fasel, Ph.D. email: [EMAIL PROTECTED] Stockpile-Complex Modeling and Analysis phone: +1 505 667 7158 University of Californiafax: +1 505 667 2960 Los Alamos National Laboratory post: D-2 MS F609; Los Alamos, NM 87545 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Combining distinct-thread state monads?
On Tue, 2004-01-06 at 22:58, Graham Klyne wrote: I'm not an expert in this, but I think what you are proposing is possible, to a point, possibly assuming that your monads have associated functions to combine and separate the monadic parts. Thanks for the below illustration of how this problem can be approached. I think you are right, this approach could solve my problem. The other solution seems to be, as you point out, the use of monadic transformers. The problem I have with these is that one would need to arbitrarily define one monad to be inside the other, whereas your approach seems more symmetric. David Espinosa, in his PhD thesis Semantic Lego seems to have a more symmetric transforming approach which he calls stratification. This looks promising, but he uses Scheme not Haskell so it's a bit hard for me to understand some parts. Cheers, Mark. P.S. I'm not sure if I need to be subscribed to haskell-cafe to reply on list. I guess I'll find out! Hmmm, let's try something... Given: combine :: ma - mb - mab separate :: mab - (ma,mb) (where ma, mb, mab are the separate and combined state monads) f :: ma () - mb () - mc () f a b = do { ma1 - fa1 a -- process state in a, returning ma1 -- fa1 :: ma - mc ma ; mb1 - fb1 b -- process state in b, returning mb1 ; let mab1 = combine ma1 mb1 ; mab2 = fab mab1 ; let (ma2,mb2) = separate mab2 ; ma3 - fa3 ma2 -- process state in ma2 ; mb3 - fb3 mb2 -- process state in mb2 ; return (fc ma3 mb3) } (This code is speculative, not tested in any way.) In this case, a third monad is used to schedule the operations on the separate monads, so in that respect the entire sequence is performed in a composite monad, within which methods defined for the separate monads can be invoked. To get the results, Monad 'mc' would need to provide a way to pick them out. It looks as if the combined monad 'mab' is probably superfluous. I think the composite monad 'mc' might be avoided, but some of the efficiency advantage of monads would be lost as the single-threading of each monad is potentially broken. I think that this may be all be achieved more cleanly using the monad transformer libraries and 'lift' methods -- can a state transformer be applied to a state monad? What I have noticed in my work with monads is that in most respects they can be treated just like any other value. Although they look different, a do sequence is just a monad-returning function, and any monad-returning function may be a do sequence. aside In my own work, I was pleasantly surprised how easy it was to use a Parsec parser monad (effectively a state monad, I think) to parse some data and return a combined state+IO monad, effectively precompiling a script, which which could then be executed by applying the resulting monad to an initial state, all within an IO monad. The code which does this can be seen at: http://www.ninebynine.org/Software/Swish-0.2.0/SwishScript.hs The main parser declaration is: script :: N3Parser [SwishStateIO ()] where 'script' is a Parsec parser monad which parses a script and returns a list of 'SwishStateIO ()' values, each of which is a combined state+IO monad. /aside #g -- Consider two state threads. The first has each state being a non-negative int, thought of as a string of binary digits. The second thread has each state being a bool. Now I want to have a state monad which modifies both threads as follows. Consider input states i (the int thought of as binary string) and b (the bool), and output states i' and b'. b' = not (b (i `mod` 2)) i' = i `div` 2 As you can see, both of these should be able to do update-in-place provided the above order is adhered to. We could achieve this using state monads where state is an (Int, Bool) pair. We would have one monad which did the first line, leaving i unchanged and a second monad which did the second line, leaving b' unchanged. But... what if before this interaction, the int thread and the bool thread were separate monads doing their own thing, and we just wanted to combine these threads briefly (using the above interaction) before letting the threads do their own thing again? Is this possible? Also, suppose we have previously defined an int thread monad which takes i, returns a value of i `mod` 2, and changes the state to i' = i `div` 2. Suppose also we have previously defined a bool thread monad which takes b, returns a nothing value, and changes the state to b' = not b. Can we use these two monads (each acting on different threads), to form a combined-interaction monad that does (same as before): b' = not (b (i `mod` 2)) i' = i `div` 2 I hope this is possible. It would facilitate both code reuse and readability. However I fear that it is not, requiring