[Haskell-cafe] ghc static linking on Windows
Hi, I tried to compile an app that uses sqlite3.dll with the -optl-static flag and the error message is: C:\ghc\ghc-6.10.3\gcc-lib\ld.exe: cannot find -lsqlite3 collect2: ld returned 1 exit status ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Breaking ghci
Hi folks, I would like to announce that I have not merely managed to make the RTS choke during runtime on stack overflows like lesser programmers, no, *I* have managed to write code that ghc is not even able to compile due to exhausting virtual memory! Top that! Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] F# mailing list?
Hi guys, is there a mailing list for haskellers that defected to F#? Not that I was I going to, just asking, absolutely hypothetically. Uhm. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: F# mailing list?
Hi Anton, cool I'll keep you in the loop. Would you mind talking about more about what you do in the F# Shop? I must admit I only came to haskell itself only 2 years ago, created 2 apps in it and have no clue for instance on how F# standing in the market is. Günther Anton Tayanovskyy schrieb: Hi Günther, I would be interested in one too. I'm a Haskeller currently working for an F# shop. There's hubFS but I would absolutely prefer a mailing list. --A On Sat, Jun 27, 2009 at 8:31 PM, GüŸnther Schmidtgue.schm...@web.de wrote: Hi guys, is there a mailing list for haskellers that defected to F#? Not that I was I going to, just asking, absolutely hypothetically. Uhm. Günther ___ 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] Re: haskelldb + sqlite problem.
Hi Cloud, this often occurs when the path to the database includes a non-ascii character. In my dev environment, the path to the database deliberately contains an umlaut and the original code base of hdbc.sqlite3 from John Goerzen, version 2.0 version 2.1 thus does not work. John Goerzen, the author of HDBC has considerably rewritten some parts of his hdbc package to use utf8-string wrapping, which includes wrapping the connection string, and in my case caused considerable problems, it just wouldn't work. So my solution was to rollback all these changes where he used the utf8-wrapping, which was quite a lot of work. I did communicate this to John, but he insists that his current solution is correct, and I'm not going to argue with him. Anyway what you can do, for now, is to put your sqlite3 database file into a location where the path contains no non-ascii characters, that should fix the problem. You may experience other, utf8-wrapping related problems, for instance when you want to insert non-ascii strings into varchar columns. They may not come back as you put them in. HTH Günther Magicloud Magiclouds schrieb: Hi, I am using haskelldb and haskelldb-hdbc-sqlite3. Well, I finally got the source compiled and ran, I got this error: App: user error (SQL error: SqlError {seState = , seNativeError = 21, seErrorMsg = prepare 74: SELECT subject,\n timestamp\nFROM notes as T1\nORDER BY timestamp DESC: library routine called out of sequence}) Any clue what I should check? Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: haskelldb + sqlite problem.
Hi John, let me first of all apologize, I didn't mean to criticize you, I'm sure you had good reasons for those changes, I'm merely mean to state how they did affect me after switching to HDBC 2.1. Since after the rollback they no longer occurred I surmise that there is a connection. The error that Magicloud describes I recall only occurring when an umlaut in the path to the database file, that may or may not be due to the utf8-wrapping or it may just be a problem of the sqlite3.dll. No harm in trying if it can be solved this way by just moving the database file to one without any non-ascii characters. While I don't think that umlauts actually cause Magiclouds problem I did notice that he signs his emails with Chinese symbols, quite possible thus, that he has paths on his machine with non-ascii characters. Günther John Goerzen schrieb: Magicloud Magiclouds wrote: Hi, I am using haskelldb and haskelldb-hdbc-sqlite3. Well, I finally got the source compiled and ran, I got this error: App: user error (SQL error: SqlError {seState = , seNativeError = 21, seErrorMsg = prepare 74: SELECT subject,\n timestamp\nFROM notes as T1\nORDER BY timestamp DESC: library routine called out of sequence}) Any clue what I should check? Thanks. At the HDBC level, I would say: I suspect that you have used a function that returns results lazily, but haven't completely read them before calling back into the database with something else. As an example, you should probably use quickQuery' instead of quickQuery, unless you are fully prepared to accept the consequences of reading data lazily from a database. I am not very familiar with HaskellDB, and can't really comment on what it's doing under the hood. If it is returning results to you lazily, make sure you have completely consumed them before sending more queries to the database. If you can post some example code, it would likely help. -- John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Could someone give me a sample about haskelldb?
Hi Magicloud, restrict (t!T.done .. constant False) should dot it but your t!T.done confuses me, is the the T.xxx due to an import? also the line 49 does not seem to be right. Would you mind to post your table and column definitions? Günther Magicloud Magiclouds schrieb: I changed it, some other problem occured. 1. How to compare a BoolT column to a True? t!c .. True could not work. 2. What shoud I use after !? Like table!col, recordset!col, what is col? Thanks. On Fri, Jun 19, 2009 at 1:24 PM, Magicloud Magicloudsmagicloud.magiclo...@gmail.com wrote: Hi, I am learning it following the very few documents on its site. Well, I failed, with the import modules, I still cannot compile it. The error is on T.*. 6 import Database.HaskellDB.HDBC.SQLite3 7 import Database.HaskellDB 8 import Database.HaskellDB.DBSpec 9 import Database.HaskellDB.DBSpec.PPHelpers 10 import Database.HaskellDB.Query 48 q = do 49 t - table $ Table notes [] 50 restrict ( t!T.done .. False ) 51 r - project ( T.subject t!T.subject ) 52 order [ desc r T.priority 53 , desc r T.dt ] 54 return r -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hs-dotnet users?
Hi all, I'm just touching base with Sigbjorns hs-dotnet package. Are there other users of this package out there who would like to share their experience? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Need some help with an infinite list - Ouch
Hi all, you have come up with so many solutions it's embarrassing to admit that I didn't come up with even one. Günther Günther Schmidt schrieb: Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] When I had set out to do this I thought, oh yeah no prob, in a heartbeat. Uhm. Help, pls! Günther PS: I know this should be a no-brainer, sry ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Which windowing toolkit to use?
Hi Patai, there is one other alternative to gtk2hs and wxhaskell: .NET Forms It is accessable through Sigbjorn Finne's hs-dotnet package. I am right now *starting* to use it myself, so just consider it an option. Both of the others are quite usable, wxhaskell has very easy to use layouts and looks fine on windows (native look) but lacks any support for MVC, ie. a click on a list will only give you back which position was clicked and it's up to you what object that should map to. Gtk2hs also has layouts, IMO not as nice as wxhaskell, does not look as nice on XP, (no true native look and feel), but does have support for mvc. Both (gtk2hs and wxhaskell) have a multithreading problem, cause it's not possible to call gui code outside the main gui event loop, and believe me, the wish for that does occur, so it's kinda hard to code a gui that is not sluggish with long computations. With the threading part, .NET Forms can handle that much easier. Günther Patai Gergely schrieb: Hi all, I intend to start coding the UI of the heap profiling toolkit I'm working on [1] soon. I'd be happy to get some advice on choosing the right windowing toolkit for this task. The main requirements are: - portability and native look feel if possible - easy to distribute executables under Windows - relatively slow code rot - sane interface that doesn't need wild workarounds even if what I'm doing is not trivial or elementary - trouble-free source installation in case someone wants to contribute As I see, at the moment there's no serious alternative besides GTK and wx, so my question is which do you think is better suited to this task? I have absolutely no development experience with GTK, and while I used a bit of wx in the past (in C++), I'm not really familiar with it either, especially not the Haskell bindings. I noticed that installing the wx binding with user rights doesn't seem to work directly from hackage (doesn't pass --user to ghc-pkg?), but it looks like a problem that can be solved with some hand editing. I'm a bit more afraid of setting up a development environment under Windows; is there any major pain involved with either of these libraries if I use MinGW? And how about their interface? Is there any significant difference? I'd especially like to hear the opinion of someone who's reasonably familiar with both. Thanks, Gergely [1] http://code.google.com/p/hp2any/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Which windowing toolkit to use?
Magnus Therning schrieb: Günther Schmidt wrote: Hi Patai, there is one other alternative to gtk2hs and wxhaskell: .NET Forms It is accessable through Sigbjorn Finne's hs-dotnet package. Is that usable with mono? Sorry Magnus, dunno. The galois guys provide a lot of really really useful code, I surmise they use it themselves quit a lot, but, the instructions are a bit sparse and since they actually make a living writing haskell code they propably just don't have much time for that. I certainly hope that something as useful as the heap profiling toolkit's GUI won't be a Windows-only thing. Is the plan to make the heap profiling ship with GHC? In that case it might be ill advised to add a dependency on dot-net/mono. Though it could be argued it's just as ill advised to add a dependency on GTK/WX. /M ___ 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] Need some help with an infinite list
Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] When I had set out to do this I thought, oh yeah no prob, in a heartbeat. Uhm. Help, pls! Günther PS: I know this should be a no-brainer, sry ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Need some help with an infinite list
Dear Ross, thanks for your post, you got it almost right, I needed something like aa, ab, ac ... It seems that Thomas has figured it out. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Need some help with an infinite list
Hi Thomas, thanks, it seems you found it. I find it a bit embarrassing that I was unable to figure this out myself. Günther Thomas Davie schrieb: letterCombos = map (:[]) ['a'..'z'] ++ concatMap (\c - map ((c++) . (:[])) ['a'..'z']) letterCombos Not hugely efficient, if you generate the strings in reverse then you can use (c:) rather than ((c++) . (:[])), but that may not be useful to you. Bob On 17 Jun 2009, at 02:28, GüŸnther Schmidt wrote: Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] When I had set out to do this I thought, oh yeah no prob, in a heartbeat. Uhm. Help, pls! Günther PS: I know this should be a no-brainer, sry ___ 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] Re: Need some help with an infinite list
Hi Tom, thanks for that. I remembered reading about that in my earliest haskell days, couldn't find it again and couldn't get it right by myself either. Günther Tom Pledger schrieb: Günther Schmidt gue.schmidt at web.de writes: Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] If you're happy to have a before the a, you can do this as a fairly cute one-liner in a similar style to this list of Fibonacci numbers. fib = 0:1:[m + n | (m, n) - zip fib (tail fib)] Regards, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Need some help with an infinite list
Hi Ross, no problem at all, I certainly appreciate it. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Need some help with an infinite list
Hi Richard, I'd have to guess here :) Maybe, what you have in mind, is: generate an infinite list with numbers from [1 ..], map it to base 26? Günther Richard O'Keefe schrieb: On 17 Jun 2009, at 12:28 pm, GüŸnther Schmidt wrote: Hi guys, I'd like to generate an infinite list, like [a, b, c .. z, aa, ab, ac .. az, ba, bb, bc .. bz, ca ...] When I had set out to do this I thought, oh yeah no prob, in a heartbeat. Let me change this slightly. [0,1,...,9,00,01,..,99,000,...999,...] Does that provide a hint? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Performance of functional priority queues
Hi Richard, just a wiiild guess on this, but anyway. Maybe Oleg has something to say on this, in particular when it comes to his domain, ie. delimited continuations. As I said, just a wild guess. Günther Richard O'Keefe schrieb: There's a current thread in the Erlang mailing list about priority queues. I'm aware of, for example, the Brodal/Okasaki paper and the David King paper. I'm also aware of James Cook's priority queue package in Hackage, have my own copy of Okasaki's book, and have just spent an hour searching the web. One of the correspondents in that thread claims that it is provably impossible to have an efficient priority queue implementation without mutability. I think he's cuckoo. But I'd like to have some numbers to back me up. Can anyone point me to some actual benchmark results comparing priority queue performance *with* mutation and priority queue performance *without* mutation, in the same functional or mostly-functional language? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] com-1.2.3 - problems installing
Hi all, I'm trying to install com-1.2.3 on Win XP with ghc-6.10.3 I get this error message: Resolving dependencies... Configuring com-1.2.3... cabal: Missing dependencies on foreign libraries: * Missing header file: include/WideStringSrc.h * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 This problem can usually be solved by installing the system packages that provide these libraries (you may need the -dev versions). If the libraries are already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are. cabal: Error: some packages failed to install: com-1.2.3 failed during the configure step. The exception was: exit: ExitFailure 1 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Non Empty List?
Hi, I need to design a container data structure that by design cannot be empty and can hold n elements. Something like a non-empty list. I started with: data Container a = Single a | Many a [a] but the problem above is that the data structure would allow to construct a Many 5 [] :: Container Int. I can't figure out how to get this right. :( Please help. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Non Empty List?
Hi Jake, Jake McArthur schrieb: Günther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above is that the data structure would allow to construct a Many 5 [] :: Container Int. I think you meant to do either data Container a = Single a | Many a (Container a) nope, I pretty much meant what I wrote above, the solution here would mean deeply nested containers, since it's a recursive data structure. I need a data structure as in my example without the [] being possible to be empty. It's quite possible that in order to achieve this I would need to split this in 2 separate data declarations. The idea behind this is that an a can pocket siblings, but only one level deep and that an a's list of pocketed/swallowed siblings must not be empty, because otherwise it would automatically be an Single a. Sorry, I really don't know how to put this better. Günther or data Container a = Container a [a] - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Non Empty List?
Hi Tom, thanks for replying, no, I'm not looking for streams. I hope I made myself a bit more clear in my response to Jake. Günther Tom Lokhorst schrieb: Are you looking for something like Streams [1]? They're infinite sequences, defined like this: data Stream a = Cons a (Stream a) They can obviously never be empty (unless you see bottom (undefined) as empty). - Tom [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Stream On Thu, Jun 4, 2009 at 11:53 PM, GüŸnther Schmidt gue.schm...@web.de wrote: Hi, I need to design a container data structure that by design cannot be empty and can hold n elements. Something like a non-empty list. I started with: data Container a = Single a | Many a [a] but the problem above is that the data structure would allow to construct a Many 5 [] :: Container Int. I can't figure out how to get this right. :( Please help. Günther ___ 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] Re: Non Empty List?
Dan Weston schrieb: Unless I'm missing something in your description, why not data Container a = Single a | Many a a [a] Hi Dan, the above solution would still allow to construct, for instance, Many 5 42 [] :: Container Int The reason why I'm trying to find the design for a data structure in which this would not even be possible is to be able to avoid writing additional bookkeeping code into the functions that operate on the structure, ie. the lookups, inserts, delete etc. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Non Empty List?
Hi Tony, that's because I wasn't sure whether or not it would be applicable here. As with monads, continuations, delimited continuations and quite a number of other high level concepts I only understand them in part even though I realize at the same time that understanding them fully would yield enormous benefits. I am aware of the power of these concepts, but have not gained the intuition yet. As for the zipper: In some of the examples I've seen, the zipper is implemented on top of an underlying data structure, but not the data structure itself. In my app I was actually going to pull a zipper over it, once I had the underlying structure right. Günther PS: please also see my reply to Tillman Tony Morris schrieb: I note that you didn't address the suggestion of a zipper. Günther Schmidt wrote: Dan Weston schrieb: Unless I'm missing something in your description, why not data Container a = Single a | Many a a [a] Hi Dan, the above solution would still allow to construct, for instance, Many 5 42 [] :: Container Int The reason why I'm trying to find the design for a data structure in which this would not even be possible is to be able to avoid writing additional bookkeeping code into the functions that operate on the structure, ie. the lookups, inserts, delete etc. Günther ___ 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] Re: Non Empty List? - Apologies
Hi Jake, apologies, Jake McArthur schrieb: Günther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above is that the data structure would allow to construct a Many 5 [] :: Container Int. I think you meant to do either data Container a = Single a | Many a (Container a) you're right, the above solution is indeed exactly what I need. It took me until Tillmans later elaborate reply to realize. Sometimes I'm unable to see things even when they bite me in the face, ouch! Günther or data Container a = Container a [a] - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Non Empty List?
Hi Tillmann, thank you for the elaborate example. This is exactly what it took for me to realize that you and Jake have indeed given me the solution that I need. I had a very hard time getting my head around it, but to my defense I'm usually working on this stuff in the wee hours. :) Günther Tillmann Rendel schrieb: Hi Günther, Günther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above I need a data structure as in my example without the [] being possible to be empty. So lets write a variant of list which cannot be empty. A usual list is empty, or a head and a tail: data List a = Empty | HeadAndTail a (List a) Now, our kind of list should be just one element, or a head and a tail: data NonEmptyList a = JustOne a | HeadAndNonEmptyTail a (NonEmptyList a) So we can replace [] by NonEmptyList in your definition to get what you want: data Container a = Single a | Many a (NonEmptyList a) However, since Container and NonEmptyList are isomorphic, we can use one instead of the other: data Container a = Single a | Many a (Container a) Whether this is a good idea depends on the purpose of the types, but I guess it is. Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Non Empty List?
Hi Jeff, it might actually be, I'll check it out after a good nights sleep. Apparently working on this in the wee hours only leads to self embarrassing requests for help. Actually when it comes to the underlying data structure, Jake and Tillmann have already found it for me, even though I failed to realize that in Jakes post and only got it after Tillmanns post. It's been a long night :) Günther Jeff Wheeler schrieb: On Fri, 2009-06-05 at 02:08 +0200, Günther Schmidt wrote: As for the zipper: In some of the examples I've seen, the zipper is implemented on top of an underlying data structure, but not the data structure itself. In my app I was actually going to pull a zipper over it, once I had the underlying structure right. I have a package on Hackage that implements a zipper-ish non-empty list structure. PointedList [1] is a datatype composed of a list of items on the left, the current item, and a list of items on the right. Is that close to what you're looking for? [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/pointedlist ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Compiling a windows app - embedding application icon
Hi all, is it possible to make ghc embedd an application icon in the .exe during the compilation process? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Compiling a windows app - embedding a manifest
Hi all, is it possible to make ghc embedd a particular manifest in the .exe during the compilation process? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Lazy Parsing
Dear Malcom, thanks for helping. I had actually come to Haskell originally because of a parsing problem. I had been using Smalltalk until I started a project which required parsing files. Until then I had not done any RW parsing. Well the route was more a Parsec - Haskell, wtf is Haskell? Anyway eventually I dropped Smalltalk and got addicted to Haskell. And managed familiarize myself with Haskell and Parsec, the latter as it turned out I didn't even need to solve my original problem. Anyway polyparse certainly is an option, but there are a few things that despite my list of failures to use it give uu-parsinglib a special appeal, the breadth-first approach with choice, I find that terrible elegant. Due to some kicks in my behind it seems that I might be able to use Doaitse's combinators now, some more details on that are in another post. Günther Malcolm Wallace schrieb: It is my pleasure to announce that after 5 days of experimenting with uu-parsinglib I have absolutely no clue, whatsoever, on how to use it. I do not even manage to write a parser for even a mere digit or a simple character. I don't know whether you will be willing to change over to polyparse library, but here are some hints about how you might use it. Given that you want the input to be a simple character stream, rather than use a more elaborate lexer, the first thing to do is to specialise the parser type for your purposes: type TextParser a = Parser Char a Now, to recognise a mere digit, digit :: TextParser Char digit = satisfy Char.isDigit and for a sequence of digits forming an unsigned integer: integer :: TextParser Integer integer = do ds - many1 digit return (foldl1 (\n d- n*10+d) (map (fromIntegral.digitToInt) ds)) `adjustErr` (++(expected one or more digits)) I mean I'd like to be able to turn 12.05.2009 into something like (12, 5, 2009) and got no clue what the code would have to look like. I do know almost every variation what the code must not look like :). date = do a - integer satisfy (=='.') b - integer satisfy (=='.') c - integer return (a,b,c) Of course, that is just the standard (strict) monadic interface used by many combinator libraries. Your original desire was for lazy parsing, and to achieve that, you must move over to the applicative interface. The key difference is that you cannot name intermediate values, but must construct larger values directly from smaller ones by something like function application. lazydate = return (,,) `apply` integer `discard` dot `apply` integer `discard` dot `apply` integer where dot = satisfy (=='.') The (,,) is the constructor function for triples. The `discard` combinator ensures that its second argument parses OK, but throws away its result, keeping only the result of its first argument. Apart from lazy space behaviour, the main observable difference between date and lazydate is when errors are reported on incorrect input. For instance: fst $ runParser date 12.05..2009 *** Exception: In a sequence: Parse.satisfy: failed expected one or more digits fst $ runParser lazydate 12.05..2009 (12,5,*** Exception: In a sequence: Parse.satisfy: failed expected one or more digits Notice how the lazy parser managed to build the first two elements of the triple, whilst the strict parser gave no value at all. I know that the error messages shown here are not entirely satisfactory, but they can be improved significantly just by making greater use of the `adjustErr` combinator in lots more places (it is rather like Parsec's ?). Errors containing positional information about the input can be constructed by introducing a separate lexical tokenizer, which is also not difficult. Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Umlauts in command line arguments
Hi all, When a command line argument contains an umlaut that argument gets garbled. I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Lazy Parsing
Dear Doaitse, It is my pleasure to announce that after 5 days of experimenting with uu-parsinglib I have absolutely no clue, whatsoever, on how to use it. Period. I do not even manage to write a parser for even a mere digit or a simple character. I have read the tutorial from a to a to z and from z to a and there were a few words I recognized. I mean I'd like to be able to turn 12.05.2009 into something like (12, 5, 2009) and got no clue what the code would have to look like. I do know almost every variation what the code must not look like :). I am guessing here that when one does define a parsing function, since all the parser combinators aren't function but methods, one *must* also provide a type signature so that the compiler knows the actual *instance* method? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Lazy Parsing
Hi all, is it possible to do lazy parsing with Parsec? I understand that one can do that with polyparse, don't know about uulib, but I happen to be already somewhat familiar with Parsec, so before I do switch to polyparse I rather make sure I actually have to. The files it has to parse is anywhere from 500 MB to 5 GB. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trying to Express Constraints using a data structure
Hi all, I'm trying to express a constraint using a data structure. Let's say I'd want to express a mapping of a to b, c to b, d to b and e to f. A mapping can also be from a to a, b to b and so on. The constraint is that one cannot map a to b if b was already mapped to let's say c. I'd like to express this constraint in a data structure, but haven't figured out how, yet. Any suggestions? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GUIs, FRP, (Delimited) Continuations and Zippers
Hi all, In my app, there is one part which has a rather complicated GUI logic, it involves n drop downs with n choices each. Whenever the current selection in one of the drop downs changes by user interaction, the other (n-1) drop downs need to be notified and their item list need to possible change too. Now I have managed to code all this and it actually behaves correctly. But I'm also using tons of IORefs and tons of bookkeeping code for it. While I'd not be ashamed to show any other part of my code to another Haskeller, this part of the code is the most clumsiest I've ever written. And I have no clue if that piece of code *can* be written in any other way, ie. without the tons of IORefs and bookkeeping. The GUI library is WXHaskell. In the last few days I read up on Conal Elliotts FRP stuff (reactive) but also on Olegs ZFS (Zippers, Delimited Continuations), the latter leaving me totally baffled. Could either of those approaches (FRP / Delimited Continuations) be a solution for implementing complex GUI code? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GLFW - Mac OS X
Hi, has anybody recently install the GLFW package on Mac OS X? It won't install on my machine. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HDBC 2.1, UTF8 and Umlauts
Hi guys, for some reason, any way I try, all the Umlauts get garbled with HDBC 2.1. HDBC 1.16 worked fine with any backend (ODBC, Sqlite3, ... what have you). Anybody else had similar problems and knows how to solve this? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Darcs and binary files
Hi, I've gotten used to darcs now, and use it for my project. There is one quirk though, I also added some rather large binary files, an sqlite database and an MS Access database to the repository. Now whenever I do a push from a branch into the main trunk the system runs out of memory. Guess I should have left the binary files out of there? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Using Takusen is a real intellectual challenge
Hi, well I'm *trying* to use Takusen to export from one database into the other. I'm using Takusen for this so that I can guarantee that during the export not a single huge result is assembled (possibly in memory) and then insert in one lump into the second database. Trying to figure out how to do that in Takusen has left me totally exhausted, my brain is pudding and I need to have a lay down now. I couldn't even figure out whether that's at all possible. help Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Compiling on windows - again
Hi guys, I'm sorry, I asked this before ... What is the flag you have to pass during ghc --make in order to produce an exe on Windows that doesn't open a DOS window. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Books recommendation for LINQ?
Hi, I'll be trying Sigbjorns haskell-dotnet package together with LINQ. What's a good book for LINQ? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Zippers for gui elements?
Hi all, I need to control some gui elements, ie. stuff like when dis button is clicked make dat one inactive. Some time ago, wish I'd remember where, I read about using Zippers for that sort of thing. Does anybody know where I might have read that? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Debugging a RecSel Error
Hi all, I'm trying to find the spot in my source code that triggered a RecSel Exception (No match in record selector ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Paper: Translating donotation to SQL, Leijden, Meijer
Hi Shan, thanks but the paper I'm looking for is actually the reference #13 from the document you're pointing me to. Günther Chung-chieh Shan schrieb: Gü?nther Schmidt gue.schm...@web.de wrote in article grcti9$c1...@ger.gmane.org in gmane.comp.lang.haskell.cafe: is the paper Translating donotation to SQL, Leijden, Meijer (1999) available anywhere? Seems to be here http://www.usenix.org/events/dsl99/full_papers/leijen/leijen_html/ no? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Paper: Translating donotation to SQL, Leijden, Meijer
Hi all, is the paper Translating donotation to SQL, Leijden, Meijer (1999) available anywhere? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell EDSL to generate SQL?
Hi Jeremy, apologies for my initial response, that was definately premature. I had a second look and am quite impressed now. What is the best resource to look for more detail examples? Günther Jeremy Shaw schrieb: At Sat, 04 Apr 2009 15:40:56 +0200, Günther Schmidt wrote: But I hope to be able to use an DSL from which I can automatically generate SQL-Strings instead of writing the SQL statements literally. Has anyone else taken a similar approach? HaskellDB has an DSL for generating SQL strings. Though, it is not a straightforward mapping. The haskellDB DSL provides you with relational algebra operators that you use to build your query. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haskelldb, how to escape table names
Hi, how can I escape table and column names, from something like: kh-internes-kennz to this: [kh-internes-kennz] ? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell EDSL to generate SQL?
Hi, I tried to solve some large data processing solely in Haskell so I could avoid lots of eventually very long and complex SQL statements. Unfortunately, as was to be expected, that approach doesn't scale. So I do need an SQL backend. But I hope to be able to use an DSL from which I can automatically generate SQL-Strings instead of writing the SQL statements literally. Has anyone else taken a similar approach? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell EDSL to generate SQL?
Hi Jeremy, thanks for that. I had come across it before but I think I'd prefer a more light-weight approach. Günther Jeremy Shaw schrieb: At Sat, 04 Apr 2009 15:40:56 +0200, Günther Schmidt wrote: But I hope to be able to use an DSL from which I can automatically generate SQL-Strings instead of writing the SQL statements literally. Has anyone else taken a similar approach? HaskellDB has an DSL for generating SQL strings. Though, it is not a straightforward mapping. The haskellDB DSL provides you with relational algebra operators that you use to build your query. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Looking for practical examples of Zippers
David, guys, sorry, this all started with a misconception on my behalf of what a Zipper is and what it is good for. In the days that followed my post this became much clearer though and I now realize my original question was pointless. It seems you spotted that and yes, generalized trie is probably more what I'm looking for, thanks! Günther David Menendez schrieb: On Mon, Mar 30, 2009 at 3:46 PM, Gü?nther Schmidt gue.schm...@web.de wrote: Thanks Don, I followed some examples but have not yet seen anything that would show me how, for instance, turn a nested Map like Map Int (Map Int (Map String Double) into a zipped version. That is presuming of course that this use is feasible at all. Are you asking about the technique for navigating recursive structures, or did you mean something having to do with the isomorphism between Map Int (Map Int (Map String Double)) and Map (Int,Int,String) Double? For the latter, the term you want is generalized trie. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Looking for practical examples of Zippers
Hi, my quest for data structures continues. Lately I came across Zippers. Can anybody point be to some useful examples? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Looking for practical examples of Zippers
Thanks Don, I followed some examples but have not yet seen anything that would show me how, for instance, turn a nested Map like Map Int (Map Int (Map String Double) into a zipped version. That is presuming of course that this use is feasible at all. Günther Don Stewart schrieb: xmonad's state is represented as a zipper on nested lists. The wikipedia article on zippers lists this and other examples. gue.schmidt: Hi, my quest for data structures continues. Lately I came across Zippers. Can anybody point be to some useful examples? Günther ___ 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] Re: Really need some help understanding a solution
Guys, I appreciate the contribution but I'm now more confused than ever :) On the Co-Induction-whatever thingy: Thanks, that's certainly something interesting and I'll try to find out more about it. But it looks like none of all the proposals offers a true solution, at least none from start to finish. The amount of data is large, but finite. So for now, I'll just stick with my initial approach as I'm running out of time. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A bit of a shock - Memoizing functions
Hi, um, well, I'm not even sure if I have correctly understood this. Some of the memoizing functions, they actually remember stuff *between* calls? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A bit of a shock - Memoizing functions
Hi Bulat, that is so cool! Günther Bulat Ziganshin schrieb: Hello Gü?nther, Friday, March 27, 2009, 11:30:41 PM, you wrote: Some of the memoizing functions, they actually remember stuff *between* calls? what i've seen in haskell - functions relying on lazy datastructures that ensure computation on first usage so this looks exactly like as memoizing: power 2 n | n=0 n100 = powersOfTwo!n power x y = x^y powersOfTwo = array (0,99) [2^n | n - [0..99] ] it's almost exact definition from ghc Prelude ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A bit of a shock - Memoizing functions
Hi Dan, yep, I've come across that one too and wouldn't you know it, the by now infamous Luke Palmer has left an interesting insight on that blog too :). So I reckon here the cycle closes. Günther Dan Piponi schrieb: 2009/3/27 Kirk Martinez kirk.marti...@gmail.com: I wonder: does the converse exist? Haskell data constructors which are really functions? How and for what might one use those? You might enjoy reading about the use of tries for memoisation. Conal Elliott explains nicely how you can an isomorphism between certain types of function and certain types of tree structure: http://conal.net/blog/posts/elegant-memoization-with-functional-memo-tries/ It's neat because the rules for constructing the isomorphism are just like some well known rules of high school algebra, but interpreted in a new way. -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Really need some help understanding a solution
Hi guys, I tried for days now to figure out a solution that Luke Palmer has presented me with, by myself, I'm getting nowhere. He has kindly provided me with this code: import Data.Monoid newtype IntTrie a = IntTrie [a] deriving Show singleton :: (Monoid a) = Int - a - IntTrie a singleton ch x = IntTrie $ replicate ch mempty ++ [x] ++ repeat mempty lookupTrie :: IntTrie a - Int - a lookupTrie (IntTrie xs) n = xs !! n instance (Monoid a) = Monoid (IntTrie a) where mempty= IntTrie (repeat mempty) mappend (IntTrie xs) (IntTrie ys) = IntTrie (infZipWith mappend xs ys) infZipWith f ~(x:xs) ~(y:ys) = f x y : infZipWith f xs ys test = mconcat [singleton (n `mod` 42) [n] | n - [0..]] `lookupTrie` 10 It's supposed to eventually help me group a list of key value pairs and then further process them in a linear (streaming like) way. The original list being something like [('a', 23), ('b', 18), ('a', 34) ...]. There are couple of techniques employed in this solution, but I'm just guessing here. The keywords I've been looking up so far: Memmoization, Deforestation, Single Pass, Linear Map and some others. Can someone please fill me in? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Really need some help understanding a solution
Dear Luke, let me thank you first of all for your response, period, and let me also assure you that your efforts are not (totally) in vain. :) Of course I had all kinds of guesses what sort of dark arts you employed here, mostly really long shots (Memoization, CPS ...). And at the end of the day it turns out to be a lot simpler than that. You've basically chosen a data structure that can be consumed while it's still being built (due to Lazy Evaluation). I certainly haven't figured it all out and it will take a lot more time to play with Tries before I have. I'm already eager to sift through the other goodies that are on your blog once I have finished my app, very interesting stuff even if can't understand half of it. :) Would you happen to know a good starting point about tries? Günther Luke Palmer schrieb: On Thu, Mar 26, 2009 at 12:21 PM, GüŸnther Schmidt gue.schm...@web.de mailto:gue.schm...@web.de wrote: Hi guys, I tried for days now to figure out a solution that Luke Palmer has presented me with, by myself, I'm getting nowhere. Sorry, I meant to respond earlier. They say you don't really understand something until you can explain it to a six year old. So trying to explain this to a colleague made me realize how little I must understand it :-).. But I'll try by saying whatever come to mind... /Lazy/ list processing is all about /right/ associativity. We need to be able to output some information knowing that our input looks like a:b:c:..., where we don't know the ... I see IntTrie [a] as an infinite collection of lists (well, it is [[a]], after all :-), one for each integer. So I want to take a structure like this: (1,2):(3,4):(3,5):... And turn it into a structure like this: { 0 - ... 1 - 2:... 2 - ... 3 - 4:5:... ... } (This is just a list in my implementation, but I intended it to be a trie, ideally, which is why I wrote the keys explicitly) So the yet-unknown information at the tail of the list turns into yet-unknown information about the tails of the keys. In fact, if you replace with _|_, you get exactly the same thing (this is no coincidence!) The spine of this trie is maximally lazy: this is key. If the structure of the spine depended on the input data (as it does for Data.Map), then we wouldn't be able to process infinite data, because we can never get it all. So even making a trie out of the list _|_ gives us: { 0 - _|_, 1 - _|_, 2 - _|_, ... } I.e. the keys are still there. Then we can combine two tries just by combining them pointwise (which is what infZipWith does). It is essential that the pattern matches on infZipWith are lazy. We're zipping together an infinite sequence of lists, and normally the result would be the length of the shortest one, which is unknowable. So the lazy pattern match forces the result ('s spine) to be infinite. Umm... yeah, that's a braindump. Sorry I couldn't be more helpful. I'm happy to answer any specific questions. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Really need some help understanding a solution
Well Folks, I've been programming for almost a decade now and making a living off it for almost 8 years. To me programing in Haskell is sometimes quite a humbling experience, because I come to realize how shallow my ventures so far were. The depth this language has is just amazing and the stuff that is tackled in this language is just aaahhh. Can't quite put it in words, maybe something along the lines the ultimate thing, key to the universe I don't know. Humbling and frustrating especially when you come across the Lukes and they do to you what he did to me in about 12 lines of code. And then you come across the blogs of the Lukes and see all the other things where you stand in awe and your jaw drops. And you realize how far away from that you still are. And now you! Sry for that Thomas, my prescription ran out today. I'll check on the link first thing once I got a refill. Günther Karl-Hinz, mei Drobbe! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Grouping - Map / Reduce
Dear Luke, I'm at a loss trying to figure out what is happening here, I'd sincerely appreciate it if you could find the time to give me more clues on this, I'm deeply impressed. If I think that what is happening *is* happening that would mean that this is a way to group in almost constant space. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Grouping - Map / Reduce
Hi, let say I got an unordered lazy list of key/value pairs like [('a', 99), ('x', 42), ('a', 33) ... ] and I need to sum up all the values with the same keys. So far I wrote a naive implementation, using Data.Map, foldl and insertWith. The result of this grouping operation, which is effectively another list of key/value pairs, just sums this time, needs to be further processed. The building of this map is of course a bottleneck, the successive processing needs to wait until the entire list is eventually consumed the Map is built and flattened again. Is there another way of doing this, something more streaming architecture like? Is Googles Map - Reduce related to this? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Grouping - Map / Reduce
Dear Luke, I suspect Black Magic at work here. This seems to work and I so don't have a clue why. But thank you very much nevertheless, I strongly suspect that, once I figured out why this works, I will have learned a very, very important trick indeed. Had I read purely functional data structures from start to finish, would I have come across this? Günther Luke Palmer schrieb: On Tue, Mar 24, 2009 at 3:51 PM, Luke Palmer lrpal...@gmail.com mailto:lrpal...@gmail.com wrote: On Tue, Mar 24, 2009 at 3:15 PM, Gü?nther Schmidt gue.schm...@web.de mailto:gue.schm...@web.de wrote: Hi, let say I got an unordered lazy list of key/value pairs like [('a', 99), ('x', 42), ('a', 33) ... ] and I need to sum up all the values with the same keys. So far I wrote a naive implementation, using Data.Map, foldl and insertWith.. The result of this grouping operation, which is effectively another list of key/value pairs, just sums this time, needs to be further processed. The building of this map is of course a bottleneck, the successive processing needs to wait until the entire list is eventually consumed the Map is built and flattened again. Is there another way of doing this, something more streaming architecture like? Yeah, make a trie. Here's a quick example. import Data.Monoid newtype IntTrie a = IntTrie [a] singleton :: (Monoid a) = Int - a - IntTrie a singleton ch x = IntTrie [ if fromIntegral ch == i then x else mempty | i - [0..] ] This definition of singleton unnecessarily leaks memory in some cases. Here's a better one: singleton ch x = IntTrie $ replicate ch mempty ++ [x] ++ repeat mempty Luke lookupTrie :: IntTrie a - Int - a lookupTrie (IntTrie xs) n = xs !! n instance (Monoid a) = Monoid (IntTrie a) where mempty = IntTrie (repeat mempty) mappend (IntTrie xs) (IntTrie ys) = IntTrie (infZipWith mappend xs ys) infZipWith f ~(x:xs) ~(y:ys) = f x y : infZipWith f xs ys test = mconcat [ singleton (n `mod` 42) [n] | n - [0..] ] `lookupTrie` 10 This is an inefficient way to find the class of n such that n mod 42 = 10. Note that it works on an infinite list of inputs. Here the trie was a simple list, but you could replace it with a more advanced data structure for better performace. Luke ___ 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] Re: Grouping - Map / Reduce
Hi Ketil, Ketil Malde schrieb: Gü?nther Schmidt gue.schm...@web.de writes: let say I got an unordered lazy list of key/value pairs like [('a', 99), ('x', 42), ('a', 33) ... ] and I need to sum up all the values with the same keys. So far I wrote a naive implementation, using Data.Map, foldl and insertWith. Data.Map.fromListWith (+) The building of this map is of course a bottleneck, the successive processing needs to wait until the entire list is eventually consumed the Map is built and flattened again. Sure this is not an artifact of the laziness of foldl? well I can't really see how the map could be consumed *while* it's still being built, I just don't see it. (I'm using foldl' and insertWith', sry for not saying so initially). Is there another way of doing this, something more streaming architecture like? I don't see how you can do this much better - for a small, fixed set of keys, you could use an (STU) array for the sums, but it depends if the added complexity is worth it. You're already doing a single pass over the data. -k ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A guess on stack-overflows - thunks build-up and tail recursion
Hi all, I've been running into stack-overflow problems for some time now. Here is what I gathered so far. I used to think that the build up of thunks caused the stack overflow when, as it turns out, it does not. I apparently can have a huge thunk build up eventhough I use a supposedly accumulative, tail-recursive algorithm. Apparently it is the evaluation of this huge build-up that causes the stack-overflow but not the thunk-build-up *as such*. Do I understand this correctly? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A guess on stack-overflows - thunks build-up and tail recursion
Thanks Bas and Ketil, the point I wanted to stress though is that the stack overflow does actually not occur doing the recursive algorithm, just a build-up of thunks. The algorithm itself will eventually complete without the stack overflow. The problem occurs when the result value is needed and thus the thunks need to be reduced, starting with the outermost, which can't be reduced without reducing the next one etc and it's these reduction steps that are pushed on the stack until its size cause a stack-overflow. Günther Günther Schmidt schrieb: Hi all, I've been running into stack-overflow problems for some time now. Here is what I gathered so far. I used to think that the build up of thunks caused the stack overflow when, as it turns out, it does not. I apparently can have a huge thunk build up eventhough I use a supposedly accumulative, tail-recursive algorithm. Apparently it is the evaluation of this huge build-up that causes the stack-overflow but not the thunk-build-up *as such*. Do I understand this correctly? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Forcing evaluation when seq or strictness annotation are not possible [was: guess on stack-overflows - thunks build-up and tail recursion]
Hi all, here I am again with my all time favorite unsolved problem: stack overflows. The advice I have received so far from the Haskell community (this list and #haskell) was to use strictness annotation or seq in most cases. And indeed it did help. It certainly helped when I used a data structure that I designed myself and a filling routine that I also wrote myself, thanks guys (and girls possibly, I mean I don't know). But sometimes neither of the 2 helps. Especially when you are using a brilliantly designed data structure such as IxSet, from happstack, originally HAppS. Since it's someone else code it's too late to add strictness annotation. Or the core insert that you have to use in your filling routine is lazy. In such cases you're just out of a luck. I have read about alternatives to the above mentioned techniques, CPS, Codensity-Monad and this http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf in Blogs, Wikis and Papers, also on this mailing list a post called stupid question #852. Well when I say alternatives I mean I *perceived* these techniques to be *meant* as alternatives, as a way to control evaluation order, or *force* evaluation. And this is my question: Am I barking up the wrong tree, is the purpose of these techniques actually not to force evaluation order? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How can I check which thunks are piling up on the stack?
Hi, How can I check which thunks are piling up on the stack? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] examples for error handling in takusen?
Hi, can someone please point me to error handling examples with takusen? I try to run a piece of code with takusen but just get the very sparse Database.InternalEnumerator.DBException ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] derive Drift - some help please
Hi, I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped to use either derive or DrIFT to generate the instance declarations for it. I tried to understand the respective user manuals but it's still all Greek to me. Someone please help! Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: derive Drift - some help please
Hi Alexander, well I have this: newtype AdmissionDate = AdmDt LocalTime deriving (Data,Typeable ..) at least that's where I wonna get. I don't know how to create the proper instance declarations though for LocalTime. AdmissionDate is an element of a larger data structure, this data structure for instance also has a newtype DischargeDate = DchrgDt LocalTime deriving (Data,Typeable ...) With my haskell work so far I was blessedly free of the need for deriving. Until now ... Günther Alexander Dunlap schrieb: What problems are you encountering? Alex On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt red...@fedoms.com wrote: Hi Sterling, sry, but I can't get it to work. Günther Sterling Clover schrieb: You shouldn't need any extra tools for this. A combination of the StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. Cheers, S. On Sun, Mar 8, 2009 at 10:30 AM, Gü?nther Schmidt gue.schm...@web.de mailto:gue.schm...@web.de wrote: Hi, I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped to use either derive or DrIFT to generate the instance declarations for it. I tried to understand the respective user manuals but it's still all Greek to me. Someone please help! Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto: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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: derive Drift - some help please
Hi Alexander, this does the trick! Günther Alexander Dunlap schrieb: Well you can do deriving instance Typeable LocalType etc. if you enable the DeriveDataTypeable and StandaloneDeriving extensions. You will get other error messages for missing instances; just keep adding deriving instance Typeable Day etc. Eventually, you will need to implement an instance by hand for Pico, because Pico's data constructors are not exported from Data.Fixed. I'm not very familiar with Data and Typeable so I can't help you there, but you can probably look at some existing instances for help. Hope that's useful for you. Alex On Sun, Mar 8, 2009 at 12:40 PM, Gü?nther Schmidt gue.schm...@web.de wrote: Hi Alexander, well I have this: newtype AdmissionDate = AdmDt LocalTime deriving (Data,Typeable ..) at least that's where I wonna get. I don't know how to create the proper instance declarations though for LocalTime. AdmissionDate is an element of a larger data structure, this data structure for instance also has a newtype DischargeDate = DchrgDt LocalTime deriving (Data,Typeable ...) With my haskell work so far I was blessedly free of the need for deriving.. Until now ... Günther Alexander Dunlap schrieb: What problems are you encountering? Alex On Sun, Mar 8, 2009 at 11:58 AM, G?uenther Schmidt red...@fedoms.com wrote: Hi Sterling, sry, but I can't get it to work. Günther Sterling Clover schrieb: You shouldn't need any extra tools for this. A combination of the StandaloneDeriving and DeriveDataTypeable extensions in GHC should suffice. Cheers, S. On Sun, Mar 8, 2009 at 10:30 AM, Gü?nther Schmidt gue.schm...@web.de mailto:gue.schm...@web.de wrote: Hi, I need to derive Data, Typeable for Data.Time.LocalTime. I had hoped to use either derive or DrIFT to generate the instance declarations for it. I tried to understand the respective user manuals but it's still all Greek to me. Someone please help! Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto: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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Looking for literature
Hi all, I'm trying to catch up with all the wonderful Haskell Types, classes, Abstract Data Types, Algebraic Data Types, Types that give peoples headaches and all the other, deeper stuff I have been happily putting off. Now to look smart I have a bookshelf full of books for smart people and TaPL is amoung them. Should I try that or will RWH teach me enough to get by? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Purely Functional Data Structures
Hi, is the above mentioned book still *the* authority on the subject? I bought the book, read about 10 pages and then put it back on the shelf. Um. In my app I have to deal with 4 csv files, each between 5 - 10 mb, and some static data. I had put all that data into an Sqlite3 database and used SQL on it. But, as the requirements keep changing the SQL becomes a bit messy. I guess we've all had that experience. So I'm wondering if I will find clues in this book how to do my querying and handling of moderately large data in a more haskellish way and be able to drop the SQL. Your suggestions appreciated. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked?
Hi all, thanks again for the explanation. So I have the impression that this approach is something with recognized merit but in a way still considered work in progress as I do not really see it advertised for the general haskell audience. And there are some that study it further. Ok. My question now is: Where do we take this from here?. Oleg seems to have published what he had to say on this years ago, takusen and hyena *use* it and beyond that there is only the occasional thread like this one. Anybody willing to take action so this stays on the radar? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked?
Hi everyone, after reading all the responses I would like to ask someone, anyone, to kind of summarize the merits of the left-fold-enumerator approach. From all that I read so far about it all I was able to gather was that it has significance but I'm still not even sure what for and what not for. Apparently Oleg has done various CS work, this particular piece just being one. But he also broaches the topic at very high level, ok, too high for me, ie. no CS or higher math background. Would one of the super geeks please summarize it up? (In RWH kind of style if possible) Günther John Lato schrieb: Hi Don, Would you please elaborate on what features or capabilities you think are missing from left-fold that would elevate it out of the special purpose category? I think that the conception is so completely different from bytestrings that just saying it's not a bytestring equivalent doesn't give me any ideas as to what would make it more useful. Since the technique is being actively developed and researched, IMO this is a good time to be making changes. Incidentally, in my package I've made newtypes that read data into strict bytestrings. It would be relatively simple to use unsafeInterleaveIO in an enumerator to create lazy bytestrings using this technique. I don't see why anyone would want to do so, however, since it would have all the negatives of lazy IO and be less efficient than simply using lazy bytestrings directly. Cheers, John On Sat, Feb 28, 2009 at 10:54 PM, Don Stewart d...@galois.com wrote: There are a few iteratee/enumerator design questions that remain, which Oleg and others would like to explore more fully. The results of that research will likely find there way into this library. I agree. There's no left-fold 'bytestring' equivalent. So it remains a special purpose technique. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] And another request on how to get started - JSON package
Hi, Sigbjorn has contributed tons of very useful packages and particularly quite a few package that are especially useful for the handful of us haskell-windows users. Right now though I could do with an example for how to actually use his JSON package. Since it's actively maintained and already there I'd like to avoid starting from scratch and re-implement the whole thing by using the samples from RWH. I had hoped that RWH and his package are 1:1 alas they are not. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Left fold enumerator - a real pearl overlooked?
Hi all, in the last few months I was looking for haskell database library, eventually settling for HDBC (thanks John btw). Takusen also caught my eye although I even failed installing it. Nevertheless a particular property of takusen, left-fold-enumerator, also sparked my interest and I tried to follow it up. I had the impression this is something of relevance but something that is not mentioned or made use of often. There are actually only a few references on the net and most of those by one person only, Oleg. There was one post from John Goerzen about Haskell HTTP libraries in which he hinted using left-fold enumerators. Anyway what I'm saying is that the whole topic is somewhat off the radar of the larger haskell community, how come, or am I merely overestimating its relevance and usefulness? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] a newbies confusion with repositories - darcs or git
Hi, now that I'm finished with my haskell app I take the opportunity to follow up on some things I hadn't quite understood in my so far short venture into the haskell world. Means: Prepare for a number of naive posts to follow. I had the impression that darcs was the preferred repository for haskellers, but there also is git. So far I've just been using the goodol' svn. But since I have the ambition to become a real haskeller I was gonna make myself acquainted with darcs. Should I skip that and head straight for git? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Samples for http package
Hi everyone, are there any examples on how to use the current version of the http package? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Need some advice on deploying an app
Hi, I've just finished developing my haskell - windows app and am ready to ship it now. I'm using Inno Setup for the installation but need another tool that would wrap my app inside itself and check for valid keys or an expiration date on every start up. Can anyone recommend a good tool for that purpose? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Scripting COM Components from Haskell - GreenCard on Hackage
Hi, does anybody know if the Greencard package / lib is the same software that is mentioned in the paper Scripting COM Components from Haskell? http://research.microsoft.com/~simonpj/papers/com.ps.gz I managed to install the hackage Greencard package on XP with GHC 6.8.3 but it seems to be quite different from what the paper describes. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ActiveX and COM
Hi, what is currently the recommend way to interface with COM from haskell? I need to create an Excel Sheet and thus need to use Excel via COM. Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe