Re: [Haskell-cafe] Haskell, successing crossplatform API standart
On Sun, Nov 30, 2008 at 17:51, Sterling Clover [EMAIL PROTECTED] wrote: Haxr provides a basic implementation of the XML-RPC protocol, and while it looks like it doesn' t build on 6.10 at the moment, getting it to build shouldn't be a problem, and although it doesn't appear to be under active development, it does seem to be getting maintenance uploads. [1] HaXR should build with GHC 6.10 now, thanks for the prod. These days, however, web services seem to be moving towards a RESTful model with a JSON layer and there are plenty of JSON libraries on hackage, which you could just throw over the fastCGI bindings. Alternately you could try JSON over one of the really lightweight haskell web servers, such as shed [2] or lucu [3]. If you go the latter route, I'd love to hear how it went. I agree with this. I would only use XML-RPC to talk to legacy applications. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haxr [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/httpd-shed [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Lucu /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log?
On Thu, Jul 31, 2008 at 6:37 PM, Don Stewart [EMAIL PROTECTED] wrote: agentzh: On Thu, Jul 31, 2008 at 1:56 AM, Don Stewart [EMAIL PROTECTED] wrote: We've had no problems with this and apache at least. Is lighttpd doing something funny with error logging? It seems that Apache is doing something funny :) According to my teammate chaoslawful, apache redirects stderr to its error log files (if any) but the fastcgi spec actually says everything should go through the socket. And lighttpd seems to be following the spec exactly :) chaoslawful++ finally come up with the following patch for lighttpd 1.4.19 to make lighttpd behave in the same way as apache. Devel.Debug is now finally working for me for my Haskell fastcgi hacking :)) --- lighttpd-1.4.19/src/log.c2007-08-22 01:40:03.0 +0800 +++ lighttpd-1.4.19-patched/src/log.c2008-07-31 15:13:10.0 +0800 @@ -83,9 +83,14 @@ /* move stderr to /dev/null */ if (close_stderr -1 != (fd = open(/dev/null, O_WRONLY))) { -close(STDERR_FILENO); +// XXX: modified by chaoslawful, don't close stderr when log into file +close(STDERR_FILENO); +if (srv-errorlog_mode == ERRORLOG_FILE srv-errorlog_fd =0 ) { +dup2(srv-errorlog_fd,STDERR_FILENO); +} else { dup2(fd, STDERR_FILENO); -close(fd); +} +close(fd); } return 0; } Best, -agentzh Interesting result, thanks for looking into this. You could also handle this issue without modifying Lighttpd by redirecting stderr to a file. Put this in your Haskell program: import System.Posix.Files import System.Posix.IO stderrToFile :: FilePath - IO () stderrToFile file = do let mode = ownerModes `unionFileModes` groupReadMode `unionFileModes` otherReadMode fileFd - openFd file WriteOnly (Just mode) (defaultFileFlags { append = True }) dupTo fileFd stdError return () main = do stderrToFile my-fastcgi-log.log runFastCGI ... Another way is to have a small wrapper shell script around your FastCGI program that does the same redirection. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [fun] HaskellDB Talk trailer
On Fri, Oct 17, 2008 at 1:54 AM, Don Stewart [EMAIL PROTECTED] wrote: kyagrd: There is an impressive HaskellDB Talk trailer on the web. http://www.vimeo.com/1983774 Cheers to the HaskellDB developers :-) AWESOME! Trailers for talks, eh? The bar has been raised. -- Don Sweet! There wouldn't happen to be a video or slides from the actual talk? I couldn't find anything about it on the PDXPUG homepage. Björn A HaskellDB developer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage - MacPorts?
On Wed, Sep 3, 2008 at 10:14 PM, John MacFarlane [EMAIL PROTECTED] wrote: It would be great if there were an automated or semi-automated way of generating a MacPorts Portfile from a HackageDB package, along the lines of dons' cabal2arch. Has anyone been working on such a thing? And, are any haskell-cafe readers MacPorts committers? I seem to remember that Eric Kidd started working on something like this at the Hackathon in Freiburg. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] String to Double conversion in Haskell
2008/8/24 Daryoush Mehrtash [EMAIL PROTECTED]: I am trying to convert a string to a float. It seems that Data.ByteString library only supports readInt.After some googling I came accross a possibloe implementation: http://sequence.svcs.cs.pdx.edu/node/373 My questions are: a) is there a standard library implementation of string - Double and float? b) Why is it that the ByteString only supports readInt? Is there a reason for it? Hi Daryoush, are you really looking for ByteString - Float conversion, or just plain String - Float? The latter is really simple, the function is called 'read' and is available in the Prelude: $ ghci GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude read 3.14 :: Float 3.14 /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building fastcgi from hackage on windows.
Hi Edward, I have never compiled the fastcgi package on Windows myself, but my best tip would be to try to install the FastCGI development kit (= C headers and libraries), see http://www.fastcgi.com/#TheDevKit /Bjorn On Fri, Aug 8, 2008 at 4:53 PM, Edward Ing [EMAIL PROTECTED] wrote: I have this installed. The problem is that I have no binary version of the Network.FastCGI. So to install it I am going through the cabal process and on the build it seems to need the Fastcgi.h to build the foreign interfaces (and probably the static libraries to link ?). Unfortunately the Microsoft download pack doesn't have that - just the .dll (or perhaps cabal can't find where the fastcgi.h are). Edward Ing On Fri, Aug 8, 2008 at 6:08 AM, Iain Barnett [EMAIL PROTECTED] wrote: have you installed this? http://www.softpedia.com/progDownload/Microsoft-FastCGI-Extension-for-IIS-Download-84830.html I use Asp.Net when I'm on Windows, so I don't know the answers to your questions but you might find more info on running it here http://forums.iis.net/1103.aspx Iain ___ 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 PNG Writer
The libgd bindings can be used to create PNG images. See http://hackage.haskell.org/cgi-bin/hackage-scripts/package/gd /Björn On Mon, May 5, 2008 at 9:05 AM, Bit Connor [EMAIL PROTECTED] wrote: It would be nice to have haskell bindings to the libpng C library. I had trouble calling libpng functions since it uses setjmp for error handling, and it wasn't clear that haskell could handle this. I ended up writing a few wrapper functions in C. An alternative more ambitious project would be a pure haskell PNG implementation. On Sat, May 3, 2008 at 11:12 PM, Nahuel Rullo [EMAIL PROTECTED] wrote: Hi list, i am new in Haskell. I need to make images (PNG, JPEG) with haskell, if you can give me a tutorial, thanks! -- Nahuel Rullo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking Daan Leijen
On Thu, Mar 27, 2008 at 6:43 PM, John Goerzen [EMAIL PROTECTED] wrote: I tried to email this to Daan, but his mail is bouncing... Subject: http://legacy.cs.uu.nl/daan/parsec.html Hi Daan, I noticed Parsec 3.0.0 on Hackage, and went to your homepage to read about the new package. But it looks like your homepage still has the old version put out in 2003. This might cause confusion for some that are looking for new releases at your website. Daan is now working at Microsoft Research, see http://research.microsoft.com/users/daan/ /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC, character encoding
2008/3/26 Adrian Neumann [EMAIL PROTECTED]: Hi, I wrote a CGI program to access a Postgres database using HDBC. The database stores books and I want to display those from a certain author. Everything works fine, unless I search for someone with an umlaut in his name. Böll, for example. I have a function like this bookByAuthor :: Connection - AutorName - IO [[String]] bookByAuthor c aName = do writeFile ./err.log ((show aName)++ ++(show $ toSql aName)) rows - quickQuery c SELECT * FROM buecher WHERE lower (autor_name) LIKE ? ORDER BY autor_name, buch_name [toSql $ map toLower $ '%':aName++%] return $ map (map fromSql) rows It returns me a SqlError. However, doing the same in ghci works perfectly. I can't understand why. err.log contains b\195\182ll SqlString b\195\182ll which is ok I think. Since quickQuery c SELECT * FROM buecher WHERE lower(autor_name) LIKE ? ORDER BY autor_name, buch_name [toSql %b\195\182%] works in ghci. I have tried b\246ll, but that doesn't even work in ghci, although the database-encoding is utf-8. This all is really annoying... I think that Peter Gammie (copied) has some code to deal with this. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to program with sqlite?
2008/3/22 Sebastian Sylvan [EMAIL PROTECTED]: On Sat, Mar 22, 2008 at 1:40 PM, Deng Chao [EMAIL PROTECTED] wrote: Hi all, I'm learning sqlite, and as I know haskell has some libraries like HDBC or HSQL can access sqlite DB. Can anybody give me a small example to show how to use it? It will be very appreciate? Thanks! Best Regards, Deng Chao Here's a quick GHCi session with HDBC. Prelude :m +Database.HDBC Prelude Database.HDBC :m +Database.HDBC.Sqlite3 Prelude Database.HDBC Database.HDBC.Sqlite3 conn - connectSqlite3 mydb Prelude Database.HDBC Database.HDBC.Sqlite3 quickQuery conn CREATE TABLE mytable (FirstName varchar, LastName varchar, Age int ) [] [] Prelude Database.HDBC Database.HDBC.Sqlite3 quickQuery conn INSERT INTO mytable VALUES ('Sebastian','Sylvan',26) [] [] Prelude Database.HDBC Database.HDBC.Sqlite3 commit conn Prelude Database.HDBC Database.HDBC.Sqlite3 quickQuery conn SELECT * FROM mytable [] [[SqlString Sebastian,SqlString Sylvan,SqlString 26]] Prelude Database.HDBC Database.HDBC.Sqlite3 disconnect conn Not sure why that Age field came back as a string though :-) This is SQLite's fault. In SQLite, all types are aliases for STRING. Whatever type you use in the create and insert, you will get strings back. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to program with sqlite?
On Tue, Mar 25, 2008 at 3:29 PM, Alex Sandro Queiroz e Silva [EMAIL PROTECTED] wrote: Hallo, Bjorn Bringert wrote: This is SQLite's fault. In SQLite, all types are aliases for STRING. Whatever type you use in the create and insert, you will get strings back. That's not true. SQLite has integers (64 bits) and reals. But, if you try to read the field as text it will gladly convert it for you. For reading as the correcting type, the binding should have used sqlite3_column_get_type first. Cheers, -alex Hi Alex, thanks for setting me straight. It would be great if you would want to submit a patch for HDBC-sqlite3 to fix this. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using HaskellDb to connect to PostgresSql
On Wed, Mar 19, 2008 at 8:32 PM, Justin Bailey [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 10:55 AM, Marc Mertens [EMAIL PROTECTED] wrote: Hello, I'm trying to learn to use HaskellDb. I have managed to finally compile and install it on my linux box (I have ghc 6.8.2). But when I try to create a database description (as described in http://haskelldb.sourceforge.net/getting-started.html) (using DBDirect-dynamic instead of DBDirect) I'm stuck. I have tried different names for the driver but I don't have much information about using DBDynamic, but I am able to connect to PostgreSQL easily. I have done it on Windows using GHC 6.8.2. I am using hdbc-postgresql, since hsql would not compile on Windows for me. Here are the import statements and the login function I have for a simple program that connects to postgresql and writes out table info: import Database.HaskellDB.DBSpec.DatabaseToDBSpec import Database.HaskellDB.DBSpec.DBSpecToDBDirect import Database.HaskellDB.Database import Database.HaskellDB.HDBC.PostgreSQL import Database.HaskellDB.PrimQuery import Database.HaskellDB.FieldType import Database.HaskellDB.DBSpec login :: MonadIO m = String - Int - String - String - String - (Database - m a) - m a login server port user password dbname = postgresqlConnect [(host, server), (port, show port), (user, user), (password, password), (dbname, dbname)] The versions of all packages I'm using are: HDBC-1.1.4 HDBC-postgresql-1.1.4.0 haskelldb-hdbc-0.10 haskelldb-hdbc-postgresql-0.10 Note you might have to modify the haskelldb cabal files to get them to use later versions of HDBC. As for recent documentation, unfortunately the darcs repository and the code is the best place to go. The haddock documentation doesn't have everything. Finally, I'd suggest joining the haskell-db users mailing list for specific questions. You can find info about that and the darcs repository on the homepage at http://haskelldb.sourceforge.net. Justin Just to add to what Justin said, try using DBDirect-hdbc-postgresql instead of DBDirect-dynamic. The dynamic driver adds an extra layer of problems, and I'm not sure that it (or hs-plugins?) has been updated to work with GHC 6.8.2. Because of a typo in a .cabal file, there was no DBDirect-hdbc-postgresql until a few minutes ago, but if you pull down the current darcs version and reinstall haskelldb-hdbc-postgresql you should get it. The HaskellDB documentation really is in a sorry state. Does anybody feel like adding a wiki page with a basic getting-started HaskellDB tutorial? It would be very appreciated. This page seems to contain mostly meta-information: http://www.haskell.org/haskellwiki/Applications_and_libraries/Database_interfaces/HaskellDB /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] File I/O question
On Wed, Mar 12, 2008 at 10:03 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Don Stewart wrote: Hey Andrew, What are you trying to do? Read and write to the same file (if so, you need to use strict IO), or are you trying something sneakier? I have a long-running Haskell program that writes status information to a log file. I'd like to be able to open and read that log file before the program has actually terminated. I have a similar program written in Tcl that allows me to do this, since apparently the Tcl interpretter doesn't lock output files for exclusive access. Haskell, however, does. (This seems to be the stipulated behaviour as per the Report.) If there's an easy way to change this, it would be useful... How about using appendFile? appendFile :: FilePath - String - IO () The computation appendFile file str function appends the string str, to the file file. See http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v%3AappendFile /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reminder: 4th Haskell Hackathon, April 11-13 in Gothenburg
Hac4 4th Haskell Hackathon April 11-13, 2008 Gothenburg, Sweden http://haskell.org/haskellwiki/Hac4 Sponsored by Credit Suisse and Galois. This is a reminder to register for the 4th Haskell Hackathon. The event will be held over 3 days, April 11-13, at Chalmers University of Technology in Gothenburg, Sweden. == NEWS == * Lunches and at least one dinner for the Hackathon attendees will be provided through our generous sponsors Credit Suisse and Galois. * If you plan to start a new project on community.haskell.org, please request an account and project in advance, so as to save valuable Hackathon time. See http://community.haskell.org/admin/ for more details. == What it is == The plan is to hack on Haskell infrastructure, tools, libraries and compilers. To attend please register, and get ready to hack those lambdas! Code to hack on: * Hackage * Cabal * Porting foreign libraries * Bug squashing * You decide! Before you attend, do start thinking and familiarizing yourself with 1 or 2 projects you wish to work on, to ensure no wasted effort during the Hackathon. A list of possible projects is available on the website. == Registration == We ask that you register your interest. Follow the instructions on the registration page: http://haskell.org/haskellwiki/Hac4/Register Once you've registered, do add your info to the attendees self-organizing page, http://haskell.org/haskellwiki/Hac4/Attendees if you are looking to share costs, or meet up prior to the hackathon, with other attendees. N.B. if you already expressed interest via the wiki, do confirm by registering `officially' anyway. == Important dates == Hackathon: April 11-13, 2008 == Organizers == Björn Bringert (local) Thomas Schilling (local) Lennart Kolmodin (local) Krasimir Angelov (local) Jean-Philippe Bernardy (local) Ian Lynagh Duncan Coutts ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Starting Haskell with a web application
On Wed, Mar 5, 2008 at 8:00 PM, Don Stewart [EMAIL PROTECTED] wrote: bos: Jonathan Gardner wrote: Where do I get started in writing a web app with Haskell? I am looking more for a framework like Pylons and less like Apache, if that helps. The closest we currently have to a web framework is Happs (http://happs.org/), but it uses the kitchen sink of advanced and unusual language extensions, which I think might be why it hasn't got all that much momentum. There's also WASH, but that has an even lower profile. I couldn't tell you if it sees much use, or even builds with recent compilers. Perhaps it is time for a haskell web apps wiki page, if there isn't one, outlining the approaches, with a structure like: * HAppS * CGI - FastCGI * Database solutions - HDBC - Takusen * Templating - HStringTemplate * JSON rpc etc. There's this: http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell It doesn't mention many of the above, but they would be nice additions. The page should probably be split into several though. /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Connection helpers: for people interested in network code
On Tue, Mar 4, 2008 at 5:15 PM, Adam Langley [EMAIL PROTECTED] wrote: On Tue, Mar 4, 2008 at 7:31 AM, Bjorn Bringert [EMAIL PROTECTED] wrote: you may want to have a look at the socket abstraction used in the HTTP package: http://hackage.haskell.org/packages/archive/HTTP/3001.0.4/doc/html/Network-Stream.html It would be great to get HTTPS support going! I should have mentioned that I had seen this in the original email. I think the major problem with this interface was that it was written in the time before ByteStrings. Now that we have ByteStrings I think that it makes a lot of sense for networking to use them. However, it shouldn't be too hard to wrap HsOpenSSL in this interface. I might try this this week. Then HTTPS should Just Work (maybe ;) There is some (dormant?) work on bringing HTTP into the age of the ByteString. Thomas Schilling (nominolo) might be able to tell you more about it. /B ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Connection helpers: for people interested in network code
On Fri, Feb 29, 2008 at 8:50 PM, Adam Langley [EMAIL PROTECTED] wrote: I generally find that I'm wrapping sockets in the same functions a lot and now I'm looking writings code which works with both Sockets and SSL connections. So I wrote a module, presumptuously called Network.Connection, although I'm not actually going to try and take that name (even in Hackage) unless I get a general agreement that this is a good thing. So, any comments on the interface, similar things that I should look at etc? http://www.imperialviolet.org/binary/network-connection/Network-Connection.html I made the BaseConnection an ADT, rather than a class because I wanted to avoid hitting the monomorphism restriction in code. That might have been a mistake, I'm not sure yet. If it doesn't excite anyone enough to reply, I'll change the name and put it in Hackage, mostly as is. Then I'll tie HsOpenSSL into it so that SSL connections work transparently. Hi Adam, you may want to have a look at the socket abstraction used in the HTTP package: http://hackage.haskell.org/packages/archive/HTTP/3001.0.4/doc/html/Network-Stream.html It would be great to get HTTPS support going! /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Working with multiple time zones
On Feb 17, 2008 12:13 AM, Dave Hinton [EMAIL PROTECTED] wrote: (This is a toy program to demonstrate only the part of my real program that I'm having trouble with.) Suppose I'm writing a program to print the current time in various time zones. The time zones are to be given symbolically on the command line in the form Europe/London or America/New_York. The idea is that either the operating system or the runtime library keeps track of what time zones different places are in, and when they are on summer time, so that my code doesn't have to worry about it. Haskell has a TimeZone type in Data.Time.LocalTime, but it only represents constant offsets from UTC — doesn't encode rules for when the clocks change. And there doesn't seem to be any way of looking up the time zone for a locality. Data.Time.LocalTime has the getTimeZone function, which returns the time zone for a given UTC time on the local machine — this takes care of summer time, but by itself only works for the local machine's locality. If I was writing this program in C, I'd get round this by setting the TZ environment variable to the locality I was interested in before doing time conversions. $ cat cnow.c #include stdio.h #include stdlib.h #include string.h #include time.h void outTime (time_t utc, char *tzName) { char env[100] = TZ=; strcat (env, tzName); putenv (env); printf (%s\t%s, tzName, asctime (localtime (utc))); } int main (int argc, char **argv) { int i; time_t utc = time (NULL); for (i = 1; i argc; ++i) outTime (utc, argv[i]); return 0; } $ gcc cnow.c -o cnow $ ./cnow Europe/Paris Europe/Moscow Europe/London Europe/ParisSat Feb 16 23:57:22 2008 Europe/Moscow Sun Feb 17 01:57:22 2008 Europe/London Sat Feb 16 22:57:22 2008 So far, so good. Here's the equivalent in Haskell: $ cat hsnow.hs import Data.Time import Data.Time.LocalTime import System.Environment import System.Posix.Env outTime utc env = do putEnv (TZ= ++ env) tz - getTimeZone utc putStrLn (env ++ \t ++ show (utcToLocalTime tz utc)) main = do utc - getCurrentTime mapM_ (outTime utc) = getArgs $ ghc --make hsnow.hs -o hsnow [1 of 1] Compiling Main ( hsnow.hs, hsnow.o ) Linking hsnow ... $ ./hsnow Europe/Paris Europe/Moscow Europe/London Europe/Paris2008-02-16 23:59:11.776151 Europe/Moscow 2008-02-16 23:59:11.776151 Europe/London 2008-02-16 23:59:11.776151 $ ./hsnow Europe/Moscow Europe/London Europe/Paris Europe/Moscow 2008-02-17 01:59:28.617711 Europe/London 2008-02-17 01:59:28.617711 Europe/Paris2008-02-17 01:59:28.617711 Not good. GHC's runtime library seems to be taking the value of TZ the first time it is called as gospel, and ignoring subsequent changes to TZ. So: 1. Is this a bug in GHC's Data.Time.LocalTime.getTimeZone? 2. If GHC's implementation is working as designed, how do I translate the C program above into Haskell? I'm running on Debian stable, with GHC 6.6. Interesting, it works for me: $ ghc --make hsnow.hs -o hsnow [1 of 1] Compiling Main ( hsnow.hs, hsnow.o ) Linking hsnow ... $ ./hsnow Europe/Paris Europe/Moscow Europe/London Europe/Paris2008-02-17 16:07:43.009057 Europe/Moscow 2008-02-17 18:07:43.009057 Europe/London 2008-02-17 15:07:43.009057 $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 $ uname -srv Darwin 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 -- /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issues with hsql-sqllite build; errors from the hackage download
Yes. It would be nice to have an updated HSQL release first though. /Björn On Feb 2, 2008 6:07 PM, Sterling Clover [EMAIL PROTECTED] wrote: Just noticed, by the way, that haskelldb doesn't build correctly because it still hasn't updated the cabal for the base split. On the other hand, the development repo (which is 0.11 -- 0.10 is on hackage) builds fine. Are the maintainers planning to get an updated version on hackage? --S On Feb 2, 2008, at 10:16 AM, Duncan Coutts wrote: On Fri, 2008-02-01 at 17:05 -0500, bbrown wrote: There seems to be an issue with the hsql-sqlite3. Anyone have a fix. Should I use what is from darcs? HSQL is currently unmaintained. Frederik Eaton was considering taking it over: http://www.nabble.com/HSQL-defunct--td14978532.html Gentoo has a fix: http://haskell.org/~gentoo/gentoo-haskell/dev-haskell/hsql-sqlite/ hsql-sqlite-1.7.ebuild The code in src_unpack() is replacing the Setup.hs with a default copy and then adding 'extra-libraries: sqlite3' to the .cabal file. Pretty straightforward. This does assume that you have sqlite3 installed in the default global location. You may also like to consider alternatives like HDBC-sqlite3. Duncan ___ 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] Browser action and new http library
On Nov 27, 2007, at 0:54 , bbrown wrote: I am trying to use the HTTP library 3001 for ghc 6.8 and cant figure out how to use a proxy to do a GET request as I am behind a proxy server. My thinking is that I could use the setProxy method it looks like it returns a BrowserAction? What do I do with that. Here is the current code (I havent really used the setProxy yet). -- -- HTTP LIBRARY version: HTTP-3001.0.2 import Data.Char (intToDigit) import Network.HTTP import Network.URI import Network.Browser (defaultGETRequest) import System.Environment (getArgs) import System.Exit (exitFailure) import System.IO (hPutStrLn, stderr) main = do args - getArgs case args of [addr] - case parseURI addr of Nothing - err Could not parse URI Just uri - do cont - get uri putStr cont _ - err Usage: lman url err :: String - IO a err msg = do hPutStrLn stderr msg exitFailure get :: URI - IO String get uri = do eresp - simpleHTTP (defaultGETRequest uri) resp - handleErr (err . show) eresp case rspCode resp of (2,0,0) - return (rspBody resp) _ - err (httpError resp) where showRspCode (a,b,c) = map intToDigit [a,b,c] httpError resp = showRspCode (rspCode resp) ++ ++ rspReason resp -- -- Handle Connection Errors handleErr :: Monad m = (ConnError - m a) - Either ConnError a - m a handleErr h (Left e) = h e handleErr _ (Right v) = return v -- End of File There aren't any examples of setProxy usage in the repo, but there was a discussion about it here a few days ago. See http:// www.nabble.com/HTTP-actions---proxy-server-t4815272.html /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] expanded standard lib
On Nov 19, 2007, at 23:13 , Henning Thielemann wrote: On Mon, 19 Nov 2007, Brandon S. Allbery KF8NH wrote: On Nov 19, 2007, at 15:47 , Radosław Grzanka wrote: If you look at the stability tag of ghc libraries you will see that a lot of them are marked as provisional (Network.URI for example) or experimental (Control.Monad.Trans). This may not refer to what most people care about; the experimental stability of Control.Monad.Trans is related to its use of fundeps and undecidable instances, and the possibility (likelihood?) of its being switched to type families (which shouldn't change its user-visible interface, as I understand it). I like to see MTL split into a Haskell98 part and an advanced part. I mostly use functionality which would nicely fit into a Haskell98 interface and find it annoying that by importing MTL my code becomes less portable. Yes! Please! /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.HTTP problem
On Nov 18, 2007, at 22:08 , Radosław Grzanka wrote: Hello again Bjorn, This is now fixed and a new release with the fix is available from http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ HTTP-3001.0.1 You have left debug flag on in the library code. Thanks, Radek. Dammit. I forgot that cabal sdist of course uses the code in the current directory, not what's recorded in darcs. Silly me. 3001.0.2 fixes this, http://hackage.haskell.org/cgi-bin/hackage-scripts/ package/HTTP-3001.0.2 Thanks! /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.HTTP problem
On Nov 17, 2007, at 17:07 , Radosław Grzanka wrote: Hello, I have a problem with Network.HTTP module (http://www.haskell.org/http/) version 3001.0.0 . I have already mailed Bjorn Bringert about it but I didn't get answer yet so maybe someone here can help me. GHC v. 6.6.1 Ubuntu 7.10 x86_64 . I have turned on debug flag. Using get example (http://darcs.haskell.org/http/test/get.hs) I can download pages like this: $ ./get http://www.haskell.org/http/ !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleHaskell HTTP package/title link href=style.css rel=stylesheet type=text/css / /head body SNIP rest of the content SNIP Also the log contain content of this file. However, some links misbehaves like: $ ./get http://www.podshow.com/feeds/gbtv.xml ... no-output ... however I see content of this xml in debug file and wget downloads almost 250 kB of data. Also: $ ./get http://digg.com/rss/indexvideos_animation.xml ... hangs ... and debug file has size 0, but wget downloads the file I could suspect this is xml problem but: $ ./get http://planet.haskell.org/rss20.xml ?xml version=1.0? rss version=2.0 xmlns:dc=http://purl.org/dc/elements/1.1/; channel titlePlanet Haskell/title linkhttp://planet.haskell.org//link languageen/language descriptionPlanet Haskell - http://planet.haskell.org//description SNIP rest of the content SNIP so it works. Do you have any idea what is going on here? What goes wrong? What other (high level) modules could I use to download files through http? Cheers, Radek. Hi Radek, thanks for the report. This turned out to be a bug in how Network.HTTP handled Chunked Transfer Encoding. The web server sent the chunk size as 4000 (according to RFC 2616 this can be non-empty sequence of hex digits). However, Network.HTTP treated any chunk size starting with '0' as a chunk size of 0, which indicates the end of the chunked encoding. This is now fixed and a new release with the fix is available from http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP-3001.0.1 /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Standalone PNG module?
On Nov 8, 2007, at 5:42 , Cale Gibbard wrote: On 06/11/2007, Peter Verswyvelen [EMAIL PROTECTED] wrote: I would like to load 32-bit images (RGB+alpha) for use with GLUT/ OpenGL. I know GTK2HS has support for loading images, but does a standalone Haskell (wrapper) module exists for loading images? PNG or TGA would be enough for me. The Imlib2 binding (called Imlib-0.1.0) on Hackage provides the necessary tools to load and manipulate images in a variety of formats including PNG, but it's under-documented and a little rough and untested. I'm currently working on a new version with proper documentation, a number of bugfixes, and a somewhat more Haskellish interface. The gd package also allows loading, manipulating and saving images in several formats, see http://hackage.haskell.org/cgi-bin/hackage-scripts/package/gd /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Posix
On Oct 16, 2007, at 3:25 , Galchin Vasili wrote: Hello, In a Hugs environment, I am able to import System.Directory but not to import System.Posix. Here is my environment ... .;{Hugs} \packages\*;C:\ftp\CatTheory\Haskell\SOE\graphics\lib\win32\*. I really want to use the Posix module. Help!!! Kind regards, Bill Halchin Hi Bill, it seems like you are using Hugs under Windows. As far as I know System.Posix is not available on Windows. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help parsing dates and times
On Oct 16, 2007, at 2:25 , Don Stewart wrote: jgbailey: I am trying to parse various date and time formats using the parseTime function found in (GHC 6.6.1) Data.Time.Format. The one that is giving me trouble looks like this: 2008-06-26T11:00:00.000-07:00 Specifically, the time zone offset isn't covered by the format parameters given. I can almost parse it with this: %FT%X.000 But that doesn't take into account the -07:00 bit. I'm sure this has been solved - can someone point me to the solution? Thanks in advance. Try %z (see http://www.haskell.org/ghc/docs/latest/html/libraries/time/Data- Time-Format.html#v%3AformatTime for all the format specifiers). Is there anything in the parsedate library? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ parsedate-2006.11.10 http://hackage.haskell.org/packages/archive/parsedate/ 2006.11.10/doc/html/System-Time-Parse.html -- Don parsedate is obsolete, unless you have ghc 6.6.1. It was rewritten to become what is now the date parsing code in the time package. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help parsing dates and times
On Oct 16, 2007, at 17:54 , Justin Bailey wrote: On 10/16/07, Bjorn Bringert [EMAIL PROTECTED] wrote: Hmm, perhaps I should clarify this: parsedate and time-1.1.1 (which comes with GHC 6.6.1) have different APIs. parsedate produces CalendarTimes, and the code in time-1.1.1 produces the new time and date data types. So I guess parsedate isn't actually obsolete, rather, it's for use with the package currently known as 'old-time'. Given this date string: 2008-06-26T11:00:00.000-07:00 The problem is the parseTime function in Data.Time.Format is a little too strict. The following GHCi session shows the different behaviors. Notice how %Z is unable to parse the time zone offset in any case. First we try parseTime: :m + Data.Time System.Time.Parse System.Locale let dateStr = 2008-06-26T11:00:00.000-07:00 parseTime defaultTimeLocale %FT%X.000%z dateStr :: Maybe UTCTime Nothing parseTime defaultTimeLocale %FT%X.000-%z dateStr :: Maybe UTCTime Nothing parseTime defaultTimeLocale %FT%X.000 dateStr :: Maybe UTCTime Nothing I guess you really want a ZonedTime here, if you want to retain the time zone info. It seems like %z and %Z require 4 digits for a time zone offset, without a colon. This works: parseTime defaultTimeLocale %FT%X.000%z 2008-06-26T11:00:00.000-0700 :: Maybe ZonedTime Just 2008-06-26 11:00:00 -0700 Should we just add XX:XX as an alternative time zone offset format accepted by %z and %Z? Is this a standard format? Now parseCalendarTime from the parseDate package: parseCalendarTime defaultTimeLocale %Y-%m-%dT%H:%M:%S dateStr Just (CalendarTime {ctYear = 2008, ctMonth = June, ctDay = 26, ctHour = 11, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay = Thursday, ctYDay = 1, ctTZName = UTC, ctTZ = 0, ctIsDST = False}) parseCalendarTime defaultTimeLocale %Y-%m-%dT%H:%M:%S.000%Z dateStr Nothing Hmm, ok, parsedate allows garbage at the end. I wonder what is the right thing to do here. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Posix
If you want to try and implement some of the System.Posix API using the win32 API, a good place to put that would be in the unix-compat package. Darcs repo: http://www.cs.chalmers.se/~bringert/darcs/unix-compat/ Hackage page: http://hackage.haskell.org/cgi-bin/hackage-scripts/ package/unix-compat-0.1 It currently re-exports the unix package if available, and if not, tries to fake it using the standard libraries or sensible defaults. Using the win32 package would be a nice addition. /Björn On Oct 16, 2007, at 20:35 , Galchin Vasili wrote: Hi Bjorn (and everybody), What would it entail to get System.Posix working on Windows? Would a mininum requirement e.g. be teh installation of http:// www.cygwin.com? Or write a POSIX API to Win32 API binding? If I understand the problem, I wouldn't mind giving a run at it! Regards, Bill On 10/16/07, Bjorn Bringert [EMAIL PROTECTED] wrote: On Oct 16, 2007, at 3:25 , Galchin Vasili wrote: Hello, In a Hugs environment, I am able to import System.Directory but not to import System.Posix. Here is my environment ... .;{Hugs} \packages\*;C:\ftp\CatTheory\Haskell\SOE\graphics\lib\win32\*. I really want to use the Posix module. Help!!! Kind regards, Bill Halchin Hi Bill, it seems like you are using Hugs under Windows. As far as I know System.Posix is not available on Windows. /Björn /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help parsing dates and times
On Oct 16, 2007, at 21:39 , Carl Witty wrote: On Tue, 2007-10-16 at 09:25 -0700, Justin Bailey wrote: On 10/16/07, Bjorn Bringert [EMAIL PROTECTED] wrote: Should we just add XX:XX as an alternative time zone offset format accepted by %z and %Z? Is this a standard format? Yes, this is standard; see below. I'm not sure, but I am getting this date from Google in their XML feeds representing calendar data. The specific element is gd:when, documented here: http://code.google.com/apis/gdata/elements.html#gdWhen That refers to XML Schema; the dateTime type in XML Schema is standardized here: http://www.w3.org/TR/xmlschema-2/#dateTime (and time zone offsets are required to have a colon in this format). Thanks, I have added this to the parser now. I can't push right now because of performance problems, but it'll be in darcs soon. Now it works: Prelude Data.Time System.Locale parseTime defaultTimeLocale %FT%T%Q% z 2008-06-26T11:00:00.087-07:00 :: Maybe ZonedTime Just 2008-06-26 11:00:00.087 -0700 Note that I use %Q for the second decimals instead of .000, this makes it accept non-integer seconds. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Style
On Aug 24, 2007, at 9:18 , Arie Groeneveld wrote: Hi, I defined several functions for calculating the number of trailing zero's of n! tm = sum . takeWhile(0) . iterate f . f where f = flip div 5 tm1 n = sum . takeWhile(0) . map (div n . (5^)) $ [1..] tm2 n = sum . takeWhile(0) . map (div n) $ iterate ((*)5) 5 tm3 = sum . takeWhile(0) . flip map (iterate ((*)5) 5) . div Questions: Which one is the most elegant one generally speaking? Which one is most natural in Haskell? Is there more 'beauty' to possible? My personal choice is 'tm'. I like 'tm3' (a revised version of tm2) in terms of pointlessness and not having a 'where', but I think it's a bit contrived because of the 'flip'. Comments? Here's a much more inefficient version, but it has the merit of being very easy to understand: tm_silly n = length $ takeWhile (=='0') $ reverse $ show $ product [1..n] /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help using CGIT
On Aug 23, 2007, at 3:34 , Rich Neswold wrote: On 8/22/07, Ian Lynagh [EMAIL PROTECTED] wrote: On Wed, Aug 22, 2007 at 01:27:00PM -0500, Rich Neswold wrote: newtype App a = App (ReaderT Connection (CGIT IO) a) deriving (Monad, MonadIO, MonadReader Connection) Unfortunately, when another module tries to actually use the monad, I get warnings about No instance for (MonadCGI App). I tried making an instance: instance MonadCGI App where cgiAddHeader = ? cgiGet = ? You have three choices: 1: 2: 3: Provide a single instance for App that does the whole thing: instance MonadCGI App where cgiAddHeader n v = App $ lift $ cgiAddHeader n v cgiGet x = App $ lift $ cgiGet x This one you would obviously have to change if you added a StateT. Bingo! Method #3 works beautifully! I missed the using-lift-with- the-constructor permutation. Thanks for your help! I started writing a tutorial for Haskell web programming with the cgi package a while back, but haven't worked on it for a while, see http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell I haven't added it to the list of tutorials yet, since it's still rather incomplete. The section on using CGIT is just a stub, perhaps you would like to contribute to it? See http://www.haskell.org/haskellwiki/ Practical_web_programming_in_Haskell#Extending_the_CGI_monad_with_monad_ transformers /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this haskelly enough?
On Jul 18, 2007, at 2:13 , ok wrote: On Jul 17, 2007, at 22:26 , James Hunt wrote: As a struggling newbie, I've started to try various exercises in order to improve. I decided to try the latest Ruby Quiz (http:// www.rubyquiz.com/quiz131.html) in Haskell. Haskell guru level: I am comfortable with higher order functions, but never think of using the list monad. Developing the answer went like this: - find all sublists - annotate each with its sum - find the best (sum, list) pair - throw away the sum best_sublist = snd . maximum . annotate_with_sums . all_sublists All sublists was easy: all_sublists = concatMap tails . inits Confession: the one mistake I made in this was using map here instead of concatMap, but the error message from Hugs was sufficiently clear. Annotating with sums is just doing something to each element, so annotate_with_sums = map (\xs - (sum xs, xs)) Put them together and you get best_sublist = snd . maximum . map (\xs - (sum xs, xs)) . concatMap tails . inits The trick here is that as far as getting a correct answer is concerned, we don't *care* whether we compare two lists with equal sums or not, either will do. To do without that trick, best_sublist = snd . maximumBy c . map s . concatMap tails . inits where s xs = (sum xs, xs) f (s1,_) (s2,_) = compare s1 s2 Confession: I actually made two mistakes. I remembered the inits and tails functions, but forgot to import List. Again, hugs caught this. However, the key point is that this is a TRICK QUESTION. What is the trick about it? This is a well known problem called The Maximum Segment Sum problem. It's described in a paper A note on a standard strategy for developing loop invariants and loops by David Gries (Science of Computer Programming 2(1984), pp 207-214). The Haskell code above finds each segment (and there are O(n**2) of them, at an average length of O(n) each) and computes the sums (again O(n) each). So the Haskell one-liner is O(n**3). But it CAN be done in O(n) time. Gries not only shows how, but shows how to go about it so that you don't have to be enormously clever to think of an algorithm like that. What would be a good exercise for functional programmers would be to implement the linear-time algorithm. The algorithm given by Gries traverses the array one element at a time from left to right, so it's not that hard. The tricky thing is modifying the algorithm to return the list; it might be simplest to just keep track of the end-points and do a take and a drop at the end. I think it is at least mildly interesting that people commented about things like whether to do it using explicit parameters (pointful style) or higher-order functions (pointless style) and whether to use the list monad or concatMap, but everyone seemed to be happy with a cubic time algorithm when there's a linear time one. Well, the original poster wanted advice on how to improve his Haskell style, not algorithmic complexity. I think that the appropriate response to that is to show different ways to write the same program in idiomatic Haskell. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this haskelly enough?
On Jul 17, 2007, at 22:26 , James Hunt wrote: Hi, As a struggling newbie, I've started to try various exercises in order to improve. I decided to try the latest Ruby Quiz (http:// www.rubyquiz.com/quiz131.html) in Haskell. Would someone be kind enough to cast their eye over my code? I get the feeling there's a better way of doing it! subarrays :: [a] - [[a]] subarrays [] = [[]] subarrays xs = (sa xs) ++ subarrays (tail xs) where sa xs = [ys | n - [1..length xs], ys - [(take n xs)]] maxsubarrays :: [Integer] - [Integer] maxsubarrays xs = msa [] (subarrays xs) where msa m [] = m msa m (x:xs) | sum x sum m = msa x xs | otherwise = msa m xs --for testing: should return [2, 5, -1, 3] main = maxsubarrays [-1, 2, 5, -1, 3, -2, 1] I've read tutorials about the syntax of Haskell, but I can't seem to find any that teach you how to really think in a Haskell way. Is there anything (books, online tutorials, exercises) that anyone could recommend? Thanks, James Hi james, here's one solution: import Data.List maxsubarrays xs = maximumBy (\x y - sum x `compare` sum y) [zs | ys - inits xs, zs - tails ys] This can be made somewhat nicer with 'on': import Data.List maxsubarrays xs = maximumBy (compare `on` sum) [zs | ys - inits xs, zs - tails ys] on, which will appear in Data.Function in the next release of base, is defined thusly: on :: (b - b - c) - (a - b) - a - a - c (*) `on` f = \x y - f x * f y /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: haskell for web
On Jul 18, 2007, at 0:27 , brad clawsie wrote: On Wed, Jul 18, 2007 at 12:17:12AM +0200, Hugh Perkins wrote: On 7/17/07, Martin Coxall [EMAIL PROTECTED] wrote: I wonder why 'we' aren't pushing things like this big time. When Ruby took off, more than anything else it was because of Rails. i agree that web programming is a domain that cannot be ignored i have wondered what it would take to get a mod_haskell for apache wash looks interesting, but very few companies and isps are going to run a niche fastcgi platform (even those already running rails). apache is still the de facto open serving platform. If you use Network.FastCGI, and compile (linking statically is a good idea as well) on your own machine, you can run Haskell code on any web host that supports FastCGI. That's what I do with Hope, http:// hope.bringert.net/ /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this haskelly enough?
On Jul 18, 2007, at 1:00 , Dan Weston wrote: Bjorn Bringert wrote: import Data.List maxsubarrays xs = maximumBy (compare `on` sum) [zs | ys - inits xs, zs - tails ys] I love this solution: simple, understandable, elegant. As a nit, I might take out the ys and zs names, which obscure the fact that there is a hidden symmetry in the problem: maxsubarrays xs = pickBest (return xs = inits = tails) where pickBest = maximumBy (compare `on` sum) -- NOTE: Since pickBest is invariant under permutation of its arg, -- the order of inits and tails above may be reversed. Dan Weston Nice. Here's a pointless version: maxsubarrays = maximumBy (compare `on` sum) . (= tails) . inits Though I avoided using the list monad in the first solution, since I thought it would make the code less understandable for a beginner. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC-ODBC build/install problem.
This is probably a HaskellDB or hs-plugins problem. DBDirect uses hs- plugins to load driver modules, and I believe hs-plugins has undergone some changes to work with GHC 6.6.1, which DBDirect might not take into account. I don't use the DBDirect executable myself, since it tends to run into this sort of problems. Instead I write a small wrapper program around the DBDirect API that uses the driver I'm interested in at the moment. If you want to try to fix it, see driver-dynamic/Database/HaskellDB/ DynConnect.hs. My guess is that the loadPackageFunction function there doesn't work with the current hs-plugins. /Björn On Jul 13, 2007, at 17:56 , Edward Ing wrote: This solved the particular problem as you suggested, but I ran into other problems and stuck at another one. So I have another question. When I am using DBDirect from haskelldb to connect through HDBC-odbc. I get the following error message (I got pass the compile problems) DBDirect.exe: user error (Couldn't load Database.HaskellDB.HDBC.ODBC.driver from package haskelldb-hdbc-odbc-0.10) I looked into the package directories and the *.o and *.a file is there. Also I looked into the installed.pkg-config file and found. exposed: True exposed-modules: Database.HaskellDB.HDBC.ODBC So it appears to me that Database.HaskellDB.HDBC.ODBC has been installed properly. Does the build of DBDirect have to be configured some way? I did not configure anything for DBDirect. Has it anything to do with hs-plugins? Your help would be appreciated. Edward Ing On 7/13/07, Bjorn Bringert [EMAIL PROTECTED] wrote: On Jul 12, 2007, at 23:35 , Edward Ing wrote: Hi Edward, the right approach would be to add it to other-modules in HDBC- odbc.cabal file, where it should have been all along. This is a bug in HDBC-odbc, I recommend that you send a patch to the maintainer. /Björn ___ 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] CGI test
On Jul 12, 2007, at 19:59 , Andrew Coppin wrote: Hugh Perkins wrote: ... Thanks for trying - but that doesn't actually work. (For starters, you need to prepend the HTTP status code to the data from the CGI script...) Actually, as it turns out, the script I want to test needs to accept POST data, and the parsing is really quite complicated, and I want it to not crash out if I type the URL wrong, and... Basically, the more I look at this, the more I realise that it really truely *is* going to be faster to just use a real web server. I thought I could just implement a tiny subset of it to get a working system, but it turns out the subset I need isn't so tiny... Sorry guys. As an earlier poster hinted, there is a version of Haskell Web Server that can run CGI programs: http://www.cs.chalmers.se/~bringert/darcs/hws-cgi/ /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDBC-ODBC build/install problem.
On Jul 12, 2007, at 23:35 , Edward Ing wrote: Hi, I am trying to make HaskellDB work with HDBC-ODBC. I did builds of HDBC/HDBC-ODBC. But when I am building HaskellDB-HDBC-ODBC, I get the following message. -- [1 of 1] Compiling Database.HaskellDB.HDBC.ODBC ( Database/HaskellDB/HDBC/ODBC.hs, dist\build/Database/HaskellDB/HDBC/ODBC.o ) C:\Program Files\Haskell\HDBC-odbc-1.1.2.0\ghc-6.6.1/Database/HDBC/ ODBC/Connection.hi Declaration for connectODBC: Failed to load interface for `Database.HDBC.ODBC.ConnectionImpl': Use -v to see a list of the files searched for. Cannot continue after interface file error -- From this, I know the problem is the linkage between Database.HDBC.ODBC.Connection and Database.HDBC.ODBC.ConnectionImple. (Also I looked at the code to see the reference.) I did a little further investigation. I looked at the package registry area (C:\Program Files\Haskell\HDBC-odbc-1.1.2.0\ghc-6.6.1\Database\HDBC\ODBC) and notice that ConnectionImpl.hi is not there. I went back to the build directory and did find ConnectoinImpl.hi and ConnectionImpl.o. It seems like runghc Setup.hs install, did not install ConnectionImpl.hi. I looked into the file named .installed-pkg-config and I saw this: exposed-modules: Database.HDBC.ODBC hidden-modules: Database.HDBC.ODBC.Connection Database.HDBC.ODBC.Statement Database.HDBC.ODBC.Types Database.HDBC.ODBC.Utils Database.HDBC.ODBC.TypeConv import-dirs: C:\\Program Files\\Haskell\\HDBC-odbc-1.1.2.0\ \ghc-6.6.1 library-dirs: C:\\Program Files\\Haskell\\HDBC-odbc-1.1.2.0\ \ghc-6.6.1 hs-libraries: HSHDBC-odbc-1.1.2.0 extra-libraries: odbc32 -- No mention of ConnectionImple.hi. It looks like the setup up script did not install ConnectionImpl.hi. Did ConnectionImpl.o get bound into libHSHDBC-odbc-1.1.2.0.a even though ConnectionImpl.hi did not get successfully installed? Does anyone know why the install target does not install ConnectionImpl.hi and how I can get around this problem? (Where is the odbc32 to be found anyways?) Here are a few things I did try which did NOT work: 1. Copy ConnectionImpl.hi over manually. HaskellDB-HDBC-ODBC builds, but at runtime there is a link error. 2. Manually alter .installed-pkg-config to add ConnectionImpl.hi as hidden module. Please comment on why these would not work ( I will learn from this.) Help would be appreciated. Hi Edward, the right approach would be to add it to other-modules in HDBC- odbc.cabal file, where it should have been all along. This is a bug in HDBC-odbc, I recommend that you send a patch to the maintainer. Approach 1 doesn't work since that does not include the .o file in the installed .a archive. Approach 2 doesn't work for several reasons, which exactly depend on what else you did, and which .installed-pkg-config file you changed. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: The danger of Monad ((-) r)
On May 15, 2007, at 14:52 , Tomasz Zielonka wrote: On Tue, May 15, 2007 at 02:27:13PM +0200, Arie Peterson wrote: Hi Tomek! Hi! Have you considered changing the statements to have type 'ReaderT Database IO ()'? Then () actually does what you want. I tried it and it made the code simpler, more readable and of course more immune to this type of bugs. Thanks! I use the same idea in Hope (http://hope.bringert.net/), with a newtype DatabaseT, and a typeclass MonadDatabase, and lifted versions of the HaskellDB database operations. The code is in the first part of this module: http://www.cs.chalmers.se/~bringert/darcs/hope/Hope/ DatabaseT.hs Perhaps this should be added to HaskellDB? /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Co-arbitrary
On May 8, 2007, at 9:33 , Joel Reymont wrote: Would someone kindly explain why we need co-arbitrary in QuickCheck and how to define it? Detailed examples would be awesome! I would be willing to paste an in-depth explanation on my wall and keep it forever. Thanks in advance, Joel Maybe this can help: http://www.cs.chalmers.se/~rjmh/QuickCheck/ manual_body.html#18 /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to parse a date and time?
On May 8, 2007, at 1:04 , Justin Bailey wrote: Looking at the libraries documentation, it seems like parsing a string into a time and date should be as simple as: import Data.Time.Format (parseTime) myDate = parseTime ... where ... is some string. But these functions don't seem to exist! I can't find many references to them in the wild, and the module Data.Time.Format is not found under GHC 6.6 or Hugs. I am running Windows, if it makes a difference. Are the docs just out of date[1] or is it my install? How can I parse a string into a Data.Time.Calendar.Day value (or some other time value)? Thanks for any help! Justin [1] http://haskell.org/ghc/docs/latest/html/libraries/time/Data- Time-Format.html parseTime is still only available in the darcs version of the time package. I don't know why the GHC library docs have the darcs version rather than the version that comes with the latest release. You can get the darcs version of the time package with: darcs get --partial http://darcs.haskell.org/packages/time/ /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Typing non-Haskell in Haskell
On Apr 12, 2007, at 14:37 , Joel Reymont wrote: I feel I should set aside a Friday of every week just to read the Haskell papers :-). After skimming through Typing Haskell in Haskell I have a couple of questions... Are type constructors (TyCon) applicable to Haskell only? Mine is a Pascal-like language. How would I type Pascal functions as opposed to Haskell ones? It seems that the approach is the same and I still need TyCon (-). Thanks, Joel Here are some lecture notes about implementing type checking for an imperative language from a programming languages course: http://www.cs.chalmers.se/Cs/Grundutb/Kurser/progs/current/lectures/ proglang-08.html /Björn___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: XMPP 0.0.1
On Apr 8, 2007, at 2:03 , Magnus Henoch wrote: I'm hacking a library for writing XMPP clients, and just decided that my work is good enough to call it version 0.0.1. Find source and documentation here: http://www.dtek.chalmers.se/~henoch/text/hsxmpp.html It contains a werewolf bot as an example. I wanted the bot to speak several languages, but I couldn't find any library that would make that easier, so I wrote one myself, in Translate.hs. Is there any other way to do that? What do other projects use? You could use GF and its grammar library to generate text in multiple languages, see http://www.cs.chalmers.se/~aarne/GF/ GF is written in Haskell and can be used as a library. I work with GF daily, so feel free to ask me any questions you may have. ... /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: MIME Strike Force
On Mar 18, 2007, at 21:36 , Jeremy Shaw wrote: Hello, If you have tried to do any MIME processing using Haskell, you are likely to have found two things: 1) There are a lot of MIME libraries for Haskell 2) None of them do everything you want So, I propose that we form a MIME Strike Force and create the one, true MIME library. The plan is something like this: 1) Document all the things the MIME library needs to support. 2) Pick the technology, and design the infrastructure for supporting these features. For example, I don't think we will be able to use Parsec because: i) We want to support ByteString ii) We want to be able to lazily parse the message 3) Try to reuse as much existing code as possible to implement the design. I have started step 1 by creating this page: http://www.haskell.org/haskellwiki/Libraries_and_tools/MIMEStrikeForce Please add your comments, requirements, etc. If you are interesting in helping contrib ideas, code, or flames, please let me know. If there is enough interest, we should probably set up a mailing list for discussion. j. ps. This *might* make a decent SoC project, but only if it results in the one, true MIME library. We definitely do not need another incomplete MIME library floating around. I added this as a SoC project proposal. We can decide on its merits when voting for the projects. See http://hackage.haskell.org/trac/ summer-of-code/ticket/1126 /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parallelism on concurrent?
On Mar 13, 2007, at 17:26 , Dusan Kolar wrote: Hello all, I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http:// www.haskell.org/ghc/docs/latest/html/libraries/base/Control- Parallel-Strategies.html BTW, could someone point me to some more deeper doc. about it? During googling I've discovered that since GHC 6.6, par, forkIO, and forkOS should make the stuff run in parallel if I have more than one CPU core. Is that right? I think not, because on my machine only par makes the things run in parallel and only during the computation (GC runs in a single thread). If it should work, how can I verify that my installation is correct? If it should not work, will it be working someday? Thanks for your patience, responses, and tips Dusan There's a bit more Haddock for Control.Parallel.Strategies in the current darcs version: http://www.haskell.org/ghc/dist/current/docs/libraries/base/Control- Parallel-Strategies.html /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] Re: [Haskell-cafe] Google summer of code
On Mar 8, 2007, at 10:40 , Simon Marlow wrote: David House wrote: On 06/03/07, Malcolm Wallace [EMAIL PROTECTED] wrote: Well, our wiki to gather ideas is now up-and-running again: http://hackage.haskell.org/trac/summer-of-code We should probably remove projects that were succeessfully completed last year, along with the lists of interested students on every project. I did some general tidying up in the Trac yesterday, including closing some of the projects that were done last year. I'd urge others to go and take a look too; I didn't do a complete sweep. I think that it would be good if we this year would make a short(ish) list of the projects that we think are the most important, and let the students focus on applying for those. My impression from last year is that there were lots of project proposals, most of which could not be considered important enough to be one of the projects we pick, no matter how good the students were who wanted to do them. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: functional database queries
On Feb 22, 2007, at 14:56 , Henning Thielemann wrote: On Wed, 21 Feb 2007 [EMAIL PROTECTED] wrote: Albert Y. C. Lai wrote: [EMAIL PROTECTED] wrote: Albert Y. C. Lai wrote: If and only if the database is a purely functional immutable data structure, this can be done. [...] Many interesting databases are not purely functional immutable; most reside in the external world and can spontaneously change behind your program's back. I don't think this is the problem because SQL requests are emitted atomically anyway. The (Query a) monad here has nothing to do with mutability of the data base. The same clock read twice, each reading atomic, can give two different results. (Cf. the monadic type signature of Data.Time.Clock.getCurrentTime.) The same SELECT to the same database issued twice, each time atomic, can give two different results. Yeah, of course. That's why the function that executes the query is in the IO-monad: query :: GetRec er vr = Database - Query (Rel er) - IO [Record vr] Hennings' question is whether the query type 'Query (Rel el)' really has to be a monad, not whether the function 'query' has to be in the IO-monad. Right. In other words, 'Query a' just assembles a valid SQL-string, it does not query or execute anything. Of course, instead of the DSEL approach don't execute anything, only construct a program in a foreign language which does that it would be nice to have a database where Haskell is the native query language, allowing to access the database content with 'map', 'filter' and so on. Have you seen CoddFish (http://wiki.di.uminho.pt/twiki/bin/view/ Research/PURe/CoddFish)? /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: functional database queries
On Feb 21, 2007, at 20:47 , [EMAIL PROTECTED] wrote: Albert Y. C. Lai wrote: [EMAIL PROTECTED] wrote: Albert Y. C. Lai wrote: If and only if the database is a purely functional immutable data structure, this can be done. [...] Many interesting databases are not purely functional immutable; most reside in the external world and can spontaneously change behind your program's back. I don't think this is the problem because SQL requests are emitted atomically anyway. The (Query a) monad here has nothing to do with mutability of the data base. The same clock read twice, each reading atomic, can give two different results. (Cf. the monadic type signature of Data.Time.Clock.getCurrentTime.) The same SELECT to the same database issued twice, each time atomic, can give two different results. Yeah, of course. That's why the function that executes the query is in the IO-monad: query :: GetRec er vr = Database - Query (Rel er) - IO [Record vr] Hennings' question is whether the query type 'Query (Rel el)' really has to be a monad, not whether the function 'query' has to be in the IO-monad. In other words, 'Query a' just assembles a valid SQL-string, it does not query or execute anything. Regards, apfelmus This is correct, the Query monad is just used to construct the query. Running the query is done in IO. If we look in the source code (http://darcs.haskell.org/haskelldb/src/ Database/HaskellDB/Query.hs), we see that the Query monad is a state monad, whose state is the current query and an Int used to generate fresh field names. It would certainly possible to do this without a monad, though it would probably require reworking the PrimQuery type. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for documentation on Control.Parallel.Strategies
On Feb 16, 2007, at 21:16 , Jefferson Heard wrote: Is there anything that documents this further than the Haddock documentation available from Haskell.org or the GHC pages? I've gotten some basic parallelism to work using parMap and using || and |, but I had a fold and a map that I could logically compute at the same time. ... Maybe that's what you're looking at, but the darcs version has some more Haddock comments, see http://www.haskell.org/ghc/dist/current/ docs/libraries/base/Control-Parallel-Strategies.html /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where can I find XmlRpc package?
On Feb 14, 2007, at 22:50 , keepbal wrote: http://www.cs.chalmers.se/~bringert/darcs/blob/Makefile BlobXmlRpc: GHCFLAGS += -package XmlRpc I can't find XmlRpc,so I use haxr instead,but it doesn't work. haxr is the new name for the XmlRpc package, so changing -package XmlRpc to -package haxr should work. If it doesn't, please include the information needed to figure out what's happening, for example what you tried and what happened (error messages etc.). Blob is quite old by the way. I can hardly remember what it does any more. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Network.CGI.Compat.pwrapper
On Feb 13, 2007, at 9:14 , Gracjan Polak wrote: Bjorn Bringert bringert at cs.chalmers.se writes: Another question is: how do I do equivalent functionality without pwrapper? You can roll you own web server if you want something very simple. If you don't want to do that, there is a version of Simon Marlow's Haskell Web Server with CGI support [1]. You could also get the original HWS [2] and merge it with your program. You might also be interested In HAppS [3]. Haskell Web Server seems to be the closest match. I don't want fully functional web server. I need more low level thing, as I need to set this up as a testing environment for some other (browser like) application. So I need a way to trigger (atrificial) errors, like protocol errors, garbage and broken connections. Thanks for the response. Is there a description what is a *CGI* protocol? Here you go: http://hoohoo.ncsa.uiuc.edu/cgi/interface.html /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.CGI.Compat.pwrapper
On Feb 12, 2007, at 23:27 , Albert Y. C. Lai wrote: Bjorn Bringert wrote: pwrapper is not an HTTP server, though the Haddock comment can make you think so. pwrapper allows you to talk *CGI* over a TCP port, but I have no idea why anyone would like to do that. Here is a scenerio. I want a basic web application: someone makes a request, and my program computes a response. * For one reason or another, I settle with CGI. * The program is huge and slow to load. (Let's say it statically links in the whole GHC API and therefore is basically GHC itself. :) ) It would suck to re-load this program at every request. By the way, here's an example application which does just that using FastCGI: http://csmisc14.cs.chalmers.se/~bjorn/dynhs/examples/wiki/ wiki.hs It uses a dynamically started FastCGI application, which means that the web server starts up new processes when needed and keeps a bunch of them around to serve future requests. ... /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.CGI.Compat.pwrapper
On Feb 12, 2007, at 14:22 , Gracjan Polak wrote: I wanted to setup really simple http server, found Network.CGI.Compat.pwrapper and decided it suits my needs. Code: module Main where import Network.CGI import Text.XHtml import Network doit vars = do return (body (toHtml (show vars))) main = withSocketsDo (pwrapper (PortNumber ) doit) Pointng any browser to http://127.0.0.1: does not render the page. It seems the response headers are broken. How do I report this bug (trac? something else?). We might want to either fix it, or just get rid of it, as nobody seems to notice the problem :) $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.6 Tested under WinXP and MacOSX 10.4.9. Hi Gracjan, pwrapper is not an HTTP server, though the Haddock comment can make you think so. pwrapper allows you to talk *CGI* over a TCP port, but I have no idea why anyone would like to do that. The functions in the Network.CGI.Compat module are deprecated, and shouldn't be used in new code. Even though I'm the maintainer of the cgi package, I don't really know what those functions could ever be useful for, and I've never seen any code which uses them. In fact, I've now removed the Network.CGI.Compat module and uploaded cgi-3001.0.0 to Hackage. Another question is: how do I do equivalent functionality without pwrapper? You can roll you own web server if you want something very simple. If you don't want to do that, there is a version of Simon Marlow's Haskell Web Server with CGI support [1]. You could also get the original HWS [2] and merge it with your program. You might also be interested In HAppS [3]. /Björn [1] http://www.cs.chalmers.se/~bringert/darcs/hws-cgi/ [2] http://darcs.haskell.org/hws/ [3] http://happs.org/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What's wrong with cgi-undecidable?
On Feb 11, 2007, at 0:12 , Robin Green wrote: On Sat, 10 Feb 2007 23:37:04 +0100 Bjorn Bringert [EMAIL PROTECTED] wrote: I've also recently changed the version number scheme on most of the packages I maintain (which includes most of the packages required by Hope) from a date-based one to a major.minor scheme. This has the unfortunate side-effect of making newer versions have smaller version numbers than older ones, but it felt silly to start with a major version number of 2008. That might have been a bad decision. The rPath Linux package management tool, conary, has a nice solution to the problem that software version numbers have inconsistent lexical ordering conventions between projects and sometimes within the same project. It does not compare version numbers at all, and (as far as I can tell) asks the package repository for the most recent package, unless you specify a particular version. Perhaps Cabal could do something similar? Of course, this way you can't express I want version = 1.2 which is kind of a bummer. Yeah, that would make specifying dependencies a bit of a drag. I think I'll just rerelease all the packages as version 3000.0.0 or something. Who cares if the version numbers look silly? /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What's wrong with cgi-undecidable?
On Feb 10, 2007, at 9:15 , Donald Bruce Stewart wrote: haskell: [EMAIL PROTECTED] said: Then another problem,after I unregistered cgi-2006.9.6,the fastcgi-2006.10.9could't work well with cgi-1.0 . You might need fastcgi-1.0: http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi Actually,I was trying my best to install hope: http://www.cs.chalmers.se/~bringert/darcs/hope and lasted for three days, it's really too hard. hope really is rather hard to install. You're best 'hope' is to get packages from hackage that match version numbers you're after: http://hackage.haskell.org/packages/archive/pkg-list.html And then anything else from darcs. hope is really the pathological case for dependencies at the moment. Perhaps shapr or Bjorn can comment on the issues involed? We hope to be able to solve the hope (and other complex package) problems with cabal-install, which will pull all dependencies off hackage, build them, and build your package, automatically. It's almost there. A few days ago I put some work into the hope.cabal file, so that you should now be able to use that to build it. Just get the versions of all packages listed in the current darcs version of hope.cabal. I think all of them except the haskelldb ones are available from Hackage. If haskelldb 0.10 was released and uploaded to Hackage, I think you could even install Hope itself from Hackage. I've also recently changed the version number scheme on most of the packages I maintain (which includes most of the packages required by Hope) from a date-based one to a major.minor scheme. This has the unfortunate side-effect of making newer versions have smaller version numbers than older ones, but it felt silly to start with a major version number of 2008. That might have been a bad decision. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternate instance Show (Maybe a)?
On Feb 2, 2007, at 21:10 , Sergey Zaharchenko wrote: Hello list, Suppose I want show Nothing to return , and show (Just foo) return show foo. I don't seem to be able to. Looks like I either have to use some other function name, like `mShow', or have to import Prelude hiding Maybe, reimplement Maybe, write all the other useful instances (Functor, Monad) for it, etc. Not particularly hard, but looks ugly. Isn't there a better solution? I recall some discussion about this, but can't find it in the archives... With GHC you can at least avoid rewriting all the instances: make a newtype, use newtype deriving to get all the instances except Show, and write your own Show instance. {-# OPTIONS_GHC -fglasgow-exts #-} newtype MyMaybe a = MyMaybe (Maybe a) deriving (Eq,Ord,Monad,Functor) instance Show a = Show (MyMaybe a) where showsPrec _ (MyMaybe Nothing) = id showsPrec n (MyMaybe (Just x)) = showsPrec n x /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: binary: high performance, pure binary serialisation
On Jan 29, 2007, at 16:38 , Ross Paterson wrote: On Fri, Jan 26, 2007 at 01:51:01PM +1100, Donald Bruce Stewart wrote: Binary: high performance, pure binary serialisation for Haskell - - The Binary Strike Team is pleased to announce the release of a new, pure, efficient binary serialisation library for Haskell, now available from Hackage: tarball:http://hackage.haskell.org/cgi-bin/hackage-scripts/ package/binary/0.2 darcs: darcs get http://darcs.haskell.org/binary haddocks: http://www.cse.unsw.edu.au/~dons/binary/Data-Binary.html Remind me again: why do you need a Put monad, which always seems to have the argument type ()? Monoids really are underappreciated. I don't know if that's the main reason, but monads give you do- notation, which can be very nice when you are doing a long sequence of puts. Here's an example from the tar package [1]: putHeaderNoChkSum :: TarHeader - Put putHeaderNoChkSum hdr = do let (filePrefix, fileSuffix) = splitLongPath 100 (tarFileName hdr) putString 100 $ fileSuffix putOct 8 $ tarFileMode hdr putOct 8 $ tarOwnerID hdr putOct 8 $ tarGroupID hdr putOct 12 $ tarFileSize hdr putOct 12 $ let TOD s _ = tarModTime hdr in s fill 8 $ ' ' -- dummy checksum putTarFileType $ tarFileType hdr putString 100 $ tarLinkTarget hdr -- FIXME: take suffix split at / if too long putString6 $ ustar putString2 $ -- strange ustar version putString 32 $ tarOwnerName hdr putString 32 $ tarGroupName hdr putOct 8 $ tarDeviceMajor hdr putOct 8 $ tarDeviceMinor hdr putString 155 $ filePrefix fill12 $ '\NUL' I guess mconcat [putX, putY, ... ] would work too, but the syntax is not quite as nice. /Björn [1] http://www.cs.chalmers.se/~bringert/darcs/tar/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple HTTP lib for Windows?
On Jan 29, 2007, at 11:11 , Yitzchak Gale wrote: Neil Mitchell wrote: I will be releasing this function as part of a library shortly Alistair Bayley wrote: no! The code was merely meant to illustrate how a really basic HTTP GET might work. It certainly doesn't deal with a lot of the additional cases, like redirects and resource moves, and non-standards-compliant HTTP servers... there are a large number of webserver implementations which do not respect the HTTP standards (1.0 or 1.1), and HTTP clients (like web browsers) have to go to some lengths in order to get sensible responses out of most of them... if your needs really are very simple, then fine. But be aware that doing the right thing with real-world HTTP responses can be a can-o'-worms. Let's not complicate things too much at the HTTP level. Low-level HTTP is a simple protocol, not hard to implement. You send a request with headers and data, and get a like response. Possibly reuse the connection. That's it. HTTP is useful for many things besides just loading web pages from large public servers. We need a simple, easy to use module that just implements HTTP. I think we have that, or we are close. Loading URLs on the web is an entirely different matter. There is a whole layer of logic that is needed to deal with the mess out there. It builds not just on HTTP, but on various other standard and non-standard protocols. URL loading is a hard problem, but usable solutions are well-known and available. I would suggest that we not re-invent the wheel here. If we want a pure Haskell solution - and that would be nice - we should start with an existing code base that is widely used, stable, and not too messy. Then re-write it in Haskell. Otherwise, just keep spawning wget or cUrl, or use MissingPy. But please don't confuse concerns by mixing URL-loading logic into the HTTP library. They made that mistake in Perl in the early days of the web, before it was clear what was about to happen. There is no reason for us to repeat the mistake. Status report for the HTTP package (http://haskell.org/http/): The Network.HTTP module is an implementation of HTTP itself. The Network.Browser module sits on top of that and does more high-level things, such as cookie handling. I maintain the current HTTP package [1], but I haven't really done much maintenance, and I have only gotten a few patches submitted. Much of the code hasn't even been touched since Warrick Gray disappeared around 2002. The reason for this state of affairs is that I hardly use the library myself, and few others have contributed to it. In fact, I just now went to have a look at the code and noticed that until now, the most important functions in Network.Browser did not show up in the Haddock documentation because of missing type signatures. This library needs a more dedicated maintainer and more contributors. Do we have any candidates in this thread? Here's a list of TODO items off the top of my head to get you started: - Add a layer (on top of Network.Browser?) for simple get and post requests, with an interface something like: get :: URI - IO String post :: URI - String - IO String - Switch to use lazy ByteStrings - Better API for Network.Browser? - Move HTTP authentication stuff to a separate module? - Move cookie stuff to a separate module? Unify with the similar code in the cgi package (Network.CGI.HTTP.Cookie)? - Use MD5 and Base64 from Dominic's new nimbler crypto package (see http://www.haskell.org/haskellwiki/Crypto_Library_Proposal) - Use the non-deprecated Network.URI API. - Implement HTTPS support. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Source Code with Haskell
On Jan 2, 2007, at 0:08 , Martin Huschenbett wrote: Hi, my aim is to transform an XML file into C++ source code with a Haskell program. The part that parses the XML is already finished (using HaXML) but the part that generates the C++ code is still remaining. Is there already any work on this topic? Maybe even on generating Java or any other object oriented or imperative language. My first approach was to simply generate the C++ code as text using a pretty printing library but this becomes ugly very fast. Next I thought about generating and rendering the AST of the resulting C++ code. But I don't want to reinvent the wheel. When I want to generate source code, I often write a grammar for the language fragment that I need and use BNFC (http://www.cs.chalmers.se/ ~markus/BNFC/) to make a pretty-printer. If you want nicely indented output, you sometimes have to tweak the generated pretty-printer a bit. /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] maybeToM
On 18 dec 2006, at 18.22, Stefan O'Rear wrote: I can't see how such a generalization could look like, especially since maybe can be used with arbitrary monad: maybe (fail Nothing) return Well, that???s a possible implementation of a maybeToM. The question is: Is it useful enough for a name on it???s own? I thought it was useful enough in genericserialize: module Data.Generics.Serialization.Standard ... -- |Convert a 'Maybe' object into any monad, using the imbedding defined by -- fail and return. fromMaybeM :: Monad m = String - Maybe a - m a fromMaybeM st = maybe (fail st) return I agree that this is useful. Several of my applications and libraries include this somewhere (with different names: maybeM and maybeToM). Though the RHS isn't much shorter than the LHS, unless its name is made shorter. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Aim Of Haskell
On 15 dec 2006, at 14.14, Neil Bartlett wrote: ... The Haskell web server that Simon Peyton-Jones et al described in their paper would be a great example. But where's the download? How do I get a copy to play with? In the real world, things don't stop with the publication of a paper ;-) ... There is a darcs repo with the HWS at: http://darcs.haskell.org/hws/ It's the 2th result if you google for haskell web server (though to be fair, I set up that repo pretty recently just because the original code was hard to find). It's not exactly the original sources, as they have been modified to compile with GHC 6.6 and current library versions. The original code is available from http://cvs.haskell.org/ cgi-bin/cvsweb.cgi/fptools/hws/ /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trivial database access in Haskell
Hi Paul, as Simon notes, I maintain HaskellDB. I think that HaskellDB isn't exactly what you are looking for at the moment. You seem to want to run SQL queries, and HaskellDB is designed to free you from writing SQL. I'm not sure if anyone has mentioned it yet, but HSQL 1.7 includes Oracle support (though I haven't tested it). You can get it from http://sourceforge.net/project/showfiles.php? group_id=65248package_id=93958 Here's what I would do in your situation: 1. Join the #haskell IRC channel on irc.freenode.net. 2. Try to install your chosen library. 3. Ask questions in the IRC channel when you run into problems. Chances are that you will have some library and Cabal developers there to help you. /Björn On 12 dec 2006, at 10.11, Simon Peyton-Jones wrote: Paul The people you want are probably HDBCJohn Goerzen [EMAIL PROTECTED] HaskellDB Anders Höckersten [EMAIL PROTECTED] and Bjorn Bringert [EMAIL PROTECTED] HSQLKrasimir Angelov [EMAIL PROTECTED] Takusen Bayley, Alistair [EMAIL PROTECTED] (did I miss any?) They probably haven't been online since your msg, but I'm sure they'll be keen to help you use the fruit of their labours -- and would welcome your help in documenting them better. You might also find help on the #haskell IRC channel. Simon | OK, thanks for the gentle push. After a bit of digging, I decided that | the takusen link looked like a darcs repository, and I downloaded | darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round | I can install stuff on just now, I'll do this properly later). On the | assumption that the takusen.cabal file means I should look at Cabal, I | had a dig and found the incantation runhaskell setup.hs. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generalizing zip
On 16 nov 2006, at 11.46, Jason Dagit wrote: In #haskell on freenode we had a discussion about isPrefixOf, which is probably implemented roughly as so: isPrefixOf [] _ = True isPrefixOf _ [] = False isPrefixOf (x:xs) (y:ys) = x == y isPrefixOf xs ys Well, this is basically just a zip with a special base case. But you can't just write it with zipWith because zipWith stops when it exausts either list. How about we define zipWith'' like this: zipWith'' _ [] _ l _ = [l] zipWith'' _ _ [] _ r = [r] zipWith'' f (x:xs) (y:ys) l r = f x y : zipWith'' f xs ys l r Then we can write: isPrefixOf xs ys = and (zipWith'' (==) xs ys True False) A point free reduction might look like the following and probably isn't worth it: isPrefixOf = (and .) . flip flip False . flip flip True . zipWith'' (==) Are there lots of other places where this zipWith'' would come in handy? It seems like I've found lots of times when I needed to manually code the recursion because of the way zip behaves when it exhausts one of its parameter lists. I needed something like this just the other day. I think that it could be made more general: zipWith'' :: (a - b - c) - [a] - [b] - ([b] - [c]) - ([a] - [c]) - [c] zipWith'' _ [] ys l _ = l ys zipWith'' _ xs [] _ r = r xs zipWith'' f (x:xs) (y:ys) l r = f x y : zipWith'' f xs ys l r Now zipWith is a special case of zipWith'': zipWith :: (a - b - c) - [a] - [b] - [c] zipWith f xs ys = zipWith'' f xs ys (const []) (const []) Though isPrefixOf becomes a bit more complex: isPrefixOf :: Eq a = [a] - [a] - Bool isPrefixOf xs ys = and (zipWith'' (==) xs ys (const [True]) (const [False])) /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] string to date?
On 10 nov 2006, at 00.29, Magnus Therning wrote: On Thu, Nov 09, 2006 at 20:43:36 +0100, Björn Bringert wrote: Dougal Stanton wrote: Quoth Magnus Therning, nevermore, I've been staring my eyes out trying to find a function that converts a string into a ClockTime or CalendarTime. Basically something like C's strptime(3). I can't seem to find anything like it in System.Time, there are function that convert _to_ a string, but nothing that converts _from_ a string it seems. Where should I look? The MissingH.Time.ParseDate [1] module might be what you want. There's also one from Bjorn Bringert [2]. I haven't used either though, so I can't recommend anything between them. Cheers, D. [1]: http://quux.org:70/devel/missingh/html/MissingH-Time- ParseDate.html [2]: http://www.cs.chalmers.se/~bringert/darcs/parsedate/ Those two are the same code. I have a preliminary new version which can also parse most of the types from the time package (Data.Time.*) available at: http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/ I noticed one thing when playing around with ParseDate.parseCalendarTime in ghci: parseCalendarTime System.Locale.defaultTimeLocale %Y 2006 Just (CalendarTime {ctYear = 2006, ctMonth = January, ctDay = 1, ctHour = 0, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay = Thursday, ctYDay = 1, ctTZName = UTC, ctTZ = 0, ctIsDST = False}) parseCalendarTime System.Locale.defaultTimeLocale %Y%m%d 20061109 Nothing parseCalendarTime System.Locale.defaultTimeLocale %C%y%m%d 20061109 Just (CalendarTime {ctYear = 2006, ctMonth = November, ctDay = 9, ctHour = 0, ctMin = 0, ctSec = 0, ctPicosec = 0, ctWDay = Thursday, ctYDay = 1, ctTZName = UTC, ctTZ = 0, ctIsDST = False}) Hi Magnus, thanks for the bug report. I have fixed this now in the version of the library available from http://www.cs.chalmers.se/~bringert/darcs/parsedate/ I intend to retire that version, and instead switch to the new implementation available at http://www.cs.chalmers.se/~bringert/darcs/parsedate-2/ This supports both CalendarTime and the new much nicer Data.Time types. However, the implementation is still incomplete (about as complete as the old version I think). It is missing support for week date formats and the like, and there is no test suite or QuickCheck properties (and thus there are surely lots of bugs). By the way, if you want to be sure that I see your bug reports about any of the libraries I maintain, please to cc the reports to me, or send them to me directly. /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] USB Drivers in Haskell
On 25 aug 2006, at 05.02, Jason Dagit wrote: Hello, I recently became the owner a USB gadget that tracks movement via GPS and also tracks heart rate (it's a training device for athletes). This device comes with software that is windows only and...doesn't like up to it's potential (to put it politely). Being a programmer type and someone that prefers to use either linux or osx I quickly realized I should write my own software to use the gadget. Fortunately, the company that makes the device provides documentation to write drivers for the device (including a minimal example USB driver for win32). So then I looked around the net for a few open source things, such as open source drivers for the device or a Haskell library to help me start writing drivers for the gadget. I didn't see anything relevant after a few minutes of searching so I figure that means there isn't much. Did I miss a Haskell library for writing device drivers, specifically USB drivers? Would this be hard to write? I would prefer to support osx and linux at a minimum and I think it would be ideal to shoot for cross platform (win32, osx, linux and *bsd). I have this feeling that it could be done by writing platform specific wrappers using hsc2hs on each platform then bringing them together through a unified 'low' level Haskell api. The Haskell api would then be exposed as a module for application developers. Any thoughts? For the interested, the documentation I spoke of can be found here: http://www.garmin.com/support/commProtocol.html For cross-platform USB drivers, you may want to have a look at libusb [1]. I have only used it under Linux, but it seems to support Linux, *BSD and OS X. There also seems to be a win32 port [2]. A Haskell binding to libusb would be very welcome. /Björn [1] http://libusb.sourceforge.net/ [2] http://libusb-win32.sourceforge.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] AJAX applications in Haskell
On Aug 10, 2006, at 6:29 AM, Adam Peacock wrote: On 8/10/06, Jared Updike [EMAIL PROTECTED] wrote: [..] http://www.ugcs.caltech.edu/~lordkaos/calc.cgi (source available here http://www.ugcs.caltech.edu/~lordkaos/ calc.tar.gz) I've only recently joined this mailing list, and there seems to be a considerable amount of talk about Haskell and web applications. Although I can't seem find any commercial sites using Haskell. I'm not after examples like the WASH gallery, I'm after non-trivial, real or commercial applications using Haskell and the web. Does anyone know of any? I haven't announced Hope here yet, only talked about it on #haskell, but since you asked, you may want to have a look at http:// hope.bringert.net/ It's not really what you asked for I guess: Hope is work in progress, only has a few users, and I don't know of any commercial sites using it (though a certain user tells me that he is working on one). /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why Not Haskell?
On Aug 4, 2006, at 11:10 PM, Bulat Ziganshin wrote: Friday, August 4, 2006, 8:17:42 PM, you wrote: 1) Haskell is too slow for practical use, but the benchmarks I found appear to contradict this. it's an advertisement :D just check yourself 2) Input and output are not good enough, in particular for graphical user interfacing and/or data base interaction. But it seems there are several user interfaces and SQL and other data base interfaces for Haskell, even though the tutorials don't seem to cover this. i've seen a paper which lists 7 (as i remember) causes of small Haskell popularity, including teaching, libraries, IDEs and so on. may be someone will give us the url Is this the paper you are referring to? Philip Wadler. Why no one uses functional languages. ACM SIGPLAN Notices, 33(8):23--27, 1998. http://citeseer.ist.psu.edu/wadler98why.html /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help building HSQL...
On Jul 10, 2006, at 2:57 AM, Martin Percossi wrote: Hi, I'm trying to build HSQL, in order to use HaskellDb. The base directory (i.e. HSQL) builds ok, as per instructions, but the PostgreSQL directory fails with the error message: Setup.lhs:17:71: Couldn't match `PackageDescription' against `LocalBuildInfo' Expected type: Args - ConfigFlags - LocalBuildInfo - IO ExitCode Inferred type: [String] - ConfigFlags - PackageDescription - LocalBuildInfo - IO ExitCode In the `postConf' field of a record In the record update: defaultUserHooks {preConf = preConf, postConf = postConf} My version of ghc is 6.4.2. My installed packages are (using ghc-pkg list): Cabal-1.0, (Cabal-1.1.4), GLUT-2.0, HUnit-1.1, MissingH-0.14.2, OpenGL-2.0, QuickCheck-1.0, base-1.0, (concurrent-1.0), (data-1.0), fgl-5.2, haskell-src-1.0, haskell98-1.0, hsql-1.7, (hssource-1.0), (lang-1.0), mtl-1.0, (net-1.0), network-1.0, parsec-1.0, (posix-1.0), readline-1.0, rts-1.0, stm-1.0, template-haskell-1.0, (text-1.0), unix-1.0, (util-1.0) Note that I have installed all of these packages, and ghc into my ~/ opt directory, as I don't have root. Has anyone seen the above error message before? Am I using the incorrect version of Cabal? Any help appreciated. Hi Martin, that definitely looks like a Cabal version problem. It looks like you have Cabal-1.0 exposed and Cabal-1.1.4 hidden. Can you try reversing that? This should do it: ghc-pkg hide Cabal-1.0 ghc-pkg expose Cabal-1.1.4 /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANNOUNCE: HNOP 0.1
On Jun 30, 2006, at 2:52 PM, Ashley Yakeley wrote: Simon Marlow wrote: My congratulations to the development team; this is an important contribution to the community. Thanks! You might want to use {-# OPTIONS_GHC #-} rather than {-# OPTIONS #-}, unless compatibility with older versions of GHC is a goal. Still, the pragma only turns on warnings, so it's harmless. Applied, thanks. At some point I want to do equivalent things for other compilers. I generally like to be pretty strict about warnings, especially as one can selectively disable them if needed. noop :: IO () -- generalise to other Monads? Only IO makes sense really, since by definition every non-IO expression does nothing, so the only interesting way to do nothing is in the IO monad. Agreed. The concept of doing nothing is best understood within the conceptual domain of doing things in the IO sense. I shall also be resisting any calls for an unsafe version (unsafeNoOp :: ()). I'm currently considering possible unit tests, since right now I rely solely on code inspection. One possibility would be to simply time the function to show that it didn't have time to do anything really long at least. But that's not very satisfactory, since that is strictly a performance test, not a functionality test. It's like any other Haskell function: I want to implement it as efficiently as possible, but I don't guarantee any particular performance. Ideally I would have tests like these: * Verify noop does nothing with the file system. * Verify noop does no networking activity. * Verify noop makes no use of stdin/stdout/stderr. * Verify noop does not modify any external IORefs. etc. Actually, I think the fourth one may be unnecessary, given that we don't have global mutable state. The third might not be too hard. It's not clear how to do the others, however. I should hate to discover that a bug in my implementation was accidentally causing it to behave as a secure distributed HTTP-addressable digital media semantic content management system. You may also want to verify that nothing is actually returned. What if there is a bug that makes it return bottom instead of nothing? This would mean that it would work fine for simple uses like your example run, but could crash your program if it actually uses the nothing (for example if HNOP is converted to a library as suggested by others). I guess this is related to the issue of exception handling. What if the program is interrupted when it's halfway through doing nothing? Ideally we would like to guarantee that it does nothing atomically. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there any url lib?
On Jun 3, 2006, at 7:46 AM, Marc Weber wrote: Did anyone implement something like pythons urllib yet? I wont to retrieve some files via http (I could use wget -O - for that ) and send some form information (post/get).. In other words: Something like expect but for downloading some documents from a website.. ;) You may want to have a look at the HTTP and Browser packages: http:// www.haskell.org/http/ Perhaps I should have another look at wash? I think I can find encoding/decoding parameters for method = get there.. For URL handling, including encoding, try Network.URI in the standard libraries: http://www.haskell.org/ghc/docs/latest/html/libraries/ network/Network-URI.html /Björn___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell RPC
On May 25, 2006, at 11:00 AM, Joel Reymont wrote: Folks, I'm curious about how the following bit of Lisp code would translate to Haskell. This is my implementation of Lisp RPC and it basically sends strings around, printed readably and read on the other end by the Lisp reader. If I have a list '(1 2) it prints as (1 2) and becomes '(1 2) again when read on the other end. I'm wrote a couple of macros to make the job of defining the RPC easier. def-remote-class defines the main (server) class as well as the client (proxy) class. def-remote-method creates the server method as well as a proxy method that sends data over and possibly waits for results and returns them (depending on the :async or :sync qualifier). My Lisp RPC code runs on top of UDP, looks good and works well. I have a soft spot for Haskell in my heart, though, so I wonder how I would go about implementing the same architecture in Haskell. This is an example from my test harness: (define-test remote-basic (def-remote-class remote (server) ()) (def-remote-method sum :sync ((self remote) (a fixnum) (b integer)) (declare (ignorable ip port)) (+ a b seqnum)) (let* ((port (+ 1000 (random 5))) (server (make-instance 'remote :port port)) (client (make-instance 'remote-proxy :host (host-address) :port port))) (assert-equal '(6) (sum client 1 2 :seqnum 3)) (stop server) (stop client) )) I think I can send Haskell code over the wire to be read on the other side just like I do with Lisp. The part that baffles me is being able to provide an interface that lets one easily define remote classes and methods. I totally hate Template Haskell because I find it incomprehensible and I'm not going to compare it to Lisp macros. Is there a way to do it without TH? Also, it seems to me that the only way to deal with variable numbers of differently typed arguments is to use the HList approach which is quite heavy machinery, IMO. Any suggestions? Thanks, Joel P.S. The Haskell Cafe has been a bit quiet lately so I do mean to stir it up some. I think this example shows the advantage of dynamically-typed languages. I'm also genuinely interested in possible Haskell solutions. Hi Joel, the attached example is a simple RPC library. It uses show and read for serialization, and some type class tricks to allow functions with different arities. This is essentially the HaXR (http:// www.haskell.org/haxr/) API, but without the XML, HTTP and error reporting stuff. /Björn simplerpc.hs Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Editors for Haskell
Hi Chris, I followed your advice and tried SubEthaEdit. It seems to work really well, except that I can't figure out how to get it to indent my Haskell code correctly. What I expected was something like the Emacs Haskell mode where I can hit tab to cycle between the different reasonable indentations for a line. Am I right that SubEthaEdit does not have this feature? Or did I not RTFM enough? Maybe it's just me, but I find it difficult to write Haskell code without it. /Björn On May 25, 2006, at 8:10 AM, Christopher Brown wrote: Hi Walt, For Mac OS X I would strongly recommend using Sub Etha Edit. Its a very simple editor to use, and offers a lot of power and flexibility. It also has a Haskell highlighting mode. You can find it at: http://www.codingmonkeys.de/subethaedit/ Chris. On 25 May 2006, at 16:02, Walter Potter wrote: All, I hope that this is the right place for this question. I'm using Haskell (GHC and Hugs) on several different platforms. Windows, OS X and Linux systems. I'd like to have an IDE that works well for medium to large size projects. I know of Eclipse and hIDE. Vim works fine but I'd like more. hiDE seems to be in process. What would you suggest? I'll be asking my students to use the same IDE. Thanks, Walt ___ 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] parsing machine-generated natural text
On May 19, 2006, at 6:35 PM, Evan Martin wrote: For a toy project I want to parse the output of a program. The program runs on someone else's machine and mails me the results, so I only have access to the output it generates, Unfortunately, the output is intended to be human-readable, and this makes parsing it a bit of a pain. Here are some sample lines from its output: France: Army Marseilles SUPPORT Army Paris - Burgundy. Russia: Fleet St Petersburg (south coast) - Gulf of Bothnia. England: 4 Supply centers, 3 Units: Builds 1 unit. The next phase of 'dip' will be Movement for Fall of 1901. I've been using Parsec and it's felt rather complicated. For example, a location is a series of words and possibly parenthesis, except if the word is SUPPORT. And that Supply centers line ends up being code filled with stuff lie char ':'; skipMany space. I actually have a separate parser that's Javascript with a bunch of regular expressions and it's far shorter than my Haskell one, which makes sense as munging this sort of text feels to me more like a regexp job than a careful parsing job. I'm considering writing a preprocessing stage in Ruby or Perl that munges those output lines into something a bit more machine-readable, but before I did that I thought I'd ask here if anyone had any pointers, hints, or better ideas. Hi Evan, if the text you want to parse is actually similar to natural language (some posters have suggested that it is much simpler), you may want to have a look at grammar formalisms designed for natural languages. Grammatical Framework (GF) [1] is such a formalism, where the grammars are functional programs. The GF implementation is written in Haskell, and it has an interactive mode and a Haskell API. [Disclaimer: I participate in the development of GF] /Björn [1] http://www.cs.chalmers.se/~aarne/GF/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can I use Haskell for web programming
Neil Mitchell wrote: Hi, Can I use Haskell to do what people do with, say, PHP? I wrote Hoogle (http://haskell.org/hoogle) using Haskell, without using any libraries - just directly as a console program. It's open source so you can download it and see how its done, if you want. Of course the web handling bit is more low level than WASH and HSP. Warning: Shameless plugs follow If you want to be somewhere in between the high-level WASH/HSP and the low-level implement-it-all-yourself approach, you may want to have a look at the following libraries. The cgi package allows you to write CGI programs without caring about low-level communication with the webserver and stuff like how form data is encoded: http://www.cs.chalmers.se/~bringert/darcs/haskell-cgi/ There is also a FastCGI wrapper you can use to get better performance from your CGI programs (written using the above library): http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi/ With the xhtml package you can create XHTML documents using simple Haskell functions: http://www.cs.chalmers.se/~bringert/darcs/haskell-xhtml/ It is a very simple adaptation of Andy Gill's Text.Html module. The URLs above all point to darcs repos for the libraries. /Björn On 21/01/06, Maurício [EMAIL PROTECTED] wrote: Hi, and more I have the need for that, and I've been looking into Ruby on Rails. Do you thing Haskell could be a choice? Of course, I don't need something exactly like PHP (for instance, I don't care if I can't insert code in the middle of xhtml pages. If I have to generate everything from Haskell code, I would probably like it. Also, CGI can be a choice). But I need reasonable efficiency and to be able to find someone to host my site. What solutions do you suggest me? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FunctionalJ - a library for Functional Programming in Java
Graham Klyne wrote: A colleague alerted me to this, which I thought might be of interest here: http://www.theserverside.com/news/thread.tss?thread_id=38430 (I have already found that my Haskell experiences have influenced my Python programming; maybe there's also hope for my Java?) I've haven't seen this before, thanks! I wrote a similar library, Higher-Order Java (HOJ), a few years ago: http://www.cs.chalmers.se/~bringert/hoj/ My library is less polished but seems to have more static typing. It uses parametrized classes (as introduced in Java 1.5) to achieve this. FunctionalJ seems to lack static typing, for example map has the type: List map(Function p_function, List p_list) In HOJ, it has this type: A,B IteratorB map(FunA,B f, Iterator? extends A xs) In the end, I never published anything about this, since it seems too cumbersome to use in practice. A simple lambda expressions requires a lot of typing overhead. This function from the Pizza paper [1]: fun boolean(char c) { n++; return '0' = c c '0' + r; } becomes this in HOJ: new FunCharacter,Boolean () { public Boolean apply (Character c) { n++; return '0' = c c '0' + r; } } /Björn [1] Pizza into Java: Translating Theory into Practice, M. Odersky and P. Wadler, 1997 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Space questions about intern and sets
Gracjan Polak wrote: Hello all, I've got two questions, both are space related so I'll put them in one e-mail. 1. I'd like to have function intern, that behaves essentially like id, but with the following constraint: if x==y then makeStableName(intern x)==makeStableName(intern y) Reasoning behind this hack: objects equal (as in Eq) should occupy the same place in memory. I've got to parse quite large file, most tokens are the same. Haskell speed is very good, but I constantly run out of memory. Here is something I wrote, but it doesn't work :( The code below seems to work for strings, and should be generalizable to any type for which you have a hash function: import Data.HashTable as H import System.IO.Unsafe (unsafePerformIO) {-# NOINLINE stringPool #-} stringPool :: HashTable String String stringPool = unsafePerformIO $ new (==) hashString {-# NOINLINE shareString #-} shareString :: String - String shareString s = unsafePerformIO $ do mv - H.lookup stringPool s case mv of Just s' - return s' Nothing - do H.insert stringPool s s return s It seems very similiar to your code, except that it uses HashTable instead of Map. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] CGI module almost useless
John Goerzen wrote: My apologies if this sounds like a bit of a rant; I know people put good effort into this, but The Network.CGI module in fptools (and GHC) is not very useful. I think that it should be removed or re-tooled. Here are the main problems with it: 1. It does not permit custom generation of output headers. Thus the CGI script cannot do things like set cookies, manage HTTP auth, etc. 2. It does not permit generation of anything other than text/html documents. Many CGI scripts are used to manage other types of documents. Notably this makes it incompatible with serving up even basic things like stylesheets and JPEGs. 3. It does not permit the use of any custom design to serve up HTML, forcing *everything* to go through Text.Html. This makes it impossible to do things like serving up HTML files from disk. 4. There is documentation in the code, but it is as comments only, and doesn't show up in the Haddock-generated GHC library reference. (Should be an easy fix) 5. It does not appear to support file uploads in any sane fashion Is there a better CGI module out there somewhere that I'm missing, or should I just set about writing my own? I wrote this module (based on the Network.CGI code) a while ago: http://www.dtek.chalmers.se/~d00bring/darcs/blob/lib/Network/SimpleCGI.hs I don't remember what it does really, but I think it solves issues 1,2,3 and some of 4. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: new Haskell hacker seeking peer review
Isaac Jones wrote: John Goerzen [EMAIL PROTECTED] writes: Here's an alternative: module Main where (snip john's version) And what list would be complete without a points-free version. It doesn't operate on stdin, though like John's does: pointsFreeCat :: IO () pointsFreeCat = getArgs = mapM readFile = putStrLn . concat Or why not the two characters shorter, but much less readable: pointsFreeCat' = getArgs = mapM_ ((= putStr) . readFile) or maybe: pointsFreeCat'' = getArgs = mapM_ (putStr . readFile) (.) :: (b - IO c) - (a - IO b) - a - IO c (.) = (.) . flip (=) Is (.) in the standard libs? If not, should it be? I'm sure there is a shorter definition of (.) that I haven't thought of. /Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] Problems installing HTTP and Browser modules
Ranasaria, Kamal Kishor wrote: Dear Sir, I was trying to install the HTTP module and came across the following error. Would really appreciate if could help me find the cause of the error. [...] I am guessing that you are using the version from http://homepages.paradise.net.nz/warrickg/haskell/http/ There is an updated version of the package at http://www.bringert.net/~d00bring/haskell-xml-rpc/http.html The code is in a darcs repo at http://cvs.haskell.org/darcs/http/ Graham Klyne has a slightly different version which uses the new Network.URI module. His code can be found at http://www.ninebynine.org/Software/HaskellUtils/Network/ /Bjorn ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Typeclass problem
Mark T.B. Carroll wrote: I have a little programme that doesn't compile: module Example where class (Show c, Ord c, Bounded c) = MyClass c showThings :: MyClass c = c - (String, String) showThings x = let foo = maxBound :: c in (show x, show foo) If I change that second-to-last line to, let foo = max x maxBound then it compiles. However, it's clearly silly to use max just to make the type of the maxBound be the same type as the x. (I'm assuming that the Ord and the Bounded instances of the type are sensibly consistent.) What should I be writing if I want foo to be the maxBound applied to the type that x is? You could use asTypeOf from the Prelude: let foo = maxBound `asTypeOf` x -- asTypeOf is a type-restricted version of const. It is usually used -- as an infix operator, and its typing forces its first argument -- (which is usually overloaded) to have the same type as the second. asTypeOf :: a - a - a asTypeOf = const Also, Hugs and GHC both support an extension which lets you put type annotations in patterns: showThings (x::c) = let foo = maxBound :: c in (show x, show foo) /Bjorn ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie: Is it possible to catch _|_ ?
Ketil Malde wrote: Russ Lewis [EMAIL PROTECTED] writes: Another newbie question: Is it possible to catch _|_ - that is, to encounter it, handle it and continue? Since _|_ is the value of a non-terminating computation, this requires you to solve the halting problem. GHC does occasionally detect loops, but for the general case, don't hold your breath :-) -kzm If all you are interested in is catching calls to error, they can be caught like normal exceptions. Here is some code from Network.XmlRpc that catches error calls and handles them in an error monad: type Err m a = ErrorT String m a -- | Evaluate the argument and catch error call exceptions errorToErr :: Monad m = a - Err m a errorToErr x = let e = unsafePerformIO (tryJust errorCalls (evaluate x)) in ErrorT (return e) Pretty nasty, using evaluate and unsafePerformIO in the same function. The essential part is (tryJust errorCalls). /Bjorn Bringert ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe