[Haskell] ANN: Chart library v1.0
I'm pleased to announce version 1.0 of the Chart library - a library for rendering 2D charts in haskell. It supports a variety of plot types, and several different rendering backends. Whilst the library has seen sporadic patches and releases in recent years, development has seen a huge spike over the last 3 months thanks to Jan Bracker's excellent GSOC work. The key changes in this release are: * The rendering backend has been abstracted, and there are rendering implementations for cairo and the diagrams library. The removal of the dependency on cairo should make the chart library more useful to haskell developers on windows and OSX. Jan Bracker has put a huge effort into this change. * The library has switched from using data-accessor to lenses to provide accessors for the plotting data model. Thanks to Ben Gamari for this change. These, along with various other API changes justify a 1.0 version. Details of the library and code examples can be found on the github wiki: https://github.com/timbod7/haskell-chart/wiki The packages and API documentation are on hackage: http://hackage.haskell.org/package/Chart http://hackage.haskell.org/package/Chart-cairo http://hackage.haskell.org/package/Chart-diagrams Tim Docker ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Problem with mailman at projects.haskell.org
Thanks - I can confirm all is working again. I believe than, within some time window. some messages may have been dropped. Tim On 14/05/13 07:06, Yitzchak Gale wrote: The mailman daemon process on the server apparently exited for some reason. I restarted it, and now mail traffic seems to be going through normally again. -Yitz On Sun, May 12, 2013 at 9:21 PM, Carter Schonwald carter.schonw...@gmail.com wrote: I've had this problem too. Was trying to sign up for the llvm HS lib list but cant. I asked on Haskell irc and no one seems to know who admins the lists currently. On May 12, 2013 7:24 AM, Tim Docker t...@dockerz.net wrote: Hi, Has anyone noticed problems with the mailman instance running at projects.haskell.org? As best I can see there are no new posts in any of the hosted list archives since mid April. I know that there have been posts made to ch...@projects.haskell.org in May, and these have neither be distributed or archived. I've not had a response from mail...@projects.haskell.org. Tim ___ 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] Problem with mailman at projects.haskell.org
Hi, Has anyone noticed problems with the mailman instance running at projects.haskell.org? As best I can see there are no new posts in any of the hosted list archives since mid April. I know that there have been posts made to ch...@projects.haskell.org in May, and these have neither be distributed or archived. I've not had a response from mail...@projects.haskell.org. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for portable Haskell or Haskell like language
On 27/04/13 15:21, Christopher Howard wrote: Hi. I've got this work situation where I've got to do all my work on /ancient/ RHEL5 systems, with funky software configurations, and no root privileges. I wanted to install GHC in my local account, but the gnu libc version is so old (2.5!) that I can't even get the binary packages to install. You can use GHC on RHEL 5 machines, it's just very tedious to set up. A blog post I wrote a while ago describes the process: http://twdkz.wordpress.com/2011/12/21/installing-ghc-7-0-3-and-the-haskell-platform-on-rhel-5-6/ I still use this, though now I have an extra step to build build GHC 7.4.2 atop of 7.0.3. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MVar which can not be null ?
On 18/03/13 19:07, s9gf4ult wrote: nor STM, becuase IO is not acceptable inside STM transaction. I just need some thread-safe blocking variable like MVar modifyMVar :: MVar http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/Control-Concurrent-MVar.html#t:MVar a - (a - IO http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/System-IO.html#t:IO (a, b)) - IO http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/System-IO.html#t:IO b Whilst it's true that IO cannot be performed within an STM action, a common pattern is to return the necessary IO action from the STM action, and then run it once the STM transaction has completed successfully. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Open-source projects for beginning Haskell students?
On 12/03/13 05:26, Jason Dagit wrote: Myself and several of my friends would find it useful to have a plotting library that we can use from ghci to quickly/easily visualize data. Especially if that data is part of a simulation we are toying with. Therefore, this proposal is for: A gnuplot-, matlab- or plotinum-like plotting API (that uses diagrams as the backend?). The things to emphasize: * Easy to install: No gtk2hs requirement. Preferably just pure haskell code and similar for any dependencies. Must be cross platform. * Frontend: graphs should be easy to construct; customizability is not as important * Backend: options for generating static images are nice, but for the use case we have in mind also being able to render in a window from ghci is very valuable. (this could imply something as purely rendering to JuicyPixels and I could write the rendering code) I maintain the Chart library: http://hackage.haskell.org/package/Chart I'd like to see it used more widely, but gtk/cairo seems to be a problem for many people. Is the cairo dependency the reason you are suggesting that an alternative plotting library be built? Is your problem with cairo the difficulty in setting it up on ms windows/osx? What graphics API would you suggest using to render in a window from ghci? If there were a good cross platform alternative to cairo, I'd happily target this additional 2D drawing API. However, I don't think there currently is one. Neither gloss nor the diagrams library currently have adequate text support. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble installing and using Chart/cairo on windows 7
On 04/03/13 07:22, Arnaud Bailly wrote: Then I managed to install splot and timeplot. I then tried to use Chart to draw a simple chart, following http://hackage.haskell.org/packages/archive/Chart/0.16/doc/html/Graphics-Rendering-Chart-Simple.html and it hang forever with a CPU at 100%. As the author of the Chart library, I'm sorry to say I don't know. Chart is developed under linux, and I do occasional testing under osx, but I don't use windows at all. Chart is a pure haskell library sitting over cairo, so it is most likely a cairo problem rather than a chart one, but I realise this doesn't help you. Do the examples that come with the haskell binding to cairo work for you? Windows and gtk continues to be problematic for many users. I'd love to see an alternative backend for the chart library, but I would need a graphics API that installs easily under windows, osx and linux, and provides good access to fonts and font metrics. Any suggestions? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache
On 29/01/2013, at 12:43 PM, Bob Hutchison hutch-li...@recursive.ca wrote: The immediate problem is mapping an input to the system, some json message containing a reference to the 'thing' (like a key of some kind). I have to take that reference and find the thing and operate on it. All operations are easily accommodated by a type class. However, since I can't have a collection with mixed types even if the types satisfy a type class, I can't quite see how to actually store the things so I can find them. So there are a couple of obvious ways to handle this. I could use an ADT and a sum type of all the known kinds of thing, but I already know that this has to be extended and that's going to be problematic with users doing this on their own. And the type signatures look ugly. So I think that's not the best. I could use an ADT that contains functions that correspond to the functions of the type class, and that close over the 'thing' in question. I think this could be made to work, but I'm concerned with walking into more nasty surprises… My advice is to go for the latter option. I'm not sure what nasty surprises you are expecting, but this record of functions approach is the one that I normally take when I am building a system that needs new types added without requiring global changes. I know that existentials and GADTs are possible solutions, but I've not needed the extra complexity here. Cheers, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Suggestiong for inter-thread communication
Hi Eric, In a previous project, I chose vty over ncurses: - you can write your own event loop, and hence handle different event sources. - more liberal license (BSD3 versus GPL) Tim On 26/01/13 19:24, Erik de Castro Lopo wrote: Hi all, I am in the process of writing a Haskell program consisting of two threads, one for performing a calculation and one for an Ncurses UI (haskell-ncurses). The calculation thread needs to feed a stream of numbers back to the UI thread (about 1 value per second) and the UI needs to take input from the user and will pass parameter changes to the calculation thread using an IORef and atomicModifyIORef. However, I'm not sure how to hande the UI thread. The UI thread would normally wait for Ncurses input using getEvent, but I need advice on how to the the data from the calculation thread. Any advice or things to try? Cheers, Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: cabal-install-1.16.0 (and Cabal-1.16.0.1)
Does this new release included the sandbox functions discussed in this blog post: http://blog.johantibell.com/2012/08/you-can-soon-play-in-cabal-sandbox.html ? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Over general types are too easy to make.
On 01/09/12 04:00, timothyho...@seznam.cz wrote: I'd have to say that there is one(and only one) issue in Haskell that bugs me to the point where I start to think it's a design flaw: It's much easier to type things over generally than it is to type things correctly. Say we have a data BadFoo = BadBar{ badFoo::Int} | BadFrog{ badFrog::String, badChicken::Int} This is fine, until we want to write a function that acts on Frogs but not on Bars. The best we can do is throw a runtime error when passed a Bar and not a Foo: deBadFrog :: BadFoo - String deBadFrog (BadFrog s _) = s deBadFrog BadBar{} = error Error: This is not a frog. We cannot type our function such that it only takes Frogs and not Bars. This makes what should be a trivial compile time error into a nasty runtime one :( The only solution I have found to this is a rather ugly one: data Foo = Bar BarT | Frog FrogT If I then create new types for each data constructor. data FrogT = FrogT{ frog::String, chicken::Int} data BarT = BarT{ foo :: Int} Then I can type deFrog correctly. deFrog :: FrogT - String deFrog (FrogT s _) = s I'm curious as to what you find ugly about this. It appears you need to distinguish between Bars and Frogs, so making them separate types (and having a 3rd type representing the union) is a natural haskell solution: data Bar = .. data Frog = .. fn1 :: Bar - .. fn2 :: Frog - .. fn3 :: Either Bar Frog - .. Perhaps a more concrete example would better illustrate your problem? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Over general types are too easy to make.
On 02/09/12 20:35, timothyho...@seznam.cz wrote: It seems to be a probability approaching law, that I run into this for a given multi-constructor type. Regardless of it's purpose. Maybe your large multi-constructor types are too monolithic? Again it's hard to know given a fabricated example, but I would have been satisfied with something like: data Foo = Foo {...} data Bar = Bar {...} data Frog = Frog {...} data LargeUnion = UFoo Foo | UBar Bar | UFrog Frog case largeUnion of (UFoo foo) - processFoo foo (UBar bar) - processBar bar (UFrog frog) - processFrog frog But I think from your original mail, you find this ugly in some way? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc-7.4 on CentOS-5.8 ?
Here's the steps I had to go go to get ghc7.0 working on RHEL 5.6: http://twdkz.wordpress.com/2011/12/21/installing-ghc-7-0-3-and-the-haskell-platform-on-rhel-5-6/ I expect that the same steps will work for ghc 7.4. I need to use a more recent version of gcc that than supplied with RHEL5.6. Tim On 27/06/2012, at 5:33 PM, Johannes Waldmann wrote: Dear all, I need a recent ghc on a not-so-recent (?) CentOS. The ghc binary package (7.2 or 7.4) does not work because of a mismatch in the libc version. ghc-7.0 is working but when I use it to compile 7.4, it breaks with some linker error (relocation R_X86_64_PC32 ...) it also suggests recompile with -fPIC but I don't see how. (In this particular case, I absolutely cannot change/update the OS.) Thanks, J.W. ___ 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] JustHub 'Sherkin' Release
On 14/06/12 18:36, Peter Simons wrote: it might be of interest to know that the Nix package manager [1] offers that functionality too, but it can install such Haskell environments on all Linux variants and on MacOS X without requiring superuser privileges. Is this actually the case? When I tried this a year or so ago I had lots of problems with Redhat Enterprise Linux 5, due to issues with it's quite old libc and kernel in that distribution. Most of the documentation at the nix website seems to relate to the nixos distribution, rather than using the nix packages on other, mainstream distributions. I'd love it if there we clear instructions on getting nix+packages up and running on RHEL. Tim ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Drawing charts over a lot of data
On 22/11/2011, at 10:55 AM, Bryan O'Sullivan wrote: Be aware that Chart is pretty slow on large data sets. I've noticed this too. I believe the issue is with the cairo bindings - hopefully a new version of gtk2hs will fix this: http://www.mail-archive.com/haskell-cafe@haskell.org/msg94451.html Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] stack overflow pain
I'm getting a stack overflow exception in code like this: -- applyAction :: A - IO [B] vs - fmap concat $ mapM applyAction sas return vs I don't get it if I change the code to this: -- applyAction :: A - IO [B] mapM_ applyAction sas return [] But of course, I need the results from the actions. I know that the returned list contains approximately 1 million items. Any suggestions on how I should rewrite the first code snippet to not blow the stack? I do find debugging stack overflow errors quite difficult - with little information from the runtime I'm often left guessing which parts of a large codebase might be causing them. Note that there's plenty of heap space available, it's the evaluation stack that is being used up. I could run with -K to increase the size of the stack, but if possible I'd rather solve this in the code. Thanks for any pointers. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stack overflow pain
On 21/09/11 02:39, Heinrich Apfelmus wrote: Tim Docker wrote: I'm getting a stack overflow exception in code like this: -- applyAction :: A - IO [B] vs - fmap concat $ mapM applyAction sas return vs I don't get it if I change the code to this: -- applyAction :: A - IO [B] mapM_ applyAction sas return [] But of course, I need the results from the actions. I know that the returned list contains approximately 1 million items. Any suggestions on how I should rewrite the first code snippet to not blow the stack? Of course, a list of 1 million items is going to take a lot of memory, unless you generate it lazily. Unfortunately mapM cannot generate its result lazily because it has to execute all IO actions before returning the list of results. I'm OK with it taking a lot of memory. I should have enough. It's the stack overflow exception I'm struggling with. I'm not entirely sure whether the stack overflow happens in this part of your code, though. What happens if you change it to map_ applyAction sas return [1..100] ? If this still throws a stack overflow, then problem is in the part of the code that consumes said list. I believe the error is happening in the concat because there are subsequent IO actions that fail to execute. ie the code is equivalent to: vs - fmap concat $ mapM applyAction sas someOtherAction consume vs and someOtherAction seems not to be run. However, to be sure, I'll confirm with code akin to what you suggest above. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] mapM is supralinear?
On 09/09/2011, at 8:19 PM, John Lato wrote: Agreed. Whenever I'd like to use mapM (or any other function for which a *M_ is available), I've found the following rules helpful: 1. If I can guarantee the list is short (~ n=20), go ahead and use mapM 2. Otherwise use mapM_, foldM_, or foldM if a real reduction is possible (i.e. not foldM snocM []). Step 2 sometimes requires changing my design, but it's always been for the better. `mapM_` tends to require more pipeline composition, so it's leveraging the language's strengths. This thread is really interesting - it relates directly to problems I am currently having with mapM over large lists (see the thread stack overflow pain). Can you explain what you mean by mapM_ tends to require more pipeline composition? In what way is it leveraging the language strengths? Thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
memory statistics via an API ?
The +RTS -s runtime arguments give some useful details the memory usage of a program on exit. eg: 102,536 bytes allocated in the heap 2,620 bytes copied during GC 36,980 bytes maximum residency (1 sample(s)) 28,556 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Is there any means of obtaining this information at runtime, via some API? It would be useful for monitoring a long running server process. Tim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] haskell platform question
I'd like to build the haskell platform against a recent GHC snapshot, for testing purposes. I see that I can download the source for the platform from: http://lambda.galois.com/hp-tmp/2011.2.0.1/haskell-platform-2011.2.0.1.tar.gz with instructions: http://www.vex.net/~trebla/haskell/haskell-platform.xhtml However when I tried this some months ago, I found that some of the packages in the above source fail to build due to recent ghc changes (eg it's stricter handling of bang patterns). Is there a more recent beta snapshot of the platform? Or a darcs/git repo somewhere? I imagine wanting to build the platform against bleeding edge ghc would be a pretty common desire. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell platform question
On 07/06/11 14:03, Brandon Allbery wrote: On Tue, Jun 7, 2011 at 07:34, Tim Dockert...@dockerz.net wrote: do others go about testing their code with many hackage dependencies against a new ghc? I would have expected that the first thing to do would be get the We don't, for the most part; ghc is a quickly moving target and usually has multiple type theory experiments going on in its code, and it's best to avoid new versions until they stabilize and any core dependents are updated. GHC announcements will often mention how usable the release is expected to be for us non-type theorists. Unless you're a ghc hacker, you shouldn't in general rush into a new ghc version. (This isn't Linux. The bleeding edge is for type theory, not geeks.) I get your point, but it's not only type theory breakthroughs that are in the bleeding edge. There's significant runtime improvements also: http://www.mail-archive.com/glasgow-haskell-users@haskell.org/msg19780.html (for certain bytestring usage patterns: 10x improvement in gc time, and a third as much memory used!). I was keen to try this out, but underestimated the effort in how much manual tweaking I'd have to do to get all the dependencies of my code working. Perhaps it's best for me to take Simon's advice and wait for the 7.2 release. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: memory slop
On 14/04/2011, at 6:24 PM, Simon Marlow wrote: I made some changes to the storage manager in the runtime today, and fixed the slop problem with your program. Here it is after the changes: 14,928,031,040 bytes allocated in the heap 313,542,200 bytes copied during GC 18,044,096 bytes maximum residency (7 sample(s)) 294,256 bytes maximum slop 37 MB total memory in use (0 MB lost due to fragmentation) INITtime0.00s ( 0.00s elapsed) MUT time6.38s ( 6.39s elapsed) GC time1.26s ( 1.26s elapsed) EXITtime0.00s ( 0.00s elapsed) Total time7.64s ( 7.64s elapsed) I think this is with a different workload than the one you used above. Before the change I was getting 15,652,646,680 bytes allocated in the heap 312,402,760 bytes copied during GC 17,913,816 bytes maximum residency (9 sample(s)) 111,424,792 bytes maximum slop 142 MB total memory in use (0 MB lost due to fragmentation) INIT time0.00s ( 0.00s elapsed) MUT time8.01s ( 8.02s elapsed) GCtime 16.86s ( 16.89s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time 24.88s ( 24.91s elapsed) (GHC 7.0.3 on x86-64/Linux) So, a pretty dramatic improvement. I'm validating the patch right now, it should be in 7.2.1. This looks really promising. Let me know when the patch is available, and I'll try it out on my real code. Thanks, Tim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
memory slop (was: Using the GHC heap profiler)
On Mon, Mar 21, 2011 at 9:59 AM, I wrote: My question on the ghc heap profiler on stack overflow: http://stackoverflow.com/questions/5306717/how-should-i-interpret-the-output-of-the-ghc-heap-profiler remains unanswered :-( Perhaps that's not the best forum. Is there someone here prepared to explain how the memory usage in the heap profiler relates to the Live Bytes count shown in the garbage collection statistics? I've made a little progress on this. I've simplified my program down to a simple executable that loads a bunch of data into an in-memory map, and then writes it out again. I've added calls to `seq` to ensure that laziness is not causing excessing memory consumption. When I run this on my sample data set, it takes ~7 cpu seconds, and uses ~120 MB of vm An equivalent python script, takes ~2 secs and ~19MB of vm :-(. The code is below. I'm mostly concerned with the memory usage rather than performance at this stage. What is interesting, is that when I turn on garbage collection statistics (+RTS -s), I see this: 10,089,324,996 bytes allocated in the heap 201,018,116 bytes copied during GC 12,153,592 bytes maximum residency (8 sample(s)) 59,325,408 bytes maximum slop 114 MB total memory in use (1 MB lost due to fragmentation) Generation 0: 19226 collections, 0 parallel, 1.59s, 1.64selapsed Generation 1: 8 collections, 0 parallel, 0.04s, 0.04selapsed INIT time0.00s ( 0.00s elapsed) MUT time5.84s ( 5.96s elapsed) GCtime1.63s ( 1.68s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time7.47s ( 7.64s elapsed) %GC time 21.8% (22.0% elapsed) Alloc rate1,726,702,840 bytes per MUT second Productivity 78.2% of total user, 76.5% of total elapsed This seems strange. The maximum residency of 12MB sounds about correct for my data. But what's with the 59MB of slop? According to the ghc docs: | The bytes maximum slop tells you the most space that is ever wasted | due to the way GHC allocates memory in blocks. Slop is memory at the | end of a block that was wasted. There's no way to control this; we | just like to see how much memory is being lost this way. There's this page also: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/Slop but it doesn't really make things clearer for me. Is the slop number above likely to be a significant contribution to net memory usage? Are there any obvious reasons why the code below could be generating so much? The data file in question has 61k lines, and is 6MB in total. Thanks, Tim Map2.hs module Main where import qualified Data.Map as Map import qualified Data.ByteString.Char8 as BS import System.Environment import System.IO type MyMap = Map.Map BS.ByteString BS.ByteString foldLines :: (a - String - a) - a - Handle - IO a foldLines f a h = do eof - hIsEOF h if eof then (return a) else do l - hGetLine h let a' = f a l a' `seq` foldLines f a' h undumpFile :: FilePath - IO MyMap undumpFile path = do h - openFile path ReadMode m - foldLines addv Map.empty h hClose h return m where addv m = m addv m s = let (k,v) = readKV s in k `seq` v `seq` Map.insert k v m readKV s = let (ks,vs) = read s in (BS.pack ks, BS.pack vs) dump :: [(BS.ByteString,BS.ByteString)] - IO () dump vs = mapM_ putV vs where putV (k,v) = putStrLn (show (BS.unpack k, BS.unpack v)) main :: IO () main = do args - getArgs case args of [path] - do v - undumpFile path dump (Map.toList v) return () ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: memory slop
On 22/03/11 05:33, Daniel Fischer wrote: On Wednesday 23 March 2011 03:32:16, Tim Docker wrote: Is the slop number above likely to be a significant contribution to net memory usage? Yes, absolutely. Are there any obvious reasons why the code below could be generating so much? I suspect packing a lot of presumably relatively short ByteStrings would generate (the lion's share of) the slop. I'm not familiar with the internals, though, so I don't know where GHC would put a newPinnedByteArray# (which is where your ByteString contents is), what alignement requirements those have. Thanks, I'm aware that that the code could be optimised eg by sticking to bytestrings and avoiding Strings and read - there were just to make the example simple. I expected this would affect speed, though not memory usage. I'm a bit shocked at the amount of wasted memory here. The sample data file has ~61k key/value pair. Hence ~122k ByteStrings - as you point out many of these are very small (1500 of them are empty). Assuming it's the bytestring that are generating slop, I am seeing ~500 bytes on average per bytestring! Tim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: memory slop
On 22/03/11 10:47, Brandon Moore wrote: It sounds like the space is allocated but unused pages. Unless you have messed with some kernel memory manager settings, unused virtual pages consume no physical RAM. You could confirm this by using ps to check how much RSS is actually used, compared to VSZ allocated (VSZ - RSS shouldn't include any actual data unless your system is actively swapping stuff to disk). If it is just unsued pages it's not a problem. Thanks. I've looked at this, and can confirm that the reported VSZ and RSS are almost the same (120MB and 116MB). I think this means that the observed memory usage is real. Tim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Using the GHC heap profiler
My question on the ghc heap profiler on stack overflow: http://stackoverflow.com/questions/5306717/how-should-i-interpret-the-output-of-the-ghc-heap-profiler remains unanswered :-( Perhaps that's not the best forum. Is there someone here prepared to explain how the memory usage in the heap profiler relates to the Live Bytes count shown in the garbage collection statistics? Many thanks, Tim ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] ANN: Chart v0.14
I'm pleased to announce v0.14 of the haskell chart library. This is a library for drawing 2D data plots. It's features include + Use of the cairo graphics engine, supporting a variety of output types: ps, pdf, png, and gtk windows. + A variety of plot types, including: points, lines, error bars, candlesticks, bar charts and pie charts. + Strong typing. Charts are parameterized by the types of their coordinates. One benefit of this is that labels etc are automatically generated appropriately for the type of the data. Currently axis types include: Double, Int, Log, LocalTime, and Indexed. + (some) support for interactivity. Charts support dynamic resizing, and mapping from device coordinates back to source values. The library is available on hackage. Additional information including details of the mailing list can be found here: http://dockerz.net/software/chart.html Thanks to Malcolm Wallace, Eugene Kirpichov, and Matt Brown for their contributions to this release. Tim Docker -- New features in v0.14 - * Plot Type: AreaSpots4D Spots with varying area and colour * Plot Type: CandleStick charts A specific type of plot often used in financial markets for stock price series. * Multiline text in Annotation Plots with flexible control over the anchoring. * Picking. The library now contains logic required to map device coordinates back to input elements. This facilitates interactivity. See tests/TestPicking.hs. * Multiple Layers of axis labels This is currently used by the LocalTime axis to show an additional set of context labels - these show the next sensible granularity of time enclosing the more detailed labels and ticks. * Avoid overlapping axis labels The axis rendering code now skips labels where there would be overlaps. This is done dynamically as the chart is rendered. * Code refactor Plots and axes have been split into separate file hierarchies, with one file per type. This makes it easier to understand, and (hopefully) makes it clearer how to add new plot types. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Candlestick charts
On 25/09/10 06:57, rgowka1 wrote: What are the libraries to use in Haskell to generate a stock candlestick chart like http://stockcharts.com/h-sc/ui?s=SPYp=Db=5g=5id=p05007254056 I will use Finance-Quote-Yahoo to get the quote data from Yahoo. The chart library: http://hackage.haskell.org/package/Chart doesn't currently have support for candlestick charts, but adding support would be straightforward - a patch would be most welcome (hint, hint!). Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Chart package segfaults when rendering to window
On 27/07/10 21:37, bri...@aracnet.com wrote: I can run any of the examples from the home page that render to screen. the AM chart is the one I'm using. BTW, the AM chart has a bug. It does not include the proper color modules and needs a (opaque color) instead of just color. gtk2hs is 11 gtk+ C library appars to be (debian package) 2.20.1 Which version of the chart library are you running? Can you provide a small example that reproduces the seg fault? Note that there's a mailing list for this library: http://groups.google.com/group/haskell-charts I'm more likely to notice questions that arise there. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] class Arbitrary in quickcheck
I've notice a behaviour of quickcheck that is unexpected to me. With this code: import Test.QuickCheck main = check myconfig ((\v - v == v) :: (Maybe Double,Maybe Double) - Bool) myconfig = defaultConfig{configMaxTest=10, configEvery = \n args - show n ++ :\n ++ unlines args} I am relying on the default Arbitrary instances to generate pairs of maybe doubles. But to my surprise, all of the pairs have these patterns: (Just _ Just _) (Nothing, Nothing) I never see patterns: (Just _, Nothing) (Nothing, Just _) Why is this the case? Thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class Arbitrary in quickcheck
On 5 May 2010 09:01, Ozgur Akgun ozgurak...@gmail.com wrote: your quick check property (in a different way of writing) is the following: prop_1 :: Maybe Double - Bool prop_1 v = v == v I think you misunderstood me. The property was fabricated just for the example. My question was why, when I generate random values for (Maybe t, Maybe t) using the Arbitrary type class, do I always see two Nothing values or two Just values, and never one of each? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: class Arbitrary in quickcheck
On May 5, 10:57 pm, Ozgur Akgun ozgurak...@gmail.com wrote: Let me try to understand you then. What happens when you run the following command in ghci? sample (arbitrary :: Gen (Maybe Int, Maybe Int) ) Do you still always get (Just _, Just _) or (Nothing, Nothing) pairs, or do you also get some (Nothing, Just _) or (Just _, Nothing) pairs? Well, I couldn't run the above code, as sample isn't part of quickcheck-1.2. But this made me wonder whether it's a version issue. This seems to be the case. If I run this with quickcheck 2.1: import Test.QuickCheck main = quickCheckWith stdArgs{maxSuccess=10} f f :: (Maybe Int,Maybe Int) - Bool f (Just _,Just _) = True f (Nothing,Nothing) = True f _ = False I see a failure almost instantly. This is what I want... I don't expect all of the generated pairs to have the same constructor in each field. However, running this with quickcheck 1.2: import Test.QuickCheck main = quickCheckWith stdArgs{maxSuccess=10} f f :: (Maybe Int,Maybe Int) - Bool f (Just _,Just _) = True f (Nothing,Nothing) = True f _ = False I see no failures... all of the generatd pairs have the same constructor in each field. So the good news is that quickcheck 2.1 behaves as I expected. I'm still curious as to the behaviour of the older version. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC-ODBC and SqlValues
Jason: Thanks for the reply. I suspect the solution is to correctly tell Haskell what type you expect and then hopefully HDBC will do the conversion. For example, using fromSql: http://software.complete.org/static/hdbc/doc/Database-HDBC.html#v% 3AfromSql Yes. I can use fromSql to convert the result back to an appropriate numerical type. But internally the numeric data has still been converted to an intermediate string representation. I'm wondering if this is intentional, and whether it matters. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC-ODBC and SqlValues
John Goerzen wrote: Tim Docker wrote: Yes. I can use fromSql to convert the result back to an appropriate numerical type. But internally the numeric data has still been converted to an intermediate string representation. I'm wondering if this is intentional, and whether it matters. Yes and no, in that order. A ByteString is a pretty universal holder for various types of data. As someone else pointed out, at query time, we don't really have access to what type you will eventually want to use it as, and supporting the vast number of different ways to get things out of databases -- with the corresponding complexities of how a database driver can convert between them -- was just not worth it. It is generally assumed that the end user will be using fromSql anyhow, so it is not particularly relevant if it's a SqlByteString or a SqlInteger internally. I was wondering whether going via an intermediate string might cause issues relating to loss of precision in floating point values, or possible date conversion problems if locales were not set correctly. I'm seeing problems with date conversion, and wonder if this is related. Depending on my intended result type, I see conversion errors, in particular the 3rd example below seem to be related to formatting of the intermediate string: *Main fmap (fromSql.head.head) $ quickQuery c select getdate() [] :: IO Data.Time.Clock.UTCTime 2010-04-09 09:59:20.67 UTC *Main fmap (fromSql.head.head) $ quickQuery c select getdate() [] :: IO Data.Time.LocalTime 2010-04-09 09:59:26.313 *Main fmap (fromSql.head.head) $ quickQuery c select getdate() [] :: IO System.Time.CalendarTime *** Exception: Convertible: error converting source data SqlString 2010-04-09 09:59:37.460 of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime: Cannot parse using default format string %Y-%m-%d %T%Q %z *Main fmap (fromSql.head.head) $ quickQuery c select getdate() [] :: IO System.Time.ClockTime *** Exception: Convertible: error converting source data SqlString 2010-04-09 09:59:49.940 of type SqlValue to type Integer: Cannot read source value as dest type Thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HDBC-ODBC and SqlValues
I'm experimenting with haskell and relational databases. I have successfully coupled unixodbc + freetds + hdbc-odbc, and can make trivial queries. However, I'm surprised at the result types: $ ghci GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude c - Database.HDBC.ODBC.connectODBC DSN=x;UID=x;PWD= Loading package syb ... linking ... done. Loading package base-3.0.3.1 ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package bytestring-0.9.1.4 ... linking ... done. Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.2 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package utf8-string-0.3.5 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package convertible-1.0.9 ... linking ... done. Loading package HDBC-2.2.4 ... linking ... done. Loading package HDBC-odbc-2.2.3.0 ... linking ... done. Prelude Database.HDBC.quickQuery c select 1+3 [] [[SqlByteString 4]] Prelude Why do I see an SqlByteString returned, rather than a numeric type? Taking a closer look at the HDBC-ODBC implementation it would appear that data will always be returned as SqlByteString, or as SqlNull. Is this the intended behaviour, or just a sign of an incomplete implementation of the ODBC driver? It would certainly seem possible for the ODBC driver to return more specific types. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] IORef memory leak
I'm having some trouble with excessive memory use in a program that uses a lot of IORefs. I was able to write a much simpler program which exhibits the same sort of behavior. It appears that modifyIORef and writeIORef leak memory; perhaps they keep a reference to the old value. I tried both ghc-6.8.3 and ghc-6.10.1. modifyIORef and writeIORef are not sufficiently strict for your needs. See this recent thread: http://www.nabble.com/Stack-overflow-td23746120.html Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack overflow
Thanks for the tip, although it seems tricky to get it right. I wonder why there is no strict version of atomicModifyIORef? Dually there might be a strict version of IORef datatype. Alternatively, you could use STM, where you can write your own atomic update function, which has the strictness you need (untested): import Control.Concurrent.STM strictUpdate :: (a-a) - TVar a - STM () strictUpdate f v = do x - readTVar v let x1 = f x x1 `seq` writeTVar v x1 g :: (Int-Int) - TVar Int - IO () g f v = atomically (strictUpdate f v) Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Binary suboptimal instance
andrewcoppin: The problem seems to boil down to this: The Binary instance for Double (and Float, by the way) is... well I guess you could argue it's very portable, but efficient it isn't. As we all know, an IEEE-754 double-precision floating-point number occupies 64 bits; 1 sign bit, 11 exponent bits, and 52 mantissa bits (implicitly 53). I had assumed that the Binary instance for Double would simply write these bits to disk, requiring approximately 0 computational power, and exactly 64 bits of disk space. I was wrong. Is there any danger that there might be some kind of improvement to the Double instance in the next version of Data.Binary? This was discussed last week. A patch was posted implementing more efficient low level double encodings. Google for the thread: Data.Binary and little endian encoding. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Data.Binary and little endian encoding
On a related matter, I am using Data.Binary to serialise data from haskell for use from other languages. The Data.Binary encoding of a Double is a long integer for the mantissa, and an int for the exponent. This doesn't work too well for interacting with other languages as I'd need to have an arbitrary precision int type there to decode/encode. The CORBA CDR standard encodes doubles in a big ended fashion like this (excuse my possibly incorrect ascii art): | byte | msb lsb | |--+---| |0 | S E6 E0 | |1 | E10 E9 E8 E7 F3 F2 F1 F0 | |2 | F11F4 | |3 | F19 F12 | |4 | F27 F20 | |5 | F35 F28 | |6 | F43 F36 | |7 | F51 F44 | Up until now, my code is pure haskell. Is it possible to get at the internal bits of a Double/CDouble in ghc? Or Should I use the FFI and write C to encode something like the above? Tim From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of David Leimbach Sent: Friday, 15 May 2009 1:58 PM To: Don Stewart Cc: Haskell Cafe Subject: Re: [Haskell-cafe] Data.Binary and little endian encoding On Thu, May 14, 2009 at 8:54 PM, Don Stewart d...@galois.com wrote: I'm speaking specifically of the encode/decode functions. I have no idea how they're implemented. Are you saying that encode is doing something really simple and the default encodings for things just happen to be big endian? If so, then I understand the pain but it still means I have to roll my own :-) I guess if one must choose, big endian kind of makes sense, except that the whole world is little endian now, except for networks :-) (No one *really* cares about anything but x86 anyway these days right?) Oh, 'encode' has type: encode :: Binary a = a - ByteString it just encodes with the default instances, which are all network order: http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page). Dave -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink)
I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and nothing gets evaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -Original Message- From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of wren ng thornton Sent: Thursday, 7 May 2009 2:06 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: Anton van Straaten wrote: The app is written for a client under NDA, so a blog about it would have to be annoyingly vague. No doubt the potential for encountering space leaks goes up as one writes less pure code, persist more things in memory, and depend on more libraries. Exactly. I'm worried about, e.g. needing to use something as simple as a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren ___ 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] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink)
I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and leaves thunks unevaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -Original Message- From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Anton van Straaten Sent: Thursday, 7 May 2009 4:28 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: On Wed, May 6, 2009 at 8:20 PM, Anton van Straaten an...@appsolutions.com wrote: The app is written for a client under NDA, so a blog about it would have to be annoyingly vague. No doubt the potential for encountering space leaks goes up as one writes less pure code, persist more things in memory, and depend on more libraries. Exactly. I'm worried about, e.g. needing to use something as simple as a stream of prime numbers (see the recent thread about leaks there) Haskell lets you easily create infinite lists, which is a powerful and useful feature. But if you abuse that feature, you'll have problems, because you don't have infinite memory. The further you traverse an infinite list, while maintaining a reference to its head, the more memory you use. It'd be a stretch to characterize this as hard. I don't see much connection between this and the space efficiency of long-running programs. I feel a bit like we're discussing a monster under the bed: i bet it's huge! its teeth must be so sharp! Maybe we should just look under the bed, i.e. implement what we need and see what happens? Anton ___ 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] Data.Map and strictness (was: Is Haskell a Good Choice for WebApplications?(ANN: Vocabulink))
Actually, I'm unsure how to fix this. For an expression like this: Data.Map.delete key map how can I use seq (or something else) to sufficiently evaluate the above to ensure that the value associated with key can be garbage collected? My knowledge of Data.Map is limited to it's haddock documentation. -Original Message- From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Tim Docker Sent: Thursday, 7 May 2009 6:04 PM To: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] Is Haskell a Good Choice for WebApplications?(ANN: Vocabulink) I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and nothing gets evaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -Original Message- From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of wren ng thornton Sent: Thursday, 7 May 2009 2:06 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: Anton van Straaten wrote: The app is written for a client under NDA, so a blog about it would have to be annoyingly vague. No doubt the potential for encountering space leaks goes up as one writes less pure code, persist more things in memory, and depend on more libraries. Exactly. I'm worried about, e.g. needing to use something as simple as a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren ___ 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
Re: [Haskell-cafe] Difficulties in accessing inner elements of data types
While writing an OrgFile is fairly easy, reading (and accessing inner parts) of an org file is very tedious, and modifying them is horrendous. Have you looked at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor It's something I've used successfully when wanting to manipulate the internals of complex types. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Animated line art
On 06/12/2008, at 6:32 AM, Andrew Coppin wrote: Tim Docker wrote: If you implement your drawing logic as a function from time to the appropriate render actions, ie | import qualified Graphics.Rendering.Cairo as C | | type Animation = Time - C.Render () then you just need to call this function multiple times to generate sucessive frames. That was my initial idea... but I'm not sure how well it would work. I want to do stuff like fade elements in and out, move complex structures around on the screen, etc. I think it might end up being a little tangled if I go with this approach. I might be wrong though... This model of animation as a function of time to a picture is probably described in many places. I first saw it described in Paul Hudaks book The haskell School of Expression: Learning functional programming through multimedia. It shows how primitive animations can be combined in various ways, including overlays and time transformations. You can download the code from the books web-site, which might be of interest even if you can't get hold of a copy of the book. It's intended for pedagogical purposes, rather than a comprehensive animation system, of course. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] detecting socket closure in haskell
This is a haskell + networking question... I have a multi threaded haskell server, which accepts client connections, processes their requests, and returns results. It currently works as desired, except where a client drops a connection whilst the server is processing a request. In this circumstance, the server currently doesn't notice that the client has gone until it finishes the processing and attempt to read the next request. I'd like to change it so that the request is aborted as soon as the client disconnects. One way of doing this would would be to maintain a separate thread that is always reading from the client, and buffers until the main thread needs the information. Whilst this would detect the remote close, it also would potentially consume large amounts of memory to maintain this buffer. Hence I seem to need a means of detecting that a socket has been closed remotely, without actually reading from it. . Does anyone know how to do this? One reference I've found is this: http://stefan.buettcher.org/cs/conn_closed.html Apparently recv() with appropriate flags can detect this - though I'm not convinced that the code as shown on that page doesn't busy wait when there is unread data from the client. Any tips or pointers? Perhaps what I'm trying to do is not currently possible in haskell, without using the FFI (which would be ok). Or perhaps it's not possible in linux at all. Thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Animated line art
It seems that the correct course of action is to design a DSL for declaratively describing animated line art. Does anybody have ideas about what such a thing might look like? Someone else already mentioned FRAN and it's ilk. But perhaps you don't need something that fancy. If you implement your drawing logic as a function from time to the appropriate render actions, ie | import qualified Graphics.Rendering.Cairo as C | | type Animation = Time - C.Render () then you just need to call this function multiple times to generate sucessive frames. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Proof of a multi-threaded application
Ketil Malde wrote: My apologies for side-tracking, but does anybody have performance numbers for STM? I have an application waiting to be written using STM, boldly parallelizing where no man has parallelized before, but if it doesn't make it faster, the whole excercise gets a lot less convincing. Most material I find seems to be of the proof-of-concept kind. Faster than what? I've used STM for a real application, and the main benefit I saw was in using a set of primitives that facilitate writing concurrent code that is clearer and more likely to be correct. Performance is fine - given it is IO bound, the time taken by STM is not an issue in this case. Are you considering using STM just to make otherwise pure code run in parallel on multiple cores? If so, then perhaps the pure parallelisation primitives are more appropriate. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] Announce: Chart-0.9
Chart-0.9 is now available via hackage and a darcs repository. This is a library for drawing 2D charts. It relies upon the haskell cairo binding that is part of gtk2hs, and hence supports several backend output formats (png, pdf, ps, etc). Further information is available here: http://dockerz.net/software/chart.html Also, there is now a mailing list for discussions about the library: http://groups.google.com/group/haskell-charts Tim ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] typeclass question
I have a typeclass related question that I have been puzzling over. In a library I am working on, I have a series of functions for converting values to Renderables: | labelToRenderable :: Label - Renderable | legendToRenderable :: Legend - Renderable | axisToRenderable :: Axis v - Renderable | layoutToRenderable :: Layout x y - Renderable These names are overloaded for convenience via a typeclass: | class ToRenderable a where | toRenderable :: a - Renderable | | instance ToRenderable Label where | toRenderable = labelToRenderable | ... But some recent changes mean that Renderable needs to become a type constructor, and the functions now product different types: | labelToRenderable :: Label - Renderable () | legendToRenderable :: Legend - Renderable String | axisToRenderable :: Axis v - Renderable () | layoutToRenderable :: Layout x y a - Renderable a Is there a nice way to overload a toRenderable function for these? Something like this is possible: | class ToRenderable a b where | toRenderable :: a - Renderable b But the above is, I think, too general for my needs. I don't want to be able to generate Renderables of different type b for a single input type a. Also, MPTC take me out of the world of haskell 98, which I was trying to avoid. Am I missing something simple? Any pointers would be much appreciated. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] typeclass question
Also, MPTC take me out of the world of haskell 98, which I was trying to avoid. Why. Everyone does it, Well, it's a library that others might use, so I would prefer to avoid using language extensions, especially functional deps which I don't understand, and which seem to have an uncertain future. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Functional references
I've discussed the license of data-accessor with it's authors (Luke Palmer Henning Thieleman). They are ok with changing it to BSD3. So I don't think the license will be a reason not to use it. Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ganesh Sittampalam Sent: Saturday, 6 September 2008 4:52 AM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Functional references On Fri, 5 Sep 2008, Jules Bean wrote: I think it would be worth spending some time (on this mailing list, perhaps, or in another forum) trying to hash out a decent API which meets most people's requirements, rather than ending up with 4 or 5 slightly different ones. This sounds like a good plan, but please make sure the result is as free as GHC, rather than GPL like data-accessor is. It's so simple that it being GPL just drives people for whom licencing is an issue to write an alternative rather than consider complying. Ganesh ___ 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] Haskell Propeganda
Dan Weston wrote: Tim Docker wrote: That differs from my experience. Most segfaults that *I've* caused (in C or C++) have been due to dereferencing null pointers. Type safety does help you here, in that Maybe lets you distinguish the types of things that are optionally present from those that must be. Huh? Type safety buys you not having to worry about dereferencing stale nonnull pointers (lifetime of reference exceeding lifetime of referent), but nothing about dereferencing null pointers, which are the moral equivalent of Nothing. Failure to handle a null pointer is just like using fromJust and results in the same program termination (undefined). Well as someone else pointed out, you can reliably catch a pattern match failure. You may or may not be able to catch a segfault. But my point is that haskell trivially lets you distinguish between values (type X), and nullable values (type Maybe X), and doing so is standard practice when using the language. The compiler will disallow any inconsistency in the use of these two types. C however, does not have a compile time distinction between a pointer to a value that might be null, and one that is guaranteed not to be null. The code writer must track this distinction manually. Mistakes result in segvs, not compile errors. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Haskell Propeganda
David Roundy wrote: Which illustrates the point that it's not type safety that protects us from segfaults, so much as bounds checking, and that's got a non-trivial runtime cost. At least, most segfaults that *I've* caused (in C or C++) have been from overwriting the bounds of arrays, and that's precisely the problem that Haskell does *not* solve using its type system. That differs from my experience. Most segfaults that *I've* caused (in C or C++) have been due to dereferencing null pointers. Type safety does help you here, in that Maybe lets you distinguish the types of things that are optionally present from those that must be. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternatives to convoluted record syntax
For access to nested record fields I implemented the record-access package. Unfortunately the field accessors must still be written manually. http://darcs.haskell.org/record-access/src/Data/Accessor/Example.hs I looked for this on hackage, but found instead this: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/data-accessor which, unless I am mistaken, is actually a different package by Luke Palmer, with similar intent. Should we be trying to avoid name overlaps like this? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: library for drawing charts
Neal Alexander wrote: I was using the HaskellCharts library and needed the same two things; so i rolled a quick and dirty pie chart generator (Barchart is on the TODO list). http://72.167.145.184:8000/Screenshot.png http://72.167.145.184:8000/PieChart.hs Nice! Do you mind if I refactor that a bit and add it to the HaskellCharts library? The license is BSD. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] library for drawing charts
Peter wrote: Has anyone got some code for drawing charts? I don't mean graphs of functions, ala http://dockerz.net/twd/HaskellCharts ... I would like something that can generate PNGs in memory, i.e. not directly to a file. The library at the above URL supports a range of backends through the (nice to use) cairo graphics API. In memory images are supported. Also, it's by no means just graphs of functions - that just happens to be several of the demos. I'd like 2D pie charts, bar charts and something like a google-o-meter. An the moment it does line charts and a few variants of these. I'll add pie and bar charts when I need them - patches in the meantime gratefully accepted. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Interesting critique of OCaml
| An interesting critique of OCaml. | | http://enfranchisedmind.com/blog/2008/05/07/why-ocaml-sucks/ Interesting to me is that my pet ocaml peeve is not there: namely the lack of convenient operator overloading. Admittedly I only used ocaml for 6 months, but I never adapted to needing to write (+) for ints, and (.+) for floats. From the F# documentation it would appear that F# does have overloaded numerical operators, at least. I'm not sure how these fit into its type system however. (Their type is documented as overloaded). Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN: Chart 0.6
A post to announce that Chart-0.6 is now available from it's darcs repository and from hackage. This is a library for drawing 2D charts. It relies upon the haskell cairo binding that is part of gtk2hs, and hence supports several backend output formats (windows, png, pdf, ps, etc). I'm announcing this particular version here because it now includes an alternative API (Data.Rendering.Chart.Simple), that is concise enough to use interactively from a ghci repl. Thanks are due to David Roundy for contributing this API. Further information is available here: http://dockerz.net/software/chart.html Tim ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] How to make GHC 6.6 and 6.8 co-exist -- was: First go at reactive programming
stevelihn wrote: In my brief experience with Ocaml's GODI, GODI has a way to specify them in a so-called config package. The install package then reads what it needs from the config package. In perl's CPAN shell, you can specify them in the cpan config file (to some extent). I suggest cabal-install looks into this so that moving from one version to another is indeed painless. 6.8.(1|2) is never the last Haskell version. The fact that Cabal records the 3rd digit version in the path indicates a diligent user has to re-install all the packages on every new 3rd-digit dot release. That is a lot of work! I like this idea (and I suggested it previously :-) http://www.mail-archive.com/haskell-cafe@haskell.org/msg33790.html It would also potentially solve problems with win32 versus unix installations also. Of course, suggesting is the easy bit... Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] hbeat: a rhythm sequencer
I've just uploaded to hackage a step-based music sequencer, called hbeat. It's little more than a toy, but it's fun. It ought to be cross platform, though has been built and tested solely on linux. Given that it's only 400 or so lines, it may be a useful example for anyone wanting to combine OpenGL graphics, interaction, and sound via the SDL libraries. It's also interesting that more than half of the code is pure (ie outside the IO monad), despite the fact that this is a stateful app with real time interaction with the real world. Further details here: http://dockerz.net/software/hbeat.html Thanks to lemmih for the SDL bindings that made this possible. Tim ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] Interesting data structure
I'm using a control structure that's a variation of a monad and I'm interested in whether - it's got a name - it deserves a name (!) - anything else similar is used elsewhere Please excuse the longer post... I have two programs that need to interact with the outside world, and I want to constrain the nature of these interactions. I don't want to just sprinkle IO throughout the code. In the first program, I am reading on-demand from a database - just reading, not making any changes. In the second, I am requesting computations to be evaluated externally, in order to take advantage of a grid of machines. In both of these cases, the external requests don't change the state of the world, and the programs can be consided pure as long as the world isn't being changed by some other means. Hence the requests can be reordered, performed in parallel, and optimised in various ways without affecting the result. To make this concrete, if an external request has a type like: a - m b where a is the input to the request, b is the response, and m is some monad, probably IO. Then a data structure capturing calculations over these requests, with result type c can be: data SCalc a b c = SCResult c | SCStage { sc_req :: a, sc_calc :: b - SCalc a b c } The idea is that we either have a result, or we need to make a external request, whose response is used to generate a new calculation. Running such a calculation is straightforward: runSC :: (Monad m ) = SCalc a b c - (a - m b) - m c runSC (SCResult v) _ = return v runSC (SCStage a cf) reqf = do b - reqf a runSC (cf b) reqf and calculations can be sequence by making a monad instance: instance Monad (SCalc a b) where return = SCResult (=) (SCResult v)cf = cf v (=) (SCStage a cf1) cf = SCStage a (\b - cf1 b = cf) Where it gets interesting, however, is that when they don't depend on each other, we can run these calculations in parallel. We need the ability to merge requests, and split responses. Hence, class Req a where merge :: a - a - a class Resp b where split :: b - (b,b) par :: (Req a, Resp b) = SCalc a b c - SCalc a b d - SCalc a b (c,d) The par primitive above can be used to define other parallel operations, such as parList :: (Req a, Resp b) = [SCalc a b c] - SCalc a b [c] I found it worthwhile to try and visualise what's going on here. Let's say I have 4 calculations that I want to run in parallel. The first doesn't need a request; the second needs to make a single request (A1); the third needs to make two requests where the second (B2) depends on the result of the first (B1), etc. The resulting parallel operations will be done in 3 batches, looking like: batch1 batch2 batch3 result calc1 V0 calc2A1 V1 calc3B1 B2 --- V2 calc4C1 C2 C3 -- V3 (excuse the ascii art). batch1 will consist of A1,B1,C1 merged together; batch2 of B2,C3 merged; etc. In practice, I've used the above data types to abstract out database access in some reporting code. It works quite well, as use of the parallel primitive above means that the haskell code talking to the database sees all of the information in each batch simultaneously, so it can optimise the queries, remove redundant requests etc. It also makes the reporting code pure despite the fact that information is being loaded on demand from the db (without any unsafe calls behind the scene). I guess the use of the term pure here should be qualified: the impure code has been factored out to a single function in a different module that has a limited and well defined interface. I haven't implemented the grid calculation example described above, though I see that it ought to be able to work similarly, potentially removing duplicate calculation requests, etc. So my questions are: does this sort of monad allowing parallel evaluation structure have a name? Is it an existing design pattern in fp somewhere that I haven't seen? thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Point and link
Andrew Coppin wrote: Such a GUI would be cool for a number of projects. It still needs to exist first. ;-) I don't think anyone has mentioned this: http://haskell.org/Blobs which I haven't used, though the screenshots look good. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] cabal under windows (was Re: Haskell-CafeDigest, Vol 51, Issue 180)
Duncan Coutts wrote: Tim Docker wrote: Is it actually reasonable to expect any cabal packages that depend on external c libraries and headers to build out of the box on windows? How can cabal find out where those files are, without requiring a config file to be edited? It's usually worse than that. The most likely situation is that the C library and header files are not even installed. This is a big problem for all packages that wrap C libs. I wonder if this could be addressed by discarding the desire to run magically out of the box, but make the requirements clearer. Currently the choices seem to be: * Require the user to install these libs+headers just right (on the PATH or in certain MSYS directories) so that they are found. * Edit the cabal package file to point to the libs+headers Perhaps a worthwhile addition to cabal would be for it to be able to read a local config file, in which a user would specify where each package should get the necessary headers and libs? You'd manually create this file, maybe like: package: SDL include-dirs: c:\libs\SDL\include lib-dirs: c:\libs\SDL\lib package: curl include-dirs: c:\dev\mycurl\include lib-dirs: c:\dev\mycurl\lib When building a package X, cabal would consult this file to work out localised options for that package. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal under windows (was Re: Haskell-Cafe Digest, Vol 51, Issue 180)
Well I'd say none of the packages I've tried, build out of the box... I'm not a windows developer, but Is it actually reasonable to expect any cabal packages that depend on external c libraries and headers to build out of the box on windows? How can cabal find out where those files are, without requiring a config file to be edited? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Chart plotting libraries
droundy: Chart has rather a complicated API. I've written a simpler API (but somewhat less flexible), if anyone's interested (Tim wasn't). My API is closer in complexity (of use) to matlab's plotting. I'd describe the API as verbose rather than complicated. It takes 5-10 lines of haskell to define a chart - see the examples on the web page. I think this is fine for use within other code, but I agree is too much typing for interactive use. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Chart plotting libraries
don: jon: I'd like some free software to help me plot charts like the one from the ray tracer language comparison: A quick search of hackage.haskell.org, http://dockerz.net/twd/HaskellCharts I need to update the package to build under ghc-6.8.1, though I think it's just a change to the cabal config, rather than any to any code. As of 6.8.1 it needs to depends on the new package called old-locale-1.0.0.0. Presumably this API is intended to become deprecated, though I don't see a replacement. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] FP design
levi.stephen wrote: I have similar questions about Haskell abstracting away implementations behind interfaces as well. I have become used to an approach where I will not worry about databases/persistence when beginning. I will create an interface to a database layer (e.g., save(object), retrieve(id), findByName(name)) etc., and an implementation that uses in memory collections to begin with. Later I will replace this with database calls. How does this type of approach work in Haskell? or what is the Haskell way to achieve this? If OO is a good approach for a problem, it's straightforward to model it in haskell. If you plan to access an external DB in any case, then the interface will involve the IO Monad. Something along the lines of: data Object data ID data ObjectStore = ObjectStore { save :: Object - IO ID, retrieve :: IO - IO (Maybe Object), retrieveByName :: String - IO (Maybe Object) } createMemoryStore :: IO ObjectStore connnectExternalStore :: ConnectionParams - IO ObjectStore Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] FP design
levi.stephen wrote: My concern (which may be inexperience ;) ) is with the monads here though. What if I hadn't seen that the IO monad (or any other Monad) was going to be necessary in the type signatures? You'd have some refactoring to do :-) But actually, it's not possible to create an interface that works this way without using some monad, as the interface relies on side-effects. A pure interface would have to look something like: data ObjectStore = ObjectStore { save :: Object - (ID,ObjectStore), retrieve :: ID - Maybe Object, retrieveByName :: Maybe Object } (ie the save method would have to return a new object store). Instead of using IO, you could have parameterised the store over the monad: data ObjectStore m = ObjectStore { save :: Object - m ID, retrieve :: ID - m (Maybe Object), retrieveByName :: String - m (Maybe Object) } but given your planned use, this may well be over-abstraction. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Best Linux for Haskell?
I can confirm that ghc-6.8.1 builds from source completely without fuss on the latest ubuntu (7.10). (... though it took a couple of hours of cpu time :-) Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Seth Gordon Sent: Wednesday, 7 November 2007 7:31 AM To: 'haskell-cafe Cafe' Subject: Re: [Haskell-cafe] Best Linux for Haskell? Peter Verswyvelen wrote: Each year I give Linux a try. And usually I kick it off my harddrive after a month, and stick to Windows. However, it does get better each year, so... So which kind Linux works best for running GHC (6.8.1) and related tools? (I want to give Yi a go, I can't get it to work on Windows). Debian? Fedora? Ubuntu? I don't know which Linux distribution is best *for Haskell*, but in my experience, Ubuntu has been the best distribution for getting up and running on Linux without fuss. The latest version lets you boot into Linux from a CD-ROM, so you can try it out and confirm that all your hardware is compatible before you touch anything on your hard drive. I haven't tried 6.8.1 yet, but I have downloaded and used the 6.6.x binaries on an Ubuntu system back when the repositories were still using an earlier version. I strongly suspect that if you got hold of 6.8.1 packages that were built for Debian, they would also install on Ubuntu, but I haven't tried doing that yet. ___ 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] Go parallel
Is it possible to use the forkIO primitive to cause pure computations to be evaluated in parallel threads? It seems to me that laziness would always prevent any evaluation until the result was used in a consuming thread (and hence would occur serially, in that thread). Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bulat Ziganshin Sent: Tuesday, 6 November 2007 10:59 AM To: Andrew Coppin Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Go parallel Hello Andrew, Monday, November 5, 2007, 11:12:33 PM, you wrote: How do I alter this to compute fn in multiple threads in parallel? (As jobs :: [IO()] let fork job = do mvar - newEmptyMVar forkIO$ do job; putMVar mvar () return mvar tasks - mapM fork jobs mapM_ takeMVar tasks these runs jobs and waits before all them will be finished -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ 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] Go parallel
Thanks - I was aware of par and it's ilk, but I couldn't imagine any way of doing the latter... how can you actually force something pure to get calculated in a worker thread? But thinking now, I guess judicious use of seq or deepseq is appropriate. Something like this might work. workerThread :: (a-b) - MVar a - MVar b - IO () workerThread f inp out = do a - takeMVar inp let b = f a in (b `seq` putMVar out b) workerThread f inp out In a spare moment I'll have to give it a go. Tim -Original Message- From: Don Stewart [mailto:[EMAIL PROTECTED] Sent: Tuesday, 6 November 2007 11:16 AM To: Tim Docker Cc: haskell-cafe@haskell.org; Bulat Ziganshin Subject: Re: [Haskell-cafe] Go parallel timd: Is it possible to use the forkIO primitive to cause pure computations to be evaluated in parallel threads? It seems to me that laziness would always prevent any evaluation until the result was used in a consuming thread (and hence would occur serially, in that thread). Try `par` and friends in Control.Parallel. You can also build referentially transparent worker gangs on top of forkIO. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Polymorphic (typeclass) values in a list?
TJ: After all, sometimes all you need to know about a list is that all the elements support a common set of operations. If I'm implementing a 3d renderer for example, I'd like to have class Renderable a where render :: a - RasterImage scene :: Renderable a = [a] Everyone has launched into explanations of how to use existentials to do this, but you may be happy in just haskell 98. In the above, you could just have: scene :: [RasterImage] Laziness will ensure that the computation/storage of the images will not occur until they are used. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Polymorphic (typeclass) values in a list?
TJ: Ah... indeed it can, in this case. It won't work if class Renderable also has a method for saving to file, etc, I suppose, unless scene :: [(RasterImage,IO (),...whatever other operations...)] In this case I would generally create a record: data Renderable = Renderable { image :: RasterImage, saveToFile :: FilePath - IO (), ... etc ... } scene :: [Renderable] You may then like to add a type class to turn things into renderables: class IsRenderable where toRenderable :: a - Renderable instance IsRendeable Point where ... instance IsRenderable Line where ... It depends on your needs, but in my limited experience, records are often more convenient for emulating OO-style programming than are type classes. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pixel plotter
Andrew Coppin: As far as I know, all of this is *possible* with Gtk2hs right now - it's just vastly more complex than making a single function call. So what I'd like to do is write a small library which will enable me to do each of the above tasks in 1 function call. However, I'm getting nowhere fast with this. Anybody have any suggestions? Despite having a large API gtk2hs is pretty easy to use for these kind of tasks. You can look at this library [1] (for plotting charts) to see simple examples of opening windows, saving images etc. It uses the (nice) 2D cairo API for drawing, though it's not too hard to work with raw pixels via the functions in Graphics.UI.Gtk.Gdk.Pixbuf. You'll need to restrict your drawing calls to a single thread - most GUI toolkits will require this. Haskell makes this easy through its ability to pass drawing actions from thread to thread. Tim [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Chart-2007.8.8 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: binary 0.4: high performance, pure binary parsing and serialisation
don: The main thing is porting to ghc 6.8 -- which means the new (*faster*) lazy bytestring representation, and the smp parallel quickcheck driver for the testsuite (it'll use N cores, watch the jobs migrate around). Great news... Thanks for the collective work on this. I'm looking forward to firing up hpc. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Vital for real Haskell?
Pivotal was/is Vital's successor: http://www.cs.kent.ac.uk/projects/pivotal/ However, it's not clear from the website how alive the project is. I'd love to see a robust implementation of something like this. Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Verswyvelen Sent: Friday, 14 September 2007 5:16 AM To: Haskell-Cafe Subject: [Haskell-cafe] Vital for real Haskell? I showed Vital (http://www.cs.kent.ac.uk/projects/vital) to some teachers at my university and they where really enthousiastic. IMHO the Haskell community needs something like this, but for *real* Haskell (preferable with extensions), and not using Java... Is any work being done on something like this? Thanks, Peter ___ 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] Knuth Morris Pratt for Lazy Bytestrings implementation
Now I wonder what that 7MB file might be? :-) We (team TNT) implemented KMP over lazy bytestrings as part of our icfp 2007 contest entry. As I remember, for the DNA evaluator it gave modest speed improvements over more naïve searching. Our implementation was based upon this blog post: http://twan.home.fmf.nl/blog/ Tim I've implemented KMP string searching for lazy bytestrings, and I'd like some help improving the performance of the code. I'd also like to know if it doesn't look correct - I've tested it pretty extensively but you never know ... I've been testing on a 7 MB file, where the search sequence is not found. Using strict byestrings, lazy bytestrings, and regular strings, I've found my algorithm is about twice as slow as the strict version. Surprisingly, the strict version is a little bit *slower* than the regular strings version. Thanks for any comments or help! Justin ___ 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] Tools for Haskell and COM
Alistair Bayley wrote: I want to interface Takusen with MS Sql Server, but AFAICT the recommended C API is OLE DB, which is a COM API. An alternative would be to write a takusen - freetds binding (http://www.freetds.org/). This would have the potential benefits of being * cross platform (ie windows and linux) * multi db (ie ms-sql and sybase) I should admit that there's a bit of self-interest here... I'd use such a binding it it existed. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] teaming up for the IFCP contest
I've put aside the weekend of July 20-23 for the ICFP contest (http:// www.icfpcontest.org/), and am looking to form or join a haskell wielding team. Any interest? Geographically I'm in Sydney, but have entered in a previous year with a team of 3 from around the globe which worked fine. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] type class question
Thanks for this - I only wonder if the page title List Instance would have suggested that this was a solution to me problem - I can't think of a better name however: Lists as type class instances perhaps? -Original Message- From: Henning Thielemann [mailto:[EMAIL PROTECTED] Sent: Tuesday, 22 May 2007 10:11 PM To: Tim Docker Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] type class question On Tue, 22 May 2007, Tim Docker wrote: I think this must almost be a FAQ, or at least a PAQ (Previously AQ)... I think it too, thus I added your case to the Wiki: http://www.haskell.org/haskellwiki/List_instance ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] type class question
I think this must almost be a FAQ, or at least a PAQ (Previously AQ)... If I have a type class for conversion to a type X: class XType a where toX :: a - X I can define instances for instance XType Int where toX = ... instance XType Double where toX = ... instance XType Tuple where toX = ... but not for Strings, given that they are a synonym for [Char]. Hence: instance XType String where toX = ... results in: Illegal instance declaration for `XType String' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `XType String' Is there some type class cleverness that can make this work in haskell 98? I can create a new wrapper type for strings: newtype StringWrap = StringWrap String and write an instance for that, but then I'll have to litter my code with calls to this constructor. I'm aware of the approach taken by class Show in the prelude, which adds a extra method to the class: class XType a where toX :: a - X listToX :: [a] - X but I believe this says that whenever we can convert a to an X we can also convert [a] to an X, whereas I only want [Char] to be acceptable. Thanks for any pointers. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] type class question
Derek Elkins wrote: I believe there is a trick where essentially you end up with, instance IsChar a = XType [a] where ... That is simple enough, and works fine. Thanks! Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Is Excel a FP language?
The pivotal project: http://www.cs.kent.ac.uk/projects/pivotal/ is more or less what you are referring to (ie an interactive environment where haskell is the evaluation language), though it doesn't have the exact GUI of a spreadsheet. Tim From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Coppin Sent: Saturday, 5 May 2007 9:43 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Excel a FP language? I just had a thought... Why doesn't somebody implement a spreadsheet where Haskell is the formula language? 8-) I have already been struggling (unsuccessfully) to write a program to graph functions, but why not go the whole hog and make an entire spreadsheet program? Possibly one of the most depressing things about Haskell is that there isn't one single large application anywhere that you can point to and say this was made with Haskell. Maybe this could be that app? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] COM and Haskell
There are also equivalent libraries (for producing xls files without excel) for python: http://sourceforge.net/projects/pyexcelerator http://sourceforge.net/projects/pyxlwriter/ perl: http://search.cpan.org/dist/Spreadsheet-WriteExcel/ so you don't have to use java... Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Kirk Sent: Friday, 20 April 2007 12:46 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] COM and Haskell I hate to recommend Java to Haskellers, but there is a project named Poi at Apache's Jakarta site[1] that will allow you to (with some Java programming) read, write, and manipulate Excel files directly. You don't have to COM to Excel, you don't even need Excel installed! Nice for producing spreadsheets for download from a web-based app on the fly. It is complete enough to do formatting, formulas, and such, but you can see the ugly internals of the Microsoft file formats bleeding out, or at least that was true 4 years ago. Maybe it would be a nice project to create a Haskell version of Poi. --doug [1] http://jakarta.apache.org/poi/ On 4/19/07, Paul Moore [EMAIL PROTECTED] wrote: On 19/04/07, Marc Weber [EMAIL PROTECTED] wrote: There is only one library: hdirect. But I don't know its status there have been some posts and some authors may have chnaged it. I'd suggest grepping some mailinglist archives (you can find them all on haskell.org) or wait till someone else gives a more helpful reply ;) I tried quite a while ago to build hdirect, and failed. It looked like it didn't quite support the then-current GHC (6.2???) As far as I can tell, the library hasn't been updated since, so I doubt there's much hope. I'd love to be proved wrong... If you application will be only small you'll be faster using VBScript. Or Python or Perl, or (probably, I'm not sure) Ruby. Or likely many others. Sad, but true... Paul. ___ 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
Re: [Haskell-cafe] Plotting in Haskell
Chirs Witte wrote: Are there any good libraries for drawing plots (2D and 3D) in Haskell (under Windows using GHC)? Dons has already mentioned my charting library: http://dockerz.net/software/chart.html This is 2D only for now. good depends your perspective :-) It is (intended to be) quite extensible. Russell O'Connor recently contributed automatic scaling log axes. The web-page + documentation is due for an update. Get the latest version from darcs. Hopefully the haddock doco + examples is enough to get going. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: OO Design in Haskell Example (Draft)
Steve Downey wrote: interesting. it leads to something that feels much more like an object based, as opposed to a class based, system. as far as haskell is concerned, everything has the same type, even though different instances have very different behavior. the question is, which plays nicer with the rest of haskell? that is, if i'm not committing to a closed dsl, which style is more likely to be reusable against other libraries. I suspect there's no right answer - it's a case of choosing the best approach for the problem. As an example, my charting library (http://dockerz.net/software/chart.html) uses the record of functions approach for composing drawings: data Renderable = Renderable { minsize :: (Render RectSize) render :: (Rect - Render ()) } Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] OO Design in Haskell Example (Draft)
Steve Downey wrote: So, I've been working on a Composite example. I've used existential types to have a generic proxy to the base type, rather than a simple algebraic type, since adding new leaves to the algebraic type means modifying the whole type, a violation of the Open-Closed principle (open for extension, closed for modification) Rather than using existential types, a simple record of functions can be often be useful. ie: data Component = Component { draw :: String add :: Component - Component } It might be worth comparing this approach with the (more complex) one you have described. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Strings in Haskell
Alexy Khabrov wrote: I wonder if that's another reason OCaml is used in a(t least one) hedge fund -- why Jane St. preferred OCaml to Haskell, I wonder? Was it the state of affairs then that OCaml was more efficient (? -- WAGuess), and would they prefer Haskell now? Ocaml definitely has more visibility in finance, due to at least two real world uses: - at Jane St Capital - The lexifi contract description language (www.lexifi.com) I'm not aware of any ongoing haskell work in finance, other that some private work being done by Alain Cremieux, reported in the HCAR. I'd be happy to learn of any more, however. I don't think there's any reasons right now why one ought to favour ocaml over haskell in this domain. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what GUI library should i select?
afaik, there are just two good enough libs - wxHaskell and GtkHs. can anyone point (or write) detailed comparison of their features? One point in wxHaskell's favour is that it supports Mac OS X directly. At present, to the best of my knowledge, you can only run GtkHs applications on OS X using the X Windows server. Whilst this works, it's a _long_ way from native look and feel. If OS X support is significant to you, this may sway your decision. Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Comma in the front
On Jul 12, 2006, at 9:18 PM, Joel Reymont wrote: Are cool kids supposed to put the comma in front like this? , foo , bar , baz Is this for historical or other reasons because Emacs formats Haskell code well enough regardless. Thanks, Joel These layouts feel a bit artificial to me. I am quite partial to python's list syntax - a trailing comma is optional. meaning you can write [ a, b, c, ] I'm surprised this approach isn't more widespread - Are there reasons why haskell syntax could not/should not be defined this way? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN: A Haskell Charting Library
I'm making available the current state of my 2D charting library for haskell. It's still at quite an early stage, but may prove useful. At present it has: - line charts, points charts, fills, and combinations. - Automatic layout sizing and adjustment. - Auto scaling of axis ranges - Extensible to support new plot types - Uses the cairo graphics library for output - a friendly haskell interface. There's tons of features that I'd like to add, but it satisfies the immediate needs of another application. A little information and a darcs repo can be found here: http://dockerz.net/software/chart.html Comments, feedback (or even patches!) are welcome. This is the first haskell library code I've written, so I'd be especially interested in comments on the API. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] Haskell as a disruptive technology?
Robert Dockins wrote: All we have to do is be ready for it when it arrives. When people see that, using Haskell, they can write programs using 1) fewer man-hours with 2) fewer bugs which 3) scale effortlessly to highly parallel hardware to beat the pants off C/C++/Java/what-have- you, they'll be beating down the doors to get it. I'd love to see Haskell on highly concurrent hardware becoming more of a reality: Haskell on the Cell is a great idea; I'd love to see Haskell over MPI (using YHC bytecode maybe?); Haskell-over-GPU (you know you like it!); and of course, SMP Haskell is also interesting. One of the things I love about Haskell is that the language definition transcends execution strategy/environment. I think your enthusiasm outstrips reality a bit here. STM appear to provide a much improved model for concurrent programming on shared memory architectures (I say appears here because I've read the papers but haven't used it). Whilst this applies directly to the limited scalability of new multi-core desktop machines, I don't think it's going to provide huge benefits to the more scalable architectures based upon message passing (eg MPI and Cell). I'd be pleased to be corrected, but I'm not aware of any mainstream haskell libs/extensions that make implementing message passing concurrent systems fundamentally easier than in other languages. Tim ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] embedded interpreters
[I've asked this question on lambda-the-ultimate, but it remained unanswered, and it's probably more appropriate here in any case] The papers referenced here: http://lambda-the-ultimate.org/node/view/552 describe a means of projecting values in an implementation language to and from values in an embedded interpreted language. The papers use ML, but Derek Elkin gives a straightforward translation to haskell, via a typeclass. An excerpt is here: data U = UF !(U - U) | UP !U !U | UU | UB !Bool | UI !Int | US !String deriving Show class EmbedProject a where embed :: a - U project :: U - a instance EmbedProject Int where embed = UI project (UI i) = i instance (EmbedProject a, EmbedProject b) = EmbedProject (a - b) where embed f = UF (embed . f . project) project (UF f) = project . f . embed This is nice and tidy. However, the project function can fail in practise - in the above, this results in pattern matching failures. I'd like have more control of this, which suggests the following: class EmbedProject a where embed :: a - U project :: U - Maybe a instance EmbedProject Int where embed = UI project (UI i) = Just i project _ = Nothing ...etc, until it comes to to defining the instance of EmbedProject for functions. embed is ok - incorrect parameters map to return values of the UU type. But I'm lost as to what needs to happen with the project function. The definition belows doesn't compile because (project.f.embed) has type a-Maybe b, but I need something of type Maybe (a-b): instance (EmbedProject a, EmbedProject b) = EmbedProject (a - b) where embed f = UF (\a - maybe UU (embed.f) (project a) ) project (UF f) = project.f.embed project _ = Nothing Any suggestions? Is there something obvious (or non-obvious!) that I am missing? Thanks, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Point-free style
Ketil Malde wrote: (.) . (.) .(.) I entered it into GHCi, and got :: forall a a b c a. (b - c) - (a - a - a - b) - a - a - a - c I spent a minute or so attempting to intuit the type signature of this, before cheating and entering it into ghci also. Is there a straightforward technique by which type signatures can be hand calculated, or does one end up needing to run the whole inference algorithm in one's head? Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell] IO, exceptions and error handling
Keith Wansbrough wrote: Read the paper _A Semantics for Imprecise Exceptions_. The problem is that the evaluation order of Haskell would have to be fixed for this not to lose referential transparency. What is the value of catchExcept (show (makeExcept E1 + makeExcept E2)) (\x - x) ? Haskell wouldn't be purely functional any more. As Graham Klyne indicated in a previous mail, in practice there are two ways of dealing with errors in purely functional code: - capture possible errors in the result type. This will probably force the use of a monad, with the subsequent sequencing of operation and coding style. - throw an exception, and hence be unable to recover from errors outside the IO monad. Both of these approaches seem fairly invasive in their effect on the code. Are people using haskell for real world tasks happy with having to choose from these? The former is more general, but any function that needs to be able to fail or propagate failure will end up being a do {} block. Tim ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] IO, exceptions and error handling
Philippa Cowderoy wrote: The ability to fail doesn't need the do notation, just use of return for success - similar for propagating failure. I'm not sure I understand. Do you mean writing functions like: sqr x | x 0 = fail less than zero | otherwise = return (sqrt x) If so, I don't see how I can use this without either do or =: test x = do v1 - sqr x v2 - sqr (x+1) return (v1+v2) I can't (easily) write text c = sqr x + sqr (x+1) which was what I was getting at. Tim ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] IO, exceptions and error handling
Keith Wansbrough wrote: s/fail/error/ s/return// Then you can easily write I can't (easily) write text c = sqr x + sqr (x+1) You just can't *catch* this outside the IO monad. Of course... that was my second alternative error strategy. I'm interest in how/when people decide when to throw exceptions versus when to thread errors using monads, given that changing code from one to the other could be quite a big deal. Tim ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: ANNOUNCE: Release of Vital, an interactive visual programming environment for Haskell
As a serious programmer, I'd be very happy to have a more graphical, more interactive programming experience as far as _output_ is concern. I'm happy to input textual expressions and definitions, but I'd like instant feedback and display of intermediate results as tables, graphs, trees, charts etc. Vital looks quite promising in the regard (though I've only browsed the website, and not used it). Spreadsheets are successful, I believe, because of the instant visual feedback they provide. An environment that worked in a similar way, but built upon a rigorous and high level language like haskell could well be a killer app. Tim -Original Message- From: Graham Klyne [mailto:[EMAIL PROTECTED] Sent: Thursday, November 13, 2003 10:03 AM To: Marcin 'Qrczak' Kowalczyk Cc: [EMAIL PROTECTED] Subject: Re: ANNOUNCE: Release of Vital, an interactive visual programming environment for Haskell [Switching to haskell-cafe] For serious programming, I entirely agree. But my view is that we are seeing some degree of programmability entering all sorts of everyday objects -- video recorders spring to mind as an early example -- and there's lots of work going on in the field of ubiquitous computing. Many of these pervasive devices may be fire-and-forget, but I suspect many will not be. Graphical displays may be more common than full keyboards. So how is the user to be presented with options to enter programming information? I don't have any final answers here, but I do have an intuition that for many users, where the programming requirement is a simple but flexible composition of existing functions, that a graphical, self-documenting interface may be an appropriate response to the video recorder programming hell syndrome. Some of my thoughts about this came from considering issues faced by a friend of mine who has recently wired his new home for total data (several kilometres of Cat5A cable in the loft!) -- it's all very well having all these intelligent devices around the home, but how to actually tell them what to do? Opening a door may signal that a light should turned on, or an alarm should be set off -- how to describe the distinction? (Assuming the owner is not an experienced programmer.) Finally, as evidence for this view of user interfaces, I note that for tasks like computer system administration, graphical interfaces have pretty much taken over from the old command-line-and-text-file approach. Even Linux systems have graphical front-ends for most of the common configuration, even though, for an experienced sysadmin, the text-based versions are generally quicker to set up and understand what's happenning. In short, it's the occasional user, not the full-time expert, who may be better served by a non-textual approach. #g -- At 23:56 12/11/03 +0100, Marcin 'Qrczak' Kowalczyk wrote: W li¶cie z ¶ro, 12-11-2003, godz. 11:06, Graham Klyne pisze: I've sometimes thought that a functional language would be the ideal platform to usher in a purely graphical style of programming; I don't understand why so many people talk about graphical programming, i.e. putting together functions, arguments, definitins etc. with the mouse instead of the keyboard, drawing arrows instead of naming etc. No wonder it didn't succeed. It would be much less convenient than typing text and less readable too. -- __( Marcin Kowalczyk \__/ [EMAIL PROTECTED] ^^ http://qrnik.knm.org.pl/~qrczak/ ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: access to fields in nested records
One thing that bugs me about the named record syntax, is that with a datatype: data T = T { t_f1 :: X, t_f2 :: X }; the function t_f1 has the type of an accessor, ie t_f1 :: T - X but there doesn't any tidy way to get at the mutator function t_f1' :: X - T - T without actually having to write the following t_f1' x t = t{t_f1=x} Or is there? Actually mutators of the general form t_f1' :: (X-X) - T - T t_f1_ f t = t{t_f1=f (t_f1 t)} ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: access to fields in nested records
(Apologies for previous incomplete post: Here's the whole thing) One thing that bugs me about the named record syntax, is that with a datatype: data T = T { t_f1 :: X, t_f2 :: X }; the function t_f1 has the type of an accessor, ie t_f1 :: T - X but there doesn't any tidy way to get at the mutator function t_f1' :: X - T - T without actually having to write the following t_f1' x t = t{t_f1=x} or is there? Actually mutators of the more general form t_f1' :: (X-X) - T - T t_f1' f t = t{t_f1=f (t_f1 t)} would seem to be quite useful, (even though they are tedious to write) as you can compose them for nested structures, ie if data X = X { x_f1 :: Int, x_f2 :: Int }; Then... (t_f1'.x_f2') (const 5) would be the functional equivalent of the imperative t.f1.f2 = 5 Tim ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell