[Haskell-cafe] GHCi with wxhaskell-dev
I'm working on a dev branch of wxHaskell [1] and one of the new features is that you can use wxHaskell in GHCi (again), but I seem to have broken something in the process: Firstly: wxHaskell works in GHCi insomuch as: You can load the hello world sample [2] in GHCi, do main, see the window spawn, close it and be returned to the GHCi prompt. What I'm interested in is the case where you call wxHaskell's start function [3] from GHCi. The result is becoming stuck with no way back to the GHCi prompt without resorting to sending kill signals. I made a screen cast to illustrate my findings [4]: 1. Once you've done start $ return () you can press ^C all you want, there's no way back to the GHCi prompt. 2. If you send three (less has no effect) kills to the GHCi process it will exit, but it will exit GHCi as well (instead of putting you back at the GHCi prompt). 3. If you do start $ return () but *do not* try and ^C, you can send a single kill to GHCi and be returned to the GHCi prompt. My questions: 1. Why doesn't GHCi respond to the ^C? 2a. Why does entering ^C from within GHCi then prevent you from getting back to the GHCi prompt? 2b. Why doesn't any other input (i.e. entering anything but ^C) cause this behaviour? 3. If you have sent ^C from GHCi, why do you then have to kill three times to get out of GHCi? Feel free to pull the repo [1] and try it out, you'll need the latest dev release of wxWidgets [5] installed. Thanks! Dave, [1] http://darcsden.com/DukeDave/wxhaskell-dev [2] http://darcsden.com/DukeDave/wxhaskell-dev/browse/samples/wx/HelloWorld.hs [3] http://darcsden.com/DukeDave/wxhaskell-dev/browse/wx/src/Graphics/UI/WX.hs#L-58 [4] http://youtu.be/sEI48ultdS0 [5] http://sourceforge.net/projects/wxwindows/files/2.9.3/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal rebuilding all of the C++ code for wxHaskell
On 30 September 2011 03:02, Claude Heiland-Allen cla...@goto10.org wrote: On 30/09/11 02:45, DukeDave wrote: 1. Is there some reason (other than 'safety') that cabal install cleans everything up? As far as I've experienced and understand it, it doesn't - it's more that GHC can detect when Haskell modules don't need recompiling while the same is not true for C or C++ sources. For example, I change one module and see GHC report only that module and its dependents being recompiled, while the other compiled modules are reused from previous 'cabal install' runs. The C-sources: are recompiled every time even if unchanged, which I too find it somewhat annoying even with my small projects. Excellent, that is consistent with what I'm seeing, and I'm glad I'm not the only one who finds it annoying. I have no familiarity with how cabal and GHC handle C-sources, but I presume that the job of building them is handed off to a local C/C++ compiler (I presume g++ in my case). Given this I can only assume that cabal is doing something: 1. Deleting the object files before calling the C compiler (and so everything must be rebuilt)? 2. Touching the source C files in some way, before calling the C compiler? 3. Passing some argument to the compiler which is telling it to rebuild everything? 4. Something else? 2. Why does setting cleanHook to return () not have any effect? I think becausae the clean hook is probably not called by 'cabal install', but by 'cabal clean'. Ah yes, that does make sense, my bad. Claude ___ 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] Cabal rebuilding of the C++ code for wxHaskell
Hi all, I've been trying to resolve a compile time issue[1] with wxHaskell, and I thought I'd throw it open to see if anyone on cafe can help. Here's the crux of the issue: The Setup.hs for wxcore (the major component of wxHaskell) uses simpleUserHooks, overriding only confHook. However there is also cleanHook, which is defined by simpleUserHooks to be: cleanHook = \p _ _ f - clean p f, If you consult the source for clean[2] you'll see that it tries to remove the whole dist/ directory rather than tracking exactly what files we created in there. I presume that's why we have to do a full re-build every time? To try and circumvent this I modified the definition of main in Setup.hs to this: main = defaultMainWithHooks simpleUserHooks { confHook = myConfHook, cleanHook = (\_ _ _ _ - return ())} Unfortunately it still seems to re-build all the C++ on each 'install' from cabal. Not sure why? Dave, [1] http://sourceforge.net/mailarchive/message.php?msg_id=2807 [2] Taken from http://www.haskell.org/ghc/docs/6.10.4/html/libraries/Cabal/src/Distribution-Simple.html#simpleUserHooks -- Cleaning clean :: PackageDescription - CleanFlags - IO () clean pkg_descr flags = do let distPref = fromFlag $ cleanDistPref flags notice verbosity cleaning... maybeConfig - if fromFlag (cleanSaveConf flags) then maybeGetPersistBuildConfig distPref else return Nothing -- remove the whole dist/ directory rather than tracking exactly what files -- we created in there. chattyTry removing dist/ $ do exists - doesDirectoryExist distPref when exists (removeDirectoryRecursive distPref) -- these live in the top level dir so must be removed separately removeRegScripts -- Any extra files the user wants to remove mapM_ removeFileOrDirectory (extraTmpFiles pkg_descr) -- If the user wanted to save the config, write it back maybe (return ()) (writePersistBuildConfig distPref) maybeConfig where removeFileOrDirectory :: FilePath - IO () removeFileOrDirectory fname = do isDir - doesDirectoryExist fname isFile - doesFileExist fname if isDir then removeDirectoryRecursive fname else if isFile then removeFile fname else return () verbosity = fromFlag (cleanVerbosity flags) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Potential problem with AC-Vector-Fancy package
Is anyone maintaining the AC-Vector-Fancy package? I haven't had a reply from the latest maintainer (Andrew Coppin) on Hackage, so I thought I'd open it up to cafe: I think I have found a problem with the union function: If you look here: http://hpaste.org/49889 You will see that line 4 gives a different result to lines 6, 8, 10; this shouldn't be the case because union is commutative. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Potential problem with AC-Vector-Fancy package
Is anyone maintaining the AC-Vector-Fancy package? I haven't had a reply from the latest maintainer (Andrew Coppin) on Hackage, so I thought I'd open it up to cafe: I think I have found a problem with the union function: If you look here: http://hpaste.org/49889 You will see that line 4 gives a different result to lines 6, 8, 10; this shouldn't be the case because union is commutative. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Calling Haskell from other languages?
Hi Colin As an alternative you may consider using Thrift: http://incubator.apache.org/thrift/ Cheers, Dave On Tue, 2008-11-11 at 16:45 +, Colin Paul Adams wrote: Is there a way to call Haskell code from other languages? I have looked on the wiki, and as far as I can see, it only talks about the other way round (when Haskell is the main program). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What *not* to use Haskell for
Hi everyone So I should clarify I'm not a troll and do see the Haskell light. But one thing I can never answer when preaching to others is what does Haskell not do well? Usually I'll avoid then question and explain that it is a 'complete' language and we do have more than enough libraries to make it useful and productive. But I'd be keen to know if people have any anecdotes, ideally ones which can subsequently be twisted into an argument for Haskell ;) Cheers, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Constructing Data.Map from ByteString
Just a few updates on this one: I've upgraded to bytestring-0.9.0.5 from Darcs, no improvement. Also this morning I tried using Data.HashMap with Bytestring's readInt and HashMap's hashInt.. The result was a Stack space overflow :( God damn it I don't want to have to go back to C++ but soon will have no choice with time constraints :( Dave, On 10/03/2008, Dave Tapley [EMAIL PROTECTED] wrote: Hi all, I've been plugging away at this all day and some discussion in #haskell has been fruitless. Perhaps you have the inspiration to see what's happening! Concerning this minimal example: http://hpaste.org/6268 It works as required, loading K/V pairs into a Data.Map, the concern is the amount of memory used. Pausing (using a getLine) after the readFile one can see (through 'ps v') that the whole file 'f' is loaded in to memory. However once the Map is created the memory footprint swells to around five times the size. Surely this can't be just overhead from Map? My reasoning was that by using ByteString and getting the whole file into memory a small and linear increase would be seen for Map overhead.. I have tried using both Data.ByteString.Char8 and Data.ByteString.Lazy.Char8 with negligible difference. For a hoot I tried it with String and yes, it's ridiculous :) Cheers, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Constructing Data.Map from ByteString
Hi all, I've been plugging away at this all day and some discussion in #haskell has been fruitless. Perhaps you have the inspiration to see what's happening! Concerning this minimal example: http://hpaste.org/6268 It works as required, loading K/V pairs into a Data.Map, the concern is the amount of memory used. Pausing (using a getLine) after the readFile one can see (through 'ps v') that the whole file 'f' is loaded in to memory. However once the Map is created the memory footprint swells to around five times the size. Surely this can't be just overhead from Map? My reasoning was that by using ByteString and getting the whole file into memory a small and linear increase would be seen for Map overhead.. I have tried using both Data.ByteString.Char8 and Data.ByteString.Lazy.Char8 with negligible difference. For a hoot I tried it with String and yes, it's ridiculous :) Cheers, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Thrift bindings
Hi everyone, This is regarding Thrift, a software framework for scalable cross-language services development(1) Present in the release tarball there is some source for Haskell but no sign of a tutorial or any sample code. I'm just picking through but as a long shot does anyone have examples they could send me? I'm also looking to put together a page on haskellwiki once I'm up and running. The project seems like a fine way to sneak Haskell into existing project ;) Cheers, Dave (1) http://developers.facebook.com/thrift/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] transparent parallelization
If I recall correctly a rather neat way of exploiting this property of qsort is exploited with Nested Data Parallelism and covered in this talk: http://www.londonhug.net/2007/05/25/video-of-spjs-talk-is-now-online/ Good food for thought :) Dave, On 18/09/2007, Thomas Girod [EMAIL PROTECTED] wrote: Hi there. Beeing rather new to the realm of Haskell and functional programming, I've been reading about how is easier it is to parallelize code in a purely functional language (am I right saying that ?). My knowledge of parallelization is also very weak, but I've been thinking about this and I have a question. Let's say we take a small piece of code, like the quicksort algorithm. qsort [] = [] qsort (x:xs) = qsort lesser ++ [x] ++ qsort greater where lesser = filter (x) xs greater = filter (=x) xs (actually I didn't test this code, this is just for the example) Here, computing lesser and greater are two disjoint actions - we don't need the result from one to compute the other, and haskell does not allow one to alter data so that would change the behaviour of the other. So I guess those could be run in parallel. Would it be fairly simple to automatically determine parts of code that can be run in parallel, and parts that cannot (at least in non-monadic code) ? So the final question is : if it is possible to automatically define segments of code that can be run in parallel, is [insert compiler name here] compiling this code as a one thread thing, or as a multithreaded version ? I guess on single processor machines, it is more efficient to do it as a single thread - but with those many-cores processors that are coming, it probably won't be true anymore. Sorry if this post is blowing off open doors (I guess this doesn't mean anything in english but it sounds cool) ... Regards Thomas Girod ___ 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] Tackling IO (the correct way)
Hi again all, I could do with some design pointers for a project I'm working on combining Haskell with a robot. My situation is: I read sensor data from the robot lazily a line at a time, as soon as a line is read in my code sends out a response down a pipe. Implemented in this fashion: mapM_ (updateFunction myIORef) fromRobot ::IO () fromRobot :: String updateFunction :: IORef - String - IO () Now I wish to update a HOpenGL window synchronously with this. To establish this I make a new HOpenGL window return an IORef (IO ()) which holds the actions to draw my graphics. In this fashion: myIORef - makeWindow --- Above code --- mainLoop This can be passed to updateFunction as shown above so every time it processes a new line from the robot is can update the graphics via the IORef. Because neither 'mapM_ (updateFunction myIORef) fromRobot' nor 'mainLoop' terminate I've been using 'forkIO' to split one off. This way the lazy evaluation keeps running and then window keeps updating itself. This works, sort of. I have problems because the my HOpenGL code also has magic to allow you to change the point of view using the keyboard. But when I do I get this after a while: LOCK SET! Previous intel_span.c:210 Current: intel_batchbuffer.c:63 Can anyone suggest how to resolve this two functions which never terminate but both share IORefs problem? Many thanks, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Exiting GLUT application
Unfortunately whilst the new code is returning me to a 'Main ' prompt as required another problem has come up. The issue here is found when the code is executed in both GHCi (6.6) and hugs (20050308). Once the code below is loaded evaluating main opens an unfilled window as required. However if this window is closed and main is evaluated again both GHCi and hugs die thus: GHCi: Illegal instruction (core dumped) hugs: Unexpected signal Any thoughts? On 31/07/07, Dave Tapley [EMAIL PROTECTED] wrote: Excellent, thank you Marc your advice worked perfectly. For reference the corrected code reads: import Graphics.UI.GLUT main = do getArgsAndInitialize createWindow actionOnWindowClose $= ContinueExectuion mainLoop Dave, On 31/07/07, Marc A. Ziegert [EMAIL PROTECTED] wrote: in old glut, the main loop was the core of the single threaded program. exiting it did mean to exit the program completely. in freeglut, you have alternatives. but for compatibility, it defaults to the old behaviour. http://haskell.org/ghc/docs/latest/html/libraries/GLUT/Graphics-UI-GLUT-Begin.html#v%3AExit - marc Am Dienstag, 31. Juli 2007 19:16 schrieb Dave Tapley: Hi everyone, I have the following skeleton GLUT code: import Graphics.UI.GLUT main = do getArgsAndInitialize createWindow mainLoop It loads into both hugs and ghci fine and when 'main' is evaluated an empty window opens as expected. However when closing the window (clicking the window manager's x button) both hugs and ghci exit with the window, as opposed to returning to the the 'Main' prompt. I suspect I need some callback to exit the GUI cleanly? Cheers, Dave ___ 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] Propositional logic question
Hopefully this is just about on topic enough.. (Oh and it's not home work, I just can't bring myself to let it go!) Taken from Simon Thompson: Type Theory and Functional Programming Section 1.1 Exercise 1.3 Question: Give a proof of (A = (B = C)) = ((A /\ B) = C). Now I can easily perform (and verify, it's given earlier in the section) the proof of implication with the terms flipped around: ((A /\ B) = C) = (A = (B = C)) Thus: [A]2 [B]1 --- (/\ I) [(A /\ B) = C]3 A /\ B (= E) C - (= I) 1 B = C -- (= I) 2 A = (B = C) --- (= I) 3 ((A /\ B) = C) = (A = (B = C)) My problem arrives finding a solution to the exercise question, my approach is to basically run the above proof backwards. Thus: A = (B = C) A - (= E) B B = C - (= E) C Now at this point I thought aha, I can use (= I) to introduce (A /\ B) and get: - (= I) 1 (A /\ B) = C But here I am only entitled to discharge (A /\ B) in the preceding proof and not A and B on their own. What proof which would allow me to discharge my assumptions A and B? I can see in my head how it makes perfect sense, but can't jiggle a way to do it using only the given derivations. Many thanks, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Propositional logic question
Whoops, okay after two lines (thanks to oerjan) on #haskell I realise that yes, it is as easy as it should have been. For completeness: [A /\ B]1 (/\ E1) [A = (B = C)]2 A - (= E) B = C [A /\ B]1 (/\ E2) B B = C - (= E) C -- (= I)1 (A /\ B) = C (= I)2 (A = (B = C)) = ((A /\ B) = C) Learning is fun :) Dave, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lambdabot
Perhaps in here we should start using \x - (unlines . (dropWhile (/= x)) . lines) Instead :) Dave, On 23/06/07, Thomas Schilling [EMAIL PROTECTED] wrote: On 22 jun 2007, at 22.17, Derek Elkins wrote: [blah blah blah] A less (potentially) offensive way of formulating this is: [...] or -snip- (You know, we don't want to accidentally piss of any newcomers. So just saying .. :) ___ 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] Parsec question
I find it's good for the soul to remember what the do notation is doing for us. Also I'm with Einstein on You do not really understand something unless you can explain it to your grandmother :) Personally I think (in this instance) your three 'Parser a' functions read nicer as: primary = (identifier = (return . PrimaryIdentifier)) | (stringLiteral = (return . PrimaryLiteral)) identifier = (many1 letter) = (return . Identifier) stringLiteral = (char '\'') (manyTill anyChar (char '\'')) = (return . StringLiteral) Looking at them in this form Tomek's point should seem clear now, especially when we look at the type signature for liftM: liftM :: Monad m = (a1 - r) - m a1 - m r So we can (marginally) shorten down to: primary = (liftM PrimaryIdentifier identifier) | (liftM PrimaryLiteral stringLiteral) identifier = liftM Identifier (many1 letter) stringLiteral = liftM StringLiteral ((char '\'') (manyTill anyChar (char '\''))) You might like: http://syntaxfree.wordpress.com/2006/12/12/do-notation-considered-harmful/ Dave, On 21/06/07, Tomasz Zielonka [EMAIL PROTECTED] wrote: On Thu, Jun 21, 2007 at 03:34:54PM +0930, Levi Stephen wrote: Is there a way through combining types/parsers that the double do block in primary could be avoided? I understand it's necessary right now because the parsers identifier and stringLiteral return different types, so I can't just write: i - identifier | stringLiteral You can use the fact that (GenParser tok st) is a monad and use liftM: i - liftM PrimaryIdentifier identifier | liftM PrimaryLiteral stringLiteral I often find it convenient to use choice instead of | for long more complicated alternatives, for example like this: primary = choice [ do i - identifier return $ PrimaryIdentifier i , do l - stringLiteral return $ PrimaryLiteral l ] So, I'm not sure whether my types need work, I have a feeling that Identifier and Literal could just be type synonyms, because newtype's don't seem to be neccesary or beneficial here. I could be wrong though - after all, I don't know your intentions and the rest of the program. Best regards Tomek ___ 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