From duncan.coutts at worc.ox.ac.uk Wed Oct 1 00:01:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Oct 1 01:57:17 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> Message-ID: <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> On Wed, 2008-10-01 at 01:59 +0200, Cetin Sert wrote: > A reminder: > > When I wanted to upgrade to yi 0.4.6.2, I needed to download the new > package list > > cabal update #download list of new packages > cabal upgrade #make any upgrades Note that 'cabal upgrade' upgrades everything you've currently got installed (which in general is not necessarily possible). The standard workflow is just: cabal update #download list of new packages cabal install yi #install latest version of yi The difference between $ cabal install yi and $ cabal upgrade yi is whether we try to upgrade the dependencies of yi as well or just try to use any currently installed versions of yi's dependencies. If anyone has some good ideas on how we can make the first step more automatic then see ticket #359 http://hackage.haskell.org/trac/hackage/ticket/359 Duncan From duncan.coutts at worc.ox.ac.uk Wed Oct 1 00:05:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Oct 1 01:57:21 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> Message-ID: <1222833947.14163.217.camel@dell.linuxdev.us.dell.com> On Wed, 2008-10-01 at 03:04 +0200, Cetin Sert wrote: > Hi, > > what is the best action to take if a package from hackage fails to > build? Is there a recommended/established common way to deal with > build failures/runtime bugs etc.? Most packages specify a maintainer which is conventionally an email address so you can contact them. Some packages also have bug trackers. Duncan From vigalchin at gmail.com Wed Oct 1 02:55:13 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Oct 1 02:51:55 2008 Subject: [Haskell-cafe] The Haskell Platform Message-ID: <5ae4f2ba0809302355h1be5f3favc18ed9bf32654f81@mail.gmail.com> Hello, I probably missed some details for which I apologize. My feeling is that "periodically" the "haskell platform server" should attempt to rebuild the Haskell library. Any library that fails to rebuild then the "maintainer" of that library should be notified, e.g. email, pager(;^)), .... Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/0490d9d9/attachment.htm From DekuDekuplex at Yahoo.com Wed Oct 1 03:35:56 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Oct 1 03:32:48 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: On Tue, 30 Sep 2008 19:54:17 +0200, Adrian Neumann wrote: >I often wonder how many cuts you need to divide a steak in n pieces. >You can obviously get n pieces with (sqrt n) cuts by cutting a grid. >But I'm sure some smart mathematician thought of a (log n) way. Good thing that the chocolate slab was only 2 kg and of finite length. Had it been of infinite length, we would need Dedekind cuts to partition it.... ;) -- Benjamin L. Russell From barsoap at web.de Wed Oct 1 03:44:22 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Oct 1 03:41:14 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: <20081001094422.7b79330a@solaris> Benjamin L.Russell wrote: > Russell > Any relationship? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From malcolm.wallace at cs.york.ac.uk Wed Oct 1 03:58:53 2008 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Oct 1 03:55:38 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> Message-ID: <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> >> When I wanted to upgrade to yi 0.4.6.2, I needed to download the new >> package list >> >> cabal update #download list of new packages >> cabal upgrade #make any upgrades I never knew there was a 'cabal update' command, and it worries me. In my unhappy experience of packaging systems (apt/Aptitude, fink/ FinkCommander, and DarwinPorts/MacPorts) it was never obvious when it should be necessary to run the update. Indeed, the advice given by each of these tools IIRC was to update every time you used it, before doing anything else. (So why was it a manual task then?) On the other hand, every one of those tools eventually failed for me on the update step, leaving me with an inconsistent and non-working configuration. Regards, Malcolm From ketil at malde.org Wed Oct 1 04:15:54 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Oct 1 04:09:21 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <1222810019.29616.3.camel@derek-laptop> (Derek Elkins's message of "Tue\, 30 Sep 2008 16\:26\:59 -0500") References: <1222810019.29616.3.camel@derek-laptop> Message-ID: <87tzbwlohx.fsf@malde.org> Derek Elkins writes: >> parseCSVFromFile "in.csv" >>= return . either (const "error!") > Whenever you see this >>= return . f pattern think liftM or fmap or <$>. ...and "return . f >>= action" is just "action . f", no? -k -- If I haven't seen further, it is by standing in the footprints of giants From conor at strictlypositive.org Wed Oct 1 04:28:46 2008 From: conor at strictlypositive.org (Conor McBride) Date: Wed Oct 1 04:24:47 2008 Subject: [Haskell-cafe] Total Functional Programming in Haskell In-Reply-To: <1222811657.29616.10.camel@derek-laptop> References: <1222811657.29616.10.camel@derek-laptop> Message-ID: <4F54A57C-F9B9-483B-9CD3-C82AEE7364F4@strictlypositive.org> Hi I've been reticent to join this thread as it has the potential to eat my life, but I thought I'd say some technical things. On 30 Sep 2008, at 22:54, Derek Elkins wrote: > On Mon, 2008-09-29 at 20:02 -0700, Jason Dagit wrote: >> Maybe instead of using (->) as the function constructor for total >> functions we use a different symbol, say (|->), and the compiler >> knows >> to use the more specialized semantics on those definitions. I'm not >> sure how make this work for values that are total functional versus >> values that are just pure (partial) functional. > > This can be done exactly the same way it is done with IO. Remove > general recursion* from Haskell and have a partiality monad with > fix :: (a -> a) -> Partial a I'm not sure that's the best type for fix, to be honest (though it would do in a pinch). It doesn't nest very neatly. Some argue for sfix :: (a -> Partial a) -> Partial a which allows you to make partial computations from recursive values. Being a happy Haskeller, I'd prefer lfix :: (Partial a -> Partial a) -> Partial a which is probably just join . fix as you present it, but says that its body gets a computation which it can choose to run, or not, as appropriate. In the dependently typed world, remember there are two separate notions of operational semantics (1) the open evaluation used by the typechecker, reducing under lambda, etc (2) the closed evaluation used at run-time, with no computation under binders It should be straightforward to make lfix a constant in (1), whilst (2) would actually run it. So that is indeed very like IO, handing off computations to an unscrupulous run-time system. Of course, we'd provide laws to reason about Partial computations (monad laws, unrolling, fixpoint induction) with sufficient means to allow escape from Partial on presentation of a (non-Partial) termination proof (erased for (2)). That's all to say that we can set things up so you can pay as you go. Of course, that's just to say we can model the phenomena, not that we can present them ergonomically... But what of Haskell? > This particular idea has been discussed several times in a couple of > places. Most people seem to think it would be too much of a hassle to > use. Not the most copper-bottomed of arguments, as well you know, but if programming in Partial entails clunky monadification of lovely terse applicative code, most people are probably right. However, what if we were to find a way to break that entailment? The idiom bracket notation is a step in that direction, but it's still not enough. Suppose we were to find a way to program with our usual notation, but with the extra freedom to vary the 'ambient' monad? We could choose Id for total programs, Partial for workaday slackness, and a whole bunch of other stuff at our convenience. We'd need some way to change the ambient monad locally, of course. To be frank, I don't know if such a setup could be made to fit with Haskell's existing design choices. But I think it's an attractive possibility, worth looking into. Locally, however, my point is to ask whether there's a specific hassle with the Partial monad beyond the usual notational annoyances that come with any monad. If so, that would be interesting to hear about, and new to my ears. All the best Conor From jon.fairbairn at cl.cam.ac.uk Wed Oct 1 04:45:19 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Wed Oct 1 04:42:08 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: Adrian Neumann writes: > I often wonder how many cuts you need to divide a steak in n > pieces. You can obviously get n pieces with (sqrt n) cuts > by cutting a grid. But I'm sure some smart mathematician > thought of a (log n) way. Are you allowed to move the pieces between cuts? From bortzmeyer at nic.fr Wed Oct 1 04:49:36 2008 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Wed Oct 1 04:46:19 2008 Subject: [Haskell-cafe] Re: cabal upgrade In-Reply-To: <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> Message-ID: <20081001084936.GA17893@nic.fr> On Wed, Oct 01, 2008 at 08:58:53AM +0100, Malcolm Wallace wrote a message of 23 lines which said: > Indeed, the advice given by each of these tools IIRC was to update > every time you used it, before doing anything else. (So why was it > a manual task then?) You can put it in cron (Ubuntu does it by default). > On the other hand, every one of those tools eventually failed for me > on the update step, leaving me with an inconsistent and non-working > configuration. ??? If something is wrong in the update step, the installed packages are not modified. If the database of *available* packages is corrupted (something I never saw with apt/aptitude or Gentoo's portage), then you cannot install new packages but existing packages work fine (the *available* packages database is distinct from the *installed* packages database). From DekuDekuplex at Yahoo.com Wed Oct 1 05:33:42 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Oct 1 05:30:33 2008 Subject: [Haskell-cafe] Re: (A little humour) References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> <48DD3670.9030203@btinternet.com> Message-ID: On Fri, 26 Sep 2008 15:40:49 -0400, "Andrew Wagner" wrote: >Brilliant. This made my day. I must admit, I looked briefly at the >paper after I saw the link, yawned, and closed it. Then I saw Andrew's >comment, skimmed the paper, becoming more and more convinced that it >was a joke, saw the last line, and then had to go back and read the >whole thing again. Just awesome. You didn't even need to read the last line. On page 6 of that paper: >A preprocessor that implements the facility for any current C++ implementation can be freely >downloaded from http://www.research.att.com/~bs/whitespace.html. Click on that link and tell me what you see. Incidentally, this is just typical Bjarne Stroustrup humor. It reminds me of "An Interview with Bjarne Stroustrup" (see http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html). Read that interview and tell me what you think. -- Benjamin L. Russell From magnus at therning.org Wed Oct 1 05:53:01 2008 From: magnus at therning.org (Magnus Therning) Date: Wed Oct 1 05:49:43 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> Message-ID: On Wed, Oct 1, 2008 at 3:31 AM, brian wrote: [..] > as big a problem as I imagined. My understanding is that I can satisfy > the requirements of the LGPL by dynamically linking, and that's > already happening. Is there something else to worry about? I'd be in > violation if I shipped something statically linked, but cabal doesn't > seem inclined to do that by default. I'm not sure I understand you here. Would you clarify your words here, bearing in mind that GHC doesn't do dynamic linking of Haskell modules? Cheers, M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From manlio_perillo at libero.it Wed Oct 1 05:59:50 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Oct 1 05:56:44 2008 Subject: [Haskell-cafe] (A little humour) In-Reply-To: <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> Message-ID: <48E34A16.3070005@libero.it> Miguel Mitrofanov ha scritto: > I think you might be interested in > http://www.research.att.com/~bs/whitespace98.pdf > By the way, is it technically possible (and feasible), in Haskell, to define a space operator? Of cource not with the current grammar. > [...] Manlio Perillo From manlio_perillo at libero.it Wed Oct 1 06:00:00 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Oct 1 05:56:49 2008 Subject: [Haskell-cafe] (A little humour) In-Reply-To: <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> Message-ID: <48E34A20.8040309@libero.it> Miguel Mitrofanov ha scritto: > I think you might be interested in > http://www.research.att.com/~bs/whitespace98.pdf > By the way, is it technically possible (and feasible), in Haskell, to define a space operator? Of cource not with the current grammar. > [...] Manlio Perillo From apfelmus at quantentunnel.de Wed Oct 1 06:09:35 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Oct 1 06:06:31 2008 Subject: [Haskell-cafe] Re: Total Functional Programming in Haskell In-Reply-To: References: Message-ID: Jason Dagit wrote: > apfelmus wrote: >> >> It seems to me that dependent types are best for ensuring totality. > > Bear with me, as I know virtual nothing about dependent types yet. Ah, my bad. Time to change that ;) Personally, I found Th. Altenkirch, C. McBride, J. McKinna. Why dependent types matter. http://www.cs.st-andrews.ac.uk/~james/RESEARCH/ydtm-submitted.pdf to be a very gentle introduction. > In the > total functional paradigm the language lacks a value for bottom. This means > general recursion is out and in the paper I cited it was replaced with > structural recursion on the inputs. How do dependent types remove bottom > from the language? Originally, all typed lambda calculi - like the simply typed lambda calculus or System F on which Haskell is based - are strongly normalizing by default, i.e. every computation terminates. Thus, bottom is actually *added* to Haskell, in particular by providing the new primitive fix :: (a -> a) -> a When viewed through the Curry-Howard Isomorphism, it's clear that fix is a bad idea. I mean, it corresponds to the "theorem" forall A. (A -> A) -> A which is clearly wrong, for it can prove the existence of Santa Claus: fix (\Santa Claus exists -> Santa Claus exists) = Santa Claus exists Since dependently typed languages perform computations on the type level, most do not add general recursion or at least pay special attention to it. Furthermore, as Luke said, they give you the necessary tools to easily express programs that are not structurally recursive, but nonetheless terminate. One example would be a function to represent a natural in binary: data Nat = Succ Nat | Zero data Digit = D0 | D1 digits :: Nat -> [Digit] digits = reverse digits' where digits' 0 = [] digits' n | even n = D0:digits' (n `div` 2) | odd n = D1:digits' (n `div` 2) This is not structurally recursive (at least not directly), but clearly terminates. You can use dependent types to prove that it does. For a more complicated example, see also http://www.iis.sinica.edu.tw/~scm/2008/well-founded-recursion-and-accessibility/ >> The IO layer can be interpreted as "co-total", i.e. as codata. > > I was asserting that Haskell is currently 2 layered. Purely functional vs. > IO. They integrate nicely and play well together, but I still think of them > as distinct layers. Perhaps this is not fair or confusing though. The > paper I cited did indeed use codata to define streams so that something, > such as an OS, that needs to process infinite streams of requests can still > do so. Well, you can interpret IO as a data type data IO a where Bind :: IO a -> (a -> IO b) -> IO b Return :: a -> IO a PutChar :: Char -> IO () GetChar :: IO Char just like any other data type. In fact, that's what W. Swierstra, Th. Altenkirch. Beauty in the Beast. http://www.cs.nott.ac.uk/~txa/publ/beast.pdf do in order to QuickCheck programs with IO. Regards, apfelmus From cetin.sert at gmail.com Wed Oct 1 06:18:15 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Wed Oct 1 06:14:58 2008 Subject: [Haskell-cafe] flipped IO sequence Message-ID: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> warn :: String ? IO Int warn = return 1 << putStrLn -- causes an error -- = \msg ? return 1 << putStrLn msg -- works just fine -- = \msg ? putStrLn msg >> return 1 -- works just fine (<<) :: Monad m ? m b ? m a ? m b b << a = a >>= \_ ? b Why do I get this compile-time error?? How can one define << ? cetin@linux-d312:~/lab/test/qths/p> ghc -fglasgow-exts -O2 -o d64x --make demo2.hs system.hs [1 of 2] Compiling Netman.System ( system.hs, system.o ) system.hs:23:14: No instance for (Num (IO Int)) arising from the literal `1' at system.hs:23:14 Possible fix: add an instance declaration for (Num (IO Int)) In the first argument of `return', namely `1' In the first argument of `(<<)', namely `return 1' In the expression: return 1 << putStrLn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/354e8c46/attachment.htm From dougal at dougalstanton.net Wed Oct 1 06:39:43 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Wed Oct 1 06:36:25 2008 Subject: [Haskell-cafe] flipped IO sequence In-Reply-To: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> References: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> Message-ID: <2d3641330810010339l51cfe5c3ucc8ca9ab8a47304e@mail.gmail.com> 2008/10/1 Cetin Sert : > warn :: String ? IO Int > warn = return 1 << putStrLn -- causes an error > -- = \msg ? return 1 << putStrLn msg -- works just fine > -- = \msg ? putStrLn msg >> return 1 -- works just fine > > (<<) :: Monad m ? m b ? m a ? m b > b << a = a >>= \_ ? b > > Why do I get this compile-time error?? How can one define << ? > > cetin@linux-d312:~/lab/test/qths/p> ghc -fglasgow-exts -O2 -o d64x --make > demo2.hs system.hs > [1 of 2] Compiling Netman.System ( system.hs, system.o ) > > system.hs:23:14: > No instance for (Num (IO Int)) > arising from the literal `1' at system.hs:23:14 > Possible fix: add an instance declaration for (Num (IO Int)) > In the first argument of `return', namely `1' > In the first argument of `(<<)', namely `return 1' > In the expression: return 1 << putStrLn > This works for me (type signature added so GHCi doesn't choke) Prelude> let (<<) = flip (>>) :: IO b -> IO a -> IO b And thus: Prelude> return 1 << putStrLn "yo" yo 1 Prelude> You might be having problems with the point-free code: Prelude> let warn' = return 1 << putStrLn :1:24: Couldn't match expected type `IO a' against inferred type `String -> IO ()' In the second argument of `(<<)', namely `putStrLn' In the expression: return 1 << putStrLn In the definition of `warn'': warn' = return 1 << putStrLn Adding in variable names straightens that out for me: Prelude> let warn s = return 1 << putStrLn s Prelude> warn "help" help 1 Prelude> Cheers, D From huschi at gmx.org Wed Oct 1 06:41:55 2008 From: huschi at gmx.org (Martin Huschenbett) Date: Wed Oct 1 06:38:37 2008 Subject: [Haskell-cafe] flipped IO sequence In-Reply-To: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> References: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> Message-ID: <48E353F3.5000604@gmx.org> Hi Cetin, what you seem to want is > warn :: String -> IO Int > warn = (return 1 <<) . putStrLn Cetin Sert schrieb: > warn :: String ? IO Int > warn = return 1 << putStrLn -- causes an error > -- = \msg ? return 1 << putStrLn msg -- works just fine > -- = \msg ? putStrLn msg >> return 1 -- works just fine > > (<<) :: Monad m ? m b ? m a ? m b > b << a = a >>= \_ ? b > > Why do I get this compile-time error?? How can one define << ? > > cetin@linux-d312:~/lab/test/qths/p> ghc -fglasgow-exts -O2 -o d64x > --make demo2.hs system.hs > [1 of 2] Compiling Netman.System ( system.hs, system.o ) > > system.hs:23:14: > No instance for (Num (IO Int)) > arising from the literal `1' at system.hs:23:14 > Possible fix: add an instance declaration for (Num (IO Int)) > In the first argument of `return', namely `1' > In the first argument of `(<<)', namely `return 1' > In the expression: return 1 << putStrLn > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Wed Oct 1 06:51:40 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Oct 1 06:46:13 2008 Subject: [Haskell-cafe] flipped IO sequence In-Reply-To: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> References: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> Message-ID: <200810011251.40695.daniel.is.fischer@web.de> Am Mittwoch, 1. Oktober 2008 12:18 schrieb Cetin Sert: > warn :: String ? IO Int > warn = return 1 << putStrLn -- causes an error try warn = (return 1 <<) . putStrLn > -- = \msg ? return 1 << putStrLn msg -- works just fine > -- = \msg ? putStrLn msg >> return 1 -- works just fine > > (<<) :: Monad m ? m b ? m a ? m b > b << a = a >>= \_ ? b (<<) = flip (>>) > > Why do I get this compile-time error?? How can one define << ? > > cetin@linux-d312:~/lab/test/qths/p> ghc -fglasgow-exts -O2 -o d64x --make > demo2.hs system.hs > [1 of 2] Compiling Netman.System ( system.hs, system.o ) > > system.hs:23:14: > No instance for (Num (IO Int)) > arising from the literal `1' at system.hs:23:14 > Possible fix: add an instance declaration for (Num (IO Int)) > In the first argument of `return', namely `1' > In the first argument of `(<<)', namely `return 1' > In the expression: return 1 << putStrLn Okay warn = (return 1) << putStrLn putStrLn :: String -> IO () return 1 :: m b (<<) :: m b -> m a -> m b warn :: String -> IO Int so we must have (String -> IO ()) === m a (String -> IO Int) === m b So the monad is ((->) String), a === IO () b === IO Int, hence in return 1 :: String -> IO Int the 1 must have type IO Int. Now 1 is actually fromInteger 1, fromInteger :: (Num a) => Integer -> a, so the compiler looks for the instance Num (IO Int) where ... which it doesn't find. From noteed at gmail.com Wed Oct 1 07:18:32 2008 From: noteed at gmail.com (minh thu) Date: Wed Oct 1 07:15:15 2008 Subject: [Haskell-cafe] postmortem question about xmonad In-Reply-To: References: <40a414c20809301233s7d99183bj6da49815e3c51230@mail.gmail.com> <20080930202024.GB28091@scytale.galois.com> Message-ID: <40a414c20810010418w65f355aah67431748eafd9969@mail.gmail.com> 2008/10/1 Jason Dagit : > > > On Tue, Sep 30, 2008 at 1:20 PM, Don Stewart wrote: >> >> noteed: >> > Hi, >> > >> > I'd like to know, now that time got by a bit, what the writers of the >> > X monad think about the use of the ReaderT/WriterT/IO brought to them >> > (to isolate Configuration data and dynamic data and glue them together >> > with IO). Are you happy of it, did it make things easier or not, would >> > you do it again ? >> >> It made the structuring and invariants between runtime data, and >> configuration data clean and precise. Yes, A+++ would buy again. > > I can add to this, saying that I used WriterT/ReaderT and Unique in a > CodeGen monad I created for a compiler I'm writing and this approach of > stacking monads (well, really transformers) works amazingly well. Many of > the existing monads abstractly handle a particular task very well. When you > combine this with generalized newtype deriving it's not just code reuse, > it's also code specialization. You quickly glue together existing > functionality that works but expose it with the API that meets your problem > domain. I'd say this is not unlike the way people glue together unix tools > on the command line. This is RAD in Haskell. > > I agree with Don, I would buy this again. In fact, I've already placed an > order for use in future projects. Thanks for your answer (to Don too). While building the stack (of transformers), do you implement several things with each one its transformer (or directly its corresponding monad) or do you try to make the good combination first ? If the former (combine them later), is it a problem to add lift (or liftIO) to go deep enough in the stack ? What approach do you use ? Thanks, Thu From tphyahoo at gmail.com Wed Oct 1 07:18:34 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Oct 1 07:15:20 2008 Subject: tutorial site back up Re: [Haskell-cafe] Version 0.4.3 of happs-tutorial is a HAppS job board, done in HAppS. Message-ID: <910ddf450810010418m2874ac6cx4e9f96b92762ebce@mail.gmail.com> Well, at least I know people are trying to read the tutorial :) I'll say a few words about what happened. The underlying problem is that HAppS dies unpredictably because of problems in the haskell network library, a but I reported at http://code.google.com/p/happs/issues/detail?id=40 I wrote a cron job to restart my server when it dies, but I recently tweaked the job in order to serve the "head" version as well as what is on hackage, and the tweak broke the cron job's functionality. (fixed now -- at least, I hope it's fixed.) To be honest I don't really understand the underlying problem in the haskell network library, but it would be great if somebody who does could fix this. Thomas. 2008/9/30 John Melesky : > Thomas, > > The tutorial site seems to be unreachable or otherwise down. > > I know the modern programming landscape is fast-moving, HAppS is new and > constantly changing, so i probably should have grabbed the content when you > posted it, but perhaps keeping it up for more than a day and a half might be > good? :-) > > -john melesky > > > On Sep 28, 2008, at 6:36 PM, Thomas Hartman wrote: > >> Hello, world. >> >> In Version 4 of the ongoing self-demoing HAppS Tutorial, we implement >> a HAppS job board using HAppS. >> >> demo: http://happstutorial.com:5001 >> >> install: sudo cabal install happs-tutorial >> >> darcs head: darcs get http://code.haskell.org/happs-tutorial >> >> There aren't any new lessons compared to the last release, but the >> code is much cleaner, and... well... the web site actually does >> something. >> >> Coming soon, lessons on form processing and HAppS State. >> >> Enjoy! >> >> Thomas. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > From alfonso.acosta at gmail.com Wed Oct 1 07:29:38 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Wed Oct 1 07:26:20 2008 Subject: [Haskell-cafe] ANN: Haskell-Embedded System Design: ForSyDe 3.0 and Tutorial Message-ID: <6a7c66fc0810010429na4e5981ld5a71d2ff832e9a@mail.gmail.com> Hi everyone, I am glad to announce the 3.0 release of ForSyDe's implementation, now available from HackageDB. The ForSyDe (Formal System Design) methodology has been developed with the objective to move system design (e.g. System on Chip, Hardware and Software systems) to a higher level of abstraction. ForSyDe is implemented as a Haskell-embedded behavioral DSL (Domain Specific Language). >From this release, ForSyDe includes a new deep-embedded DSL and embedded compiler. We have also published tutorial which should be much more user-friendly than the Haddock documentation and the ForSyDe research papers. ForSyDe includes two DSL flavours which offer different features: 1) Deep-embedded DSL (ForSyDe.Signal) Deep-embedded signals, based on the same concepts as Lava, are aware of the system structure. Based on that structural information ForSyDe's embedded compiler, can perform different analysis and transformations. o Thanks to Template Haskell, computations are expressed in Haskell, not needing to specifically design a DSL for that purpose. o Embedded compiler backends: + Simulation + VHDL (with support for Modelsim and Quartus II) + GraphML (with yFiles graphical markup support.) o Synchronous model of computation. o Support for components. o Support for fixed-sized vectors ? la VHDL. 2) Shallow-embedded DSL (ForSyDe.Shallow.Signal) Shallow-embedded signals are modeled as streams of data isomorphic to lists. Systems built with them are unfortunately restricted to simulation, however, shallow-embedded signals provide a rapid-prototyping framework with which to experiment with Models of Computation (MoCs). o Synchronous MoC. o Untimed MoC. o Continuous Time MoC. o Domain Interfaces allow connecting various subsystems with different timing (domains) regardless of their MoC. o Deep-embedded models can be integrated through simulation. Links ==== ForSyDe website: http://www.ict.kth.se/org/ict/ecs/sam/projects/forsyde/www/ ForSyDe tutorial: http://www.ict.kth.se/org/ict/ecs/sam/projects/forsyde/www/files/tutorial/tutorial.html HackageDB package page: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ForSyDe Darcs repository: darcs get http://www.ict.kth.se/org/ict/ecs/sam/projects/forsyde/www/darcs/ForSyDe/ From v.dijk.bas at gmail.com Wed Oct 1 07:29:53 2008 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Oct 1 07:26:35 2008 Subject: [Haskell-cafe] Class Quantification In-Reply-To: <4cf038ee0809301801t2c34de0bx23b9cc1ef02c5682@mail.gmail.com> References: <3c6288ab0809301425j71526a5cs7a1c7ce82193e62@mail.gmail.com> <4cf038ee0809301801t2c34de0bx23b9cc1ef02c5682@mail.gmail.com> Message-ID: On Wed, Oct 1, 2008 at 3:01 AM, Reiner Pope wrote: > I believe there is no way to simply express this "abstraction over classes", > but the Scrap your boilerplate with class[1] paper discusses this same > problem and present a workaround by defining the class's dictionary of > methods as an explicit type. > > What follows is the code to implement their workaround for your example. > > First some fairly standard extensions: > >> {-# LANGUAGE Rank2Types, EmptyDataDecls, FlexibleInstances, KindSignatures >> #-} > > And some more controversial, but necessary ones: > >> {-# LANGUAGE UndecidableInstances, OverlappingInstances #-} >> >> module Cls where >> > > The working bla function. Unfortunately, the "pseudoclass" cls needs > to have its type explicitly named, hence the (uninhabited) Proxy type. > >> bla :: forall cls a c d. (Sat (cls c), Sat (cls d)) => Proxy cls -> >> (forall b. Sat (cls b) => a -> b) -> a -> (c,d) >> bla _ f x = (f x, f x) > > Again, testFoo and testBar unfortunately have to name which dictionary type > to use, via the Proxy. > >> testFoo = bla (undefined :: Proxy NumD) fromInteger 1 :: (Int,Float) >> testBar = bla (undefined :: Proxy ReadD) read "1" :: (Int,Float) > > The Sat class, straight from SYB: > >> class Sat a where >> dict :: a >> data Proxy (cxt :: * -> *) > > The explicit dictionary construction for the Read class: > >> data ReadD a = ReadD { readsPrecD :: Int -> ReadS a } >> instance (Read a) => Sat (ReadD a) where >> dict = ReadD readsPrec >> instance (Sat (ReadD a)) => Read a where >> readsPrec = readsPrecD dict > > The explicit dictionary construction for the Num class: > >> data NumD a = NumD { plusD :: a -> a -> a, >> timesD :: a -> a -> a, >> negateD :: a -> a, >> absD :: a -> a, >> signumD :: a -> a, >> fromIntegerD :: Integer -> a } >> instance (Num a) => Sat (NumD a) where >> dict = NumD (+) (*) negate abs signum fromInteger > > We define these fake Eq,Show instances just to make the > Num instance valid. It would be longer, but not more > difficult, to genuinely encode the (Eq,Show)=>Num hierarchy. > >> instance (Sat (NumD a)) => Show a where {} >> instance (Sat (NumD a)) => Eq a where {} >> instance (Sat (NumD a)) => Num a where >> (+) = plusD dict >> (*) = timesD dict >> negate = negateD dict >> abs = absD dict >> signum = signumD dict >> fromInteger = fromIntegerD dict > > [1] http://homepages.cwi.nl/~ralf/syb3/ Sections 3.2 and 4.1 > > On Wed, Oct 1, 2008 at 9:01 AM, Bas van Dijk wrote: >> >> On Tue, Sep 30, 2008 at 11:25 PM, Sean Leather >> wrote: >> > But perhaps you're looking for potentially unknown classes? >> >> Yes indeed. >> >> Thanks, >> >> Bas >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > Nice! The explicit passing of the proxy type is indeed unfortunate but it's nice that the type of your 'bla' is almost identical to mine: > bla :: forall cls a c d. (Sat (cls c), Sat (cls d)) => Proxy cls -> (forall b. Sat (cls b) => a -> b) -> a -> (c,d) > bla :: forall cls. (cls c, cls d) => (forall b. cls b => a -> b) -> a -> (c, d) Thanks, Bas From M.Bott at lawrenceharvey.com Wed Oct 1 07:35:07 2008 From: M.Bott at lawrenceharvey.com (Michael Bott) Date: Wed Oct 1 07:32:37 2008 Subject: [Haskell-cafe] Job Opportunity Message-ID: Afternoon, I have been recommended to use this site from a couple of people I have spoken to. Sorry if this offends anyone but I have an amazing opportunity for a 2 Functional Programmers based in London. Functional Programming - (HASKELL / ERLANG / OCAML) - Financial This is an incredible opportunity for a FUNCTIONAL PROGRAMMER (Haskell / Erlang or Ocaml) to join an expanding London software house who specialise in Asset Management for top financial clients - they specialise in providing algorithmic execution solutions for hedge funds. My client are a leading provider in financial software, they are looking for a top Graduates or 1-2 years experienced Java / Functional Programmers to join the team and really make a difference to the company and work with the biggest clients in the UK. Desirable Skills - * Functional Programming - ( Haskell or Erlang or Ocaml to name 3). * Java * Degree Education - top University - 2:1 and above only. * Experience within the finance and/or banking sector would be highly advantageous. This is an URGENT requirement and my client are keen to get at least 2 exceptional developers into the team ASAP. You will join a relaxed team who work on exciting projects, and use the most up to date technologies........ To learn more about the role and the client please contact Mike at Lawrence Harvey. Please contact me if you are interested. Kind Regards, Mike Michael Bott Java Recruitment Specialist Lawrence Harvey Search & Selection Tel: +44 (0)208 875 4353 Fax: +44 (0)208 870 8116 Mobile: +44 (0)7966 554892 Email: m.bott@Lawrenceharvey.com Web: www.Lawrenceharvey.com LinkedIn - http://www.linkedin.com/in/mikebott The information transmitted contains confidential material and is intended only for the person or organisation to which it is addressed. Any review, retransmission, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. No liability whatsoever is accepted by Lawrence Harvey Search & Selection in respect of the contents of this email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/95ae788d/attachment-0001.htm From barsoap at web.de Wed Oct 1 08:08:51 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Oct 1 08:05:41 2008 Subject: [Haskell-cafe] Re: (A little humour) References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> <48DD3670.9030203@btinternet.com> Message-ID: <20081001140851.48828de9@solaris> Benjamin L.Russell wrote: > Read that interview and tell me what you think. > I think I'll link that in my next CV for a job requiring C++ knowledge. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From emax at chalmers.se Wed Oct 1 08:12:24 2008 From: emax at chalmers.se (Emil Axelsson) Date: Wed Oct 1 08:09:06 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> Message-ID: <48E36928.6090602@chalmers.se> Hi Cetin! Glad to see at least one person trying my package :) The error comes from using QuickCheck 2, which happens to also use the operator (><). I can see two ways to solve the problem: (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. (2) Add "hiding ((><))" after "import Test.QuickCheck" in Data/Hardware/Internal.hs I guess this means you can't use cabal-install...? Does anybody know the best way to avoid this problem without manual intervention? Or should I just require people to use QuickCheck 2? PS. Cetin, please let me know if you have any questions regarding Wired. I'm slowly working on enhancing the library, and I'll soon upload a version with timing analysis and a DEF backend in. / Emil Cetin Sert skrev: > Hi, > > what is the best action to take if a package from hackage fails to > build? Is there a recommended/established common way to deal with build > failures/runtime bugs etc.? > > For example: > > cetin@linux-d312:~/Links/Elite/ac> cabal install wired > Resolving dependencies... > Downloading Wired-0.1.1... > Configuring Wired-0.1.1... > Preprocessing library Wired-0.1.1... > Building Wired-0.1.1... > [ 1 of 21] Compiling Data.Hardware.Internal ( Data/Hardware/Internal.hs, > dist/build/Data/Hardware/Internal.o ) > > Data/Hardware/Internal.hs:198:15: > Ambiguous occurrence `><' > It could refer to either `Data.Hardware.Internal.><', defined at > Data/Hardware/Internal.hs:129:4 > or `Test.QuickCheck.><', imported from > Test.QuickCheck at Data/Hardware/Internal.hs:11:0-21 > cabal: Error: some packages failed to install: > Wired-0.1.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Regards, > CS > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From barsoap at web.de Wed Oct 1 08:10:24 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Oct 1 08:11:44 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: <20081001141024.04e446b6@solaris> Jon Fairbairn wrote: > Adrian Neumann writes: > > > I often wonder how many cuts you need to divide a steak in n > > pieces. You can obviously get n pieces with (sqrt n) cuts > > by cutting a grid. But I'm sure some smart mathematician > > thought of a (log n) way. > > Are you allowed to move the pieces between cuts? > Later you're also going to demand to bend it in N dimensions, aren't you? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From deduktionstheorem at web.de Wed Oct 1 08:45:04 2008 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Wed Oct 1 08:41:52 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <48E36928.6090602@chalmers.se> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> <48E36928.6090602@chalmers.se> Message-ID: <48E370D0.7040100@web.de> Emil Axelsson wrote: > [...] > > The error comes from using QuickCheck 2, which happens to also use the > operator (><). I can see two ways to solve the problem: > > (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. > > (2) Add "hiding ((><))" after "import Test.QuickCheck" in > Data/Hardware/Internal.hs Emil, my suggestion is: Please use alternative (2), at least if there are no further problems with quickcheck 2! Otherwise, depending on quickcheck <2 just introduces unnecessary package incompatibilities. > > [...] > //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From neil.mitchell.2 at credit-suisse.com Wed Oct 1 08:50:51 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Wed Oct 1 08:53:06 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <48E370D0.7040100@web.de> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> <48E36928.6090602@chalmers.se> <48E370D0.7040100@web.de> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3A64@ELON17P32001A.csfb.cs-group.com> > > The error comes from using QuickCheck 2, which happens to > also use the > > operator (><). I can see two ways to solve the problem: > > > > (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. > > > > (2) Add "hiding ((><))" after "import Test.QuickCheck" in > > Data/Hardware/Internal.hs > > Emil, > > my suggestion is: Please use alternative (2), at least if > there are no further problems with quickcheck 2! Otherwise, > depending on quickcheck > <2 just introduces unnecessary package incompatibilities. Note that if you import hiding something that doesn't existing you'll have a problem. Therefore this fix will require >= 2 for quickcheck, and introduce incompatibilities either way. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From emax at chalmers.se Wed Oct 1 08:59:18 2008 From: emax at chalmers.se (Emil Axelsson) Date: Wed Oct 1 08:56:00 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <48E370D0.7040100@web.de> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> <48E36928.6090602@chalmers.se> <48E370D0.7040100@web.de> Message-ID: <48E37426.9060805@chalmers.se> Stephan Friedrichs skrev: > Emil Axelsson wrote: >> [...] >> >> The error comes from using QuickCheck 2, which happens to also use the >> operator (><). I can see two ways to solve the problem: >> >> (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. >> >> (2) Add "hiding ((><))" after "import Test.QuickCheck" in >> Data/Hardware/Internal.hs > > Emil, > > my suggestion is: Please use alternative (2), at least if there are no > further problems with quickcheck 2! Otherwise, depending on quickcheck > <2 just introduces unnecessary package incompatibilities. Hi Stephan, Option (1) was only meant as a temporary solution for Cetin. It just occurred that the obvious solution to make both QC1 and QC2 users happy is to have an explicit import list rather than hiding (><) (there are no further problems with QC2). I'll do this until QC2 is standard in GHC. / Emil From gianfranco.alongi at gmail.com Wed Oct 1 09:14:51 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Wed Oct 1 09:11:32 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: <20081001141024.04e446b6@solaris> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <20081001141024.04e446b6@solaris> Message-ID: Are we assuming the bars to have an even distribution of mass along the whole body? On Wed, Oct 1, 2008 at 2:10 PM, Achim Schneider wrote: > Jon Fairbairn wrote: > >> Adrian Neumann writes: >> >> > I often wonder how many cuts you need to divide a steak in n >> > pieces. You can obviously get n pieces with (sqrt n) cuts >> > by cutting a grid. But I'm sure some smart mathematician >> > thought of a (log n) way. >> >> Are you allowed to move the pieces between cuts? >> > Later you're also going to demand to bend it in N dimensions, aren't > you? > > -- > (c) this sig last receiving data processing entity. Inspect headers > for copyright history. All rights reserved. Copying, hiring, renting, > performance and/or quoting of this signature prohibited. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From derek.a.elkins at gmail.com Wed Oct 1 09:32:36 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Wed Oct 1 09:29:32 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <87tzbwlohx.fsf@malde.org> References: <1222810019.29616.3.camel@derek-laptop> <87tzbwlohx.fsf@malde.org> Message-ID: <1222867956.32224.5.camel@derek-laptop> On Wed, 2008-10-01 at 10:15 +0200, Ketil Malde wrote: > Derek Elkins writes: > > >> parseCSVFromFile "in.csv" >>= return . either (const "error!") > > > Whenever you see this >>= return . f pattern think liftM or fmap or <$>. > > ...and "return . f >>= action" is just "action . f", no? Well actually that's \x -> action (return (f x)) x via the (r ->) instance of Monad. I think what you wanted was \x -> return (f x) >>= action which is \x -> action (f x) action . f via the monad laws. From dominic.steinitz at blueyonder.co.uk Wed Oct 1 09:33:13 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Wed Oct 1 09:30:03 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: Adrian Neumann inf.fu-berlin.de> writes: > > I often wonder how many cuts you need to divide a steak in n pieces. > You can obviously get n pieces with (sqrt n) cuts by cutting a grid. > But I'm sure some smart mathematician thought of a (log n) way. > You might try the ham sandwich theorem http://en.wikipedia.org/wiki/Ham_sandwich_theorem as an hors d'oeuvre. From jules at jellybean.co.uk Wed Oct 1 09:48:35 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Oct 1 09:45:17 2008 Subject: [Haskell-cafe] Class Quantification In-Reply-To: References: <3c6288ab0809301425j71526a5cs7a1c7ce82193e62@mail.gmail.com> <4cf038ee0809301801t2c34de0bx23b9cc1ef02c5682@mail.gmail.com> Message-ID: <48E37FB3.6090005@jellybean.co.uk> Bas van Dijk wrote: > On Wed, Oct 1, 2008 at 3:01 AM, Reiner Pope wrote: >> I believe there is no way to simply express this "abstraction over classes", >> but the Scrap your boilerplate with class[1] paper discusses this same >> problem and present a workaround by defining the class's dictionary of >> methods as an explicit type. >> >> What follows is the code to implement their workaround for your example. >> >> First some fairly standard extensions: >> >>> {-# LANGUAGE Rank2Types, EmptyDataDecls, FlexibleInstances, KindSignatures >>> #-} >> And some more controversial, but necessary ones: >> >>> {-# LANGUAGE UndecidableInstances, OverlappingInstances #-} Just an observation: That terrifying list of extensions is needed for this 'full' solution. To just literally encode what the OP wanted you just need a concrete dictionary and existentials, AFAIK. Jules From tphyahoo at gmail.com Wed Oct 1 10:14:36 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Wed Oct 1 10:11:18 2008 Subject: [Haskell-cafe] Version 0.4.3 of happs-tutorial is a HAppS job board, done in HAppS. In-Reply-To: References: <910ddf450809281836h20bd6fc9h70f47ce5216ef587@mail.gmail.com> Message-ID: <910ddf450810010714s2235ec12tcd2f874130cb3a15@mail.gmail.com> Oh, the whole point of this was to put preview of the latest chapters I've been working on. The new stuff is at http://happstutorial.com:5002/ So far there's an introduction to macid, macid data safety and backups, and using utf8 data with happs. I'm particularly intereted in hearing what the happs devs and others have to say on the topic of keeping data safe: http://happstutorial.com:5002/tutorial/macid-data-safety Thomas. 2008/9/30 John Melesky : > Thomas, > > The tutorial site seems to be unreachable or otherwise down. > > I know the modern programming landscape is fast-moving, HAppS is new and > constantly changing, so i probably should have grabbed the content when you > posted it, but perhaps keeping it up for more than a day and a half might be > good? :-) > > -john melesky > > > On Sep 28, 2008, at 6:36 PM, Thomas Hartman wrote: > >> Hello, world. >> >> In Version 4 of the ongoing self-demoing HAppS Tutorial, we implement >> a HAppS job board using HAppS. >> >> demo: http://happstutorial.com:5001 >> >> install: sudo cabal install happs-tutorial >> >> darcs head: darcs get http://code.haskell.org/happs-tutorial >> >> There aren't any new lessons compared to the last release, but the >> code is much cleaner, and... well... the web site actually does >> something. >> >> Coming soon, lessons on form processing and HAppS State. >> >> Enjoy! >> >> Thomas. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > From gianfranco.alongi at gmail.com Wed Oct 1 10:38:08 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Wed Oct 1 10:34:50 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: Throw the "no free lunch"-theorem on top of that. http://en.wikipedia.org/wiki/No_free_lunch_theorem On Wed, Oct 1, 2008 at 3:33 PM, Dominic Steinitz wrote: > Adrian Neumann inf.fu-berlin.de> writes: > >> >> I often wonder how many cuts you need to divide a steak in n pieces. >> You can obviously get n pieces with (sqrt n) cuts by cutting a grid. >> But I'm sure some smart mathematician thought of a (log n) way. >> > > You might try the ham sandwich theorem > http://en.wikipedia.org/wiki/Ham_sandwich_theorem as an hors d'oeuvre. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From anton at appsolutions.com Wed Oct 1 11:38:47 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Wed Oct 1 11:19:52 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: <20081001141024.04e446b6@solaris> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <20081001141024.04e446b6@solaris> Message-ID: <48E39987.1010900@appsolutions.com> Achim Schneider wrote: > Jon Fairbairn wrote: > >> Adrian Neumann writes: >> >>> I often wonder how many cuts you need to divide a steak in n >>> pieces. You can obviously get n pieces with (sqrt n) cuts >>> by cutting a grid. But I'm sure some smart mathematician >>> thought of a (log n) way. >> Are you allowed to move the pieces between cuts? >> > Later you're also going to demand to bend it in N dimensions, aren't > you? If extra dimensions are needed, perhaps the LHC could be pressed into service. Any Haskell programmers working there? I'm sure we could settle many of these questions by injecting some chocolate particles into the accelerator. Who among us hasn't wondered what chocolate looks like when traveling at relativistic speeds? Best case, we produce an infinitely dense micro-black hole made of chocolate, which pretty much takes care of the whole recursive subdividing problem. Plus, when popped into your mouth, it would evaporate via the tastiest Hawking radiation imaginable. Anton From simonmarhaskell at gmail.com Wed Oct 1 13:03:39 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Wed Oct 1 13:00:54 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> Message-ID: <48E3AD6B.2010409@gmail.com> brian wrote: > On Tue, Sep 30, 2008 at 8:54 PM, Stefan Monnier > wrote: >>> That still leaves anyone free to use LGPL if they want to, but please >>> don't assume that it allows commercial use by all potential users. >> It *does* allow commercial use. Your example just shows that some >> people may decide not to take advantage of it, based not on problematic >> restrictions but just on paranoia. > > I was confused and worried about this subject lately, too; at some > point in the future, I may want to ship closed-source commercial > software that uses various LGPL libraries. But it doesn't seem to be > as big a problem as I imagined. My understanding is that I can satisfy > the requirements of the LGPL by dynamically linking, and that's > already happening. Dynamic linking doesn't solve all the problems, we still have the problem that GHC does a lot of cross-module inlining, regardless of whether dynamic linking is used. However, I really would like to have a way to have complete control over what is exposed across a package boundary. We need this not just for licensing reasons, but also for making a dynamic library with a fixed ABI, so it can be upgraded later. Incedentally the lack of this feature is one reason I've not being rushing to get shared libraries into GHC. They're just not that useful unless you can upgrade a library independently of the things it depends on. Cheers, Simon From dons at galois.com Wed Oct 1 13:38:50 2008 From: dons at galois.com (Don Stewart) Date: Wed Oct 1 13:35:23 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Haskell-Embedded System Design: ForSyDe 3.0 and Tutorial In-Reply-To: <6a7c66fc0810010429na4e5981ld5a71d2ff832e9a@mail.gmail.com> References: <6a7c66fc0810010429na4e5981ld5a71d2ff832e9a@mail.gmail.com> Message-ID: <20081001173850.GC32701@scytale.galois.com> alfonso.acosta: > Hi everyone, > > I am glad to announce the 3.0 release of ForSyDe's implementation, now > available from HackageDB. > Awesome, native packages now available, http://aur.archlinux.org/packages.php?ID=20422 -- Don From duncan.coutts at worc.ox.ac.uk Wed Oct 1 13:54:15 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Oct 1 13:55:17 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> Message-ID: <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> On Wed, 2008-10-01 at 08:58 +0100, Malcolm Wallace wrote: > >> When I wanted to upgrade to yi 0.4.6.2, I needed to download the new > >> package list > >> > >> cabal update #download list of new packages > >> cabal upgrade #make any upgrades > > I never knew there was a 'cabal update' command, and it worries me. > In my unhappy experience of packaging systems (apt/Aptitude, fink/ > FinkCommander, and DarwinPorts/MacPorts) it was never obvious when it > should be necessary to run the update. Indeed, the advice given by > each of these tools IIRC was to update every time you used it, before > doing anything else. (So why was it a manual task then?) Because we actually consult the index of available packages more often than you think. Every time you cabal install in a local directory we make sure all the required packages are available and consistent. If we had to go to the network every time you would not be happy. There should be a solution here that lets us update more automatically while still allowing people to do offline operations. I'm not sure what that solution is yet though. > On the other hand, every one of those tools eventually failed for me on the > update step, leaving me with an inconsistent and non-working > configuration. You will be glad to know that cabal's update is atomic (as of cabal-install-0.5.2). It downloads the new index and atomically replaces the old. So if the download is corrupted it should fail to gunzip and we would not overwrite the old index. Duncan From leather at cs.uu.nl Wed Oct 1 13:58:47 2008 From: leather at cs.uu.nl (Sean Leather) Date: Wed Oct 1 13:55:29 2008 Subject: [Haskell-cafe] Haskell, GHC, and ABI Message-ID: <3c6288ab0810011058i1e307927j642714f267687a0@mail.gmail.com> > Dynamic linking doesn't solve all the problems, we still have the problem > that GHC does a lot of cross-module inlining, regardless of whether dynamic > linking is used. However, I really would like to have a way to have > complete control over what is exposed across a package boundary. We need > this not just for licensing reasons, but also for making a dynamic library > with a fixed ABI, so it can be upgraded later. > > Incedentally the lack of this feature is one reason I've not being rushing > to get shared libraries into GHC. They're just not that useful unless you > can upgrade a library independently of the things it depends on. > I completely agree. Having a fixed ABI that survives library changes and compiler upgrades is an important factor in achieving a useful system. Incidentally, I perused http://hackage.haskell.org/trac/ghc/wiki/DynamicLinking and didn't see much about this here. Is there some notes or a plan for reaching this goal with GHC (or any other Haskell compiler)? Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/3fa271ee/attachment.htm From dons at galois.com Wed Oct 1 14:22:08 2008 From: dons at galois.com (Don Stewart) Date: Wed Oct 1 14:18:40 2008 Subject: [Haskell-cafe] The Haskell Platform In-Reply-To: <5ae4f2ba0809302355h1be5f3favc18ed9bf32654f81@mail.gmail.com> References: <5ae4f2ba0809302355h1be5f3favc18ed9bf32654f81@mail.gmail.com> Message-ID: <20081001182208.GC456@scytale.galois.com> vigalchin: > Hello, > > I probably missed some details for which I apologize. My feeling is > that "periodically" the "haskell platform server" should attempt to > rebuild the Haskell library. Any library that fails to rebuild then the > "maintainer" of that library should be notified, e.g. email, pager(;^)), > .... Yes, automated build reporting and emails to maintainers are on the agenda. -- Don From dons at galois.com Wed Oct 1 14:27:29 2008 From: dons at galois.com (Don Stewart) Date: Wed Oct 1 14:24:01 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> Message-ID: <20081001182729.GD456@scytale.galois.com> magnus: > On Wed, Oct 1, 2008 at 3:31 AM, brian wrote: > [..] > > as big a problem as I imagined. My understanding is that I can satisfy > > the requirements of the LGPL by dynamically linking, and that's > > already happening. Is there something else to worry about? I'd be in > > violation if I shipped something statically linked, but cabal doesn't > > seem inclined to do that by default. > > I'm not sure I understand you here. Would you clarify your words > here, bearing in mind that GHC doesn't do dynamic linking of Haskell > modules? Yes, its very simple: * C libraries are classically dynamically linked, so you're in compliance there with any LGPL C lib you use. (under the usual interpretation of the LGPL) * Haskell libraries are always statically linked and agressively inlined, so opinion seems to be that LGPL licensed *Haskell libaries* are unsuitable for any projects you want to ship commercially, without source code. * Only a small percent of Haskell libarires are LGPL, and nothing for which we don't have workarounds (e.g. HDBC vs galois-sqlite3 vs takusen). * None of the core system or Haskell platform are LGPLd, they're all "BSD3" * "BSD3" style reminds the vast majority, and preferred license, for Haskell code. IANAL. -- Don "ship some Haskell today" Stewart From svein.ove at aas.no Wed Oct 1 14:53:33 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 1 14:50:14 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> Message-ID: <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> On Wed, Oct 1, 2008 at 7:54 PM, Duncan Coutts > Because we actually consult the index of available packages more often > than you think. Every time you cabal install in a local directory we > make sure all the required packages are available and consistent. If we > had to go to the network every time you would not be happy. > > There should be a solution here that lets us update more automatically > while still allowing people to do offline operations. I'm not sure what > that solution is yet though. > The solution seems obvious to me, actually: Check the timestamp of the package file at every access. If it's older than some configurable value, and you have network access, start updating it. From malcolm.wallace at cs.york.ac.uk Wed Oct 1 14:57:34 2008 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Oct 1 14:54:16 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081001182729.GD456@scytale.galois.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> Message-ID: Just a small nuance to what Don wrote: > * Haskell libraries are always statically linked and agressively > inlined, But only for GHC (and jhc?). > so opinion seems to be that LGPL licensed *Haskell > libaries* are unsuitable for any projects you want to ship > commercially, without source code. Unless you use a different compiler. Regards, Malcolm "keeping the dream of multiple implementations alive" Wallace From barsoap at web.de Wed Oct 1 14:59:53 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Oct 1 14:56:41 2008 Subject: [Haskell-cafe] Re: cabal upgrade References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> Message-ID: <20081001205953.7f733b95@solaris> "Svein Ove Aas" wrote: > On Wed, Oct 1, 2008 at 7:54 PM, Duncan Coutts > > Because we actually consult the index of available packages more > > often than you think. Every time you cabal install in a local > > directory we make sure all the required packages are available and > > consistent. If we had to go to the network every time you would not > > be happy. > > > > There should be a solution here that lets us update more > > automatically while still allowing people to do offline operations. > > I'm not sure what that solution is yet though. > > > The solution seems obvious to me, actually: > > Check the timestamp of the package file at every access. If it's older > than some configurable value, and you have network access, start > updating it. > Additionally, you could use rsync instead of a tbz download to speed things up. Gentoo does this right. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From manlio_perillo at libero.it Wed Oct 1 15:08:04 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Oct 1 15:05:03 2008 Subject: [Haskell-cafe] Re: Doing something constructive. [Was: Climbing up the shootout...] In-Reply-To: <20080924193145.GA4672@scytale.galois.com> References: <534345625.20080922211206@gmail.com> <61951769.20080922230925@gmail.com> <1797097834.20080923030028@gmail.com> <20080922231237.GB27786@scytale.galois.com> <48D8B890.5030405@libero.it> <48DA79D8.4040105@gmail.com> <48DA9421.7090309@libero.it> <20080924193145.GA4672@scytale.galois.com> Message-ID: <48E3CA94.8060908@libero.it> Don Stewart ha scritto: > manlio_perillo: >> However I'm looking for a good environment for implementing generic >> internet servers, or web applications with special needs. >> As an example one of my "maybe future" tasks is to write a simple >> BitTorrent tracker + seeder. > > You could look at conjure, the bitorrent client that uses STM for > network multiplexing, > > http://darcs.haskell.org/~lemmih/conjure/ > Its unfortunate that the project seems to be dead. >> Twisted (a Python asynchronous framework) is a confortable environment, >> but I feel concurrent Haskell is superior. > > Should be a lot faster, given there's compiled native code, and no > global locks. With Twisted you usually don't use threads. > [...] Manlio Perillo From gour at mail.inet.hr Wed Oct 1 15:08:22 2008 From: gour at mail.inet.hr (Gour) Date: Wed Oct 1 15:05:19 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> Message-ID: <87od24dtg9.fsf@gaura-nitai.no-ip.org> >>>>> "Don" == Don Stewart writes: Don> * Only a small percent of Haskell libarires are LGPL, and Don> nothing for which we don't have workarounds (e.g. HDBC vs Don> galois-sqlite3 vs takusen). Hmm, Gtk2Hs & wxhaskell - major GUI libs... Sincerely, Gour -- Gour | Zagreb, Croatia | GPG key: C6E7162D ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/0540b1a6/attachment.bin From manlio_perillo at libero.it Wed Oct 1 15:09:36 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Oct 1 15:06:19 2008 Subject: [Haskell-cafe] pure Haskell database In-Reply-To: References: <48DAAE4D.9010807@libero.it> <48DBFDF7.1060506@libero.it> <48E2270E.2050604@libero.it> Message-ID: <48E3CAF0.8030606@libero.it> Graham Fawcett ha scritto: > [...] >> Never though about sparse array, what is the advantage? >> For the complexity, the same of a good hash map. > > Almost certainly worse complexity than a hash map; but the overhead > could be much smaller. If (for example) you only needed a small number > of key/value pairs (say, hundreds of thousands), you could implement > your "database" trivially, e.g. a NULL-terminated array of key/value > structs in shared memory. (Though having separate arrays for keys and > values might help cache locality and boost performance). Lookup might > be O(n) but with a small-ish N and with such a low overhead, it could > perform very, very well. > This seems an interesting idea, thanks. Manlio Perillo From svein.ove at aas.no Wed Oct 1 15:18:39 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 1 15:15:20 2008 Subject: [Haskell-cafe] Re: cabal upgrade In-Reply-To: <20081001205953.7f733b95@solaris> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <20081001205953.7f733b95@solaris> Message-ID: <221b53ab0810011218y73eba576h5b2c1e7b3b21d75b@mail.gmail.com> On Wed, Oct 1, 2008 at 8:59 PM, Achim Schneider wrote: > Additionally, you could use rsync instead of a tbz download to speed > things up. Gentoo does this right. > It wouldn't be *that* much faster, and the server load would be higher. The current package index is.. what, half a megabyte? It's something to consider in the future, although a change-aware "filesystem" (git, say? It's fast) would probably be better. From andrewcoppin at btinternet.com Wed Oct 1 15:51:12 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 1 15:47:56 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: References: Message-ID: <48E3D4B0.5030801@btinternet.com> wman wrote: > Long story short, I promised him a one-liner to "show the power and > beauty of Haskell". > > (writeFile "output.csv") =<< (liftM printCSV $ liftM (map updateLine) > $ parseCSVFromFile "input.csv") > > Is there room for improvement ? Um... Does anybody else find it interesting that we are "showing the beauty of Haskell" by attempting to construct the most terse, cryptic, unmaintainable tangle of point-free code that the combined mindpower of the entire mailing list can produce? Yes, there is much to be said for the power and brevity of Haskell. But you *can* go over the top here, people! o_O Keep it short _yet comprehensible_, IMHO. From martindemello at gmail.com Wed Oct 1 15:52:47 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 15:49:29 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> Message-ID: On Tue, Sep 30, 2008 at 9:01 PM, Duncan Coutts wrote: > On Wed, 2008-10-01 at 01:59 +0200, Cetin Sert wrote: >> A reminder: >> >> When I wanted to upgrade to yi 0.4.6.2, I needed to download the new >> package list >> >> cabal update #download list of new packages >> cabal upgrade #make any upgrades > > Note that 'cabal upgrade' upgrades everything you've currently got > installed (which in general is not necessarily possible). > > The standard workflow is just: > > cabal update #download list of new packages > cabal install yi #install latest version of yi $ cabal install yi Resolving dependencies... 'yi-0.4.6.2' is cached. Configuring yi-0.4.6.2... cabal: alex version >=2.0.1 && <3 is required but it could not be found. cabal: Error: some packages failed to install: yi-0.4.6.2 failed during the configure step. The exception was: exit: ExitFailure 1 $ cabal install yi-gtk Resolving dependencies... cabal: cannot configure yi-gtk-0.2.1. It requires sourceview >=0.9.11 There is no available version of sourceview that satisfies >=0.9.11 Trying cabal upgrade didn't fix it - it still throws the same error. martin From andrewcoppin at btinternet.com Wed Oct 1 15:56:07 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 1 15:52:49 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: <48E3D5D7.9040407@btinternet.com> Benjamin L.Russell wrote: > On Tue, 30 Sep 2008 19:54:17 +0200, Adrian Neumann > wrote: > > >> I often wonder how many cuts you need to divide a steak in n pieces. >> You can obviously get n pieces with (sqrt n) cuts by cutting a grid. >> But I'm sure some smart mathematician thought of a (log n) way. >> > > Good thing that the chocolate slab was only 2 kg and of finite length. > Had it been of infinite length, we would need Dedekind cuts to > partition it.... ;) > You know, it's interesting... I posted this in another forum, and people just said "dude, why would you try to eat a whole 2 Kg of chocolate? That's really unhealthy." I post the same thing here and now people are arguing about Dedekind cuts... da HELL?! o_O An interesting dichotomy of perspectives, don't you think? From monnier at iro.umontreal.ca Wed Oct 1 15:56:50 2008 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Wed Oct 1 15:53:39 2008 Subject: [Haskell-cafe] Re: cabal upgrade References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <20081001205953.7f733b95@solaris> <221b53ab0810011218y73eba576h5b2c1e7b3b21d75b@mail.gmail.com> Message-ID: > It's something to consider in the future, although a change-aware > "filesystem" (git, say? It's fast) would probably be better. ^^^ You misspelled "darcs". Stefan From dons at galois.com Wed Oct 1 16:00:04 2008 From: dons at galois.com (Don Stewart) Date: Wed Oct 1 15:56:44 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> Message-ID: <20081001200004.GI456@scytale.galois.com> malcolm.wallace: > Just a small nuance to what Don wrote: > > > * Haskell libraries are always statically linked and agressively > > inlined, > > But only for GHC (and jhc?). > > > so opinion seems to be that LGPL licensed *Haskell > > libaries* are unsuitable for any projects you want to ship > > commercially, without source code. > > Unless you use a different compiler. > > Malcolm "keeping the dream of multiple implementations alive" And keep dividing our compiler teams' efforts, while single-implementation languages conquer :) Don "thinking that compiler developer fragmentation doesn't help now the language research is 'done'" From svein.ove at aas.no Wed Oct 1 16:03:24 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 1 16:00:06 2008 Subject: [Haskell-cafe] Re: cabal upgrade In-Reply-To: References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <20081001205953.7f733b95@solaris> <221b53ab0810011218y73eba576h5b2c1e7b3b21d75b@mail.gmail.com> Message-ID: <221b53ab0810011303t1dc579f4v34d3552230c3fab0@mail.gmail.com> On Wed, Oct 1, 2008 at 9:56 PM, Stefan Monnier wrote: >> It's something to consider in the future, although a change-aware >> "filesystem" (git, say? It's fast) would probably be better. > ^^^ > > You misspelled "darcs". > I know how git would improve on darcs here: It's (much) faster, and uses less space. How would darcs improve on git? From svein.ove at aas.no Wed Oct 1 16:04:51 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 1 16:01:32 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> Message-ID: <221b53ab0810011304sb8ed4bav5005fa2e4d467d92@mail.gmail.com> On Wed, Oct 1, 2008 at 9:52 PM, Martin DeMello wrote: > > $ cabal install yi > Resolving dependencies... > 'yi-0.4.6.2' is cached. > Configuring yi-0.4.6.2... > cabal: alex version >=2.0.1 && <3 is required but it could not be found. > cabal: Error: some packages failed to install: > yi-0.4.6.2 failed during the configure step. The exception was: > exit: ExitFailure 1 > > $ cabal install yi-gtk > Resolving dependencies... > cabal: cannot configure yi-gtk-0.2.1. It requires sourceview >=0.9.11 > There is no available version of sourceview that satisfies >=0.9.11 > > Trying cabal upgrade didn't fix it - it still throws the same error. > This is because the sourceview package is not on hackage - it's legacy, non-cabal code and can be found on http://www.haskell.org/gtk2hs/ You'll have to install it manually, I'm afraid. From martindemello at gmail.com Wed Oct 1 16:07:30 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 16:04:10 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <221b53ab0810011304sb8ed4bav5005fa2e4d467d92@mail.gmail.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <221b53ab0810011304sb8ed4bav5005fa2e4d467d92@mail.gmail.com> Message-ID: On Wed, Oct 1, 2008 at 1:04 PM, Svein Ove Aas wrote: > On Wed, Oct 1, 2008 at 9:52 PM, Martin DeMello wrote: >> >> $ cabal install yi >> Resolving dependencies... >> 'yi-0.4.6.2' is cached. >> Configuring yi-0.4.6.2... >> cabal: alex version >=2.0.1 && <3 is required but it could not be found. >> cabal: Error: some packages failed to install: >> yi-0.4.6.2 failed during the configure step. The exception was: >> exit: ExitFailure 1 >> >> $ cabal install yi-gtk >> Resolving dependencies... >> cabal: cannot configure yi-gtk-0.2.1. It requires sourceview >=0.9.11 >> There is no available version of sourceview that satisfies >=0.9.11 >> >> Trying cabal upgrade didn't fix it - it still throws the same error. >> > This is because the sourceview package is not on hackage - it's > legacy, non-cabal code and can be found on > http://www.haskell.org/gtk2hs/ > > You'll have to install it manually, I'm afraid. It's not just yi-gtk, though - yi itself isn't installing via cabal, due to the alex version >=2.0.1 && <3 dependency. martin From gwern0 at gmail.com Wed Oct 1 16:06:59 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Oct 1 16:04:45 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> Message-ID: <20081001200659.GA31035@craft> On 2008.10.01 12:52:47 -0700, Martin DeMello scribbled 1.2K characters: > On Tue, Sep 30, 2008 at 9:01 PM, Duncan Coutts > wrote: > > On Wed, 2008-10-01 at 01:59 +0200, Cetin Sert wrote: > >> A reminder: > >> > >> When I wanted to upgrade to yi 0.4.6.2, I needed to download the new > >> package list > >> > >> cabal update #download list of new packages > >> cabal upgrade #make any upgrades > > > > Note that 'cabal upgrade' upgrades everything you've currently got > > installed (which in general is not necessarily possible). > > > > The standard workflow is just: > > > > cabal update #download list of new packages > > cabal install yi #install latest version of yi > > $ cabal install yi > Resolving dependencies... > 'yi-0.4.6.2' is cached. > Configuring yi-0.4.6.2... > cabal: alex version >=2.0.1 && <3 is required but it could not be found. > cabal: Error: some packages failed to install: > yi-0.4.6.2 failed during the configure step. The exception was: > exit: ExitFailure 1 > > $ cabal install yi-gtk > Resolving dependencies... > cabal: cannot configure yi-gtk-0.2.1. It requires sourceview >=0.9.11 > There is no available version of sourceview that satisfies >=0.9.11 > > Trying cabal upgrade didn't fix it - it still throws the same error. > > martin Yi fails on Alex because Cabal doesn't track executables, nor executables needed for installation. You want 'cabal install alex yi'; I believe the FAQ covers this. As for cabal install yi-gtk, unless things have changed since I last looked, the answer is Don't Do That. yi-gtk and yi-vty are solely for yi 0.3 and below - it's obsolete, in other words. Yi depends directly on vty (which cabal install will handle) and GTK2HS, which unfortunately is not on Hackage and so you or your distro has to handle that. -- gwern beef Croatian Waco, Mace H -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/423694b0/attachment.bin From Tom.Schrijvers at cs.kuleuven.be Wed Oct 1 16:08:31 2008 From: Tom.Schrijvers at cs.kuleuven.be (Tom Schrijvers) Date: Wed Oct 1 16:06:06 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081001200004.GI456@scytale.galois.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> Message-ID: > Don "thinking that compiler developer fragmentation doesn't help now the language research is 'done'" Language researchers should move to a new language? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijvers@cs.kuleuven.be url: http://www.cs.kuleuven.be/~toms/ From flippa at flippac.org Wed Oct 1 16:13:03 2008 From: flippa at flippac.org (Philippa Cowderoy) Date: Wed Oct 1 16:08:32 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081001200004.GI456@scytale.galois.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> Message-ID: On Wed, 1 Oct 2008, Don Stewart wrote: > malcolm.wallace: > > Just a small nuance to what Don wrote: > > > so opinion seems to be that LGPL licensed *Haskell > > > libaries* are unsuitable for any projects you want to ship > > > commercially, without source code. > > > > Unless you use a different compiler. > > > > Malcolm "keeping the dream of multiple implementations alive" > > And keep dividing our compiler teams' efforts, while > single-implementation languages conquer :) > > Don "thinking that compiler developer fragmentation doesn't help now > the language research is 'done'" > I'm not at all sure I agree with you there. That said, licensing's a particularly poor reason for a separate implementation. -- flippa@flippac.org 'In Ankh-Morpork even the shit have a street to itself... Truly this is a land of opportunity.' - Detritus, Men at Arms From 666wman at gmail.com Wed Oct 1 16:23:00 2008 From: 666wman at gmail.com (wman) Date: Wed Oct 1 16:19:41 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <48E3D4B0.5030801@btinternet.com> References: <48E3D4B0.5030801@btinternet.com> Message-ID: Thats why i put those quotation marks around that part of sequence ;-)) AFAIK one-liners never were about comprehensibility, just about what you can cram into one line of code. Any programmer should have no problems guessing what the line does does (even more so when looking at the "final" version without the abundant liftM's), the beauty of it lies in figuring how the heck it does what it does. And figuring that out should bring the "profound enlightenment experience; that experience which should make you a better programmer for the rest of your days, even if you never actually use Lisp -erm Haskell- itself a lot" (my apologies, P. Graham, for cannibalizing your words). I should probably get myself a signature stating that i will explicitly warn the reader when being serious ;-) PS: Sorry, Andrew, that I first posted the reply directly to you, still getting used to the fact that gmail kindly replies to the user on whose behalf the message was sent, not to the list. On Wed, Oct 1, 2008 at 9:51 PM, Andrew Coppin wrote: > wman wrote: > >> Long story short, I promised him a one-liner to "show the power and beauty >> of Haskell". >> >> (writeFile "output.csv") =<< (liftM printCSV $ liftM (map updateLine) $ >> parseCSVFromFile "input.csv") >> >> Is there room for improvement ? >> > > Um... Does anybody else find it interesting that we are "showing the beauty > of Haskell" by attempting to construct the most terse, cryptic, > unmaintainable tangle of point-free code that the combined mindpower of the > entire mailing list can produce? > > Yes, there is much to be said for the power and brevity of Haskell. But you > *can* go over the top here, people! o_O > > Keep it short _yet comprehensible_, IMHO. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/d38d169e/attachment.htm From martindemello at gmail.com Wed Oct 1 16:24:55 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 16:21:36 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <20081001200659.GA31035@craft> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <20081001200659.GA31035@craft> Message-ID: On Wed, Oct 1, 2008 at 1:06 PM, Gwern Branwen wrote: > Yi fails on Alex because Cabal doesn't track executables, nor executables needed for installation. You want 'cabal install alex yi'; Yay, that finally worked :) Had to add ~/.cabal/bin to my path first, which wasn't hard to figure out but should probably also be in a faq somewhere. > I believe the FAQ covers this. Nope. I was following http://www.haskell.org/haskellwiki/Yi when I got stuck, and the page makes no mention of how to resolve the alex dependency > As for cabal install yi-gtk, unless things have changed since I last looked, the answer is Don't Do That. yi-gtk and yi-vty are solely for yi 0.3 and below - it's obsolete, in other words. Yi depends directly on vty (which cabal install will handle) and GTK2HS, which unfortunately is not on Hackage and so you or your distro has to handle that. Okay, thanks :) martin From allbery at ece.cmu.edu Wed Oct 1 16:25:04 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Oct 1 16:21:45 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <48E3D4B0.5030801@btinternet.com> References: <48E3D4B0.5030801@btinternet.com> Message-ID: On Oct 1, 2008, at 15:51 , Andrew Coppin wrote: > wman wrote: >> Long story short, I promised him a one-liner to "show the power and >> beauty of Haskell". >> >> (writeFile "output.csv") =<< (liftM printCSV $ liftM (map >> updateLine) $ parseCSVFromFile "input.csv") >> >> Is there room for improvement ? > > Um... Does anybody else find it interesting that we are "showing the > beauty of Haskell" by attempting to construct the most terse, > cryptic, unmaintainable tangle of point-free code that the combined > mindpower of the entire mailing list can produce? To a certain geek mindset, that *is* the power and beauty. (Then again, that's the mindset that publishes incomprehensible JAPHs in their .signature files.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From martindemello at gmail.com Wed Oct 1 16:25:56 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 16:22:37 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: References: <48E3D4B0.5030801@btinternet.com> Message-ID: 2008/10/1 wman <666wman@gmail.com>: > > PS: Sorry, Andrew, that I first posted the reply directly to you, still > getting used to the fact that gmail kindly replies to the user on whose > behalf the message was sent, not to the list. I think that's a list setting, not a gmail one. martin From andrewcoppin at btinternet.com Wed Oct 1 16:40:08 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 1 16:36:46 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: References: <48E3D4B0.5030801@btinternet.com> Message-ID: <48E3E028.6040406@btinternet.com> wman wrote: > Thats why i put those quotation marks around that part of sequence ;-)) > AFAIK one-liners never were about comprehensibility, just about what > you can cram into one line of code. > > Any programmer should have no problems guessing what the line does > does (even more so when looking at the "final" version without the > abundant liftM's), the beauty of it lies in figuring how the heck it > does what it does. And figuring that out should bring the "profound > enlightenment experience; that experience which should make you a > better programmer for the rest of your days, even if you never > actually use Lisp -erm Haskell- itself a lot" (my apologies, P. > Graham, for cannibalizing your words). > > I should probably get myself a signature stating that i will > explicitly warn the reader when being serious ;-) Ah, well then... ;-) Over in the land of POV-Ray, it's sort-of a tradition for your email signature to contain a tiny block of Scene Description Language source code that causes POV-Ray to render your name, or at least render something appropriate. (For those who don't know, POV-Ray is a ray tracer who's Scene Description Language is now in fact Turing-complete - although it is only a sort of macro expansion kind of beast.) Maybe I should start a new tradition where Haskellers have a blob of Haskell as their sig? (I can't *wait* to see what the luminaries such as dons, dcoutts and igloo come up with...) Ah, but a blob of code that does _what_? POV-Ray renders your name in trippy 3D, but Haskell...? From vanenkj at gmail.com Wed Oct 1 16:46:55 2008 From: vanenkj at gmail.com (John Van Enk) Date: Wed Oct 1 16:43:40 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell Message-ID: There's the well known "How to shoot your self in the foot" list which I have it printed and taped on my desk at work. http://www-users.cs.york.ac.uk/susan/joke/foot.htm I had a co-worker ask me how you'd shoot your self in the foot with Haskell. Here's the best I could do: "You shoot the gun, but the bullet gets trapped in the IO monad." I fully realize how un-clever this is. Some one please give me something more worth of the original list. :) -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/4ba3e799/attachment.htm From mail at joachim-breitner.de Wed Oct 1 16:48:53 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Wed Oct 1 16:45:35 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <1222894133.3317.102.camel@otto.ehbuehl.net> Hi, Am Mittwoch, den 01.10.2008, 16:46 -0400 schrieb John Van Enk: > There's the well known "How to shoot your self in the foot" list which > I have it printed and taped on my desk at work. > > http://www-users.cs.york.ac.uk/susan/joke/foot.htm > > I had a co-worker ask me how you'd shoot your self in the foot with > Haskell. Here's the best I could do: > > "You shoot the gun, but the bullet gets trapped in the IO monad." You shoot the gun, but nobody notices because no-one evaluates the target. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/8fcf0451/attachment.bin From ketil at malde.org Wed Oct 1 16:59:55 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Oct 1 16:53:19 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <48E3D4B0.5030801@btinternet.com> (Andrew Coppin's message of "Wed\, 01 Oct 2008 20\:51\:12 +0100") References: <48E3D4B0.5030801@btinternet.com> Message-ID: <87myhouj3o.fsf@malde.org> Andrew Coppin writes: >> (writeFile "output.csv") =<< (liftM printCSV $ liftM (map >> updateLine) $ parseCSVFromFile "input.csv") > Um... Does anybody else find it interesting that we are "showing the > beauty of Haskell" by attempting to construct the most terse, cryptic, > unmaintainable tangle of point-free code I don't agree at all! How could a pipeline like this possibly be more clearly expressed than by the pattern: readInputFile "input" >>= mungeStuff >>= writeOutputFile "output" ? The OP asks for improvements, which got rid of a couple of gratuitous liftMs and such, but otherwise I think it's a pretty straightforward idiom. -k -- If I haven't seen further, it is by standing in the footprints of giants From gwern0 at gmail.com Wed Oct 1 17:17:41 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Oct 1 17:15:07 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <20081001200659.GA31035@craft> Message-ID: <20081001211741.GA21851@craft> On 2008.10.01 13:24:55 -0700, Martin DeMello scribbled 0.9K characters: > On Wed, Oct 1, 2008 at 1:06 PM, Gwern Branwen wrote: > > > Yi fails on Alex because Cabal doesn't track executables, nor executables needed for installation. You want 'cabal install alex yi'; > > Yay, that finally worked :) Had to add ~/.cabal/bin to my path first, > which wasn't hard to figure out but should probably also be in a faq > somewhere. The exact issue of where to install executables is somewhat tricky; adding ~/.cabal/bin is one option, but you could've used --prefix=/home/martin/ or you could've used the symlink option in ~/.cabal/config or... There's not really a Cabal-install FAQ for that because there's no clear answer. > > I believe the FAQ covers this. > > Nope. I was following http://www.haskell.org/haskellwiki/Yi when I got > stuck, and the page makes no mention of how to resolve the alex > dependency > > > As for cabal install yi-gtk, unless things have changed since I last looked, the answer is Don't Do That. yi-gtk and yi-vty are solely for yi 0.3 and below - it's obsolete, in other words. Yi depends directly on vty (which cabal install will handle) and GTK2HS, which unfortunately is not on Hackage and so you or your distro has to handle that. > > Okay, thanks :) > > martin I've added those 2 questions to the installation section. They've come up so often I was sure they were already there. -- gwern monarchist DCJFTF EADA SASSTIXS Kamumaruha Waihopai phones Colonel IA wideband -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/fa536ad9/attachment.bin From 666wman at gmail.com Wed Oct 1 17:22:20 2008 From: 666wman at gmail.com (wman) Date: Wed Oct 1 17:19:00 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <48E3E028.6040406@btinternet.com> References: <48E3D4B0.5030801@btinternet.com> <48E3E028.6040406@btinternet.com> Message-ID: On Wed, Oct 1, 2008 at 10:40 PM, Andrew Coppin wrote: > Maybe I should start a new tradition where Haskellers have a blob of > Haskell as their sig? > > (I can't *wait* to see what the luminaries such as dons, dcoutts and igloo > come up with...) > Some haskell equivalent of : (((((lambda(x)((((((((x x)x)x)x)x)x)x)x)) (lambda(x)(lambda(y)(x(x y))))) (lambda(x)(x)x)) (lambda()(printf "Greetings, Jos~n")))) ? ;-))) and seeing ketil's sig, i cannot keep to myself this beautiful bastardization of the "shoulders of giants" line which i found today: Most men stand on the shoulders of giants. Matthew Garrett stamps on the testicles of midgets. PS: it seems the list won't re-send the message to people to whom it was directly addressed. so to stay in my on-click lazy mode, i'm trying the reply-to-all button. In the case i start flooding your mailboxes, just kindly kick my butt. thx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/0cb71717/attachment.htm From martindemello at gmail.com Wed Oct 1 17:26:39 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 17:23:19 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <1222894133.3317.102.camel@otto.ehbuehl.net> References: <1222894133.3317.102.camel@otto.ehbuehl.net> Message-ID: 2008/10/1 Joachim Breitner : > > You shoot the gun, but nobody notices because no-one evaluates the > target. Who'd've thunk it! m. From claus.reinke at talk21.com Wed Oct 1 17:31:22 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Oct 1 17:28:07 2008 Subject: [Haskell-cafe] csv one-liner References: <48E3D4B0.5030801@btinternet.com> <87myhouj3o.fsf@malde.org> Message-ID: <24485A6CEC9D40BB8E452A889153A607@cr3lt> >>> (writeFile "output.csv") =<< (liftM printCSV $ liftM (map >>> updateLine) $ parseCSVFromFile "input.csv") > >> Um... Does anybody else find it interesting that we are "showing the >> beauty of Haskell" by attempting to construct the most terse, cryptic, >> unmaintainable tangle of point-free code > > I don't agree at all! How could a pipeline like this possibly be more > clearly expressed than by the pattern: > > readInputFile "input" >>= mungeStuff >>= writeOutputFile "output" interact pureMungeStuff After all, you're looking for oneliners, not real programs. interact $ either (error . show) (printCSV . map updateLine) . parseCSV "" Claus -- some people need a vacation From duncan.coutts at worc.ox.ac.uk Wed Oct 1 16:52:35 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Oct 1 17:33:49 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> Message-ID: <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> On Wed, 2008-10-01 at 20:53 +0200, Svein Ove Aas wrote: > On Wed, Oct 1, 2008 at 7:54 PM, Duncan Coutts > > Because we actually consult the index of available packages more often > > than you think. Every time you cabal install in a local directory we > > make sure all the required packages are available and consistent. If we > > had to go to the network every time you would not be happy. > > > > There should be a solution here that lets us update more automatically > > while still allowing people to do offline operations. I'm not sure what > > that solution is yet though. > > > The solution seems obvious to me, actually: > > Check the timestamp of the package file at every access. If it's older > than some configurable value, Yes, that's the interim solution we're suggesting in the ticket, though warning rather than actually blocking and going to the network. > and you have network access, start updating it. That's hard. Detecting if we would be able to make a network connection without actually doing it is not something I know how to do (esp in a portable way). We would very much appreciate some help in this area. Duncan From jake at pikewerks.com Wed Oct 1 17:42:51 2008 From: jake at pikewerks.com (Jake McArthur) Date: Wed Oct 1 17:39:35 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <48E3EEDB.9090606@pikewerks.com> John Van Enk wrote: > I had a co-worker ask me how you'd shoot your self in the foot with > Haskell. [...] Some one please give me something more worth of the > original list. Couldn't match expected type 'Deer' against inferred type 'Foot' - Jake From dpiponi at gmail.com Wed Oct 1 17:45:00 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Wed Oct 1 17:41:44 2008 Subject: [Haskell-cafe] (A little humour) In-Reply-To: <48E34A16.3070005@libero.it> References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> <48E34A16.3070005@libero.it> Message-ID: <625b74080810011445v221b3842u31658b2dde5ec2c6@mail.gmail.com> On Wed, Oct 1, 2008 at 2:59 AM, Manlio Perillo wrote: > Miguel Mitrofanov ha scritto: > By the way, is it technically possible (and feasible), in Haskell, to define > a space operator? In a way it's what is described in this paper: http://www.cs.nott.ac.uk/~ctm/IdiomLite.pdf In the proposed notation, within [[]]'s there is an implied <*> for every space. -- Dan From 666wman at gmail.com Wed Oct 1 17:55:21 2008 From: 666wman at gmail.com (wman) Date: Wed Oct 1 17:52:03 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> Message-ID: On Wed, Oct 1, 2008 at 10:52 PM, Duncan Coutts wrote: > > and you have network access, start updating it. > > That's hard. Detecting if we would be able to make a network connection > without actually doing it is not something I know how to do (esp in a > portable way). We would very much appreciate some help in this area. > > Duncan > Well, i wouldn't try to detect it. If someone has some auto-update interval specified, it would be sensible enough to try the update automatically imho. Or, if the package server would responds to ICMP echo requests (seems like it doesn't), this seems as a cheap-enough way to test whether it should try to update. Or how about http/1.1 if-modified-since header field ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/a7732566/attachment.htm From svein.ove at aas.no Wed Oct 1 18:00:23 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 1 17:57:04 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> Message-ID: <221b53ab0810011500t6aea057aw4ba8417e2b79d130@mail.gmail.com> On Wed, Oct 1, 2008 at 10:52 PM, Duncan Coutts wrote: > On Wed, 2008-10-01 at 20:53 +0200, Svein Ove Aas wrote: >> and you have network access, start updating it. > > That's hard. Detecting if we would be able to make a network connection > without actually doing it is not something I know how to do (esp in a > portable way). We would very much appreciate some help in this area. > OS X has a function to test that, and a way to get notified when the access state changes; it never occurred to me that other OSs might not. It only tests for local connectivity, though. That aside, why not start downloading in the background, while it's doing whatever you started cabal for? Assuming the network is working, you should have an updated package list by the time it's done; granted, it won't be used for *that* invocation, but next time you invoke cabal it will. If the download fails, just ignore it. From olsner at gmail.com Wed Oct 1 18:27:02 2008 From: olsner at gmail.com (Simon Brenner) Date: Wed Oct 1 18:23:42 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: On 10/1/08, John Van Enk wrote: > There's the well known "How to shoot your self in the foot" list which I > have it printed and taped on my desk at work. > > http://www-users.cs.york.ac.uk/susan/joke/foot.htm > > I had a co-worker ask me how you'd shoot your self in the foot with > Haskell. Here's the best I could do: > > "You shoot the gun, but the bullet gets trapped in the IO monad." While compiling your program the compiler produces a type error long enough to overflow a kernel buffer, overwrite the trigger control register and shoot you in the foot. or After trying to decipher the type errors from the compiler, your head explodes. or After you've finally found a way to circumvent the type system and shoot yourself in the foot, Oleg appears out of nothing and shoots you in the foot for coming up with it before him. :-) From allbery at ece.cmu.edu Wed Oct 1 18:27:42 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Oct 1 18:24:27 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: <48E3D5D7.9040407@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <48E3D5D7.9040407@btinternet.com> Message-ID: <8E39D53B-6A39-4A87-9695-64DF8E24AE31@ece.cmu.edu> On 2008 Oct 1, at 15:56, Andrew Coppin wrote: > Benjamin L.Russell wrote: >> On Tue, 30 Sep 2008 19:54:17 +0200, Adrian Neumann >> wrote: >>> I often wonder how many cuts you need to divide a steak in n >>> pieces. You can obviously get n pieces with (sqrt n) cuts by >>> cutting a grid. But I'm sure some smart mathematician thought of >>> a (log n) way. >> >> Good thing that the chocolate slab was only 2 kg and of finite >> length. >> Had it been of infinite length, we would need Dedekind cuts to >> partition it.... ;) > > You know, it's interesting... I posted this in another forum, and > people just said "dude, why would you try to eat a whole 2 Kg of > chocolate? That's really unhealthy." I post the same thing here and > now people are arguing about Dedekind cuts... da HELL?! o_O > > An interesting dichotomy of perspectives, don't you think? And if you'd posted on the LOPSA (http://lopsa.org) list it would probably be a discussion of which OS is which kind of chocolate. So? :) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From dagit at codersbase.com Wed Oct 1 18:38:08 2008 From: dagit at codersbase.com (Jason Dagit) Date: Wed Oct 1 18:34:49 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: On Wed, Oct 1, 2008 at 3:27 PM, Simon Brenner wrote: > On 10/1/08, John Van Enk wrote: > > There's the well known "How to shoot your self in the foot" list which I > > have it printed and taped on my desk at work. > > > > http://www-users.cs.york.ac.uk/susan/joke/foot.htm > > > > I had a co-worker ask me how you'd shoot your self in the foot with > > Haskell. Here's the best I could do: > > > > "You shoot the gun, but the bullet gets trapped in the IO monad." > > While compiling your program the compiler produces a type error long > enough to overflow a kernel buffer, overwrite the trigger control > register and shoot you in the foot. > > or > > After trying to decipher the type errors from the compiler, your head > explodes. Or as GHC says: My brain just exploded. And of course it says that because: I can't handle pattern bindings for existentially-quantified constructors. Instead, use a case-expression, or do-notation, to unpack the constructor. But, telling people that part takes the fun out of :) > > > or > > After you've finally found a way to circumvent the type system and > shoot yourself in the foot, Oleg appears out of nothing and shoots you > in the foot for coming up with it before him. Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck Norris reputation. Except that Oleg has really earned the respect he gets from our teasing. BTW, is there an Oleg Facts website? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/53f63393/attachment-0001.htm From gtener at gmail.com Wed Oct 1 18:39:29 2008 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Wed Oct 1 18:36:09 2008 Subject: [Haskell-cafe] cabal upgrade In-Reply-To: <221b53ab0810011500t6aea057aw4ba8417e2b79d130@mail.gmail.com> References: <20080926104917.5ee0e228@solaris> <1222447424.4242.8.camel@dell.linuxdev.us.dell.com> <1ff5dedc0809301659i77807167h2a9031dd62473dc5@mail.gmail.com> <1222833707.14163.216.camel@dell.linuxdev.us.dell.com> <72B07887-1841-4C7E-B6F1-FB4C4AC77FAE@cs.york.ac.uk> <1222883655.14163.244.camel@dell.linuxdev.us.dell.com> <221b53ab0810011153w54bde127lc5f664b97bfab7b@mail.gmail.com> <1222894355.14163.247.camel@dell.linuxdev.us.dell.com> <221b53ab0810011500t6aea057aw4ba8417e2b79d130@mail.gmail.com> Message-ID: <220e47b40810011539g3989b745w47ccbbd619a2ab3b@mail.gmail.com> On Thu, Oct 2, 2008 at 00:00, Svein Ove Aas wrote: > That aside, why not start downloading in the background, while it's > doing whatever you started cabal for? Assuming the network is working, > you should have an updated package list by the time it's done; > granted, it won't be used for *that* invocation, but next time you > invoke cabal it will. If the download fails, just ignore it. Personally I don't like the idea: If we know that there is newer package list, why not use it? It feels somewhat unintuitive to me. All best Christophe Skrz?tnicki From vanenkj at gmail.com Wed Oct 1 18:42:02 2008 From: vanenkj at gmail.com (John Van Enk) Date: Wed Oct 1 18:38:42 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: On Wed, Oct 1, 2008 at 6:38 PM, Jason Dagit wrote: > > > Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck > Norris reputation. Except that Oleg has really earned the respect he gets > from our teasing. BTW, is there an Oleg Facts website? > > Jason > > Not that I know of, but there is a Stallman Facts website: Originated here: http://www.reddit.com/r/programming/comments/675jj/richard_stallman_is_the_new_chuck_norris URLed here: http://www.stallmanfacts.com/ -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/91793022/attachment.htm From dpiponi at gmail.com Wed Oct 1 18:46:57 2008 From: dpiponi at gmail.com (Dan Piponi) Date: Wed Oct 1 18:43:36 2008 Subject: [Haskell-cafe] (A little humour) In-Reply-To: <625b74080810011445v221b3842u31658b2dde5ec2c6@mail.gmail.com> References: <48DD2C46.6080104@btinternet.com> <0AFAE613-3304-4D81-9C53-172AA4CFD536@yandex.ru> <48E34A16.3070005@libero.it> <625b74080810011445v221b3842u31658b2dde5ec2c6@mail.gmail.com> Message-ID: <625b74080810011546i57a98264l457a7fc9b446a59b@mail.gmail.com> On Wed, Oct 1, 2008 at 2:45 PM, Dan Piponi wrote: > In the proposed notation, within [[]]'s there is an implied <*> for every space. Come to think of it, surely that's why they're called *applicative* functors. In Haskell, a space between identifiers corresponds implicitly to the 'application' operator. (Sometimes it's written explicitly as @, as in http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.54.6644). Applicative functors are simply a mechanism to allow the redefinition of application, just like how monads allow you to 'redefine' the semicolon. -- Dan From william.wood3 at comcast.net Wed Oct 1 18:37:40 2008 From: william.wood3 at comcast.net (Bill) Date: Wed Oct 1 18:44:36 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: <48E3D5D7.9040407@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <48E3D5D7.9040407@btinternet.com> Message-ID: <1222900660.19782.3.camel@localhost> On Wed, 2008-10-01 at 20:56 +0100, Andrew Coppin wrote: . . . > You know, it's interesting... I posted this in another forum, and people > just said "dude, why would you try to eat a whole 2 Kg of chocolate? > That's really unhealthy." I post the same thing here and now people are > arguing about Dedekind cuts... da HELL?! o_O > > An interesting dichotomy of perspectives, don't you think? Maybe the dichotomy is in the distribution of free-wheeling imagination. I'm reminded of the (apocryphal?) story about Hilbert's assessment of poetry and mathematics. -- Bill Wood From william.wood3 at comcast.net Wed Oct 1 18:39:49 2008 From: william.wood3 at comcast.net (Bill) Date: Wed Oct 1 18:46:45 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <1222900789.19782.5.camel@localhost> On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: . . . > I fully realize how un-clever this is. Some one please give me > something more worth of the original list. :) You shoot the gun but nothing happens (Haskell is pure, after all). From qdunkan at gmail.com Wed Oct 1 18:54:14 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Oct 1 18:50:55 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <1222900789.19782.5.camel@localhost> References: <1222900789.19782.5.camel@localhost> Message-ID: <2518b95d0810011554n7854508ds44e6ad669576340d@mail.gmail.com> On Wed, Oct 1, 2008 at 3:39 PM, Bill wrote: > On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: > . . . >> I fully realize how un-clever this is. Some one please give me >> something more worth of the original list. :) > > You shoot the gun but nothing happens (Haskell is pure, after all). Your foot is fine, until you try to walk on it, at which point it becomes mangled. From list at phaedrusdeinus.org Wed Oct 1 18:56:13 2008 From: list at phaedrusdeinus.org (John Melesky) Date: Wed Oct 1 18:52:58 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <6AA40D14-6B7E-4FDD-BDDE-9C2770C7AA1D@phaedrusdeinus.org> On Oct 1, 2008, at 1:46 PM, John Van Enk wrote: > "You shoot the gun, but the bullet gets trapped in the IO monad." You have a shootFoot function which you've proven correct. QuickCheck validates it for arbitrary you-like values. It will be evaluated only when you end up at the hospital. You hope this doesn't come to pass, as it actually returns a bullet-ridden copy of yourself and you don't want to be garbage-collected. or foreign import ccall "shootparts.h shootfoot" shoot_foot :: Gun -> Programmer -> IO () -johnnnnnnn From martindemello at gmail.com Wed Oct 1 19:08:35 2008 From: martindemello at gmail.com (Martin DeMello) Date: Wed Oct 1 19:05:15 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <1222900789.19782.5.camel@localhost> References: <1222900789.19782.5.camel@localhost> Message-ID: On Wed, Oct 1, 2008 at 3:39 PM, Bill wrote: > On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: > . . . >> I fully realize how un-clever this is. Some one please give me >> something more worth of the original list. :) > > You shoot the gun but nothing happens (Haskell is pure, after all). putting the unsafe in unsafePerformIO! martin From gwern0 at gmail.com Wed Oct 1 19:32:12 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Oct 1 19:30:15 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <20081001233212.GA17998@craft> On 2008.10.01 15:38:08 -0700, Jason Dagit scribbled 4.3K characters: > Heh. Nice. Oleg has earned himself the Haskell equivalent of a Chuck Norris reputation. > Except that Oleg has really earned the respect he gets from our teasing. BTW, is there an > Oleg Facts website? > > Jason Lambdabot has/had a number of OlegFacts in its quote database. @quote as usual, or if you want to look at the whole list of quotes, gunzip State/quote. -- gwern Trade UXO Consul Golf genetic import JOTS DCSS Flame lead -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081001/89f4139d/attachment.bin From lrpalmer at gmail.com Wed Oct 1 19:38:08 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 1 19:34:48 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <48E3EEDB.9090606@pikewerks.com> References: <48E3EEDB.9090606@pikewerks.com> Message-ID: <7ca3f0160810011638j6ed0f846pe87f340aff383060@mail.gmail.com> On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur wrote: > John Van Enk wrote: >> >> I had a co-worker ask me how you'd shoot your self in the foot with >> Haskell. [...] Some one please give me something more worth of the original >> list. > > Couldn't match expected type 'Deer' against inferred type 'Foot' This one is my favorite! Luke From wren at freegeek.org Wed Oct 1 19:53:18 2008 From: wren at freegeek.org (wren ng thornton) Date: Wed Oct 1 19:49:58 2008 Subject: [Haskell-cafe] Re: Total Functional Programming in Haskell In-Reply-To: References: Message-ID: <48E40D6E.8040009@freegeek.org> Jason Dagit wrote: > I was asserting that Haskell is currently 2 layered. Purely functional vs. > IO. They integrate nicely and play well together, but I still think of them > as distinct layers. Perhaps this is not fair or confusing though. The > paper I cited did indeed use codata to define streams so that something, > such as an OS, that needs to process infinite streams of requests can still > do so. For a first take on monads, that's not a bad way of thinking about it. But, once you move beyond first thoughts, monads aren't a special separate layer and thinking of them as such is liable to land you in trouble. Monads really are pure, it's just that they get there by existentializing over impurities.[1] Perhaps you really do mean only the IO monad and not any others, but then the question becomes: whose IO? The IO monad is well-known to be a sin bin for things people don't know or care enough about. Over time things get added to IO and over time things get broken off into their own monads. So then where is the layer boundary over time? I assert that there's no meaningful place to draw the boundary because there's nothing particularly special about IO that isn't shared by other monads like ST or ACIO. It'd be nice to have a total core language, but it's not clear how to helpfully represent such things in the type system. One variety of non-totality is the |error| function. We could design our types to say that people can't call it, but the whole purpose of |error| is to raise exceptions (a monadic action) from pure code; so as far as the types are concerned, we already can't do any such things. We can eliminate many instances of those non-totalities by adding in refinement types (a modest proposal), in order to prevent people from passing [] to |head| or |tail|, or passing 0 as the denominator of (/), etc. But there are other non-totalities, such as _|_ which cannot be captured by such means. In order to capture many instances of _|_ we'd need to have our type represent their depth so that we can do co/induction in order to ensure that the function terminates. While we can capture a surprising level of such detail in Haskell's type system, this is marching off in the direction of dependent types which would be making things more complex rather than simpler. I'm not saying that we shouldn't head there, but it doesn't seem to be addressing the goals you had in mind. [1] Just like existential types, you can put something in but you can never get it back out again. For inescapable monads like IO and ST, this is why they have the behavior of sucking your whole program into the existential black-hole. -- Live well, ~wren From lrpalmer at gmail.com Wed Oct 1 20:01:29 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 1 19:58:10 2008 Subject: [Haskell-cafe] flipped IO sequence In-Reply-To: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> References: <1ff5dedc0810010318s45c4071arff2b8a599f1e3fb6@mail.gmail.com> Message-ID: <7ca3f0160810011701r5e449668j12cd5ef6e73d8267@mail.gmail.com> 2008/10/1 Cetin Sert : > warn :: String ? IO Int > warn = return 1 << putStrLn -- causes an error > -- = \msg ? return 1 << putStrLn msg -- works just fine > -- = \msg ? putStrLn msg >> return 1 -- works just fine > > (<<) :: Monad m ? m b ? m a ? m b > b << a = a >>= \_ ? b > > Why do I get this compile-time error?? How can one define << ? While this isn't directly what you're doing, you might be interested in the Kleisli composition operators in Control.Monad: (>=>) :: (Monad m) => (a -> m b) -> (b -> m c) -> (a -> m c) (<=<) :: (Mnoad m) => (b -> m c) -> (a -> m b) -> (a -> m c) Luke From porges at porg.es Wed Oct 1 20:56:21 2008 From: porges at porg.es (George Pollard) Date: Wed Oct 1 20:53:03 2008 Subject: [Haskell-cafe] Restricted file reading monad Message-ID: <1222908981.16905.15.camel@porges-laptop> Hello all, I'm currently working on a (toy) ID3 [1] tag reader, which made me think of a library which might be quite useful. The structure of an ID3 tag goes something like this: Header: - total size of tag - other header info A series of frames, each with: - total size of frame - other header info - frame data Since the ID3 tag as a whole has size information, I need to pass that into the frame-reading functions to ensure that I never read past the end of the total header. This exact same requirement is present within the frame-reading function itself; it must read the frame data without reading past the end of the frame. It would be nice to have some kind of monad or similar so that I could do: > readTag = do > size <- -- read size > -- read other header info > withLimit size $ -- read frames then the read-frames function would be able to do its work without having to worry about size-checking all the time, as this would be implicit. (And similarly with the frame-reading functions as well.) This could easily be extended to: > f x = readManyWithLimit size readerFunction where readManyWithLimit would return a list of results of applying the reader function as many times as possible within the size limit (and possibly returning some kind of error if the reader function 'bails early' and doesn't gobble right up to the end of the size limit). The thing is, I've not implemented a monad of any substantial size so I don't have a clue where to start. Calling it FileReader (for want of a better name), I guess it would almost be the same as a parsing monad, so the type would have a reference to the file Handle and the current index into the file, as well as the last point that it's allowed to read up to. So, umm... a rather open-ended question, but how would I go about this? [1]: http://www.id3.org/Developer_Information -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/a145d907/attachment.bin From jason.dusek at gmail.com Wed Oct 1 21:35:11 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 1 21:31:51 2008 Subject: [Haskell-cafe] Restricted file reading monad In-Reply-To: <1222908981.16905.15.camel@porges-laptop> References: <1222908981.16905.15.camel@porges-laptop> Message-ID: <42784f260810011835m5e4b5376y1ab6fbc353375103@mail.gmail.com> This is something of the blind leading the blind, but you seem to need a bit of state monad mixed with IO monad. So you could look into StateT, a monad transformer, which should make you a StateIO monad specialized to FileReader. Then you define a `runFileReader` that allows you to jump into the FileReader monad. I defined a "pointer walking" monad a while back, but that did all the IO with `unsafePerformIO`, so I could use a pure State monad. -- _jsn From ajb at spamcop.net Wed Oct 1 21:39:01 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Wed Oct 1 21:35:41 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <7ca3f0160810011638j6ed0f846pe87f340aff383060@mail.gmail.com> References: <48E3EEDB.9090606@pikewerks.com> <7ca3f0160810011638j6ed0f846pe87f340aff383060@mail.gmail.com> Message-ID: <20081001213901.79sgq6gusogo000o-nwo@webmail.spamcop.net> G'day all. On Wed, Oct 1, 2008 at 3:42 PM, Jake McArthur wrote: > Couldn't match expected type 'Deer' against inferred type 'Foot' No instance for (Target Foot) arising from use of `shoot' at SelfInflictedInjury.hs:1:0 Possible fix: add an instance declaration for (Target Foot) In the expression: shoot foot Cheers, Andrew Bromage From marcot at riseup.net Wed Oct 1 21:46:35 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Wed Oct 1 21:44:33 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: References: <48E3D4B0.5030801@btinternet.com> Message-ID: <1222911995.7567.1.camel@quindinho.domain.invalid> Op woensdag 01-10-2008 om 13:25 uur [tijdzone -0700], schreef Martin DeMello: > 2008/10/1 wman <666wman@gmail.com>: > > > > PS: Sorry, Andrew, that I first posted the reply directly to you, still > > getting used to the fact that gmail kindly replies to the user on whose > > behalf the message was sent, not to the list. > > I think that's a list setting, not a gmail one. The list could set reply-to, which is usually not very recommended in netiquettes. And gmail doesn't have a reply-to-list option, which is very useful when the lists doesn't set reply-to, like haskell-cafe. Greetings. -- marcot P?gina: http://marcotmarcot.iaaeee.org/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From marcot at riseup.net Wed Oct 1 21:48:46 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Wed Oct 1 21:45:31 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <87tzbwlohx.fsf@malde.org> References: <1222810019.29616.3.camel@derek-laptop> <87tzbwlohx.fsf@malde.org> Message-ID: <1222912126.7567.4.camel@quindinho.domain.invalid> Op woensdag 01-10-2008 om 10:15 uur [tijdzone +0200], schreef Ketil Malde: > Derek Elkins writes: > > >> parseCSVFromFile "in.csv" >>= return . either (const "error!") > > > Whenever you see this >>= return . f pattern think liftM or fmap or <$>. > > ...and "return . f >>= action" is just "action . f", no? Maybe you meant "return f >>= action" is the same as "action f". Greetings. -- marcot P?gina: http://marcotmarcot.iaaeee.org/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From jason.dusek at gmail.com Wed Oct 1 21:59:46 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 1 21:56:25 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <1222911995.7567.1.camel@quindinho.domain.invalid> References: <48E3D4B0.5030801@btinternet.com> <1222911995.7567.1.camel@quindinho.domain.invalid> Message-ID: <42784f260810011859m6b07e1f2u8cf95ba2262033d9@mail.gmail.com> Reply to all? -- _jsn From byorgey at seas.upenn.edu Wed Oct 1 22:17:09 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Oct 1 22:13:48 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 87 - October 1, 2008 Message-ID: <20081002021709.GA31623@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20081001 Issue 87 - October 01, 2008 --------------------------------------------------------------------------- Welcome to issue 87 of HWN, a newsletter covering developments in the [1]Haskell community. ICFP was held last week in Victoria, and by all accounts was a great success! This edition of the HWN includes much ICFP and Haskell Symposium-related content, including [2]videos of the Haskell symposium presentations, [3]programming contest results, some [4]notes on the future of Haskell, and slides from [5]a Haskell tutorial and [6]a talk about the Haskell Platform. But ICFP didn't seem to slow down the community all that much: you'll find the usual mix of newly released and updated packages, blog posts, mailing list discussions, and silly quotes as well. Announcements Haskell-Embedded System Design: ForSyDe 3.0 and Tutorial. Alfonso Acosta [7]announced the [8]3.0 release of [9]ForSyDe. The ForSyDe (Formal System Design) methodology has been developed with the objective to move system design (e.g. System on Chip, Hardware and Software systems) to a higher level of abstraction. ForSyDe is implemented as a Haskell-embedded behavioral DSL (Domain Specific Language). The 3.0 release includes a new deep-embedded DSL and embedded compiler, as well as a new user-friendly tutorial. Graphalyze-0.1. Ivan Miljenovic [10]announced the initial release of his graph-theoretic analysis library, [11]Graphalyze. This is a pre-release of the library he is writing for his mathematics honours thesis, "Graph-Theoretic Analysis of the Relationships in Discrete Data". Symposium videos. Malcolm Wallace [12]announced [13]guerrilla videos of the Haskell Symposium 2008 presentations. ICFP programming contest results. Malcolm Wallace [14]sent a link to [15]a video of the ICFP programming contest results presentation. Version 0.4.3 of happs-tutorial is a HAppS job board, done in HAppS.. Thomas Hartman [16]announced version 4 of the [17]self-demoing HAppS tutorial, a HAppS job board. TH code for deriving Binary and NFData instances. Tim Newsham [18]announced some [19]Template Haskell code for automatically deriving Data.Binary and Control.Parallel.Strategies.NFData instances. Notes on the future of Haskell from ICFP. Bryan O'Sullivan [20]posted a [21]writeup from the ICFP conference floor on the future of Haskell and functional programming. datapacker 1.0.1. John Goerzen [22]announced the [23]release of datapacker 1.0.1. A Functional Implementation of the Garsia-Wachs Algorithm. Nicolas Pouillard [24]announced a [25]Haskell implementation of an algorithm that builds a binary tree with minimum weighted path length from weighted leaf nodes given in symmetric order. This can be used to build optimum search tables, to balance a 'ropes' data structure in an optimal way. graphviz-2008.9.20. Ivan Miljenovic [26]announced a new version of [27]Matthew Sackman's Haskell bindings to Graphviz. See Ivan's original announcement for information on what new features are included, and what the difference is among the various graphviz-related packages on Hackage. darcs 2.1.0pre2. Eric Kow [28]announced the release of darcs 2.1.0pre2, formerly known as 2.0.3. See Eric's announcement for a list of new features and bug fixes in this release. protocol-buffers-0.2.9 for Haskell is ready. ChrisK [29]announced the release of the [30]protocol-buffers package, which generates Haskell data types that can be converted back and forth to lazy ByteStrings that interoperate with Google's generated code in C++/Java/python. panda blog engine. Jinjing Wang [31]announced the release of [32]panda, a simple blog engine written in Haskell. OpenSPARC project applicant chosen. Duncan Coutts [33]announced that Ben Lippmeier has been chosen for the [34]OpenSPARC project. Ben will spend three months hacking on GHC to make it perform well on the latest multi-core OpenSPARC chips. Hugs on the iPhone. Alberto Galdo [35]announced that he has gotten Hugs to run on the iPhone, and has made packages available for others who would like to install it as well. Discussion Shooting yourself in the foot in Haskell. John Van Enk [36]asked how to shoot yourself in the foot with Haskell, with humorous results. Total Functional Programming in Haskell. Jason Dagit started a [37]discussion on total functional programming, Haskell, abstraction boundaries and the IO monad, and related topics. Health effects. Andrew Coppin told a [38]story about a chocolate bar and recursion, which led to a discussion of optimization problems, Dedekind cuts, some meta-discussion of the discussion, and entirely too many puns. The container problem. Andrew Coppin [39]asked about the possibility if abstracting over various sorts of containers in Haskell, and why there isn't a widely used library that does this. A discussion of various container libraries and the language issues that arise followed. Red-Blue Stack. Matthew Eastman [40]asked how to implement a certain data structure (red-blue stacks) in Haskell. Several people responded with increasingly clever solutions, and a comparison of mutating vs. non-mutating algorithms. Climbing up the shootout.... Don Stewart began a long and ongoing [41]discussion about improving Haskell's performance on benchmarks in the [42]Shootout, now that there is a quad core machine for running benchmarks! Line noise. Andrew Coppin started an [43]interesting discussion about perceptions of Haskell syntax by programmers who aren't familiar with it. Jobs London FP job in asset management. Michael Bott [44]announced an opportunity for two functional programmers based in London, with a software house specialising in asset management. Blog noise [45]Haskell news from the [46]blogosphere. * Creighton Hogg: [47]Some first steps with Data.Reactive. Creighton gives some simple examples of using Conal Elliott's Reactive library. More to come! * Bryan O'Sullivan: [48]Unix hacking in Haskell: better pseudoterminal support. * Creighton Hogg: [49]One last thought on laziness. In Creighton's opinion, laziness is the single hardest thing to get used to in Haskell. If you're learning Haskell, don't despair, break out the pencil and paper! * Douglas M. Auclair (geophf): [50]Animal as RDR, part III. * Neil Mitchell: [51]General Updates. * Don Stewart (dons): [52]Newest Mersenne Prime. Haskell doesn't even break a sweat computing the largest known prime number. * Douglas M. Auclair (geophf): [53]Animal as RDR, part II. * Bryan O'Sullivan: [54]Using Bloom filters for large scale gene sequence analysis in Haskell. A paper that Bryan and Ketil Malde submitted to PADL 09. "The Cliff's Notes version: Bloom filters are almost unused in bioinformatics; they're tremendously useful; and our Haskell code is really fast. * >>> Zubin Wadia: [55]Simon Peyton Jones & Microsoft Research Cambridge. Zubin thinks quite highly of SPJ and MSR Cambridge. * Bryan O'Sullivan: [56]Slides from my DEFUN 2008 Haskell tutorial. * Mads Lindstroem: [57]Inheritance in Composites and Overlapping Instances. * >>> Micah Cowan: [58]Adventures in Haskell. Micah shares some thoughts on learning Haskell. * Bryan O'Sullivan: [59]Some notes on the future of Haskell and FP. * Well-Typed.Com: [60]Slides from the Haskell Platform talk. * Paul Johnson: [61]Why the banks collapsed, and how a paper on Haskell programming can help stop it happening next time. * >>> Nathan Sanders: [62]Two weeks of Haskell. Nathan shares some thoughts on his first two weeks learning Haskell. * Bryan O'Sullivan: [63]Twittering from ICFP / Haskell symposium / CUFP. * Real-World Haskell: [64]Slides from ACCU talk. * Eric Kow (kowey): [65]darcs weekly news #5. * John Goerzen (CosmicRay): [66]New version of datapacker. * >>> James Cowie: [67]Haskell, the verdict!. James is impressed with Haskell after using it for a few weeks. * >>> Alex Combas: [68]What's all this fuss about Haskell?. Alex is thinking of learning Haskell in his spare time. * Aaron Tomb: [69]Parsing the Linux kernel with Haskell: experience with Language.C. Aaron is impressed by the new Language.C libraries, which parses all 18 million pre-processed lines of Linux kernel source with no problems! Quotes of the Week * Fuse_: Oh, sorry for hijacking mathematical purity with dirty fiscal dynamical systems. :o * mauke: data Mushroom badger = Mushroom badger badger badger badger badger badger badger badger badger where's the snake deriving Snake * ddarius: higher order of lambdabot deployment and management engineers or HOLDME * Botje: #haskell: parallellising your homework answers! * olsner: most everything gives nicer everything than perl * Botje: fuzzy feelings aren't always aerodynamic, unfortunately. * chrisdone: benchmarks only exist to make fun of ruby * Claus Reinke: [on breaking code up into smaller bits] Once your readers understand your code, you can add the one-liner and ask for applause. * Jake Mcarthur: A fold by any other name would smell as sweet. * lispy: Schroedinger's cat is really in a thunk not a box * Bulat: Haskell was developed with goal to hide implementation details from egg-headed scientists and this obviously should have some drawbacks About the Haskell Weekly News New editions are posted to [70]the Haskell mailing list as well as to [71]the Haskell Sequence and [72]Planet Haskell. [73]RSS is also available, and headlines appear on [74]haskell.org. To help create new editions of this newsletter, please see the information on [75]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [76]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://haskell.org/haskellwiki/Video_presentations/Haskell_Symposium_2008 3. http://video.google.com/videoplay?docid=-4697764813432201693 4. http://www.serpentine.com/blog/2008/09/26/some-notes-on-the-future-of-haskell-and-fp/ 5. http://www.serpentine.com/blog/2008/09/27/slides-from-my-defun-2008-haskell-tutorial/ 6. http://blog.well-typed.com/2008/09/slides-from-the-haskell-platform-talk/ 7. http://article.gmane.org/gmane.comp.lang.haskell.general/16443 8. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ForSyDe 9. http://www.ict.kth.se/org/ict/ecs/sam/projects/forsyde/www/ 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16442 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16440 13. http://haskell.org/haskellwiki/Video_presentations/Haskell_Symposium_2008 14. http://article.gmane.org/gmane.comp.lang.haskell.general/16438 15. http://video.google.com/videoplay?docid=-4697764813432201693 16. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45332 17. http://happstutorial.com:5001/ 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45305 19. http://www.thenewsh.com/~newsham/store/DeriveBinary.hs 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45272 21. http://www.serpentine.com/blog/2008/09/26/some-notes-on-the-future-of-haskell-and-fp/ 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45185 23. http://changelog.complete.org/posts/760-New-version-of-datapacker.html 24. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45002 25. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/garsia-wachs 26. http://article.gmane.org/gmane.comp.lang.haskell.cafe/44863 27. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphviz 28. http://www.haskell.org//pipermail/haskell-cafe/2008-September/048094.html 29. http://article.gmane.org/gmane.comp.lang.haskell.cafe/44845 30. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers 31. http://article.gmane.org/gmane.comp.lang.haskell.cafe/44840 32. http://jinjing.blog.easymic.com/ 33. http://article.gmane.org/gmane.comp.lang.haskell.cafe/44836 34. http://haskell.org/opensparc/ 35. http://www.haskell.org//pipermail/haskell-cafe/2008-September/047838.html 36. http://www.haskell.org//pipermail/haskell-cafe/2008-October/048506.html 37. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/45393 38. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/45370 39. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/45242 40. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/45122 41. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/44916 42. http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=all 43. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/44886 44. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45506 45. http://planet.haskell.org/ 46. http://haskell.org/haskellwiki/Blog_articles 47. http://abstractabsurd.blogspot.com/2008/09/some-first-steps-with-datareactive.html 48. http://www.serpentine.com/blog/2008/09/30/unix-hacking-in-haskell-better-pseudoterminal-support/ 49. http://abstractabsurd.blogspot.com/2008/09/one-last-thought-on-laziness.html 50. http://logicaltypes.blogspot.com/2008/09/animal-as-rdr-part-iii.html 51. http://neilmitchell.blogspot.com/2008/09/general-updates.html 52. http://www.cse.unsw.edu.au/~dons/blog/2008/09/30#primes 53. http://logicaltypes.blogspot.com/2008/09/animal-as-rdr-part-ii.html 54. http://www.serpentine.com/blog/2008/09/28/using-bloom-filters-for-large-scale-gene-sequence-analysis-in-haskell/ 55. http://zwadia.com/?p=58 56. http://www.serpentine.com/blog/2008/09/27/slides-from-my-defun-2008-haskell-tutorial/ 57. http://lindstroem.wordpress.com/2008/09/27/inheritance-in-composites-and-overlapping-instances/ 58. http://micah.cowan.name/2008/09/26/computers/software-development/adventures-in-haskell/ 59. http://www.serpentine.com/blog/2008/09/26/some-notes-on-the-future-of-haskell-and-fp/ 60. http://blog.well-typed.com/2008/09/slides-from-the-haskell-platform-talk/ 61. http://paulspontifications.blogspot.com/2008/09/why-banks-collapsed-and-how-paper-on.html 62. http://sandersn.com/blog/index.php?title=two_weeks_of_haskell 63. http://www.serpentine.com/blog/2008/09/25/twittering-from-icfp-haskell-symposium-cufp/ 64. http://www.realworldhaskell.org/blog/2008/09/25/slides-from-accu-talk/ 65. http://koweycode.blogspot.com/2008/09/darcs-weekly-news-5.html 66. http://changelog.complete.org/posts/760-New-version-of-datapacker.html 67. http://www.jcowie.co.uk/2008/09/haskell-the-verdict/ 68. http://combas3d.com/2008/09/whats-all-this-fuss-about-haskell/ 69. http://www.galois.com/blog/2008/09/17/parsing-the-linux-kernel-with-haskell-experience-with-languagec/ 70. http://www.haskell.org/mailman/listinfo/haskell 71. http://sequence.complete.org/ 72. http://planet.haskell.org/ 73. http://sequence.complete.org/node/feed 74. http://haskell.org/ 75. http://haskell.org/haskellwiki/HWN 76. http://code.haskell.org/~byorgey/code/hwn/ From ajb at spamcop.net Wed Oct 1 23:05:18 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Wed Oct 1 23:01:57 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: <20081001230518.ko8o7e158oog0co8-nwo@webmail.spamcop.net> G'day all. Quoting Adrian Neumann : > I often wonder how many cuts you need to divide a steak in n pieces. One, if the cut is allowed to be curved and self-intersecting. I think that the spirit of the problem, though is encapsulated in this question: Given a circle, what is the maximum number of pieces that you can divide it into by performing n straight cuts? This is a great problem to set undergraduates, because if you work out some small values of n on paper, you get: n #pieces 0 1 1 2 2 4 3 7 Most undergrads will stall at this point trying to work out how to place the third line to get 8 pieces, and probably come up with an incorrect justification for why it should be 2^n. The details are here: http://www.research.att.com/~njas/sequences/A000124 Cheers, Andrew Bromage From oleg at okmij.org Thu Oct 2 00:41:41 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Oct 2 00:40:13 2008 Subject: [Haskell-cafe] Class Quantification Message-ID: <20081002044141.E7709AE54@Adric.metnet.fnmoc.navy.mil> Bas van Dijk wrote: > ... it's possible to define 'foo' and 'bar' like so: > > > foo :: (Num c, Num d) => (forall b. Num b => a -> b) -> a -> (c, d) > > foo f x = (f x, f x) > > > bar :: (Read c, Read d) => (forall b. Read b => a -> b) -> a -> (c, d) > > bar f x = (f x, f x) > > Which allows us to write: > > > testFoo = foo fromInteger 1 :: (Int, Float) > > testBar = bar read "1" :: (Int, Float) > > Now I would like to generalise 'foo' and 'bar' to 'bla' so that I can write: > > testBla1 = bla fromInteger 1 :: (Int, Float) > testBla2 = bla read "1" :: (Int, Float) Quantification over classes is *easily* achievable in Haskell. Although functional dependencies are required, overlapping or undecidable instances are not. The technique is also far simpler than that in SYB3 and takes only a few lines to write. The complete code follows. One may note that Rank2 types are *not* needed. Therefore, we do not even have to give signature to the function bla as it can be inferred. That technique suggests that Rank2 types are already present in some form in Haskell (even Haskell98) already. In more detail, the technique is explained in Class-parameterized classes, and the type-level logarithm http://okmij.org/ftp/Haskell/types.html#peano-arithm Type-class overloaded functions: second-order typeclass programming with backtracking http://okmij.org/ftp/Haskell/types.html#poly2 Here is the code {-# LANGUAGE RankNTypes, MultiParamTypeClasses, FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-} -- the result type determines the argument type class RApply l a b | l b -> a where rapply :: l -> a -> b -- the expected instance instance RApply (a->b) a b where rapply = ($) data LRead = LRead instance Read b => RApply LRead String b where rapply _ = read data LFromInt = LFromInt instance Num b => RApply LFromInt Integer b where rapply _ = fromInteger bla x arg = (rapply x arg, rapply x arg) testBla1 = bla LFromInt 1 :: (Int, Float) testBla2 = bla LRead "1" :: (Int, Float) From oleg at okmij.org Thu Oct 2 00:51:56 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Oct 2 00:50:27 2008 Subject: [Haskell-cafe] Restricted file reading monad Message-ID: <20081002045156.C4321AE54@Adric.metnet.fnmoc.navy.mil> George Pollard wrote: > The structure of an ID3 tag goes something like this: > Header: > - total size of tag > - other header info > A series of frames, each with: > - total size of frame > - other header info > - frame data > > Since the ID3 tag as a whole has size information, I need to pass that > into the frame-reading functions to ensure that I never read past the > end of the total header. This exact same requirement is present within > the frame-reading function itself; it must read the frame data without > reading past the end of the frame. The structure of the chunk-encoded content is similar: first comes the size, then come data of that size. We have to read exactly that amount (and then check for the chunk trailer, CRLF). In a sense, we have a data stream embedded inside another stream. The Iteratee IO framework was specifically designed to process these sorts of arbitrarily nested and encoded data streams. In particular, the file http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs contains the function -- Read n elements from a stream and apply the given iteratee to the -- stream of the read elements. Unless the stream is terminated early, we -- read exactly n elements (even if the iteratee has accepted fewer). -- This procedure shows a different way of composing two iteratees: -- `vertical' rather than `horizontal' stake :: Monad m => Int -> IterateeG el m a -> IterateeGM el m (IterateeG el m a) The implementation is 11 lines long, counting the `where' line. I believe the code is declarative rather than imperative. The function stake (the analogue of List.take) is then used in enum_chunk_decoded :: Monad m => Iteratee m a -> IterateeM m a The end of the file IterateeM.hs has several complete tests. From haskell at colquitt.org Thu Oct 2 02:56:08 2008 From: haskell at colquitt.org (John Dorsey) Date: Thu Oct 2 02:52:49 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 Message-ID: <20081002065608.GA27422@colquitt.org> Fellow Haskellers, Much attention has been paid over the years to the regrettable omission of singleton tuples from Haskell. I am pleased to announce OneTuple, a humble implementation of the singleton tuple for Haskell. Now you can: * Wrap a single value of any type in a OneTuple ! * Pattern match to retrieve your value ! * Solve any of the software problems that cannot be solved without the singleton tuple ! * Enjoy instances for all the classes normal tuples have, plus more ! * Proclaim feature parity with Python ! Note: the singleton tuple does not support tuple syntax. Contributions are welcome. The project could use a tutorial, and a decent test suite. Strict singleton tuples are planned for the next version. Enjoy! Regards, John Dorsey From ajb at spamcop.net Thu Oct 2 03:10:35 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Thu Oct 2 03:07:15 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002065608.GA27422@colquitt.org> References: <20081002065608.GA27422@colquitt.org> Message-ID: <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> G'day all. Quoting John Dorsey : > Contributions are welcome. The project could use a tutorial, and a > decent test suite. Strict singleton tuples are planned for the next > version. I hope it has a Monad instance. But more to the point: Can it send email? Cheers, Andrew Bromage From olsner at gmail.com Thu Oct 2 03:17:51 2008 From: olsner at gmail.com (Simon Brenner) Date: Thu Oct 2 03:14:30 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> Message-ID: On 10/2/08, ajb@spamcop.net wrote: > G'day all. > > Quoting John Dorsey : > > > > Contributions are welcome. The project could use a tutorial, and a > > decent test suite. Strict singleton tuples are planned for the next > > version. > > > > I hope it has a Monad instance. You could always use this one-tuple instead and get Functor, Monad and MonadFix for free: http://hackage.haskell.org/packages/archive/mtl/1.1.0.1/doc/html/Control-Monad-Identity.html From simonpj at microsoft.com Thu Oct 2 03:31:19 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Oct 2 03:41:37 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081001200004.GI456@scytale.galois.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32D768965F1@EA-EXMSG-C334.europe.corp.microsoft.com> | > Unless you use a different compiler. | > | > Malcolm "keeping the dream of multiple implementations alive" | | And keep dividing our compiler teams' efforts, while | single-implementation languages conquer :) | | Don "thinking that compiler developer fragmentation doesn't help now the language research | is 'done'" Don, I usually agree with almost everything you say -- but not this! I think diversity in compilers is good. They tend to focus on different aspects (e.g. one might be small and accessible while another is more fully-featured but harder to modify), they keep each other on their toes, they serve as vehicles to explore different parts of the design space (eg jhc's implementation model is very different to ghc's). Furthermore, language research in Haskell is *far* from done. I regard GHC as a research platform, not as a product. These goals are in tension but not in conflict -- GHC's usefulness as a research platform is derived in large part from the fact that it is so widely used, which in turn is because it is a decent product. Yes, splitting effort has costs, and those costs are particularly apparent to you because of your fantastic work on libraries, packaging, and distribution. But diversity also has benefits that I would hate to lose. Much as I love GHC, my first baby, I'm glad GHC has siblings. Simon From lrpalmer at gmail.com Thu Oct 2 03:49:51 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Oct 2 03:46:30 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> Message-ID: <7ca3f0160810020049t7938d886h2a6c43c431295842@mail.gmail.com> On Thu, Oct 2, 2008 at 1:17 AM, Simon Brenner wrote: > On 10/2/08, ajb@spamcop.net wrote: >> G'day all. >> >> Quoting John Dorsey : >> >> >> > Contributions are welcome. The project could use a tutorial, and a >> > decent test suite. Strict singleton tuples are planned for the next >> > version. >> > >> >> I hope it has a Monad instance. > > You could always use this one-tuple instead and get Functor, Monad and > MonadFix for free: > http://hackage.haskell.org/packages/archive/mtl/1.1.0.1/doc/html/Control-Monad-Identity.html But that one is different: newtype Identity a = Identity { runIdentity :: a } data OneTuple a = OneTuple { only :: a } So OneTuple has one more value than Identity (Identity Int has Identity _|_ and Identity n for each n, whereas OneTuple Int has _|_, OneTuple _|_, and OneTuple n for each n) Luke From lrpalmer at gmail.com Thu Oct 2 03:59:27 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Oct 2 03:56:07 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002065608.GA27422@colquitt.org> References: <20081002065608.GA27422@colquitt.org> Message-ID: <7ca3f0160810020059v271821fdy5c5a6cbf376d2c07@mail.gmail.com> Hmm, it looks like you forgot to write a Traversable instance. I don't believe: sequenceA (OneTuple [1,2,3,4]) = _|_ is correct. Here is my contribution! instance Traversable OneTuple where sequenceA (OneTuple x) = fmap OneTuple x Luke On Thu, Oct 2, 2008 at 12:56 AM, John Dorsey wrote: > Fellow Haskellers, > > Much attention has been paid over the years to the regrettable > omission of singleton tuples from Haskell. > > I am pleased to announce OneTuple, a humble implementation of the > singleton tuple for Haskell. Now you can: > > * Wrap a single value of any type in a OneTuple ! > > * Pattern match to retrieve your value ! > > * Solve any of the software problems that cannot be solved without > the singleton tuple ! > > * Enjoy instances for all the classes normal tuples have, plus more ! > > * Proclaim feature parity with Python ! > > Note: the singleton tuple does not support tuple syntax. > > Contributions are welcome. The project could use a tutorial, and a > decent test suite. Strict singleton tuples are planned for the next > version. > > Enjoy! > > Regards, > John Dorsey > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Thu Oct 2 04:07:47 2008 From: dons at galois.com (Don Stewart) Date: Thu Oct 2 04:04:26 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C32D768965F1@EA-EXMSG-C334.europe.corp.microsoft.com> References: <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> <638ABD0A29C8884A91BC5FB5C349B1C32D768965F1@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <20081002080747.GA3256@scytale.galois.com> simonpj: > | > Unless you use a different compiler. > | > > | > Malcolm "keeping the dream of multiple implementations alive" > | > | And keep dividing our compiler teams' efforts, while > | single-implementation languages conquer :) > | > | Don "thinking that compiler developer fragmentation doesn't help now the language research > | is 'done'" > > Don, I usually agree with almost everything you say -- but not this! > I think diversity in compilers is good. They tend to focus on > different aspects (e.g. one might be small and accessible while > another is more fully-featured but harder to modify), they keep each > other on their toes, they serve as vehicles to explore different parts > of the design space (eg jhc's implementation model is very different > to ghc's). > > Furthermore, language research in Haskell is *far* from done. I > regard GHC as a research platform, not as a product. These goals are > in tension but not in conflict -- GHC's usefulness as a research > platform is derived in large part from the fact that it is so widely > used, which in turn is because it is a decent product. > > Yes, splitting effort has costs, and those costs are particularly > apparent to you because of your fantastic work on libraries, > packaging, and distribution. But diversity also has benefits that I > would hate to lose. Much as I love GHC, my first baby, I'm glad GHC > has siblings. Yes, I shouldn't tease. We need continued sources of new ideas to keep things moving, since (going back to Malcolm's point) we see that some implementations solve particular problems in easier ways than others. My point was really that investing the effort required to get nhc98 into the shape that we could actually use it to ship the kind of code that we do with GHC -- to make nhc98 a GHC competitor product -- would not be as an efficient use of our researchers and engineers. That effort is better spent either working on GHC, or generating new ideas in areas not directly competing with GHC (like YHC's javascript backend, Hugs on the iphone, or nhc98's bytecode compression). So keep the ideas coming! -- Don From DekuDekuplex at Yahoo.com Thu Oct 2 04:13:48 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Oct 2 04:10:49 2008 Subject: [Haskell-cafe] Re: Announcing OneTuple-0.1.0 References: <20081002065608.GA27422@colquitt.org> Message-ID: On Thu, 2 Oct 2008 02:56:08 -0400, John Dorsey wrote: >Fellow Haskellers, > >Much attention has been paid over the years to the regrettable >omission of singleton tuples from Haskell. > >I am pleased to announce OneTuple, a humble implementation of the >singleton tuple for Haskell. Wonderful! I'm intrigued.... >Note: the singleton tuple does not support tuple syntax. What is the syntax for the singleton tuple? We have a dilemma: If we extend the singleton syntax to support non-singleton tuples, then we'll have at least two definitions of a tuple for each non-singleton tuple, which is syntactically inelegant; however, if we don't, then the singleton syntax will be different from the non-singleton syntax, which is also syntactically inelegant. What is your solution? -- Benjamin From aneumann at inf.fu-berlin.de Thu Oct 2 04:25:07 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Thu Oct 2 04:22:13 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: The Wikipedia says: > "For a finite set of points in the plane, each colored "red" or > "blue", > there is a line that simultaneously bisects the red points and bisects > the blue points, that is, the number of red points on either side > of the > line is equal and the number of blue points on either side of the > line is equal." Does this work with more than two colours? i.e. can I recursively subdivide the halves into quarters with another cut? > Am 01.10.2008 um 15:33 schrieb Dominic Steinitz: > > Adrian Neumann inf.fu-berlin.de> writes: > >> >> I often wonder how many cuts you need to divide a steak in n pieces. >> You can obviously get n pieces with (sqrt n) cuts by cutting a grid. >> But I'm sure some smart mathematician thought of a (log n) way. >> > > You might try the ham sandwich theorem > http://en.wikipedia.org/wiki/Ham_sandwich_theorem as an hors d'oeuvre. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/99262514/PGP.bin From bulat.ziganshin at gmail.com Thu Oct 2 04:48:03 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 2 04:45:42 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081002080747.GA3256@scytale.galois.com> References: <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> <638ABD0A29C8884A91BC5FB5C349B1C32D768965F1@EA-EXMSG-C334.europe.corp.microsoft.com> <20081002080747.GA3256@scytale.galois.com> Message-ID: <964566619.20081002124803@gmail.com> Hello Don, Thursday, October 2, 2008, 12:07:47 PM, you wrote: >> Don, I usually agree with almost everything you say -- but not this! and i usually answer only in those few cases when i disagree ;) > My point was really that investing the effort required to get nhc98 into > the shape that we could actually use it to ship the kind of code that we > do with GHC -- to make nhc98 a GHC competitor product -- would not be as > an efficient use of our researchers and engineers. imho it's true for short-term, false for a longer terms. we need different haskell platforms, otherwise haskell will eventually die, and core libraries such as FPS are essential part of these platforms and according to my experience, writing s/w in portable way is easy if you care about it from the beginning of project. adding portability later costs much more -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From arnarbi at gmail.com Thu Oct 2 05:15:25 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 2 05:12:05 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <1222900789.19782.5.camel@localhost> References: <1222900789.19782.5.camel@localhost> Message-ID: <28012bc60810020215s79ae9c8aufb3374aaa129e2ce@mail.gmail.com> On Thu, Oct 2, 2008 at 00:39, Bill wrote: > On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: > . . . >> I fully realize how un-clever this is. Some one please give me >> something more worth of the original list. :) > > You shoot the gun but nothing happens (Haskell is pure, after all). Realizing that I pressed "reply" instead of "reply to all" yesterday, here's my message again (sorry Bill). A little refinement: You shoot in the direction of your foot, but since you are inside the STM monad you can just retry until you figure out what to do. Alternatively: You shoot yorself in the foot, but you are perfectly fine as long you just don't evaluate the foot. Same, but more subtle: You shoot yourself in the foot, but nothing happens unless you start walking. cheers, Arnar From jon.fairbairn at cl.cam.ac.uk Thu Oct 2 05:27:43 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Thu Oct 2 05:24:38 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <20081001141024.04e446b6@solaris> Message-ID: Achim Schneider writes: > Jon Fairbairn wrote: > >> Adrian Neumann writes: >> >> > I often wonder how many cuts you need to divide a steak in n >> > pieces. You can obviously get n pieces with (sqrt n) cuts >> > by cutting a grid. But I'm sure some smart mathematician >> > thought of a (log n) way. >> >> Are you allowed to move the pieces between cuts? >> > Later you're also going to demand to bend it in N dimensions, aren't > you? I don't know about you, but I demand that my steaks have at least four dimensions (in particular they should be much larger in the fourth than an ?clair), but as to bending, no, to get to log n you wouldn't need that. If you allow it to be arbitrarily bendable, you can do it in one cut, except that I imagine there's an unstated requirement that all (map (( Message-ID: Benjamin L.Russell writes: >>Note: the singleton tuple does not support tuple syntax. > > What is the syntax for the singleton tuple? [...] > the singleton syntax will be different from the non-singleton syntax, > which is also syntactically inelegant. > > What is your solution? Replace () in tuple syntax with ?? (unicode 0x27e8 and 0x27e0). I always wanted Haskell to be defined in terms of an idealised syntax together with a (at the time ASCII) machine representation that approximated it. As time went by, we could gradually have made the approximation approach the ideal. It would probably have been a mistake politically, though (people would have muttered about APL). Nowadays it might be more acceptable. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2008-04-26) From jeanchristophe.mincke at gmail.com Thu Oct 2 05:46:20 2008 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Thu Oct 2 05:43:00 2008 Subject: [Haskell-cafe] A question about constraints Message-ID: Hello, Given a type T, this type identifies a set of values and this set can be deduced from the structure of type T. i.e the type String is the set of all possible lists of character whatever their length. This being said, I have the following question: Given a type T, how is it possible to further restrict its set of values? i.e, in the above case, how is it possible to define a type String2 whose elements are any list of characters whose length is <= 5. I believe the best way to deal with that is to make String2 an ADT. This allows the constraint (in this case, the length) to be checked but hides the structure of the type, thus limits the use of pattern matching (in this case I do not want to hide the implementation of the type, so the ADT is not used that way). If one wants to use pattern matching, then the module must provide a way to convert from String2 to a type whose constructors are visible (asString in this exemple) module A ( String2 ,mkString2 ,asString ) where import List data String2 = String2 String mkString2 l = if (length l) <= 5 then String2 l else error "length > 5" asString (String2 l) = l Btw, F# has found a nice solution to this problem, it allows the user to define an "active pattern", that is, a pattern to applies on ADT: http://blogs.msdn.com/dsyme/archive/2007/04/07/draft-paper-on-f-active-patterns.aspx Is there another way to address that problem in Haskell? Thank you Regards J-C Mincke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/30c40357/attachment.htm From noteed at gmail.com Thu Oct 2 05:50:58 2008 From: noteed at gmail.com (minh thu) Date: Thu Oct 2 05:47:36 2008 Subject: [Haskell-cafe] Re: Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> Message-ID: <40a414c20810020250s5d5e2a57h57ffbd16bd14b25@mail.gmail.com> 2008/10/2 Jon Fairbairn : > Benjamin L.Russell writes: > >>>Note: the singleton tuple does not support tuple syntax. >> >> What is the syntax for the singleton tuple? [...] >> the singleton syntax will be different from the non-singleton syntax, >> which is also syntactically inelegant. >> >> What is your solution? > > Replace () in tuple syntax with ?? (unicode 0x27e8 and 0x27e0). > I thought to this idea in another way : parenthesis could be used for s-expressions and ?? (unicode 0x27e8 and 0x27e0) could be used for regular grouping. This would allow to switch in the same code between infix and s-expr (e.g. enabling SXML)... Cheers, Thu From noteed at gmail.com Thu Oct 2 05:59:15 2008 From: noteed at gmail.com (minh thu) Date: Thu Oct 2 05:55:54 2008 Subject: [Haskell-cafe] A question about constraints In-Reply-To: References: Message-ID: <40a414c20810020259x1692b6b7tf3176a988688d110@mail.gmail.com> 2008/10/2 jean-christophe mincke : > Hello, > > Given a type T, this type identifies a set of values and this set can be > deduced from the structure of type T. > > i.e the type String is the set of all possible lists of character whatever > their length. > > This being said, I have the following question: > > Given a type T, how is it possible to further restrict its set of values? > i.e, in the above case, how is it possible to define a type String2 whose > elements are any list of characters whose length is <= 5. > > I believe the best way to deal with that is to make String2 an ADT. This > allows the constraint (in this case, the length) to be checked but hides the > structure of the type, thus limits the use of pattern matching (in this case > I do not want to hide the implementation of the type, so the ADT is not used > that way). > > If one wants to use pattern matching, then the module must provide a way to > convert from String2 to a type whose constructors are visible (asString in > this exemple) > > module A > ( > String2 > ,mkString2 > ,asString > ) > where > > import List > > data String2 = String2 String > > > mkString2 l = if (length l) <= 5 then String2 l > else error "length > 5" > > asString (String2 l) = l > > Btw, F# has found a nice solution to this problem, it allows the user to > define an "active pattern", that is, a pattern to applies on ADT: > > > http://blogs.msdn.com/dsyme/archive/2007/04/07/draft-paper-on-f-active-patterns.aspx > > Is there another way to address that problem in Haskell? I believe several proposal have been made to extend the current pattern matching mechanism. The author of the Fonctional Graph Library (FGL) has made one for instance. (Maybe see the proposals for Haskell') With the current mechanism, he uses instead a function that is applied in a case expression (thus on the right hand side of the definition). Cheers, Thu From bulat.ziganshin at gmail.com Thu Oct 2 06:11:23 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 2 06:09:23 2008 Subject: [Haskell-cafe] A question about constraints In-Reply-To: References: Message-ID: <1778819867.20081002141123@gmail.com> Hello jean-christophe, Thursday, October 2, 2008, 1:46:20 PM, you wrote: > If one wants to use pattern matching, afaik we had so-called views in early haskell versions. they proivide way to define two-way constructors - used for deconstruction via pattern-matching too views wa removed from haskell (or not included) in 1998 because they makes harder some theoretic operation, i don't remeber exactly finally, ghc now includes some form of active patterns which may be used to define your own way to decompose values. but their syntax isn't compatible with constructors so you can't define complex type which mimicks simple ones, and in particular you can replace simple type with complex one w/o rewriting all the client code imho it's serious lack in haskell support for Abstract Data Types -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jeremy.odonoghue at gmail.com Thu Oct 2 06:12:46 2008 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Thu Oct 2 06:09:27 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> Message-ID: <1222942366.14335.1277119993@webmail.messagingengine.com> On Tue, 30 Sep 2008 21:54:34 -0400, "Stefan Monnier" said: > > I am not allowed to use such an interpretation. The (expensive and very > > carefully researched) legal advice used to shape the use of Open Source > > code at my employer has resulted in a "no LGPL under any circumstances > > whatsoever" policy. > [...] > > That still leaves anyone free to use LGPL if they want to, but please > > don't assume that it allows commercial use by all potential users. > > It *does* allow commercial use. Your example just shows that some > people may decide not to take advantage of it, based not on problematic > restrictions but just on paranoia. The LGPL does not state that a "work that uses the library" may be distributed in conjunction with a closed source commercial program, although I grant that many (presumably including some who have actually consulted lawyers) believe that such an interpretation is reasonable. However, the policy in place in my workplace was designed by lawyers familiar with contract law in multiple jurisdictions worldwide. I may not personally agree with their conclusions in every respect, but I'd be hard pressed to consider them "paranoid" - they are simply doing their job, and have concluded that the potential risk of a court somewhere in the World taking an aggressive view of the provisions of clause 5 is unacceptable. I guess what I really mean is that if you choose LGPL as a license, some people who would like to use it in commercial products will do so, but others (who would have chosen to use the work if differently licensed) will not. Not a question of paranoia so much as corporate appetite for license risk. Regards Jeremy -- Jeremy O'Donoghue jeremy.odonoghue@gmail.com From manlio_perillo at libero.it Thu Oct 2 07:32:34 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Oct 2 07:29:23 2008 Subject: [Haskell-cafe] Climbing up the shootout... In-Reply-To: <20080922052712.GB24712@scytale.galois.com> References: <20080922052712.GB24712@scytale.galois.com> Message-ID: <48E4B152.70508@libero.it> Don Stewart ha scritto: > Thanks to those guys who've submitted parallel programs to the language > benchmarks game, we're climbing up the rankings, now in 3rd, and ahead > of C :) > > http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=all > > Just one or two more parallel programs required... > > Submit them here, and we can test on quad core, > > http://haskell.org/haskellwiki/Shootout/Parallel > There is a lot of efforts to improve CPU time, but what about memory usage? http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ghc Compared to C versions: mandelbrot requires 18x memory k-nucleotide requires 13x memory reverse-complement requires 4.9x memory The main problem is with k-nucleotide, that requires a total of 2,920,980 KB! http://shootout.alioth.debian.org/u64q/benchmark.php?test=knucleotide&lang=all&sort=kb http://shootout.alioth.debian.org/u64q/benchmark.php?test=revcomp&lang=all&sort=kb For mandelbrot there is an alternate version with better memory and CPU usage. > -- Don Manlio Perillo From ketil at malde.org Thu Oct 2 08:05:33 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 2 07:58:58 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: (Adrian Neumann's message of "Thu\, 2 Oct 2008 10\:25\:07 +0200") References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> Message-ID: <87vdwbqk1e.fsf@malde.org> Adrian Neumann writes: > Does this work with more than two colours? i.e. can I recursively > subdivide the halves into quarters with another cut? I don't think so. In order to divide a group, a line needs to pass through somewhere "in the middle", or more precisely, it must intersect the convex hull of the group. Now group each category together so that their convex hulls don't overlap. A solution with two lines and four categories would require the two lines would need to have four disjoint points of intersection. Which is too many. :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From kowey at darcs.net Thu Oct 2 08:07:52 2008 From: kowey at darcs.net (Eric Kow) Date: Thu Oct 2 08:04:35 2008 Subject: [Haskell-cafe] announcing darcs 2.1.0pre3 Message-ID: <20081002120752.GA56508@Macintosh.local> Hi everybody, The third pre-release of darcs 2.1 is now available at http://darcs.net/darcs-2.1.0pre3.tar.gz Since the last pre-release, we have resolved two of the items on our work list and a recently discovered darcs 2 bug. On the other hand, we have discovered a new regression from darcs 2.0.2 and some performance issues in our recent work for issue971. We are confident that we can resolve these within the upcoming week, but since regressions are involved, I think it might be prudent to delay the release so that we at least have one week to test these changes. At the very latest, darcs 2.1 should be released on 17 October, but I hope we will be able to get it out soon after the tenth. We are now very close to the finish line. More news in a week! Upcoming release schedule ------------------------- 2008-10-10: darcs 2.1.0pre4 2008-10-17: darcs 2.1.0 Work remaining -------------- * Backing out http://bugs.darcs.net/issue971 (Petr Ro?kai) We have observed a performance regression in the newer, more robust version of the darcs repair code and will be postponing this feature for next release. The work for this week consists of undoing the relevant changes and auditing the undo. * http://bugs.darcs.net/issue1095 Darcs sometimes crashes in darcs send. It is clear to us why the crash happens and how to fix it. The work for this week consists of creating a minimal test case for our regression testing suite and implementing the relevant changes. * http://bugs.darcs.net/issue1026 Improve the error messages for 'bug in get_extra' errors, which can happen if darcs is fooled into thinking that two patches are the same. Changes since the last pre-release ---------------------------------- * Bug Fix: Eliminate an error merging repeated conflicts in darcs-2 repositories (issue1043, David Roundy) * New Feature: Hide 'Ignore-this:' lines which will be generated by future versions of darcs to prevent patch-id collisions. (issue1102, Eric Kow, David Roundy) * Bug Fix: Support darcs repositories which have symbolic links in their paths (issue1078, Dmitry Kurochkin) * Bug Fix: Make ssh connection sharing (darcs transfer-mode) work with old-fashioned repositories (issue1003, David Roundy) -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/4f0de64a/attachment.bin From bortzmeyer at nic.fr Thu Oct 2 08:12:56 2008 From: bortzmeyer at nic.fr (Stephane Bortzmeyer) Date: Thu Oct 2 08:09:34 2008 Subject: [Haskell-cafe] Re: [Streams] Couldn't match expected type ?`Distribution.Verbosity.Verbosity' In-Reply-To: <20080925001434.GE22722@laperouse.bortzmeyer.org> References: <20080925001434.GE22722@laperouse.bortzmeyer.org> Message-ID: <20081002121256.GA4227@nic.fr> On Wed, Sep 24, 2008 at 08:14:34PM -0400, Stephane Bortzmeyer wrote a message of 34 lines which said: > I cannot compile Streams 0.1: This problem is experienced by other people: http://groups.google.com/group/fa.haskell/browse_thread/thread/bafa0006f9fb2ba7 but nobody seems to know what to do? From darrinth at gmail.com Thu Oct 2 08:26:13 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Thu Oct 2 08:22:52 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <20081001200004.GI456@scytale.galois.com> References: <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> Message-ID: On Wed, Oct 1, 2008 at 4:00 PM, Don Stewart wrote: > And keep dividing our compiler teams' efforts, while > single-implementation languages conquer :) > > Seems like Haskell has a pretty clear story about which is the right implementation for general purpose use. I don't see a Scheme problem here. -- Darrin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/a7d2aecc/attachment.htm From anton.tayanovskyy at gmail.com Thu Oct 2 08:29:44 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Thu Oct 2 08:26:21 2008 Subject: [Haskell-cafe] SCGI module Message-ID: Hello, SCGI module from Hackage is not working for me with Apache mod_scgi, I think because it uses LazyBytestring to hGetContents on a socket handle and the Apache side does not close the socket. Also, looking at the source I didn't see any fork* calls, so I assume it is not doing concurrency. So I ended up writing a replacement and would like to invite comments. It does forkIO per request and, if asked to, timeouts those threads. So far it works for me on simple examples from http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell giving roughly 800 requests a second versus 250 on plain CGI (both through Apache). http://hpaste.org/10842 Thanks! Also, in general, is there any interest in using SCGI, or FastCGI (plain CGI, HappS, you name it) is vastly superior? --Anton From lrpalmer at gmail.com Thu Oct 2 09:22:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Oct 2 09:19:31 2008 Subject: [Haskell-cafe] A question about constraints In-Reply-To: <1778819867.20081002141123@gmail.com> References: <1778819867.20081002141123@gmail.com> Message-ID: <7ca3f0160810020622t31e8d858p7664186162e8f2ee@mail.gmail.com> On Thu, Oct 2, 2008 at 4:11 AM, Bulat Ziganshin wrote: > finally, ghc now includes some form of active patterns which may be > used to define your own way to decompose values. but their syntax > isn't compatible with constructors so you can't define complex type > which mimicks simple ones, and in particular you can replace simple > type with complex one w/o rewriting all the client code > > imho it's serious lack in haskell support for Abstract Data Types Not that this hasn't probably been discussed at length elsewhere, I wholeheartedly agree. The ability to mimic a simple type with a complex one is precisely what moves views from "syntax sugar", which does little more than to make code easier on the eyes, into a proper abstraction mechanism that actually adds engineering value. Luke From leimy2k at gmail.com Thu Oct 2 09:30:24 2008 From: leimy2k at gmail.com (David Leimbach) Date: Thu Oct 2 09:27:03 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <1222942366.14335.1277119993@webmail.messagingengine.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <1222942366.14335.1277119993@webmail.messagingengine.com> Message-ID: <3e1162e60810020630p3236ee5etfaa9c31bcab2e623@mail.gmail.com> On Thu, Oct 2, 2008 at 3:12 AM, Jeremy O'Donoghue < jeremy.odonoghue@gmail.com> wrote: > > On Tue, 30 Sep 2008 21:54:34 -0400, "Stefan Monnier" > said: > > > I am not allowed to use such an interpretation. The (expensive and very > > > carefully researched) legal advice used to shape the use of Open Source > > > code at my employer has resulted in a "no LGPL under any circumstances > > > whatsoever" policy. > > [...] > > > That still leaves anyone free to use LGPL if they want to, but please > > > don't assume that it allows commercial use by all potential users. > > > > It *does* allow commercial use. Your example just shows that some > > people may decide not to take advantage of it, based not on problematic > > restrictions but just on paranoia. > > The LGPL does not state that a "work that uses the library" may be > distributed > in conjunction with a closed source commercial program, although I grant > that > many (presumably including some who have actually consulted lawyers) > believe > that such an interpretation is reasonable. I believe the LGPL states that mere aggregation doesn't indicate derivative works. In fact commercial video games have been distributed for linux that used the SDL library that I used to work with myself in a former life. So I think we should all speak to our lawyers before assuming how it can be used. The GPL and LGPL are needlessly difficult for mere mortals to understand in their entirety, and as you've alluded to, many lawyers would interpret it differently. I suspect many different judges would too. > > > However, the policy in place in my workplace was designed by lawyers > familiar > with contract law in multiple jurisdictions worldwide. I may not > personally > agree with their conclusions in every respect, but I'd be hard pressed > to > consider them "paranoid" - they are simply doing their job, and have > concluded > that the potential risk of a court somewhere in the World taking an > aggressive > view of the provisions of clause 5 is unacceptable. > > I guess what I really mean is that if you choose LGPL as a license, some > people > who would like to use it in commercial products will do so, but others > (who would > have chosen to use the work if differently licensed) will not. Not a > question of > paranoia so much as corporate appetite for license risk. Yes, there's enough anti-GPL or GPL derived momentum in many places that I must say that using the LGPL or GPL would be highly frowned upon at my workplace as well. That said, I'm a huge fan of apache, BSD, MIT and Perl's licenses :-) > > > Regards > Jeremy > -- > Jeremy O'Donoghue > jeremy.odonoghue@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/88c98635/attachment.htm From leimy2k at gmail.com Thu Oct 2 09:31:42 2008 From: leimy2k at gmail.com (David Leimbach) Date: Thu Oct 2 09:28:20 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <20081001200004.GI456@scytale.galois.com> Message-ID: <3e1162e60810020631g6de1d8dajdfab8b1b615c062b@mail.gmail.com> 2008/10/2 Darrin Thompson > On Wed, Oct 1, 2008 at 4:00 PM, Don Stewart wrote: > >> And keep dividing our compiler teams' efforts, while >> single-implementation languages conquer :) >> >> > Seems like Haskell has a pretty clear story about which is the right > implementation for general purpose use. I don't see a Scheme problem here. > Just make Haskell more difficult to implement than Scheme and you've preemptively avoided that problem :-) > > > -- > Darrin > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/f3992871/attachment.htm From jwlato at gmail.com Thu Oct 2 09:50:49 2008 From: jwlato at gmail.com (John Lato) Date: Thu Oct 2 09:47:27 2008 Subject: [Haskell-cafe] enumeration I/O and non-sequential access Message-ID: <9979e72e0810020650l43d5f775ka7d97836e6096d3f@mail.gmail.com> Hello, I've recently been looking at Oleg's Iteratee approach to I/O (http://okmij.org/ftp/Haskell/Iteratee/), and I was wondering about something. In general this seems to be a very good approach to handling sequential access, but I don't see a means of applying it where non-sequential (esp. random) access is desired. In fact, the only way I see of doing so is to either hold references to all read data in memory until the file has finished processing, or to iterate over the file multiple times, depending on how the data is to be processed. I can't see how either of these approaches would scale well. Is this an actual problem? Is there already a solution that I'm not aware of? Thanks, John Lato From marlowsd at gmail.com Thu Oct 2 10:09:50 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Oct 2 10:06:31 2008 Subject: [Haskell-cafe] Re: System.Process In-Reply-To: <48E13158.1050502@btinternet.com> References: <48E13158.1050502@btinternet.com> Message-ID: <48E4D62E.60303@gmail.com> Andrew Coppin wrote: > Anyway, the point I'm trying to get to is... would it be hard for > however maintains this library to add a little more flexibility in what > it can do please? In the new System.Process, that comes with GHC 6.10.1: Prelude System.Process> createProcess (shell "echo $FOO"){ env = Just [("FOO","BAR")] } Prelude System.Process> BAR Cheers, Simon From anton.tayanovskyy at gmail.com Thu Oct 2 10:37:49 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Thu Oct 2 10:34:26 2008 Subject: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues Message-ID: Hello, I had some difficulty building hsql and hsql-mysql (native driver) packages under GHC 8.3 on Fedora 9. Namely, they do not install with cabal install, because of a few API changes. Is this considered all right as GHC 8.3 is still experimental, or should the packages be updated? If so, can somebody please do it. I love when things just work with cabal install! The problem looks very basic -- just some Cabal file incompatibilities. However I am not experienced with the Cabal build process, so I'll just write what I did to get it to work on my platform, maybe it will help someone. == hsql.cabal == name: hsql version: 1.7 license: BSD3 author: Krasimir Angelov category: Database description: Simple library for database access from Haskell. exposed-modules: Database.HSQL, Database.HSQL.Types build-depends: base, old-time build-type: Simple ghc-options: -O2 extensions: ForeignFunctionInterface, TypeSynonymInstances, CPP, RankNTypes, DeriveDataTypeable == hsql-mysql.cabal == name: hsql-mysql version: 1.7 license: BSD3 author: Krasimir Angelov category: Database description: MySQL driver for HSQL. ghc-options: -O2 build-depends: base, hsql, Cabal, old-time extensions: ForeignFunctionInterface, CPP include-dirs: Database/HSQL, /usr/include/mysql build-type: Simple extra-source-files: Database/HSQL/HsMySQL.h extra-libraries: mysqlclient extra-lib-dirs: /usr/lib/mysql exposed-modules: Database.HSQL.MySQL == hsql-mysql*/Setup.lhs == #!/usr/bin/runghc \begin{code} import Distribution.Simple main = defaultMain \end{code} Of course this hsql-mysql.cabal should not mention Fedora-specific locations as /usr/lib/mysql and /usr/include/mysql but I don't know how to make that generic. The original version had a big custom Setup.lhs file which wouldn't compile with the new Cabal and which I couldn't tweak myself. Thanks, --A From marcot at riseup.net Thu Oct 2 09:27:25 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Thu Oct 2 10:49:54 2008 Subject: [Haskell-cafe] csv one-liner In-Reply-To: <42784f260810011859m6b07e1f2u8cf95ba2262033d9@mail.gmail.com> References: <48E3D4B0.5030801@btinternet.com> <1222911995.7567.1.camel@quindinho.domain.invalid> <42784f260810011859m6b07e1f2u8cf95ba2262033d9@mail.gmail.com> Message-ID: <1222954045.3558.9.camel@quindinho.domain.invalid> Op woensdag 01-10-2008 om 18:59 uur [tijdzone -0700], schreef Jason Dusek: > Reply to all? No. Reply-to-list is a different thing. When you reply-to-all to a person who is in the list, the person gets two copies of the e-mail with different headers, which messes with filters and replies. Greetings. -- marcot P?gina: http://marcotmarcot.iaaeee.org/ Blog: http://marcotmarcot.blogspot.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From trebla at vex.net Thu Oct 2 11:11:04 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu Oct 2 11:07:44 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <48E4E488.2030300@vex.net> Don't forget about memory consumption! If you don't look, the bullet causes heap overflow. If you look, the bullet causes stack overflow. From pkeir at dcs.gla.ac.uk Thu Oct 2 11:20:18 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Oct 2 11:16:56 2008 Subject: [Haskell-cafe] One liner? Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> Hi all, There's a common little situation I keep bumping up against. I don't understand where I'm going wrong, so I've made a little example. It's to do with binding a result to a variable name using "<-". This code works fine: ---------------------------------------------- module Main where import System.Directory (getDirectoryContents) main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc ---------------------------------------------- But if I try to avoid the use of the bind to "dc", I fail: ---------------------------------------------- mapM_ putStrLn (getDirectoryContents "./foo/") ---------------------------------------------- I've tried using map instead of mapM_, and inserted "return"s here and there, but no luck. Can anyone tell me where and why I'm going wrong? The error message is below. Cheers, Paul Couldn't match expected type `[String]' against inferred type `IO [FilePath]' In the second argument of `mapM_', namely `(getDirectoryContents "./foo/")' In the expression: mapM_ putStrLn (getDirectoryContents "./foo/") In the definition of `main': main = mapM_ putStrLn (getDirectoryContents "./foo/") -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/fb315acc/attachment.htm From arnarbi at gmail.com Thu Oct 2 11:25:25 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 2 11:22:04 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <48E4E488.2030300@vex.net> References: <48E4E488.2030300@vex.net> Message-ID: <28012bc60810020825g79c00c08o8c3bd2a5405321d8@mail.gmail.com> On Thu, Oct 2, 2008 at 17:11, Albert Y. C. Lai wrote: > Don't forget about memory consumption! > > If you don't look, the bullet causes heap overflow. If you look, the bullet > causes stack overflow. So it is a Heisenberg-bullet? Arnar From neil.mitchell.2 at credit-suisse.com Thu Oct 2 11:26:23 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Thu Oct 2 11:24:19 2008 Subject: [Haskell-cafe] One liner? In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> Hi You can translate this step by step. main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc Translating out the do notation (http://www.haskell.org/haskellwiki/Keywords#do): main = getDirectoryContents >>= \dc -> mapM_ putStrLn dc Then we can chop out the dc argument, as its \x -> .... x, and can be removed (eta reduction): main = getDirectoryContents >>= mapM_ putStrLn And finally we just remove the newline: main = getDirectoryContents >>= mapM_ putStrLn Alternatively, we can flip the >>= for =<< and write: main = mapM_ putStrLn =<< getDirectoryContents This is now one line, and mirrors how you would write the function if it was pure using function composition. Thanks Neil This material is sales and trading commentary and does not constitute investment research. Please follow the attached hyperlink to an important disclaimer > ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Paul Keir Sent: 02 October 2008 4:20 pm To: haskell-cafe@haskell.org Subject: [Haskell-cafe] One liner? Hi all, There's a common little situation I keep bumping up against. I don't understand where I'm going wrong, so I've made a little example. It's to do with binding a result to a variable name using "<-". This code works fine: ---------------------------------------------- module Main where import System.Directory (getDirectoryContents) main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc ---------------------------------------------- But if I try to avoid the use of the bind to "dc", I fail: ---------------------------------------------- mapM_ putStrLn (getDirectoryContents "./foo/") ---------------------------------------------- I've tried using map instead of mapM_, and inserted "return"s here and there, but no luck. Can anyone tell me where and why I'm going wrong? The error message is below. Cheers, Paul Couldn't match expected type `[String]' against inferred type `IO [FilePath]' In the second argument of `mapM_', namely `(getDirectoryContents "./foo/")' In the expression: mapM_ putStrLn (getDirectoryContents "./foo/") In the definition of `main': main = mapM_ putStrLn (getDirectoryContents "./foo/") ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From johan.tibell at gmail.com Thu Oct 2 11:28:07 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu Oct 2 11:24:45 2008 Subject: [Haskell-cafe] enumeration I/O and non-sequential access In-Reply-To: <9979e72e0810020650l43d5f775ka7d97836e6096d3f@mail.gmail.com> References: <9979e72e0810020650l43d5f775ka7d97836e6096d3f@mail.gmail.com> Message-ID: <90889fe70810020828o37a642easd3bd0108614dc330@mail.gmail.com> On Thu, Oct 2, 2008 at 3:50 PM, John Lato wrote: > Hello, > > I've recently been looking at Oleg's Iteratee approach to I/O > (http://okmij.org/ftp/Haskell/Iteratee/), and I was wondering about > something. In general this seems to be a very good approach to > handling sequential access, but I don't see a means of applying it > where non-sequential (esp. random) access is desired. In fact, the > only way I see of doing so is to either hold references to all read > data in memory until the file has finished processing, or to iterate > over the file multiple times, depending on how the data is to be > processed. I can't see how either of these approaches would scale > well. Is this an actual problem? Is there already a solution that > I'm not aware of? You could have the iteratee return the next position in the file it would like to operate on. The enumerator would use e.g. `pread` to perform random access reads in constant memory. I would have to know a little more about your use case before I can say if this would be a good idea or not. Cheers, Johan From Malcolm.Wallace at cs.york.ac.uk Thu Oct 2 11:16:46 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Thu Oct 2 11:25:12 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <3e1162e60810020630p3236ee5etfaa9c31bcab2e623@mail.gmail.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <1222942366.14335.1277119993@webmail.messagingengine.com> <3e1162e60810020630p3236ee5etfaa9c31bcab2e623@mail.gmail.com> Message-ID: <20081002161646.3e993d14.Malcolm.Wallace@cs.york.ac.uk> > The GPL and LGPL are needlessly difficult for mere > mortals to understand in their entirety, and as you've alluded to, > many lawyers would interpret it differently. I suspect many different > judges would too. I think the evidence is rather to the contrary. Most lawsuits involving the GPL are settled out of court, precisely because the lawyers for the violating party tend to realise they have no leg to stand on. Of those few cases which have made it to court, the judge has always decided in favour of the GPL. That is, the GPL is as solid a guarantee of code freedom as you could wish for. The lesson, from the point of view of an entity that wants to distribute non-free code but making use of some free code, is simply to play nicely with the community whose work you are using gratis. Keeping to the original authors' intent is ultimately cheaper than either writing your own replacement code, or paying lawyers to fight it out. In addition, if you want legal certainty , most GPL authors would probably be happy to assign you a separate non-exclusive commercial license, in return for a small payment or royalty agreement. Regards, Malcolm From aspam at cox.net Thu Oct 2 11:32:04 2008 From: aspam at cox.net (Joe Buehler) Date: Thu Oct 2 11:28:27 2008 Subject: [Haskell-cafe] Re: Shooting your self in the foot with Haskell In-Reply-To: <28012bc60810020825g79c00c08o8c3bd2a5405321d8@mail.gmail.com> References: <48E4E488.2030300@vex.net> <28012bc60810020825g79c00c08o8c3bd2a5405321d8@mail.gmail.com> Message-ID: Arnar Birgisson wrote: > So it is a Heisenberg-bullet? I'm uncertain. -- Joe Buehler From ketil at malde.org Thu Oct 2 11:35:13 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Oct 2 11:28:36 2008 Subject: [Haskell-cafe] One liner? In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> (Paul Keir's message of "Thu\, 2 Oct 2008 16\:20\:18 +0100") References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> Message-ID: <87bpy3qaby.fsf@malde.org> "Paul Keir" writes: > module Main where > > import System.Directory (getDirectoryContents) > > main = do dc <- getDirectoryContents "./foo/" > mapM_ putStrLn dc > mapM_ putStrLn (getDirectoryContents "./foo/") > Couldn't match expected type `[String]' "mapM_ putStrLn" needs a "[String]" as an argument, > against inferred type `IO [FilePath]' but you try to give it an "IO [FilePath]" (i.e. IO [String]). As you probably know, do-notation is syntactic sugar for the monad operators, and you can rewrite your function thusly: main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc => main = getDirectoryContents "./foo" >>= \dc -> mapM_ putStrLn dc => main = getDirectoryContents "./foo" >>= mapM_ putStrLn -k -- If I haven't seen further, it is by standing in the footprints of giants From trebla at vex.net Thu Oct 2 11:33:02 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu Oct 2 11:29:41 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <20081001230518.ko8o7e158oog0co8-nwo@webmail.spamcop.net> References: <48E12FF9.7020301@btinternet.com> <479DC903-3CE2-4B69-96EE-532B6B7A15C9@inf.fu-berlin.de> <20081001230518.ko8o7e158oog0co8-nwo@webmail.spamcop.net> Message-ID: <48E4E9AE.3030202@vex.net> ajb@spamcop.net wrote: > One, if the cut is allowed to be curved and self-intersecting. Crouching Tiger, Hidden Dragon? Kill Bill? From neil.mitchell.2 at credit-suisse.com Thu Oct 2 11:35:14 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Thu Oct 2 11:36:03 2008 Subject: [Haskell-cafe] One liner? In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3A80@ELON17P32001A.csfb.cs-group.com> > main = do dc <- getDirectoryContents "./foo/" > mapM_ putStrLn dc > > Translating out the do notation > (http://www.haskell.org/haskellwiki/Keywords#do): > > main = getDirectoryContents >>= \dc -> > mapM_ putStrLn dc Woops, I lost "./foo/" here, but it should be fairly easy to insert through the remaining translations. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From pkeir at dcs.gla.ac.uk Thu Oct 2 11:43:18 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Oct 2 11:42:47 2008 Subject: [Haskell-cafe] One liner? References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCAA7@EX2.ad.dcs.gla.ac.uk> Thanks, and to Ketil too. I did see past the missing "./foo/". That's certainly a solution I'm happy with, and I didn't know the term eta reduction, so thanks for that too. Paul -----Original Message----- From: Mitchell, Neil [mailto:neil.mitchell.2@credit-suisse.com] Sent: Thu 02/10/2008 16:26 To: Paul Keir; haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] One liner? Hi You can translate this step by step. main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc Translating out the do notation (http://www.haskell.org/haskellwiki/Keywords#do): main = getDirectoryContents >>= \dc -> mapM_ putStrLn dc Then we can chop out the dc argument, as its \x -> .... x, and can be removed (eta reduction): main = getDirectoryContents >>= mapM_ putStrLn And finally we just remove the newline: main = getDirectoryContents >>= mapM_ putStrLn Alternatively, we can flip the >>= for =<< and write: main = mapM_ putStrLn =<< getDirectoryContents This is now one line, and mirrors how you would write the function if it was pure using function composition. Thanks Neil This material is sales and trading commentary and does not constitute investment research. Please follow the attached hyperlink to an important disclaimer > ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Paul Keir Sent: 02 October 2008 4:20 pm To: haskell-cafe@haskell.org Subject: [Haskell-cafe] One liner? Hi all, There's a common little situation I keep bumping up against. I don't understand where I'm going wrong, so I've made a little example. It's to do with binding a result to a variable name using "<-". This code works fine: ---------------------------------------------- module Main where import System.Directory (getDirectoryContents) main = do dc <- getDirectoryContents "./foo/" mapM_ putStrLn dc ---------------------------------------------- But if I try to avoid the use of the bind to "dc", I fail: ---------------------------------------------- mapM_ putStrLn (getDirectoryContents "./foo/") ---------------------------------------------- I've tried using map instead of mapM_, and inserted "return"s here and there, but no luck. Can anyone tell me where and why I'm going wrong? The error message is below. Cheers, Paul Couldn't match expected type `[String]' against inferred type `IO [FilePath]' In the second argument of `mapM_', namely `(getDirectoryContents "./foo/")' In the expression: mapM_ putStrLn (getDirectoryContents "./foo/") In the definition of `main': main = mapM_ putStrLn (getDirectoryContents "./foo/") ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/6e64efd6/attachment.htm From bulat.ziganshin at gmail.com Thu Oct 2 11:37:14 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 2 11:46:43 2008 Subject: [Haskell-cafe] One liner? In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA4@EX2.ad.dcs.gla.ac.uk> <33A3F585590A6F4E81E3D45AA4A111C902CD3A7F@ELON17P32001A.csfb.cs-group.com> Message-ID: <619073995.20081002193714@gmail.com> Hello Neil, Thursday, October 2, 2008, 7:26:23 PM, you wrote: shortly speaking, getDirectoryContents is an action (having "IO a" type) while second mapM_ argument should be a value returned by this action. by using dc variable or >>= operator, you can evaluate action and pass its result to mapM_. of course, after imperative languages experience, it's hard to see difference. take look at http://haskell.org/haskellwiki/IO_inside > Hi > > You can translate this step by step. > > main = do dc <- getDirectoryContents "./foo/" > mapM_ putStrLn dc > Translating out the do notation > (http://www.haskell.org/haskellwiki/Keywords#do): > main = getDirectoryContents >>= \dc -> > mapM_ putStrLn dc > Then we can chop out the dc argument, as its \x -> .... x, and can be > removed (eta reduction): > main = getDirectoryContents >>= > mapM_ putStrLn > And finally we just remove the newline: > main = getDirectoryContents >>= mapM_ putStrLn > Alternatively, we can flip the >>= for =<< and write: > main = mapM_ putStrLn =<< getDirectoryContents > This is now one line, and mirrors how you would write the function if it > was pure using function composition. > Thanks > Neil > > This material is sales and trading commentary and does not constitute > investment research. Please follow the attached hyperlink to an > important disclaimer > > > > ________________________________ > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Paul Keir > Sent: 02 October 2008 4:20 pm > To: haskell-cafe@haskell.org > Subject: [Haskell-cafe] One liner? > > > Hi all, > > There's a common little situation I keep bumping up against. I > don't understand where I'm going wrong, so I've made a little example. > It's to do with binding a result to a variable name using "<-". This > code works fine: > > ---------------------------------------------- > module Main where > > import System.Directory (getDirectoryContents) > > main = do dc <- getDirectoryContents "./foo/" > mapM_ putStrLn dc > ---------------------------------------------- > > But if I try to avoid the use of the bind to "dc", I fail: > > ---------------------------------------------- > mapM_ putStrLn (getDirectoryContents "./foo/") > ---------------------------------------------- > > I've tried using map instead of mapM_, and inserted "return"s > here and there, but no luck. Can anyone tell me where and why I'm going > wrong? The error message is below. > > Cheers, > Paul > > > Couldn't match expected type `[String]' > against inferred type `IO [FilePath]' > In the second argument of `mapM_', namely > `(getDirectoryContents "./foo/")' > In the expression: mapM_ putStrLn (getDirectoryContents > "./foo/") > In the definition of `main': > main = mapM_ putStrLn (getDirectoryContents "./foo/") > > ============================================================================== > Please access the attached hyperlink for an important electronic communications disclaimer: > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > ============================================================================== > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jwlato at gmail.com Thu Oct 2 11:51:38 2008 From: jwlato at gmail.com (John Lato) Date: Thu Oct 2 11:48:26 2008 Subject: [Haskell-cafe] enumeration I/O and non-sequential access In-Reply-To: <90889fe70810020828o37a642easd3bd0108614dc330@mail.gmail.com> References: <9979e72e0810020650l43d5f775ka7d97836e6096d3f@mail.gmail.com> <90889fe70810020828o37a642easd3bd0108614dc330@mail.gmail.com> Message-ID: <9979e72e0810020851m5dd079a3k61ad1f85e2e1351c@mail.gmail.com> On Thu, Oct 2, 2008 at 4:28 PM, Johan Tibell wrote: > On Thu, Oct 2, 2008 at 3:50 PM, John Lato wrote: >> Hello, >> >> I've recently been looking at Oleg's Iteratee approach to I/O >> (http://okmij.org/ftp/Haskell/Iteratee/), and I was wondering about >> something. In general this seems to be a very good approach to >> handling sequential access, but I don't see a means of applying it >> where non-sequential (esp. random) access is desired. In fact, the >> only way I see of doing so is to either hold references to all read >> data in memory until the file has finished processing, or to iterate >> over the file multiple times, depending on how the data is to be >> processed. I can't see how either of these approaches would scale >> well. Is this an actual problem? Is there already a solution that >> I'm not aware of? > > You could have the iteratee return the next position in the file it > would like to operate on. The enumerator would use e.g. `pread` to > perform random access reads in constant memory. I would have to know a > little more about your use case before I can say if this would be a > good idea or not. > > Cheers, > > Johan > Well, I feel a little stupid now, because that seems pretty obvious in retrospect. I don't have a particular use case in mind other than a generic "algorithm that requires random access to a file." In fact, for a lot of cases other than true random access, I can think of better approaches (often interleaving multiple enumerators). Thanks, John From dons at galois.com Thu Oct 2 12:06:34 2008 From: dons at galois.com (Don Stewart) Date: Thu Oct 2 12:03:08 2008 Subject: [Haskell-cafe] Climbing up the shootout... In-Reply-To: <48E4B152.70508@libero.it> References: <20080922052712.GB24712@scytale.galois.com> <48E4B152.70508@libero.it> Message-ID: <20081002160634.GA4485@scytale.galois.com> manlio_perillo: > Don Stewart ha scritto: > >Thanks to those guys who've submitted parallel programs to the language > >benchmarks game, we're climbing up the rankings, now in 3rd, and ahead > >of C :) > > > > http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=all > > > >Just one or two more parallel programs required... > > > >Submit them here, and we can test on quad core, > > > > http://haskell.org/haskellwiki/Shootout/Parallel > > > > There is a lot of efforts to improve CPU time, but what about memory usage? > > http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ghc No one is looking at memory at the moment, as the parallel/multicore profiler isn't working in 6.8.2. -- Don From ryani.spam at gmail.com Thu Oct 2 12:49:07 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 2 12:45:45 2008 Subject: [Haskell-cafe] Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> Message-ID: <2f9b2d30810020949l464d9ba9pdc4cecac9d41d341@mail.gmail.com> It seems like if your primitive operation is "break bar in two" you need exactly n-1 breaks to get n squares, no matter what choice you make for where to break along the chocolate grid. This is a simple consequence of the fact that each break increases the number of pieces by one. If you're allowed to hold multiple pieces in your hand when you do the break it's different. Then you need a model of how the hands hold the chocolate. I think there is a problem when the breaks get complicated, as if you have to hold the pieces for too long while setting up the break, some of the chocolate will melt onto your fingers. -- ryan On Tue, Sep 30, 2008 at 12:56 AM, apfelmus wrote: > Andrew Coppin wrote: >> The other day, I sat down to eat a 2 Kg block of chocolate - one of >> those ones that's divided into lots of little squares. I proceeded to >> recursively subdivide it into smaller and smaller blocks, and then eat >> the individual squares in depth-first order. It was only after getting >> through 16 of the things that I stopped to notice that the whole bar >> just happens to have an exact power of two squares on it. >> >> And it was some time after *that* when I thought to myself "...woah, >> maybe do too much Haskell?" o_O >> >> Seriously, who recursively subdivides their food? I think I have >> something wrong with me... > > A much more important question is: how many "break bar in two" > operations did you perform? Can you do it with less? > > > Regards, > apfelmus > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Thu Oct 2 12:57:46 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 12:54:20 2008 Subject: [Haskell-cafe] Re: System.Process In-Reply-To: <48E4D62E.60303@gmail.com> References: <48E13158.1050502@btinternet.com> <48E4D62E.60303@gmail.com> Message-ID: <48E4FD8A.3010903@btinternet.com> Simon Marlow wrote: > Andrew Coppin wrote: > >> Anyway, the point I'm trying to get to is... would it be hard for >> however maintains this library to add a little more flexibility in >> what it can do please? > > In the new System.Process, that comes with GHC 6.10.1: > > Prelude System.Process> createProcess (shell "echo $FOO"){ env = Just > [("FOO","BAR")] } > Prelude System.Process> BAR Ah, cool. So it's already in hand then... From andrewcoppin at btinternet.com Thu Oct 2 13:00:04 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 12:56:39 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <48E4FE14.7020007@btinternet.com> John Van Enk wrote: > There's the well known "How to shoot your self in the foot" list which > I have it printed and taped on my desk at work. > > http://www-users.cs.york.ac.uk/susan/joke/foot.htm > > I had a co-worker ask me how you'd shoot your self in the foot with > Haskell. The interesting thing about Haskell is: You *appear* to have deliberately shot yourself in the foot, and yet your program actually runs perfectly OK due to lazy evaluation. (So long as you remember to not look at your foot...) From andrewcoppin at btinternet.com Thu Oct 2 13:18:19 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 13:14:52 2008 Subject: [Haskell-cafe] Stacking monads Message-ID: <48E5025B.1040908@btinternet.com> Consider the following beautiful code: run :: State -> Foo -> ResultSet State run_and :: State -> Foo -> Foo -> ResultSet State run_and s0 x y = do s1 <- run s0 x s2 <- run s1 y return s2 run_or :: State -> Foo -> Foo -> ResultSet State run_or s0 x y = merge (run s0 x) (run s0 y) That works great. Unfortunately, I made some alterations to the functionallity the program has, and now it is actually possible for 'run' to fail. When this happens, a problem should be reported to the user. (By "user" I mean "the person running my compiled application".) After an insane amount of time making my head hurt, I disocvered that the type "Either ErrorType (ResultSet State)" is actually a monad. (Or rather, a monad within a monad.) Unfortunately, this causes some pretty serious problems: run :: State -> Foo -> Either ErrorType (ResultSet State) run_or :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) run_or s0 x y = do rset1 <- run s0 x rset2 <- run s1 y return (merge rset1 rset2) run_and :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) run_and s0 x y = run s0 x >>= \rset1 -> rset1 >>= \s1 -> run s1 y The 'run_or' function isn't too bad. However, after about an hour of trying, I cannot construct any definition for 'run_and' which actually typechecks. The type signature for (>>=) requires that the result monad matches the source monad, and there is no way for me to implement this. Since ResultSet *just happens* to also be in Functor, I can get as far as run_and s0 x y = run s0 x >>= \rset1 -> fmap (\s1 -> run s1 y) rset1 but that still leaves me with a value of type ResultSet (Either ErrorType (ResultSet State)) and no obvious way to fix this. At this point I am sorely tempted to just change ResultSet to include the error functionallity I need. However, ResultSet is *already* an extremely complicated monad that took me weeks to get working correctly... I'd really prefer to just layer error handling on the top. But I just can't get it to work right. It's soooo fiddly untangling the multiple monads to try to *do* any useful work. Does anybody have any idea how this whole monad stacking craziness is *supposed* to work? From manlio_perillo at libero.it Thu Oct 2 13:37:38 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Oct 2 13:34:42 2008 Subject: [Haskell-cafe] Climbing up the shootout... In-Reply-To: <20081002160634.GA4485@scytale.galois.com> References: <20080922052712.GB24712@scytale.galois.com> <48E4B152.70508@libero.it> <20081002160634.GA4485@scytale.galois.com> Message-ID: <48E506E2.8030009@libero.it> Don Stewart ha scritto: > [...] >> There is a lot of efforts to improve CPU time, but what about memory usage? >> >> http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ghc > > No one is looking at memory at the moment, as the parallel/multicore > profiler isn't working in 6.8.2. > But the k-nucleotide application don't make use of concurrent or parallel features... > -- Don > Manlio Perillo From jonathanccast at fastmail.fm Thu Oct 2 13:55:23 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Oct 2 13:58:51 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5025B.1040908@btinternet.com> References: <48E5025B.1040908@btinternet.com> Message-ID: <1222970123.21944.27.camel@jcchost> On Thu, 2008-10-02 at 18:18 +0100, Andrew Coppin wrote: > Consider the following beautiful code: > > run :: State -> Foo -> ResultSet State > > run_and :: State -> Foo -> Foo -> ResultSet State > run_and s0 x y = do > s1 <- run s0 x > s2 <- run s1 y > return s2 > > run_or :: State -> Foo -> Foo -> ResultSet State > run_or s0 x y = merge (run s0 x) (run s0 y) > > That works great. Unfortunately, I made some alterations to the > functionallity the program has, and now it is actually possible for > 'run' to fail. When this happens, a problem should be reported to the > user. (By "user" I mean "the person running my compiled application".) > After an insane amount of time making my head hurt, I disocvered that > the type "Either ErrorType (ResultSet State)" is actually a monad. It's a monad if you can write a function join :: Either ErrorType (ResultSet (Either ErrorType (ResultSet alpha))) -> Either ErrorType (ResultSet alpha) (which follows from being able to write a function interleave :: Either ErrorType (ResultSet alpha) -> ResultSet (Either ErrorType alpha) satisfying certain laws). Otherwise not, as you noticed. > (Or > rather, a monad within a monad.) Unfortunately, this causes some pretty > serious problems: > > run :: State -> Foo -> Either ErrorType (ResultSet State) > > run_or :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) > run_or s0 x y = do > rset1 <- run s0 x > rset2 <- run s1 y > return (merge rset1 rset2) > > run_and :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) > run_and s0 x y = run s0 x >>= \rset1 -> rset1 >>= \s1 -> run s1 y > > The 'run_or' function isn't too bad. However, after about an hour of > trying, I cannot construct any definition for 'run_and' which actually > typechecks. The type signature for (>>=) requires that the result monad > matches the source monad, and there is no way for me to implement this. > Since ResultSet *just happens* to also be in Functor, It doesn't just happen to be one. liftM is *always* a law-abiding definition for fmap, when used at a law-abiding monad. (This is why posters here are always bringing up head-hurting category theory, btw. Absorbing it sufficiently actually teaches you useful things about Haskell programming.) > I can get as far as > > run_and s0 x y = run s0 x >>= \rset1 -> fmap (\s1 -> run s1 y) rset1 > > but that still leaves me with a value of type ResultSet (Either > ErrorType (ResultSet State)) and no obvious way to fix this. > At this point I am sorely tempted to just change ResultSet to include > the error functionallity I need. However, ResultSet is *already* an > extremely complicated monad that took me weeks to get working > correctly... What does it look like? Quite possibly it can be factored out into smaller pieces using monad transformers. (In which case adding error handling is just sticking in another transformer at the right layer in the stack --- that is, the layer where adding error handling works :). > I'd really prefer to just layer error handling on the top. > But I just can't get it to work right. It's soooo fiddly untangling the > multiple monads to try to *do* any useful work. > > Does anybody have any idea how this whole monad stacking craziness is > *supposed* to work? No. [1] But we know how it *can* work; this is what monad transformers exist to do. You want to either change ResultSet to be a monad transformer, (which can admittedly be a major re-factoring, depending on what exactly ResultSet is doing --- compare http://haskell.org/haskellwiki/ListT_done_right to regular lists), or you want the monad ErrorT ErrorType ResultSet. Very little can be said in general without knowing what ResultSet looks like. jcc [1] I've seen plenty of things that *claim* to be a general solution, but they all seem to boil down to re-implementing everything in terms of State (or State + Cont). I'm not satisfied that's actually the right way to solve these issues. From rwbarton at math.harvard.edu Thu Oct 2 14:02:46 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Thu Oct 2 13:59:37 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5025B.1040908@btinternet.com> References: <48E5025B.1040908@btinternet.com> Message-ID: <20081002180246.GA21590@rwbarton.mit.edu> On Thu, Oct 02, 2008 at 06:18:19PM +0100, Andrew Coppin wrote: > run :: State -> Foo -> Either ErrorType (ResultSet State) > > run_and :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) > {- some Either-ified version of > run_and :: State -> Foo -> Foo -> ResultSet State > run_and s0 x y = do > s1 <- run s0 x > s2 <- run s1 y > return s2 > -} I'll assume for simplicity and concreteness that ResultSet = []. > The 'run_or' function isn't too bad. However, after about an hour of > trying, I cannot construct any definition for 'run_and' which actually > typechecks. The type signature for (>>=) requires that the result monad > matches the source monad, and there is no way for me to implement this. That's right. The type mismatches are telling you that there's a situation you haven't thought about, or at least, haven't told us how you want to handle. Suppose run s0 x = Right [s1a, s1b, s1c] and run s1a y = Left err, run s1b = Right [s2], run s1c = Left err'. What should the overall result of run_and s0 x y be? Somehow you have to choose whether it's a Left or a Right, and which error to report in the former case. For the [] monad, there is a natural way to make this choice: it's encoded in the function sequence :: Monad m => [m a] -> m [a], where in this setting m = Either ErrorType. For your problem, it would probably be a good start to write an instance of Traversable for the ResultSet monad. In general, one way to make the composition of two monads m and n into a monad is to write a function n (m a) -> m (n a); this is the sequence method of a Traversable instance for n. Then you can write join :: m (n (m (n a))) -> m (n a) as m (n (m (n a))) --- fmap sequence ---> m (m (n (n a))) ------ join ---------> m (n (n a)) ------ join ---------> m (n a). Regards, Reid Barton From dave at zednenem.com Thu Oct 2 14:11:44 2008 From: dave at zednenem.com (David Menendez) Date: Thu Oct 2 14:08:23 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5025B.1040908@btinternet.com> References: <48E5025B.1040908@btinternet.com> Message-ID: <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> On Thu, Oct 2, 2008 at 1:18 PM, Andrew Coppin wrote: > > At this point I am sorely tempted to just change ResultSet to include the > error functionallity I need. However, ResultSet is *already* an extremely > complicated monad that took me weeks to get working correctly... I'd really > prefer to just layer error handling on the top. But I just can't get it to > work right. It's soooo fiddly untangling the multiple monads to try to *do* > any useful work. > > Does anybody have any idea how this whole monad stacking craziness is > *supposed* to work? In general, monads don't compose. That is, there's no foolproof way to take two monads m1 and m2 and create a third monad m3 which does everything m1 and m2 does. People mostly get around that by using monad transformers. You could try using an exception monad transformer here, but that won't give you the same semantics. "ErrorT ErrorType ResultSet a" is isomorphic to "ResultSet (Either ErrorType a)". If you must have something equivalent to Either ErrorType (ResultSet a), you either need to (1) redesign ResultSet to include error handling, (2) redesign ResultSet to be a monad transformer, or (3) restrict yourself to the operations in Applicative. Option (3) works because applicative functors *do* compose. (Also, every instance of Monad is trivially an instance of Applicative.) -- Dave Menendez From dave at zednenem.com Thu Oct 2 14:20:34 2008 From: dave at zednenem.com (David Menendez) Date: Thu Oct 2 14:17:11 2008 Subject: [Haskell-cafe] Re: Total Functional Programming in Haskell In-Reply-To: <48E40D6E.8040009@freegeek.org> References: <48E40D6E.8040009@freegeek.org> Message-ID: <49a77b7a0810021120r4c7c78a6vadff50074ac7683e@mail.gmail.com> On Wed, Oct 1, 2008 at 7:53 PM, wren ng thornton wrote: > > [1] Just like existential types, you can put something in but you can never > get it back out again. For inescapable monads like IO and ST, this is why > they have the behavior of sucking your whole program into the existential > black-hole. That's true for IO, but the whole point of ST is that it *is* escapable. What makes ST (and IO and STM) unusual is that it can't be implemented in pure Haskell without special support from the run-time system. -- Dave Menendez From g9ks157k at acme.softbase.org Thu Oct 2 14:25:20 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Thu Oct 2 14:22:03 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <1222726710.14163.98.camel@dell.linuxdev.us.dell.com> References: <20080929213933.GF23645@scytale.galois.com> <1222726710.14163.98.camel@dell.linuxdev.us.dell.com> Message-ID: <200810022025.20473.g9ks157k@acme.softbase.org> Am Dienstag, 30. September 2008 00:18 schrieb Duncan Coutts: > Yet another reason for getting dynamic linking / shared libs for Haskell > packages working reliably on all platforms. You mean shared libraries without the opportunity to inline library code? This would result in a huge performance loss, I think. Best wishes, Wolfgang From micah at cowan.name Thu Oct 2 14:33:27 2008 From: micah at cowan.name (Micah Cowan) Date: Thu Oct 2 14:30:06 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <200810022025.20473.g9ks157k@acme.softbase.org> References: <20080929213933.GF23645@scytale.galois.com> <1222726710.14163.98.camel@dell.linuxdev.us.dell.com> <200810022025.20473.g9ks157k@acme.softbase.org> Message-ID: <48E513F7.7030401@cowan.name> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Wolfgang Jeltsch wrote: > Am Dienstag, 30. September 2008 00:18 schrieb Duncan Coutts: >> Yet another reason for getting dynamic linking / shared libs for Haskell >> packages working reliably on all platforms. > > You mean shared libraries without the opportunity to inline library code? > This would result in a huge performance loss, I think. Usually _mild_ performance loss, in exchange for major code-size savings, I would think. C obviously has worked quite fine under exactly this restraint (though C implementations obviously aren't built to take as great advantage of inlining library code as Haskell may be). Just because there's an important loss in value, doesn't mean there's not a significant net gain for some needs. Dynamically linked libs in Haskell have obvious benefits, as well as obvious drawbacks. - -- But hey, YMMV. Just my opinion. Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer. GNU Maintainer: wget, screen, teseq http://micah.cowan.name/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFI5RP37M8hyUobTrERAgn3AJ9JfWDY269PiRyh2hei1uH6W+dJ2wCfY/YG ztVcGYvH1+pQqG/fryr+YPw= =ekJT -----END PGP SIGNATURE----- From magnus at therning.org Thu Oct 2 15:04:15 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 2 15:00:57 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <48E3AD6B.2010409@gmail.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <48E3AD6B.2010409@gmail.com> Message-ID: On Wed, Oct 1, 2008 at 6:03 PM, Simon Marlow wrote: [..] > Dynamic linking doesn't solve all the problems, we still have the problem > that GHC does a lot of cross-module inlining, regardless of whether dynamic > linking is used. However, I really would like to have a way to have > complete control over what is exposed across a package boundary. We need > this not just for licensing reasons, but also for making a dynamic library > with a fixed ABI, so it can be upgraded later. I have a really hard time following this. Are you seriously saying that GHC is inlining code from modules _and_ link dynamically at the same time. That seems like a remarkably strange thing to do, or maybe I'm just missing something. My understanding from another thread on here was that dynamic linking isn't working reliably, not even on Windows, where it once was supported. It has never worked on any other platform. Am I wrong about this? IIRC I've never seen GHC produce anything that's dynamically linked to _any_haskell module, and all modules I compile are always packaged up in .hi and .a files. Not a .so or .dll as far I can see. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From g9ks157k at acme.softbase.org Thu Oct 2 15:25:52 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Thu Oct 2 15:22:31 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <48E513F7.7030401@cowan.name> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> Message-ID: <200810022125.52631.g9ks157k@acme.softbase.org> Am Donnerstag, 2. Oktober 2008 20:33 schrieben Sie: > Wolfgang Jeltsch wrote: > > You mean shared libraries without the opportunity to inline library code? > > This would result in a huge performance loss, I think. > > Usually _mild_ performance loss, in exchange for major code-size > savings, I would think. C obviously has worked quite fine under exactly > this restraint (though C implementations obviously aren't built to take > as great advantage of inlining library code as Haskell may be). I think that the performance loss is much higher in the case of Haskell because of Lazy Evaluation, massive use of higher order functions and possibly more. Maybe one of the GHC developers could comment on this? Best wishes, Wolfgang From leimy2k at gmail.com Thu Oct 2 15:39:16 2008 From: leimy2k at gmail.com (David Leimbach) Date: Thu Oct 2 15:35:58 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <200810022025.20473.g9ks157k@acme.softbase.org> References: <20080929213933.GF23645@scytale.galois.com> <1222726710.14163.98.camel@dell.linuxdev.us.dell.com> <200810022025.20473.g9ks157k@acme.softbase.org> Message-ID: <3e1162e60810021239t3b5af0dfwb7a7cb2785151dbe@mail.gmail.com> On Thu, Oct 2, 2008 at 11:25 AM, Wolfgang Jeltsch < g9ks157k@acme.softbase.org> wrote: > Am Dienstag, 30. September 2008 00:18 schrieb Duncan Coutts: > > Yet another reason for getting dynamic linking / shared libs for Haskell > > packages working reliably on all platforms. > > You mean shared libraries without the opportunity to inline library code? > This would result in a huge performance loss, I think. Not all platforms even have shared libraries. Assuming that mechanism exists to begin with is somewhat flawed if you're interested in wide portability. > > > Best wishes, > Wolfgang > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/3003ea81/attachment.htm From andrewcoppin at btinternet.com Thu Oct 2 15:40:31 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 15:37:10 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> Message-ID: <48E523AF.3000903@btinternet.com> David Menendez wrote: > In general, monads don't compose. That is, there's no foolproof way to > take two monads m1 and m2 and create a third monad m3 which does > everything m1 and m2 does. People mostly get around that by using > monad transformers. > ...OK then. > You could try using an exception monad transformer here I thought I already was? At least, I spent about an hour reading through Control.Monad.Error trying to figure out what the hell is going on, and eventually arrived at a type signature that represents what I'm trying to do and seems to be accepted as a monad. But I can't define a working AND function with it. :-( I was under the impression that you can stack monad transformers on top of each other and get it to work, but it doesn't seem to want to work for me... > but that > won't give you the same semantics. "ErrorT ErrorType ResultSet a" is > isomorphic to "ResultSet (Either ErrorType a)". > Hmm. That would be something quite different. Either the entire computation fails returning a reason why, or it produces a normal result set. > If you must have something equivalent to Either ErrorType (ResultSet > a), you either need to (1) redesign ResultSet to include error > handling, (2) redesign ResultSet to be a monad transformer, or (3) > restrict yourself to the operations in Applicative. > > Option (3) works because applicative functors *do* compose. (Also, > every instance of Monad is trivially an instance of Applicative.) > Uh... what's Applicative? (I had a look at Control.Applicative, but it just tells me that it's "a strong lax monoidal functor". Which isn't very helpful, obviously.) From andrewcoppin at btinternet.com Thu Oct 2 15:47:56 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 15:44:33 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <20081002180246.GA21590@rwbarton.mit.edu> References: <48E5025B.1040908@btinternet.com> <20081002180246.GA21590@rwbarton.mit.edu> Message-ID: <48E5256C.2000305@btinternet.com> Reid Barton wrote: > I'll assume for simplicity and concreteness that ResultSet = []. > It more or less is. (But with a more complex internal structure, and correspondingly more complex (>>=) implementation.) > That's right. The type mismatches are telling you that there's a > situation you haven't thought about, or at least, haven't told us how > you want to handle. Suppose run s0 x = Right [s1a, s1b, s1c] and > run s1a y = Left err, run s1b = Right [s2], run s1c = Left err'. What > should the overall result of run_and s0 x y be? Somehow you have to > choose whether it's a Left or a Right, and which error to report in > the former case. > > For the [] monad, there is a natural way to make this choice: it's > encoded in the function sequence :: Monad m => [m a] -> m [a], where > in this setting m = Either ErrorType. Yeah, while testing I accidentally got a definition that typechecks only because I was using [] as a dummy standin for ResultSet. (Rather than the real implementation.) The sequence function appears to define the basic functionallity I'm after. > For your problem, it would > probably be a good start to write an instance of Traversable for the > ResultSet monad. Wuh? What's Traversable? > In general, one way to make the composition of two > monads m and n into a monad is to write a function n (m a) -> m (n a); > this is the sequence method of a Traversable instance for n. Oh, *that's* Traversable? Mind you, looking at Data.Traversable, it demands instances for something called "Foldable" first (plus Functor, which I already happen to have). (Looking up Foldable immediately meantions something called "Monoid"... I'm rapidly getting lost here.) > Then you > can write join :: m (n (m (n a))) -> m (n a) as > > m (n (m (n a))) --- fmap sequence ---> m (m (n (n a))) > ------ join ---------> m (n (n a)) > ------ join ---------> m (n a). > Um... OK. Ouch. :-S From bulat.ziganshin at gmail.com Thu Oct 2 15:47:34 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 2 15:45:17 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <200810022125.52631.g9ks157k@acme.softbase.org> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> Message-ID: <1183887849.20081002234734@gmail.com> Hello Wolfgang, Thursday, October 2, 2008, 11:25:52 PM, you wrote: >> > You mean shared libraries without the opportunity to inline library code? >> > This would result in a huge performance loss, I think. >> >> Usually _mild_ performance loss, in exchange for major code-size >> savings, I would think. C obviously has worked quite fine under exactly >> this restraint (though C implementations obviously aren't built to take >> as great advantage of inlining library code as Haskell may be). > I think that the performance loss is much higher in the case of Haskell > because of Lazy Evaluation, massive use of higher order functions and > possibly more. Maybe one of the GHC developers could comment on this? and type classes. once i've forget to addinline pragma, my program (serializing arrays) becomes 200x slower. it was due to use of hieararchy of several type classes. afaiu, their dictionaries are also lazily evaluated plus we have usual overhead of haskell closures that are ready for particular application -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From andrewcoppin at btinternet.com Thu Oct 2 15:53:24 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 15:49:59 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <1222970123.21944.27.camel@jcchost> References: <48E5025B.1040908@btinternet.com> <1222970123.21944.27.camel@jcchost> Message-ID: <48E526B4.3080905@btinternet.com> Jonathan Cast wrote: > On Thu, 2008-10-02 at 18:18 +0100, Andrew Coppin wrote: > >> After an insane amount of time making my head hurt, I disocvered that >> the type "Either ErrorType (ResultSet State)" is actually a monad. >> > > It's a monad if you can write a function > > join :: Either ErrorType (ResultSet (Either ErrorType (ResultSet alpha))) > -> Either ErrorType (ResultSet alpha) > > (which follows from being able to write a function > > interleave :: Either ErrorType (ResultSet alpha) > -> ResultSet (Either ErrorType alpha) > > satisfying certain laws). Otherwise not, as you noticed. > Er... OK. Yes, I guess that kind of makes sense... >> Since ResultSet *just happens* to also be in Functor, >> > > It doesn't just happen to be one. liftM is *always* a law-abiding > definition for fmap, when used at a law-abiding monad. I'm lost... (What does liftM have to do with fmap?) > (This is why > posters here are always bringing up head-hurting category theory, btw. > Absorbing it sufficiently actually teaches you useful things about > Haskell programming.) > That would be a surprising and unexpected result. After all, knowing about set theory doesn't help you write SQL... >> At this point I am sorely tempted to just change ResultSet to include >> the error functionallity I need. However, ResultSet is *already* an >> extremely complicated monad that took me weeks to get working >> correctly... >> > > What does it look like? A list, basically. (But obviously slightly more complicated than that.) > Quite possibly it can be factored out into > smaller pieces using monad transformers. (In which case adding error > handling is just sticking in another transformer at the right layer in > the stack --- that is, the layer where adding error handling works :). > Well I'm *already* trying to layer an error transformer on the top and it's failing horribly. I don't see how splitting things up even more could do anything but make the program even *more* complex. >> Does anybody have any idea how this whole monad stacking craziness is >> *supposed* to work? >> > > No. [1] > Ah, good. :-) > But we know how it *can* work; this is what monad transformers exist to > do. You want to either change ResultSet to be a monad transformer, > or > you want the monad ErrorT ErrorType ResultSet. Very little can be said > in general without knowing what ResultSet looks like. > I thought ErrorT was a class name...? From haskell at colquitt.org Thu Oct 2 15:58:12 2008 From: haskell at colquitt.org (John Dorsey) Date: Thu Oct 2 15:54:50 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> Message-ID: <20081002195812.GA14510@colquitt.org> All, I'm bundling responses to save paper. ajb@spamcop.net wrote: > I hope it has a Monad instance. Naturally! > But more to the point: Can it send email? Can you give an example of a use case? Do the Haskell-98 standard tuples have a correspondence feature? I wasn't able to find one with Hoogle. Simon Brenner wrote: > You could always use this one-tuple instead and get Functor, Monad and > MonadFix for free: As Luke pointed out, that one seems to be too strict. It may simplify the strict implementation, though. The initial release did have Monad and Functor instances... I'll look into MonadFix (thanks!). Luke Palmer wrote: > Hmm, it looks like you forgot to write a Traversable instance. Oops... I included the instance statement but retained the default, mutually recursive methods. Too bad GHC didn't warn me. (Pesky halting problem.) Your change is in 0.1.1 -- thanks! Benjamin L.Russell wrote: > Wonderful! I'm intrigued.... Thank you. > What is the syntax for the singleton tuple? [...] What is your > solution? Haskell has no such syntax, of course. '(x)' is no good due to ambiguity with parens' usual associative use. '(x,)' has been discussed, I think. It's ugly; it's inconsistent with other tuples, which don't share its final comma; it looks a bit like a tuple section, which could cause confusion. My solution was to use a normal Algebraic Data Type: data OneTuple a = OneTuple a I think the need for singleton tuples is rare enough that the syntactic inconsistency is tolerable. Jon Fairbairn suggests using unicode 0x27e8 and 0x27e0 in place of parentheses for tuples. I like the idea, especially as an alternate syntax for the same tuple types, permitting the singleton. minh thu writes: > I thought to this idea in another way : parenthesis could be used for > s-expressions and [unicode 0x27e8 and 0x27e0] could be used for > regular grouping. This would allow to switch in the same code between > infix and s-expr (e.g. enabling SXML)... I don't think I fully understand your proposal, although it sounds interesting. Regards, John Dorsey From anton at appsolutions.com Thu Oct 2 16:32:22 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Oct 2 16:13:35 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E526B4.3080905@btinternet.com> References: <48E5025B.1040908@btinternet.com> <1222970123.21944.27.camel@jcchost> <48E526B4.3080905@btinternet.com> Message-ID: <48E52FD6.80905@appsolutions.com> Andrew Coppin wrote: > I thought ErrorT was a class name...? No, it's the name of the error monad transformer type. "Error" is just an ordinary monad, it's ErrorT that's the transformer. So it sounds like the answer to your question below: > > You could try using an exception monad transformer here > > I thought I already was? ...is no, you weren't. You need to construct your monad stack using ErrorT, not Error. Anton From jgoerzen at complete.org Thu Oct 2 16:35:05 2008 From: jgoerzen at complete.org (John Goerzen) Date: Thu Oct 2 16:31:47 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002195812.GA14510@colquitt.org> References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> <20081002195812.GA14510@colquitt.org> Message-ID: <20081002203505.GA5701@hustlerturf.com> On Thu, Oct 02, 2008 at 03:58:12PM -0400, John Dorsey wrote: > All, > > I'm bundling responses to save paper. > > ajb@spamcop.net wrote: > > I hope it has a Monad instance. > > Naturally! > > > But more to the point: Can it send email? > > Can you give an example of a use case? Do the Haskell-98 standard > tuples have a correspondence feature? I wasn't able to find one with > Hoogle. Pfft, that kind of thinking never stopped Emacs! :-) From robgreayer at yahoo.com Thu Oct 2 16:36:52 2008 From: robgreayer at yahoo.com (Robert Greayer) Date: Thu Oct 2 16:33:32 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E526B4.3080905@btinternet.com> Message-ID: <27480.20163.qm@web65709.mail.ac4.yahoo.com> --- On Thu, 10/2/08, Andrew Coppin wrote: > I'm lost... > > (What does liftM have to do with fmap?) They're (effectively) the same function. i.e. liftM :: (Monad m) => (a -> b) -> m a -> m b fmap :: (Functor f) => (a -> b) -> f a -> f b liftM turns a function from a to b into a function from m a to m b; fmap turns a function from a to b into a function from f a to f b; If your datatype with a Monad instance also has a Functor instance (which it *can* have, you just need to declare the instance), then liftM is equivalent to fmap. From andrewcoppin at btinternet.com Thu Oct 2 16:40:13 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 2 16:36:48 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <27480.20163.qm@web65709.mail.ac4.yahoo.com> References: <27480.20163.qm@web65709.mail.ac4.yahoo.com> Message-ID: <48E531AD.3050906@btinternet.com> Robert Greayer wrote: > --- On Thu, 10/2/08, Andrew Coppin wrote: > >> I'm lost... >> >> (What does liftM have to do with fmap?) >> > > They're (effectively) the same function. > > i.e. > > liftM :: (Monad m) => (a -> b) -> m a -> m b > fmap :: (Functor f) => (a -> b) -> f a -> f b > Hmm. Interesting. I hadn't thought of it like that... From duncan.coutts at worc.ox.ac.uk Thu Oct 2 11:39:34 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Oct 2 16:37:26 2008 Subject: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues In-Reply-To: References: Message-ID: <1222961974.14163.310.camel@dell.linuxdev.us.dell.com> On Thu, 2008-10-02 at 17:37 +0300, Anton Tayanovskyy wrote: > Hello, > > I had some difficulty building hsql and hsql-mysql (native driver) > packages under GHC 8.3 on Fedora 9. Namely, they do not install with > cabal install, because of a few API changes. Is this considered all > right as GHC 8.3 is still experimental, or should the packages be > updated? If so, can somebody please do it. I love when things just > work with cabal install! The problem here really is that HSQL has no maintainer and has not been updated for about two years if my memory serves me correctly. Some distros, Fedora, Gentoo etc have patched HSQL to keep it working with ghc-6.8. The answer is to find someone to maintain it, take over maintenance yourself or switch to another lib like hdbc or takusen. Duncan From bos at serpentine.com Thu Oct 2 16:45:12 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Oct 2 16:41:53 2008 Subject: [Haskell-cafe] Restricted file reading monad In-Reply-To: <1222908981.16905.15.camel@porges-laptop> References: <1222908981.16905.15.camel@porges-laptop> Message-ID: 2008/10/1 George Pollard : > Since the ID3 tag as a whole has size information, I need to pass that > into the frame-reading functions to ensure that I never read past the > end of the total header. What you want for this is the environment monad, also known as the Reader monad in Haskell. It gives you something similar to a piece of read-only global state. For this application, you'd pass in two pieces of state: the file handle to read, and the limit on the number of bytes that a client can read. Since we can't easily combine the normal Reader monad and IO, we use a monad transformer stack. I've attached an example for your amusement. -------------- next part -------------- A non-text attachment was scrubbed... Name: ReadHelper.hs Type: application/octet-stream Size: 1475 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/3982e87b/ReadHelper.obj From noteed at gmail.com Thu Oct 2 16:56:43 2008 From: noteed at gmail.com (minh thu) Date: Thu Oct 2 16:53:23 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002195812.GA14510@colquitt.org> References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> <20081002195812.GA14510@colquitt.org> Message-ID: <40a414c20810021356o6713def3w2f045670c4e0ba54@mail.gmail.com> 2008/10/2 John Dorsey : > All, > > I'm bundling responses to save paper. > > ajb@spamcop.net wrote: >> I hope it has a Monad instance. > > Naturally! > >> But more to the point: Can it send email? > > Can you give an example of a use case? Do the Haskell-98 standard > tuples have a correspondence feature? I wasn't able to find one with > Hoogle. > > Simon Brenner wrote: >> You could always use this one-tuple instead and get Functor, Monad and >> MonadFix for free: > > As Luke pointed out, that one seems to be too strict. It may simplify > the strict implementation, though. The initial release did have Monad > and Functor instances... I'll look into MonadFix (thanks!). > > Luke Palmer wrote: >> Hmm, it looks like you forgot to write a Traversable instance. > > Oops... I included the instance statement but retained the default, > mutually recursive methods. Too bad GHC didn't warn me. (Pesky > halting problem.) Your change is in 0.1.1 -- thanks! > > Benjamin L.Russell wrote: >> Wonderful! I'm intrigued.... > > Thank you. > >> What is the syntax for the singleton tuple? [...] What is your >> solution? > > Haskell has no such syntax, of course. '(x)' is no good due to > ambiguity with parens' usual associative use. '(x,)' has been > discussed, I think. It's ugly; it's inconsistent with other tuples, > which don't share its final comma; it looks a bit like a tuple section, > which could cause confusion. > > My solution was to use a normal Algebraic Data Type: > data OneTuple a = OneTuple a > > I think the need for singleton tuples is rare enough that the > syntactic inconsistency is tolerable. > > Jon Fairbairn suggests using unicode 0x27e8 and 0x27e0 in place of > parentheses for tuples. I like the idea, especially as an alternate > syntax for the same tuple types, permitting the singleton. > > minh thu writes: >> I thought to this idea in another way : parenthesis could be used for >> s-expressions and [unicode 0x27e8 and 0x27e0] could be used for >> regular grouping. This would allow to switch in the same code between >> infix and s-expr (e.g. enabling SXML)... > > I don't think I fully understand your proposal, although it sounds > interesting. > (It's not related to your tuple) Here is an example, quite contrived: With angle bracket: f a b c d = a + (+ b ?c + d?) -- the + before the b is in prefix position is equivalent to Normal Haskell: f a b c d = a + (b + (c + d)) With angle brackets, parenthesis mean "this is an s-expr" and angle brackets mean "this is an standard (infix) expression". In the s-expr, there is no precedence rules while they are kept in the top level or in angle brackets. Hope it's clearer, Thu From anton.tayanovskyy at gmail.com Thu Oct 2 17:14:18 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Thu Oct 2 17:10:55 2008 Subject: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues In-Reply-To: <1222961974.14163.310.camel@dell.linuxdev.us.dell.com> References: <1222961974.14163.310.camel@dell.linuxdev.us.dell.com> Message-ID: On Thu, Oct 2, 2008 at 6:39 PM, Duncan Coutts wrote: > The problem here really is that HSQL has no maintainer and has not been > updated for about two years if my memory serves me correctly. Some > distros, Fedora, Gentoo etc have patched HSQL to keep it working with > ghc-6.8. I see. True, it was updated Apr 9, 2007. Well, it's a pity that neither Hackage nor the Haskell wiki mentions those patches. > > The answer is to find someone to maintain it, take over maintenance > yourself or switch to another lib like hdbc or takusen. Hmm.. That's too bad. AFAIK hdbc and takusen do not have native MySQL backends. Last time I tried working with MySQL through ODBC on Linux it was quite slow to connect, compared to the native backend. Taking over myself is out of question, it is beyond me. So by elimination I'll have to find someone! --A From manlio_perillo at libero.it Thu Oct 2 17:23:05 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Oct 2 17:19:48 2008 Subject: [Haskell-cafe] Alex and Flex Message-ID: <48E53BB9.6060806@libero.it> Hi. I'm starting to write a CSS parser with Alex and Happy. The grammar is defined here: http://www.w3.org/TR/CSS21/grammar.html However I have noted that there are some difference in the syntax between Alex and Flex? What is the rationale? One more thing. Here: http://www.haskell.org/alex/doc/html/alex-files.html it seems that there is an error with macrodef := @smac '=' set | @rmac '=' regexp it should be macrodef := $smac '=' set | @rmac '=' regexp Thanks Manlio Perillo From manlio_perillo at libero.it Thu Oct 2 17:31:13 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Oct 2 17:27:55 2008 Subject: [Haskell-cafe] Alex and Flex Message-ID: <48E53DA1.7040205@libero.it> Hi. I'm starting to write a CSS parser with Alex and Happy. The grammar is defined here: http://www.w3.org/TR/CSS21/grammar.html However I have noted that there are some difference in the syntax between Alex and Flex? What is the rationale? One more thing. Here: http://www.haskell.org/alex/doc/html/alex-files.html it seems that there is an error with macrodef := @smac '=' set | @rmac '=' regexp it should be macrodef := $smac '=' set | @rmac '=' regexp Thanks Manlio Perillo From jonathanccast at fastmail.fm Thu Oct 2 17:26:26 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Oct 2 17:29:56 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E526B4.3080905@btinternet.com> References: <48E5025B.1040908@btinternet.com> <1222970123.21944.27.camel@jcchost> <48E526B4.3080905@btinternet.com> Message-ID: <1222982786.21944.40.camel@jcchost> On Thu, 2008-10-02 at 20:53 +0100, Andrew Coppin wrote: > Jonathan Cast wrote: > > On Thu, 2008-10-02 at 18:18 +0100, Andrew Coppin wrote: > > > >> After an insane amount of time making my head hurt, I disocvered that > >> the type "Either ErrorType (ResultSet State)" is actually a monad. > >> > > > > It's a monad if you can write a function > > > > join :: Either ErrorType (ResultSet (Either ErrorType (ResultSet alpha))) > > -> Either ErrorType (ResultSet alpha) > > > > (which follows from being able to write a function > > > > interleave :: Either ErrorType (ResultSet alpha) > > -> ResultSet (Either ErrorType alpha) > > > > satisfying certain laws). Otherwise not, as you noticed. > > > > Er... OK. Yes, I guess that kind of makes sense... > > >> Since ResultSet *just happens* to also be in Functor, > >> > > > > It doesn't just happen to be one. liftM is *always* a law-abiding > > definition for fmap, when used at a law-abiding monad. > > I'm lost... > > (What does liftM have to do with fmap?) OK, I'll try again. If I have a Haskell type constructor m, and m has a law-abiding instance of Monad, then instance Functor m where fmap = liftM is *always* a law-abiding instance of Functor. Furthermore, if m is an instance of Functor, then according to the Haskell report, fmap = liftM is one of the monad laws. > > (This is why > > posters here are always bringing up head-hurting category theory, btw. > > Absorbing it sufficiently actually teaches you useful things about > > Haskell programming.) > > > > That would be a surprising and unexpected result. It also happens to be true. Most computer-related technologies started as engineering solutions, and pulled in mathematical concepts mostly when those concepts managed to inspire vaguely similar engineering solutions. Haskell doesn't have that kind of heritage; its ultimate ancestor is ML, which was originally a component of a theorem-proving system, and its design has traditionally been (despite denials) about pulling concepts from math directly into programming. > After all, knowing > about set theory doesn't help you write SQL... SQL has an extremely tenuous relationship to set theory. Set theory can sometimes inspire SQL database design, and it can excuse features that would otherwise just be weird, but mostly SQL queries return lists, not sets. > >> At this point I am sorely tempted to just change ResultSet to include > >> the error functionallity I need. However, ResultSet is *already* an > >> extremely complicated monad that took me weeks to get working > >> correctly... > >> > > > > What does it look like? > > A list, basically. (But obviously slightly more complicated than that.) Nuts. We know how to turn [] into a real monad transformer, but it's ugly. Nevertheless, if you could post the actual type definition, it might make this easier to do. > > Quite possibly it can be factored out into > > smaller pieces using monad transformers. (In which case adding error > > handling is just sticking in another transformer at the right layer in > > the stack --- that is, the layer where adding error handling works :). > > > > Well I'm *already* trying to layer an error transformer on the top and > it's failing horribly. Right. The most global property of the system goes with the monad transfomer on bottom. > I don't see how splitting things up even more > could do anything but make the program even *more* complex. Your problem isn't complexity, it's that the monad transformer that goes on top isn't implemented as one (so it wants to go on bottom). Re-factoring might make it easier to generalize that problem away. Or not. > >> Does anybody have any idea how this whole monad stacking craziness is > >> *supposed* to work? > >> > > > > No. [1] > > > > Ah, good. :-) > > But we know how it *can* work; this is what monad transformers exist to > > do. You want to either change ResultSet to be a monad transformer, > > or > > you want the monad ErrorT ErrorType ResultSet. Very little can be said > > in general without knowing what ResultSet looks like. > > > > I thought ErrorT was a class name...? No. It's a (higher-order) type constructor. jcc From jason.dusek at gmail.com Thu Oct 2 17:46:32 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Oct 2 17:43:22 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002065608.GA27422@colquitt.org> References: <20081002065608.GA27422@colquitt.org> Message-ID: <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> John Dorsey wrote: > Now you can: > * Solve any of the software problems that cannot be solved without > the singleton tuple ! What would those be? I'm still trying to figure out how a singelton tuple is really distinct from a plain value. -- _jsn From rendel at daimi.au.dk Thu Oct 2 17:56:43 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Thu Oct 2 17:53:31 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E523AF.3000903@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> Message-ID: <48E5439B.9010606@daimi.au.dk> Hi Andrew, Andrew Coppin wrote: > Uh... what's Applicative? (I had a look at Control.Applicative, but > it just tells me that it's "a strong lax monoidal functor". Which > isn't very helpful, obviously.) Seriously, what are you talking about? The haddock page for Control.Applicative hoogle links to begins with > This module describes a structure intermediate between a functor and > a monad: it provides pure expressions and sequencing, but no binding. > (Technically, a strong lax monoidal functor.) For more details, see > Applicative Programming with Effects, by Conor McBride and Ross > Paterson, online at > http://www.soi.city.ac.uk/~ross/papers/Applicative.html. > > This interface was introduced for parsers by Niklas R?jemo, because > it admits more sharing than the monadic interface. The names here are > mostly based on recent parsing work by Doaitse Swierstra. > > This class is also useful with instances of the Traversable class. I agree that this is hard to understand, but it's more then just "strong lax monoidal functor", isn't it? More importantly, there is a reference to a wonderful and easy to read paper. (easy in the "easy for Haskell programmers" sense, not in the "easy for the authors, and maybe the inventors of Haskell" sense). Just give it a try. Just in case you missed the link for some reason, here is it again: http://www.soi.city.ac.uk/~ross/papers/Applicative.html Tillmann PS. Regarding Applicative, you may be interested in the original proposal introducing it, which can be found here: http://www.soi.city.ac.uk/~ross/papers/Applicative.html PPS. Don't miss McBride's and Peterson's great paper about applicative functors at http://www.soi.city.ac.uk/~ross/papers/Applicative.html. PPPS. You may also be interested in http://www.soi.city.ac.uk/~ross/papers/Applicative.pdf. PPPPS. If you wonder what do to next when visiting http://www.soi.city.ac.uk/~ross/papers/Applicative.html, you could consider clicking on the link to http://www.soi.city.ac.uk/~ross/papers/Applicative.pdf. Its a very interesting paper, well, actually, it reads more like a tutorial. Just like a blog post, but so much better then the usual blog post. From dave at zednenem.com Thu Oct 2 18:01:24 2008 From: dave at zednenem.com (David Menendez) Date: Thu Oct 2 17:58:03 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E523AF.3000903@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> Message-ID: <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> On Thu, Oct 2, 2008 at 3:40 PM, Andrew Coppin wrote: > David Menendez wrote: >> >> You could try using an exception monad transformer here > > I thought I already was? No, a monad transformer is a type constructor that takes a monad as an argument and produces another monad. So, (ErrorT ErrorType) is a monad transformer, and (ErrorT ErrorType m) is a monad, for any monad m. If it helps, a monad will always have kind * -> *, so a monad transformer will have kind (* -> *) -> (* -> *). When people talk about stacking monads, they're almost always talking about composing monad transformers, e.g. ReaderT Env (ErrorT ErrorType (StateT State IO)) :: * -> * is a monad built by successively applying three monad transformers to IO. If you look at the type you were using, you see that it breaks down into (Either ErrorType) (ResultSet State), where Either ErrorType :: * -> * and ResultSet State :: *. Thus, the monad is Either ErrorType. The fact that ResultSet is also a monad isn't enough to give you an equivalent to (>>=), without one of the functions below. inner :: ResultSet (Either ErrorType (ResultSet alpha)) -> Either ErrorType (ResultSet alpha) outer :: Either ErrorType (ResultSet (Either ErrorType alpha)) -> Either ErrorType (ResultSet alpha) swap :: ResultSet (Either ErrorType alpha) -> Either ErrorType (ResultSet alpha) >> If you must have something equivalent to Either ErrorType (ResultSet >> a), you either need to (1) redesign ResultSet to include error >> handling, (2) redesign ResultSet to be a monad transformer, or (3) >> restrict yourself to the operations in Applicative. >> >> Option (3) works because applicative functors *do* compose. (Also, >> every instance of Monad is trivially an instance of Applicative.) >> > > Uh... what's Applicative? (I had a look at Control.Applicative, but it just > tells me that it's "a strong lax monoidal functor". Which isn't very > helpful, obviously.) Applicative is a class of functors that are between Functor and Monad in terms of capabilities. Instead of (>>=), they have an operation (<*>) :: f (a -> b) -> f a -> f b, which generalizes Control.Monad.ap. The nice thing about Applicative functors is that they compose. If F and G are applicative functors, it's trivial to create a new applicative functor Comp F G. newtype Comp f g a = Comp { deComp :: f (g a) } instance (Functor f, Functor g) => Functor (Comp f g) where fmap f = Comp . fmap (fmap f) . deComp instance (Applicative f, Applicative g) => Applicative (Comp f g) where pure = Comp . pure . pure a <*> b = Comp $ liftA2 (<*>) (deComp a) (deComp b) With monads, you can't make (Comp m1 m2) a monad without a function analogous to inner, outer, or swap. >From your code examples, it isn't clear to me that applicative functors are powerful enough, but I can't really say without knowing what you're trying to do. The fact that the functions you gave take a state as an argument and return a state suggests that things could be refactored further. -- Dave Menendez From dons at galois.com Thu Oct 2 18:22:49 2008 From: dons at galois.com (Don Stewart) Date: Thu Oct 2 18:19:58 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <1183887849.20081002234734@gmail.com> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> <1183887849.20081002234734@gmail.com> Message-ID: <20081002222249.GJ5887@scytale.galois.com> bulat.ziganshin: > Hello Wolfgang, > > Thursday, October 2, 2008, 11:25:52 PM, you wrote: > > >> > You mean shared libraries without the opportunity to inline library code? > >> > This would result in a huge performance loss, I think. > >> > >> Usually _mild_ performance loss, in exchange for major code-size > >> savings, I would think. C obviously has worked quite fine under exactly > >> this restraint (though C implementations obviously aren't built to take > >> as great advantage of inlining library code as Haskell may be). > > > I think that the performance loss is much higher in the case of Haskell > > because of Lazy Evaluation, massive use of higher order functions and > > possibly more. Maybe one of the GHC developers could comment on this? > > and type classes. once i've forget to addinline pragma, my program > (serializing arrays) becomes 200x slower. it was due to use of > hieararchy of several type classes. afaiu, their dictionaries are also > lazily evaluated plus we have usual overhead of haskell closures that > are ready for particular application How long ago was this, Bulat? I'd be interested to know if any of the compilers since 6.8.x, with all its inlining improvements, exhibited the same fragility. If I recall correctly, your experiments were around the 6.4.x series of compilers? -- Don From dons at galois.com Thu Oct 2 18:23:51 2008 From: dons at galois.com (Don Stewart) Date: Thu Oct 2 18:20:22 2008 Subject: [Haskell-cafe] SCGI module In-Reply-To: References: Message-ID: <20081002222351.GK5887@scytale.galois.com> anton.tayanovskyy: > Hello, > > SCGI module from Hackage is not working for me with Apache mod_scgi, I > think because it uses LazyBytestring to hGetContents on a socket > handle and the Apache side does not close the socket. Also, looking at > the source I didn't see any fork* calls, so I assume it is not doing > concurrency. > > So I ended up writing a replacement and would like to invite comments. > It does forkIO per request and, if asked to, timeouts those threads. > So far it works for me on simple examples from > http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell > giving roughly 800 requests a second versus 250 on plain CGI (both > through Apache). > > http://hpaste.org/10842 > > Thanks! > > Also, in general, is there any interest in using SCGI, or FastCGI > (plain CGI, HappS, you name it) is vastly superior? Good work. If you find it useful, upload it to hackage.haskell.org please! -- Don From bulat.ziganshin at gmail.com Thu Oct 2 18:32:11 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Oct 2 18:37:57 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <20081002222249.GJ5887@scytale.galois.com> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> <1183887849.20081002234734@gmail.com> <20081002222249.GJ5887@scytale.galois.com> Message-ID: <01464265.20081003023211@gmail.com> Hello Don, Friday, October 3, 2008, 2:22:49 AM, you wrote: >> and type classes. once i've forget to addinline pragma, my program >> (serializing arrays) becomes 200x slower. it was due to use of >> hieararchy of several type classes. afaiu, their dictionaries are also >> lazily evaluated plus we have usual overhead of haskell closures that >> are ready for particular application > How long ago was this, Bulat? I'd be interested to know if any > of the compilers since 6.8.x, with all its inlining improvements, > exhibited the same fragility. > If I recall correctly, your experiments were around the 6.4.x series of > compilers? yes, exactly. not tried with anything newer, so can't say anything about it -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dagit at codersbase.com Thu Oct 2 19:00:22 2008 From: dagit at codersbase.com (Jason Dagit) Date: Thu Oct 2 18:57:05 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> Message-ID: On Thu, Oct 2, 2008 at 2:46 PM, Jason Dusek wrote: > John Dorsey wrote: > > Now you can: > > * Solve any of the software problems that cannot be solved without > > the singleton tuple ! > > What would those be? I'm still trying to figure out how a > singelton tuple is really distinct from a plain value. Careful when making (or not making) this distinction. It could lead to infinite types such as, a = OneTuple a. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/bd331c53/attachment.htm From lennart at augustsson.net Thu Oct 2 19:09:03 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Oct 2 19:05:44 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002065608.GA27422@colquitt.org> References: <20081002065608.GA27422@colquitt.org> Message-ID: Just FYI, at Credit Suisse I wrote a 1-tuple type a few years ago. It was the only way to get a consistent way of dealing with certain things. But I called it One. I think the OneTuple should be in the base library, I mean, ask an 8 year old what number is missing in this sequence 0,2,3,4,5,6,7,8,9,... -- Lennart On Thu, Oct 2, 2008 at 7:56 AM, John Dorsey wrote: > Fellow Haskellers, > > Much attention has been paid over the years to the regrettable > omission of singleton tuples from Haskell. > > I am pleased to announce OneTuple, a humble implementation of the > singleton tuple for Haskell. Now you can: > > * Wrap a single value of any type in a OneTuple ! > > * Pattern match to retrieve your value ! > > * Solve any of the software problems that cannot be solved without > the singleton tuple ! > > * Enjoy instances for all the classes normal tuples have, plus more ! > > * Proclaim feature parity with Python ! > > Note: the singleton tuple does not support tuple syntax. > > Contributions are welcome. The project could use a tutorial, and a > decent test suite. Strict singleton tuples are planned for the next > version. > > Enjoy! > > Regards, > John Dorsey > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jgoerzen at complete.org Thu Oct 2 19:41:47 2008 From: jgoerzen at complete.org (John Goerzen) Date: Thu Oct 2 19:38:31 2008 Subject: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues In-Reply-To: References: <1222961974.14163.310.camel@dell.linuxdev.us.dell.com> Message-ID: <20081002234147.GA9041@hustlerturf.com> On Fri, Oct 03, 2008 at 12:14:18AM +0300, Anton Tayanovskyy wrote: > On Thu, Oct 2, 2008 at 6:39 PM, Duncan Coutts > wrote: > > The problem here really is that HSQL has no maintainer and has not been > > updated for about two years if my memory serves me correctly. Some > > distros, Fedora, Gentoo etc have patched HSQL to keep it working with > > ghc-6.8. > > I see. True, it was updated Apr 9, 2007. Well, it's a pity that > neither Hackage nor the Haskell wiki mentions those patches. > > > > > The answer is to find someone to maintain it, take over maintenance > > yourself or switch to another lib like hdbc or takusen. > > Hmm.. That's too bad. AFAIK hdbc and takusen do not have native MySQL > backends. Last time I tried working with MySQL through ODBC on Linux > it was quite slow to connect, compared to the native backend. Taking > over myself is out of question, it is beyond me. So by elimination > I'll have to find someone! It is true that HDBC does not have a native MySQL backend. However, you should not notice a significant performance change with ODBC. There are a lot of variables that can come into play with ODBC, though, such as your local configuration, whether you set it up to use TCP, which ODBC package you are using, etc. What's more, HDBC has a stronger and more versatile API than HSQL, which permits even more speed improvements. Features such as precompiled queries can be huge for many apps, as can referencing result columns as an ordered list instead of an association list or map. Personally, I spent the time to write the Sqlite3, ODBC, and PostgreSQL bindings for HDBC owing to existing needs. I have no need for a MySQL binding because I avoid MySQL wherever possible, and where not possible, use ODBC. That said, the API is designed to make development of database backends easy. FFI also is quite nice. It should not be a significant task for an interested party to write a MySQL backend. I think it has not happened yet because the ODBC backend is fully functional for MySQL. -- John From ryani.spam at gmail.com Thu Oct 2 19:48:51 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 2 19:45:29 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <27480.20163.qm@web65709.mail.ac4.yahoo.com> References: <48E526B4.3080905@btinternet.com> <27480.20163.qm@web65709.mail.ac4.yahoo.com> Message-ID: <2f9b2d30810021648u56fa921dy43cfd3733176232e@mail.gmail.com> > If your datatype with a Monad instance also has a Functor instance (which it *can* have, you just need to declare the instance), then liftM is equivalent to fmap. Only if you ignore efficiency issues, of course. Some monads have an fmap which is significantly faster than bind. liftM f m = do a <- m return (f a) Consider []; this becomes liftM f m = m >>= \a -> return (f a) = concatMap (\a -> [f a]) m which, in the absence of other optimizations, is going to do a lot more allocation and branching than fmap fmap f m = map f m -- ryan From mgross21 at verizon.net Thu Oct 2 20:47:38 2008 From: mgross21 at verizon.net (Murray Gross) Date: Thu Oct 2 20:22:26 2008 Subject: [Haskell-cafe] Source of 16x16 Sudokus? Message-ID: Folks: For research on the behavior of parallel Haskell, does anyone know of a source for graded (easy through evil) 16x16 Sudoku puzzles? Our hardware runs too fast for us to get meaningful timings on 9x9's. I suppose we could insert time wasters, but I think that would also distort the results . . . . Thanks in advance, Murray Gross Brooklyn College From allbery at ece.cmu.edu Thu Oct 2 21:05:50 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Oct 2 21:02:36 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> Message-ID: <2CD30C9A-6EE3-46DF-8BB5-8DB144439AE9@ece.cmu.edu> On 2008 Oct 2, at 19:00, Jason Dagit wrote: > On Thu, Oct 2, 2008 at 2:46 PM, Jason Dusek > wrote: > John Dorsey wrote: > > Now you can: > > * Solve any of the software problems that cannot be solved without > > the singleton tuple ! > > What would those be? I'm still trying to figure out how a > singelton tuple is really distinct from a plain value. > > Careful when making (or not making) this distinction. It could lead > to infinite types such as, a = OneTuple a. As for the difference, doesn't the tuple have an additional _|_ compared to a direct value? _|_, (_|_,), (value,). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081002/f5d0f7b1/attachment.htm From dstigant at comcast.net Thu Oct 2 23:11:09 2008 From: dstigant at comcast.net (David Stigant) Date: Thu Oct 2 23:07:58 2008 Subject: [Haskell-cafe] Source of 16x16 Sudokus? In-Reply-To: References: Message-ID: <1F72E494C6E94566BCAC4C63F3798252@Euler> Simon Tatham has a sudoku program which generates Sudoku's of any size in varying difficulties: http://www.chiark.greenend.org.uk/~sgtatham/puzzles/ It's down at the bottom and is called Solo. I can't speak to the actual quality/difficulty of the puzzles, but every feature you asked for is there plus unlimited puzzles. ----- Original Message ----- From: "Murray Gross" To: Sent: Thursday, October 02, 2008 7:47 PM Subject: [Haskell-cafe] Source of 16x16 Sudokus? > > Folks: > > For research on the behavior of parallel Haskell, does anyone know of a > source for graded (easy through evil) 16x16 Sudoku puzzles? Our hardware > runs too fast for us to get meaningful timings on 9x9's. I suppose we > could insert time wasters, but I think that would also distort the results > . . . . > > Thanks in advance, > > Murray Gross > Brooklyn College > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ajb at spamcop.net Fri Oct 3 01:41:17 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Fri Oct 3 01:37:59 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081002195812.GA14510@colquitt.org> References: <20081002065608.GA27422@colquitt.org> <20081002031035.dbe6dub1ss0ggsg0-nwo@webmail.spamcop.net> <20081002195812.GA14510@colquitt.org> Message-ID: <20081003014117.spcm8qu4g84k8408-nwo@webmail.spamcop.net> G'day all. I asked: >> But more to the point: Can it send email? Quoting John Dorsey : > Can you give an example of a use case? I don't need one. It's not maximally flexible until it can send email. Cheers, Andrew Bromage From ajb at spamcop.net Fri Oct 3 01:42:36 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Fri Oct 3 01:39:15 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> Message-ID: <20081003014236.7q030lwf4gksok8g-nwo@webmail.spamcop.net> G'day all. Quoting Lennart Augustsson : > But I called it One. That's a _terrible_ name. One, surely is (), just as Zero is Void. While I'm at it, I really don't like the lexical syntax of comments. Someone should fix that. Cheers, Andrew Bromage From DekuDekuplex at Yahoo.com Fri Oct 3 02:10:43 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 3 02:07:39 2008 Subject: [Haskell-cafe] Re: Announcing OneTuple-0.1.0 References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> Message-ID: On Thu, 2 Oct 2008 14:46:32 -0700, "Jason Dusek" wrote: >John Dorsey wrote: >> Now you can: >> * Solve any of the software problems that cannot be solved without >> the singleton tuple ! > > What would those be? I'm still trying to figure out how a > singelton tuple is really distinct from a plain value. Actually, part of my original motivation for suggesting a singleton tuple had to do with in using it as a tool for modeling complete partial orders (a.k.a. "cpos") (see http://en.wikipedia.org/wiki/Complete_partial_order), such as those that appear in a lattice (see http://en.wikipedia.org/wiki/Lattice_(order)). A lattice is a partially ordered set in which every pair of elements has a unique supremum (see http://en.wikipedia.org/wiki/Supremum) and infimum (see http://en.wikipedia.org/wiki/Infimum). When I was in college, one of the courses that I took was on domain theory (see http://en.wikipedia.org/wiki/Domain_theory), where we used complete partial orders to model (partial) results of a computation, where elements higher in the order extended the information of the elements below them in a consistent way. _|_ (bottom) represented an undefined result, and, if present in a cpo, was a least element for that cpo. In a lattice, unlike in a list, since every pair of elements has a unique supremum and infimum, it is possible to have an ordering where a pair of elements X1, Y1 < Z1 for some element Z1, and X1, Y2 < Z2 for some other elements Y2, Z2, but neither Z1 < Z2 nor Z2 < Z1. This kind of ordering cannot be represented in a list in which every element is a number. My idea was that it may be possible to use nesting of tuples to represent this kind of ordering if we, say, allow nesting an element in a tuple to distinguish that element from the same element not nested in a tuple, and to define elements or tuples X to have a lower ordering than either the same elements or tuples X with more nesting (e.g., X < (X)), or less than elements containing either those elements or containing tuples containing those elements (e.g., X < (X) and X < ((X), (Y)) (in the above-mentioned example) (() as _|_ being a unique least element). E.g. (in the above-mentioned example), let: X1 = (X) Y1 = (Y) Y2 = ((Y)) Then, in order to define Z1 and Z2, since X1 < Z1, Y1 < Z1 i.e., (X) < Z1, (Y) < Z1 and X1 < Z1, Y2 < Z2 i.e., (X) < Z1, ((Y)) < Z2 just define: Z1 = ((X), (Y)) Z2 = ((X), ((Y))) Then: X1 < Z1 i.e., (X) < ((X), (Y)) and Y1 < Z1 i.e., (Y) < ((X), (Y)) and X1 < Z2 i.e., (X) < ((X), ((Y))) Y2 < Z2 i.e., ((Y)) < ((X), ((Y))) but not: Z1 < Z2 i.e., not: ((X), (Y)) < ((X), ((Y))) (since they cannot be compared) and not: Z2 < Z1 i.e., not: ((X), ((Y))) < ((X), (Y)) (again, since they cannot be compared) Forgive me if this makes little sense, but I just thought that being able to define, say, (X) = X1 < ((X)) = X2 < (((X))) = X3 < .. < (..(^nX)..)^n = Xn would be useful in this kind of ordering. Then, X is not the same as (X), because X = X0, (X) = X1, ..., (..(^nX)..)^n = Xn, and in the context of this example, X < (X) < ... < (..(^nX)..)^n. Having a singleton tuple might then allow the representation of lattices using tuples, in which _|_ (bottom) = () is a unique least element, and for each element X in the lattice, X < (X) and X < each tuple containing X. Without a singleton tuple, we cannot define X < (X), because then X = (X). Does this sound plausible? -- Benjamin L. Russell From lrpalmer at gmail.com Fri Oct 3 02:11:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 3 02:08:30 2008 Subject: [Haskell-cafe] A question about constraints In-Reply-To: References: <1778819867.20081002141123@gmail.com> <7ca3f0160810020622t31e8d858p7664186162e8f2ee@mail.gmail.com> Message-ID: <7ca3f0160810022311s2e2e79a1ya70478af673f01c1@mail.gmail.com> On Thu, Oct 2, 2008 at 7:51 AM, jean-christophe mincke wrote: > Hello, > > Thank you for your comments. > > Would not it be feasible to add constraints at type definition, something > like, in a somewhat free style syntax > > data String2 = String2 (s::String) with length s <= 5 > > and with a polymorphic type > > data List5 a= List5 (l::[a]) with length l <= 5 Well, yeah, it is possible that to a language. However, it's a question of how far you take it. What do you want that to do? Is it a runtime check on the constructor? Is it a compile-time guarantee? If it's runtime, how lazy is it -- i.e. when does it check? If it's compile-time, how do you enforce it? Basically it dumps the contents of pandora's box all over the design space, so it's easier to leave it out and just let module abstraction take care of the hard questions. There are definitely ways to simulate it: You can simulate the runtime checks as follows: subtype :: (a -> Bool) -> (a -> b) -> a -> b subtype p f x = if p x then f x else error "Subtype constraint failed" string2 :: String -> String2 string2 = subtype (\s -> length s < 5) String2 -- And don't expose String2 from the module, so string2 is the only way to make them But to give an example of why this is not a straightforward thing to answer, here's a different way which might also be correct, depending on what you want: string2 :: String -> String2 string2 s = partial 5 s where partial 0 _ = error "Subtype constraint failed" partial n [] = [] partial n (x:xs) = x:partial (n-1) xs Which lazily checks the constraint; i.e. only errors if a value is demanded beyond the index 5 and exists. Implementing Compile-time checks is typically much harder, and demands a bit more cleverness, since the way you do it is different for each type of constraint you have. For this example, you could create an algebra of lengthed lists: import Prelude hiding (++) -- Type level numbers; Z = 0, S n = n + 1. data Z data S n -- Lists of length exactly n data Listn n a where Nil :: Listn Z a Cons :: a -> Listn n a -> Listn (S n) a -- Type-level addition of numbers type family Plus m n :: * type instance Plus Z n = n type instance Plus (S m) n = S (Plus m n) -- Typed append; appends the lists, adds the lengths. -- The compiler verifies that the implementation actually does this! (++) :: Listn m a -> Listn n a -> Listn (Plus m n) a Nil ++ ys = ys Cons x xs ++ ys = Cons x (xs ++ ys) -- Type-level less than or equal; represents the type of *proofs* that m <= n. data m :<= n where LeN :: n :<= n LeS :: m :<= n -> m :<= S n -- A List5 a is a function which takes a proof than n <= 5, and returns a Listn n a type List5 a = forall n. n :<= S (S (S (S (S Z)))) -> Listn n a So that was a bit of work, wasn't it? But this solution is quite expressive; the compiler will not even compile your code if you try to construct a list with more than 5 elements. Furthermore, you can actually write most things you'd expect to because of Haskell's great GADT typechecking features :-) The downside is that you have to redefine all the standard list operations, because, well, they have different types now. The above is approaching what dependently typed languages do. My favorite is Coq (a lot of haskell folks like Agda 2), and in it you can express directly the constraint you want without all this type boilerplate: Definition List5 a := { l : List a | length l <= 5 }. But internally it is doing something very similar to the above Haskell program. This also has the property that it is impossible to write a well-typed program that constructs a List5 of length > 5. In addition, you can use all the standard list functions, however you have to prove what they do to the constraint: Theorem append_length : forall m n a (xs ys : List a), (length xs <= m) -> (length ys <= n) -> (length (xs ++ ys) <= m+n). (* prove prove prove.... *) Qed. And then you can use that theorem to prove that the parts of your program that use List5 are well-typed. Whew, so now that we're done with that, in summary, it depends on your situation how you want to do it, and there's really no "easy answer". I hope you got something out of seeing these techniques. Adding notation like that you suggest is a challenge for the language, since a runtime constraint changes the strictness properties of the object, and a compile-time constraint written that concisely actually does require full dependent types. Best to leave it to the users. Luke From gianfranco.alongi at gmail.com Fri Oct 3 02:45:19 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Fri Oct 3 02:42:00 2008 Subject: [Haskell-cafe] Source of 16x16 Sudokus? In-Reply-To: <1F72E494C6E94566BCAC4C63F3798252@Euler> References: <1F72E494C6E94566BCAC4C63F3798252@Euler> Message-ID: Nice set of games :) Truly a source of inspiration for programming. /Gianfranco On Fri, Oct 3, 2008 at 5:11 AM, David Stigant wrote: > Simon Tatham has a sudoku program which generates Sudoku's of any size in > varying difficulties: > > http://www.chiark.greenend.org.uk/~sgtatham/puzzles/ > > It's down at the bottom and is called Solo. > > I can't speak to the actual quality/difficulty of the puzzles, but every > feature you asked for is there plus unlimited puzzles. > > > ----- Original Message ----- From: "Murray Gross" > To: > Sent: Thursday, October 02, 2008 7:47 PM > Subject: [Haskell-cafe] Source of 16x16 Sudokus? > > >> >> Folks: >> >> For research on the behavior of parallel Haskell, does anyone know of a >> source for graded (easy through evil) 16x16 Sudoku puzzles? Our hardware >> runs too fast for us to get meaningful timings on 9x9's. I suppose we could >> insert time wasters, but I think that would also distort the results . . . . >> >> Thanks in advance, >> >> Murray Gross >> Brooklyn College >> >> _______________________________________________ >> 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 > -- Patience is the last resort for those unable to take action From DekuDekuplex at Yahoo.com Fri Oct 3 03:02:32 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 3 02:59:28 2008 Subject: [Haskell-cafe] Re: Announcing OneTuple-0.1.0 References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> Message-ID: Actually, on second thought, there might be one problem with using nested tuples in cpos in Haskell: Each tuple would have a different type. I.e., if we let X /= (X) /= ... /= (..(^nX)..)^n then :type X would yield a different result from :type (X) which would yield a different result from :type ((X)) which would yield a different result from ... which would yield a different result from :type (..(^nX)..) (using my notation here). It might then be difficult to order the tuples of different nesting.... I may need to think of a way around this issue.... -- Benjamin L. Russell --- On Fri, 10/3/08, Benjamin L. Russell wrote: > From: Benjamin L. Russell > Subject: Re: Announcing OneTuple-0.1.0 > To: > Date: Friday, October 3, 2008, 3:10 PM > On Thu, 2 Oct 2008 14:46:32 -0700, "Jason Dusek" > wrote: > > >John Dorsey wrote: > >> Now you can: > >> * Solve any of the software problems that cannot > be solved without > >> the singleton tuple ! > > > > What would those be? I'm still trying to figure > out how a > > singelton tuple is really distinct from a plain > value. > > Actually, part of my original motivation for suggesting a > singleton > tuple had to do with in using it as a tool for modeling > complete > partial orders (a.k.a. "cpos") (see > http://en.wikipedia.org/wiki/Complete_partial_order), such > as those > that appear in a lattice (see > http://en.wikipedia.org/wiki/Lattice_(order)). A lattice > is a > partially ordered set in which every pair of elements has a > unique > supremum (see http://en.wikipedia.org/wiki/Supremum) and > infimum (see > http://en.wikipedia.org/wiki/Infimum). > > When I was in college, one of the courses that I took was > on domain > theory (see http://en.wikipedia.org/wiki/Domain_theory), > where we used > complete partial orders to model (partial) results of a > computation, > where elements higher in the order extended the information > of the > elements below them in a consistent way. _|_ (bottom) > represented an > undefined result, and, if present in a cpo, was a least > element for > that cpo. > > In a lattice, unlike in a list, since every pair of > elements has a > unique supremum and infimum, it is possible to have an > ordering where > a pair of elements X1, Y1 < Z1 for some element Z1, and > X1, Y2 < Z2 > for some other elements Y2, Z2, but neither Z1 < Z2 nor > Z2 < Z1. This > kind of ordering cannot be represented in a list in which > every > element is a number. > > My idea was that it may be possible to use nesting of > tuples to > represent this kind of ordering if we, say, allow nesting > an element > in a tuple to distinguish that element from the same > element not > nested in a tuple, and to define elements or tuples X to > have a lower > ordering than either the same elements or tuples X with > more nesting > (e.g., X < (X)), or less than elements containing either > those > elements or containing tuples containing those elements > (e.g., X < (X) > and X < ((X), (Y)) (in the above-mentioned example) (() > as _|_ being a > unique least element). > > E.g. (in the above-mentioned example), let: > > X1 = (X) > Y1 = (Y) > Y2 = ((Y)) > > Then, in order to define Z1 and Z2, since > > X1 < Z1, Y1 < Z1 > i.e., > (X) < Z1, (Y) < Z1 > > and > > X1 < Z1, Y2 < Z2 > i.e., > (X) < Z1, ((Y)) < Z2 > > just define: > > Z1 = ((X), (Y)) > Z2 = ((X), ((Y))) > > Then: > > X1 < Z1 > i.e., > (X) < ((X), (Y)) > > and > > Y1 < Z1 > i.e., > (Y) < ((X), (Y)) > > and > > X1 < Z2 > i.e., > (X) < ((X), ((Y))) > > Y2 < Z2 > i.e., > ((Y)) < ((X), ((Y))) > > but not: Z1 < Z2 > i.e., > not: ((X), (Y)) < ((X), ((Y))) (since they cannot be > compared) > > and not: Z2 < Z1 > i.e., > not: ((X), ((Y))) < ((X), (Y)) (again, since they cannot > be compared) > > Forgive me if this makes little sense, but I just thought > that being > able to define, say, (X) = X1 < ((X)) = X2 < (((X))) > = X3 < .. < > (..(^nX)..)^n = Xn > > would be useful in this kind of ordering. > > Then, X is not the same as (X), because X = X0, (X) = X1, > ..., > (..(^nX)..)^n = Xn, and in the context of this example, X > < (X) < ... > < (..(^nX)..)^n. > > Having a singleton tuple might then allow the > representation of > lattices using tuples, in which _|_ (bottom) = () is a > unique least > element, and for each element X in the lattice, X < (X) > and X < each > tuple containing X. > > Without a singleton tuple, we cannot define X < (X), > because then X = > (X). > > Does this sound plausible? > > -- Benjamin L. Russell From vigalchin at gmail.com Fri Oct 3 03:07:10 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Oct 3 03:03:48 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... Message-ID: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> Hello, One of my interests based on my education is "grand challenge science". Ok .. let's take the CERN Hadrian Accelerator. Where do you think Haskell can fit into the CERN Hadrian effort currently? Where do you think think Haskell currently is lacking and will have to be improved in order to participate in CERN Hadrian? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/9eff2d46/attachment.htm From jason.dusek at gmail.com Fri Oct 3 03:17:18 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 3 03:13:56 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> Message-ID: <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> Jason Dagit wrote: > Jason Dusek wrote: > > John Dorsey wrote: > > > Now you can: > > > * Solve any of the software problems that cannot be > > > solved without the singleton tuple ! > > > > What would those be? I'm still trying to figure out how a > > singelton tuple is really distinct from a plain value. > > Careful when making (or not making) this distinction. It > could lead to infinite types such as, a = OneTuple a. Perhaps I am lacking in imagination, but I still can't see the value of one tuples. -- _jsn From neil.mitchell.2 at credit-suisse.com Fri Oct 3 03:33:43 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Fri Oct 3 03:31:20 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <200810022125.52631.g9ks157k@acme.softbase.org> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> Hi > > > You mean shared libraries without the opportunity to > inline library code? > > > This would result in a huge performance loss, I think. > > > > Usually _mild_ performance loss, in exchange for major code-size > > savings, I would think. C obviously has worked quite fine under > > exactly this restraint (though C implementations obviously aren't > > built to take as great advantage of inlining library code > as Haskell may be). > > I think that the performance loss is much higher in the case > of Haskell because of Lazy Evaluation, massive use of higher > order functions and possibly more. Example 1: foo x | "test" `isPrefixOf` xs = ... | otherwise = ... If you have cross-module inlining, you get the rather obvious if like construct. If you don't, you have to evaluate otherwise and test its value. Example 2: (a :: Int) + b If you have cross-module specialisation you get a primitive integer arithmetic instruction (possibly with a bit of unboxing, although often not). If you don't, you get a dictionary lookup, followed by a higher order application. One reason cross-module inlining is essential is that many Haskell functions don't do very much, think of (+), (||), (>>), not, otherwise etc. In C these would be built-in's, so are always available to the optimiser (and usually just one instruction), in Haskell you need to get them from the Prelude. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From DekuDekuplex at Yahoo.com Fri Oct 3 03:49:36 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 3 03:46:23 2008 Subject: [Haskell-cafe] Is Haskell-Cafe down? Message-ID: About two hours ago, I sent two follow-ups to the "Announcing OneTuple-0.1.0" thread on the Haskell-Cafe mailing list, neither of which has appeared in either my newsreader or my Inbox, even though they have both appeared on the Web archive; viz.: [Haskell-cafe] Re: Announcing OneTuple-0.1.0 http://www.haskell.org/pipermail/haskell-cafe/2008-October/048633.html [Haskell-cafe] Re: Announcing OneTuple-0.1.0 http://www.haskell.org/pipermail/haskell-cafe/2008-October/048636.html Is Haskell-Cafe down? -- Benjamin L. Russell From neil.mitchell.2 at credit-suisse.com Fri Oct 3 05:09:35 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Fri Oct 3 05:09:37 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <20081003014236.7q030lwf4gksok8g-nwo@webmail.spamcop.net> References: <20081002065608.GA27422@colquitt.org> <20081003014236.7q030lwf4gksok8g-nwo@webmail.spamcop.net> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3A8B@ELON17P32001A.csfb.cs-group.com> > Quoting Lennart Augustsson : > > > But I called it One. I did a similar one for Yhc, and I think I called it Box. My guess was that boxing/unboxing wasn't an overloaded enough term :-) Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From alfonso.acosta at gmail.com Fri Oct 3 06:06:14 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Fri Oct 3 06:02:50 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: Haskell-Embedded System Design: ForSyDe 3.0 and Tutorial In-Reply-To: <20081001173850.GC32701@scytale.galois.com> References: <6a7c66fc0810010429na4e5981ld5a71d2ff832e9a@mail.gmail.com> <20081001173850.GC32701@scytale.galois.com> Message-ID: <6a7c66fc0810030306k4d22d667l15a0ff23b7535e5c@mail.gmail.com> On Wed, Oct 1, 2008 at 7:38 PM, Don Stewart wrote: > Awesome, native packages now available, > > http://aur.archlinux.org/packages.php?ID=20422 Thanks Don! From fw at deneb.enyo.de Fri Oct 3 06:22:02 2008 From: fw at deneb.enyo.de (Florian Weimer) Date: Fri Oct 3 06:18:41 2008 Subject: [Haskell-cafe] Kind-agnostic type classes Message-ID: <87r66y567p.fsf@mid.deneb.enyo.de> I'm trying to encode a well-known, informally-specified type system in Haskell. What causes problems for me is that type classes force types to be of a specific kind. The system I'm targeting however assumes that its equivalent of type classes are kind-agnositic. For instance, I've got class Assignable a where assign :: a -> a -> IO () class Swappable a where swap :: a -> a -> IO () class CopyConstructible a where copy :: a -> IO a class (Assignable a, CopyConstructible a) => ContainerType a class (Swappable c, Assignable c, CopyConstructible c) => Container c where size :: (Num i, ContainerType t) => c t -> IO i I suppose I could address this with creating aliases for the relevant classes, but I wonder if there is a better workaround. I see that the ML module system has a similar restriction on type sharing. Is there a fundamental reasons behind this? From dougal at dougalstanton.net Fri Oct 3 06:47:58 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Fri Oct 3 06:44:35 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> Message-ID: <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> 2008/10/3 Galchin, Vasili : > Hello, > > One of my interests based on my education is "grand challenge science". > Ok .. let's take the CERN Hadrian Accelerator. > > Where do you think Haskell can fit into the CERN Hadrian effort > currently? > > Where do you think think Haskell currently is lacking and will have to > be improved in order to participate in CERN Hadrian? Is that the experiment where Picts are accelerated to just short of the speed of light in order to smash through to the Roman Empire? ;-) I don't know what the main computational challenges are to the LHC researchers. The stuff in the press has mostly been about infrastructure --- how to store the gigabytes of data per second that they end up keeping, out of the petabytes that are produced in the first place (or something). Cheers, D From anton.tayanovskyy at gmail.com Fri Oct 3 06:58:41 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Fri Oct 3 06:55:32 2008 Subject: [Haskell-cafe] mysql (hsql-mysql-1.7) on Linux with GHC 8.3 - cabal issues In-Reply-To: <20081002234147.GA9041@hustlerturf.com> References: <1222961974.14163.310.camel@dell.linuxdev.us.dell.com> <20081002234147.GA9041@hustlerturf.com> Message-ID: John, Thank you for your reply. I benchmarked HDBC.ODBC with MySQL and it is indeed working well. So whatever slow results I used to get were due to that particular setup. It looks that HDBC will suit my needs as well. Thanks, --A > What's more, HDBC has a stronger and more versatile API than HSQL, > which permits even more speed improvements. Features such as > precompiled queries can be huge for many apps, as can referencing > result columns as an ordered list instead of an association list or > map. > > Personally, I spent the time to write the Sqlite3, ODBC, and > PostgreSQL bindings for HDBC owing to existing needs. I have no need > for a MySQL binding because I avoid MySQL wherever possible, and where > not possible, use ODBC. > > That said, the API is designed to make development of database > backends easy. FFI also is quite nice. It should not be a > significant task for an interested party to write a MySQL backend. I > think it has not happened yet because the ODBC backend is fully > functional for MySQL. > > -- John > From lennart at augustsson.net Fri Oct 3 07:10:14 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Oct 3 07:06:53 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> Message-ID: Let me pick one example. Let's make a class that can convert between tuples and lists. Of course there are restriction when this works, but it can still be useful. class TupleList t l | t -> l where tupleToList :: t -> l listToTuple :: l -> t instance TupleList () [a] where tupleToList () = [] listToTuple [] = () -- XXX This doesn't work, and is just wrong. --instance TupleList (a) [a] where -- tupleToList (a) = [a] -- listToTuple [a] = (a) instance TupleList (a,a) [a] where tupleToList (a1,a2) = [a1, a2] listToTuple [a1,a2] = (a1, a2) instance TupleList (a,a,a) [a] where tupleToList (a1,a2,a3) = [a1, a2, a3] listToTuple [a1,a2,a3] = (a1, a2, a3) On Fri, Oct 3, 2008 at 8:17 AM, Jason Dusek wrote: > Jason Dagit wrote: > Perhaps I am lacking in imagination, but I still can't see the > value of one tuples. > > -- > _jsn From noteed at gmail.com Fri Oct 3 07:32:22 2008 From: noteed at gmail.com (minh thu) Date: Fri Oct 3 07:29:00 2008 Subject: [Haskell-cafe] Is Haskell-Cafe down? In-Reply-To: References: Message-ID: <40a414c20810030432u5853e026j2c682ed05837f55f@mail.gmail.com> 2008/10/3 Benjamin L. Russell : > About two hours ago, I sent two follow-ups to the "Announcing > OneTuple-0.1.0" thread on the Haskell-Cafe mailing list, neither of > which has appeared in either my newsreader or my Inbox, even though > they have both appeared on the Web archive; viz.: > > [Haskell-cafe] Re: Announcing OneTuple-0.1.0 > http://www.haskell.org/pipermail/haskell-cafe/2008-October/048633.html > > [Haskell-cafe] Re: Announcing OneTuple-0.1.0 > http://www.haskell.org/pipermail/haskell-cafe/2008-October/048636.html > > Is Haskell-Cafe down? I've received both, if it is what you ask... Thu From noteed at gmail.com Fri Oct 3 07:36:24 2008 From: noteed at gmail.com (minh thu) Date: Fri Oct 3 07:33:01 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> Message-ID: <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> 2008/10/3 Mitchell, Neil : > > Hi > > >> > > You mean shared libraries without the opportunity to >> inline library code? >> > > This would result in a huge performance loss, I think. >> > >> > Usually _mild_ performance loss, in exchange for major code-size >> > savings, I would think. C obviously has worked quite fine under >> > exactly this restraint (though C implementations obviously aren't >> > built to take as great advantage of inlining library code >> as Haskell may be). >> >> I think that the performance loss is much higher in the case >> of Haskell because of Lazy Evaluation, massive use of higher >> order functions and possibly more. > > Example 1: > > foo x | "test" `isPrefixOf` xs = ... > | otherwise = ... > > If you have cross-module inlining, you get the rather obvious if like > construct. If you don't, you have to evaluate otherwise and test its > value. > > Example 2: > > (a :: Int) + b > > If you have cross-module specialisation you get a primitive integer > arithmetic instruction (possibly with a bit of unboxing, although often > not). If you don't, you get a dictionary lookup, followed by a higher > order application. > > One reason cross-module inlining is essential is that many Haskell > functions don't do very much, think of (+), (||), (>>), not, otherwise > etc. In C these would be built-in's, so are always available to the > optimiser (and usually just one instruction), in Haskell you need to get > them from the Prelude. What happens in the C++ world where good chunk of functionnalities are in header files (templates or inline methods); is there the same LGPL problem that the one discussed here w.r.t. static/shared linking ? Thanks, Thu From simonmarhaskell at gmail.com Fri Oct 3 07:59:30 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Fri Oct 3 07:56:46 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <48E3AD6B.2010409@gmail.com> Message-ID: <48E60922.2040309@gmail.com> Magnus Therning wrote: > On Wed, Oct 1, 2008 at 6:03 PM, Simon Marlow wrote: > [..] >> Dynamic linking doesn't solve all the problems, we still have the problem >> that GHC does a lot of cross-module inlining, regardless of whether dynamic >> linking is used. However, I really would like to have a way to have >> complete control over what is exposed across a package boundary. We need >> this not just for licensing reasons, but also for making a dynamic library >> with a fixed ABI, so it can be upgraded later. > > I have a really hard time following this. Are you seriously saying > that GHC is inlining code from modules _and_ link dynamically at the > same time. That seems like a remarkably strange thing to do, or maybe > I'm just missing something. That's exactly what would happen, if we shipped dynamic linking support with GHC as it stands. It's just a linking mechanism, an alternative to static linking, and has no impact on the amount or nature of inter-module optimisation that GHC does. > My understanding from another thread on here was that dynamic linking > isn't working reliably, not even on Windows, where it once was > supported. It has never worked on any other platform. The fundamental mechanisms are working on {x86, x86-64, PPC, PPC64} / {Linux, OS X, Windows} and possibly other OSs. However right now you need a few small patches to the source tree to get it to build. Most of the unresolved issues are around how to construct binary installs, and how executables will find their libraries when the run (e.g. if you install GHC privately in your home directory). Cheers, Simon From derek.a.elkins at gmail.com Fri Oct 3 09:23:10 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Oct 3 09:19:51 2008 Subject: [Haskell-cafe] Kind-agnostic type classes In-Reply-To: <87r66y567p.fsf@mid.deneb.enyo.de> References: <87r66y567p.fsf@mid.deneb.enyo.de> Message-ID: <1223040190.6360.0.camel@derek-laptop> On Fri, 2008-10-03 at 12:22 +0200, Florian Weimer wrote: > I'm trying to encode a well-known, informally-specified type system in > Haskell. What causes problems for me is that type classes force types > to be of a specific kind. The system I'm targeting however assumes that > its equivalent of type classes are kind-agnositic. > > For instance, I've got > > class Assignable a where > assign :: a -> a -> IO () > > class Swappable a where > swap :: a -> a -> IO () > > class CopyConstructible a where > copy :: a -> IO a > > class (Assignable a, CopyConstructible a) => ContainerType a > > class (Swappable c, Assignable c, CopyConstructible c) => Container c where > size :: (Num i, ContainerType t) => c t -> IO i instane Container Maybe where... What does copy :: Maybe -> IO Maybe mean? From manlio_perillo at libero.it Fri Oct 3 09:24:00 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Oct 3 09:20:45 2008 Subject: [Haskell-cafe] Alex and Flex In-Reply-To: <48E53BB9.6060806@libero.it> References: <48E53BB9.6060806@libero.it> Message-ID: <48E61CF0.1000901@libero.it> Manlio Perillo ha scritto: > Hi. > > I'm starting to write a CSS parser with Alex and Happy. > The grammar is defined here: > http://www.w3.org/TR/CSS21/grammar.html > > However I have noted that there are some difference in the syntax > between Alex and Flex? > What is the rationale? > > > One more thing. > Here: http://www.haskell.org/alex/doc/html/alex-files.html > it seems that there is an error with > macrodef := @smac '=' set > | @rmac '=' regexp > > it should be > macrodef := $smac '=' set > | @rmac '=' regexp > Ok, this is not an error, sorry. By the way, here is the list of differences between Alex and Flex I have found, for people interested: 1) Alex make a distinction between "character set macros" and "regular expression macros". 2) Alex support the set '#' set0 syntax for "character set macros" 3) Alex does not support [_a-z0-9-] that must be rewritten as [_a-z0-9\-] 4) In Alex the order of macro definitions is important. A macro must be defined before it is used in another macro definition. 5) For reasons I still don't understand, this: \"([^\n\r\f\\"]|\\@nl|@escape)*\" cause a parse error, but these are ok: \'([^\n\r\f\\']|\\@nl|@escape)*\' \"([^\n\r\f\\"]|\\@nl|@escape)* 6) As with 3), these are not parsed: [^*] [^/*] and must be rewritten as [^\*] [^\/\*] 7) I don't understand why, but this is not parsed: -?@nmstart@nmchar* The -? at the beginning must be removed. How can I fix this? Thanks Manlio Perillo From wchogg at gmail.com Fri Oct 3 09:29:59 2008 From: wchogg at gmail.com (Creighton Hogg) Date: Fri Oct 3 09:26:38 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> Message-ID: <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> On Fri, Oct 3, 2008 at 5:47 AM, Dougal Stanton wrote: > 2008/10/3 Galchin, Vasili : >> Hello, >> >> One of my interests based on my education is "grand challenge science". >> Ok .. let's take the CERN Hadrian Accelerator. >> >> Where do you think Haskell can fit into the CERN Hadrian effort >> currently? >> >> Where do you think think Haskell currently is lacking and will have to >> be improved in order to participate in CERN Hadrian? > > Is that the experiment where Picts are accelerated to just short of > the speed of light in order to smash through to the Roman Empire? ;-) > > I don't know what the main computational challenges are to the LHC > researchers. The stuff in the press has mostly been about > infrastructure --- how to store the gigabytes of data per second that > they end up keeping, out of the petabytes that are produced in the > first place (or something). Well, with the LHC efforts I don't think a technology like Haskell really has a place...at least not now. Even just a few years back, when I worked on this stuff, we were still doing lots of simulation in preparation for the actual live experiment and Haskell might have been a good choice for some of the tools. All of the detector simulation was written in C++, because C++ is the new FORTRAN to physicists, and you ain't seen nothing till you've seen a jury-rigged form of lazy evaluation built into a class hierarchy in C++. Now, would the C++ based simulation have run faster than a Haskell based one? Quite possibly. On the other hand, I remember how many delays and problems were caused by the sheer complexity of the codebase. That's where a more modern programming language might have been extremely helpful. From lrpalmer at gmail.com Fri Oct 3 09:49:38 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 3 09:46:15 2008 Subject: [Haskell-cafe] Kind-agnostic type classes In-Reply-To: <87r66y567p.fsf@mid.deneb.enyo.de> References: <87r66y567p.fsf@mid.deneb.enyo.de> Message-ID: <7ca3f0160810030649k204e0720r808bec8d79e6380a@mail.gmail.com> On Fri, Oct 3, 2008 at 4:22 AM, Florian Weimer wrote: > I'm trying to encode a well-known, informally-specified type system in > Haskell. What causes problems for me is that type classes force types > to be of a specific kind. The system I'm targeting however assumes that > its equivalent of type classes are kind-agnositic. There is no choice of kinds, they are forced by the methods (since the kind of an actual argument is * by definition). But see below. > For instance, I've got > > class Assignable a where > assign :: a -> a -> IO () > > class Swappable a where > swap :: a -> a -> IO () > > class CopyConstructible a where > copy :: a -> IO a > > class (Assignable a, CopyConstructible a) => ContainerType a > > class (Swappable c, Assignable c, CopyConstructible c) => Container c where > size :: (Num i, ContainerType t) => c t -> IO i Which is illegal because the three above classes force c to be kind *, but you're using it here as kind * -> *. What you want is not this informal "kind-agnostic" classes so much as quantification in constraints, I presume. This, if it were supported, would solve your problem. class (forall t. Swappable (c t), forall t. Assignable (c t), forall t. CopyConstructible (c t)) => Contanter c where ... Incidentally, you *can* do this if you go to a dictionary passing style (because then you are providing the proofs, rather than asking the compiler to infer them, which is probably undecidable (what isn't ;-)). data Assignable a = Assignable { assign :: a -> a -> IO () } data Swappable a = Swappable { swap :: a -> a -> IO () } data CopyConstructible a = CopyConstructible { copy :: a -> IO a } data ContainerType a = ContainerType (Assignable a) (CopyConstructor a) data Container c t = Container { containerAssignable :: forall t. ContainerType t -> Assignable (c t), containerSwappable :: forall t. ContainerType t -> Swappable (c t), containerCopyConstructible :: forall t. ContainerType t -> CopyConstructible (c t), size :: forall i. (Num i) => ContainerType t -> c t -> IO i } And then to make an "instance" of Container (construct an object of it), you need to provide a "proof" of eg. forall t. ContainerType t -> Assignable (c t). For what it's worth, this is a well-known but very infrequently used technique. Try to come up with something simpler that accomplishes the "big picture" you have in mind (spend more time thinking about the problem and less about the solution you think you want). Also, OO-esque modeling like this in Haskell almost always leads to overcomplexity, pain, and desire for yet more "missing" features. A more functional solution will serve you well (it takes time to learn how to come up with functional solutions). Luke From fw at deneb.enyo.de Fri Oct 3 10:09:02 2008 From: fw at deneb.enyo.de (Florian Weimer) Date: Fri Oct 3 10:05:42 2008 Subject: [Haskell-cafe] Kind-agnostic type classes In-Reply-To: <1223040190.6360.0.camel@derek-laptop> (Derek Elkins's message of "Fri, 03 Oct 2008 08:23:10 -0500") References: <87r66y567p.fsf@mid.deneb.enyo.de> <1223040190.6360.0.camel@derek-laptop> Message-ID: <874p3t3h4x.fsf@mid.deneb.enyo.de> * Derek Elkins: > On Fri, 2008-10-03 at 12:22 +0200, Florian Weimer wrote: >> I'm trying to encode a well-known, informally-specified type system in >> Haskell. What causes problems for me is that type classes force types >> to be of a specific kind. The system I'm targeting however assumes that >> its equivalent of type classes are kind-agnositic. >> >> For instance, I've got >> >> class Assignable a where >> assign :: a -> a -> IO () >> >> class Swappable a where >> swap :: a -> a -> IO () >> >> class CopyConstructible a where >> copy :: a -> IO a >> >> class (Assignable a, CopyConstructible a) => ContainerType a >> >> class (Swappable c, Assignable c, CopyConstructible c) => Container c where >> size :: (Num i, ContainerType t) => c t -> IO i > > instane Container Maybe where... > > What does copy :: Maybe -> IO Maybe mean? Maybe is not an instance of CopyConstructible, so this shouldn't compile. On the other hand, for IORef a, copy = (>>= newIORef) . readIORef and for mutable arrays, copy = mapArray id (if I'm not mistaken). From vanenkj at gmail.com Fri Oct 3 10:16:14 2008 From: vanenkj at gmail.com (John Van Enk) Date: Fri Oct 3 10:12:52 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> Message-ID: "...gigabytes of data per second that they end up keeping, out of the petabytes that are produced in the first place..." Sounds like a good application for lazy evaluation! (Actually, they may have to read over it all to make sure they can throw it away...) On Fri, Oct 3, 2008 at 6:47 AM, Dougal Stanton wrote: > 2008/10/3 Galchin, Vasili : > > Hello, > > > > One of my interests based on my education is "grand challenge > science". > > Ok .. let's take the CERN Hadrian Accelerator. > > > > Where do you think Haskell can fit into the CERN Hadrian effort > > currently? > > > > Where do you think think Haskell currently is lacking and will have > to > > be improved in order to participate in CERN Hadrian? > > Is that the experiment where Picts are accelerated to just short of > the speed of light in order to smash through to the Roman Empire? ;-) > > I don't know what the main computational challenges are to the LHC > researchers. The stuff in the press has mostly been about > infrastructure --- how to store the gigabytes of data per second that > they end up keeping, out of the petabytes that are produced in the > first place (or something). > > Cheers, > > D > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/1698297e/attachment.htm From RafaelGCPP.Linux at gmail.com Fri Oct 3 10:19:43 2008 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Fri Oct 3 10:16:21 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <351ff25e0810030718w152e3c2fg8374632d31b74d71@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <351ff25e0810030718w152e3c2fg8374632d31b74d71@mail.gmail.com> Message-ID: <351ff25e0810030719u4781b8c0pfa9ab43dd8899c39@mail.gmail.com> > > > > On Fri, Oct 3, 2008 at 07:47, Dougal Stanton wrote: > >> 2008/10/3 Galchin, Vasili : >> > Hello, >> > >> > One of my interests based on my education is "grand challenge >> science". >> > Ok .. let's take the CERN Hadrian Accelerator. >> > >> > Where do you think Haskell can fit into the CERN Hadrian effort >> > currently? >> > >> > Where do you think think Haskell currently is lacking and will have >> to >> > be improved in order to participate in CERN Hadrian? >> >> Is that the experiment where Picts are accelerated to just short of >> the speed of light in order to smash through to the Roman Empire? ;-) >> > Man, that was almost as good as the Large Hardon Collider !!! > >> I don't know what the main computational challenges are to the LHC >> researchers. The stuff in the press has mostly been about >> infrastructure --- how to store the gigabytes of data per second that >> they end up keeping, out of the petabytes that are produced in the >> first place (or something). >> >> > There is a lot of data filtering, looking for the right trigger event... -- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/4f1eb390/attachment.htm From anton at appsolutions.com Fri Oct 3 10:59:12 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Fri Oct 3 10:39:50 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> Message-ID: <48E63340.50505@appsolutions.com> Dougal Stanton wrote: > 2008/10/3 Galchin, Vasili : >> Hello, >> >> One of my interests based on my education is "grand challenge science". >> Ok .. let's take the CERN Hadrian Accelerator. >> >> Where do you think Haskell can fit into the CERN Hadrian effort >> currently? >> >> Where do you think think Haskell currently is lacking and will have to >> be improved in order to participate in CERN Hadrian? > > Is that the experiment where Picts are accelerated to just short of > the speed of light in order to smash through to the Roman Empire? ;-) That's close: http://www.motivatedphotos.com/?id=3343&d=2 From magnus at therning.org Fri Oct 3 11:25:40 2008 From: magnus at therning.org (Magnus Therning) Date: Fri Oct 3 11:22:46 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <48E60922.2040309@gmail.com> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <48E3AD6B.2010409@gmail.com> <48E60922.2040309@gmail.com> Message-ID: On Fri, Oct 3, 2008 at 12:59 PM, Simon Marlow wrote: > Magnus Therning wrote: >> >> On Wed, Oct 1, 2008 at 6:03 PM, Simon Marlow >> wrote: >> [..] >>> >>> Dynamic linking doesn't solve all the problems, we still have the problem >>> that GHC does a lot of cross-module inlining, regardless of whether >>> dynamic >>> linking is used. However, I really would like to have a way to have >>> complete control over what is exposed across a package boundary. We need >>> this not just for licensing reasons, but also for making a dynamic >>> library >>> with a fixed ABI, so it can be upgraded later. >> >> I have a really hard time following this. Are you seriously saying >> that GHC is inlining code from modules _and_ link dynamically at the >> same time. That seems like a remarkably strange thing to do, or maybe >> I'm just missing something. > > That's exactly what would happen, if we shipped dynamic linking support with > GHC as it stands. It's just a linking mechanism, an alternative to static > linking, and has no impact on the amount or nature of inter-module > optimisation that GHC does. Ah, now I understand. The object for GHC would be to reduce the system-wide use of memory rather than substitutability of DLLs then, right? Why would it be interesting to have sharable objects without substitutability? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From marlowsd at gmail.com Fri Oct 3 11:50:52 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Oct 3 11:47:31 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <48E3AD6B.2010409@gmail.com> <48E60922.2040309@gmail.com> Message-ID: <48E63F5C.8070608@gmail.com> Magnus Therning wrote: > On Fri, Oct 3, 2008 at 12:59 PM, Simon Marlow wrote: >> Magnus Therning wrote: >>> On Wed, Oct 1, 2008 at 6:03 PM, Simon Marlow >>> wrote: >>> [..] >>>> Dynamic linking doesn't solve all the problems, we still have the problem >>>> that GHC does a lot of cross-module inlining, regardless of whether >>>> dynamic >>>> linking is used. However, I really would like to have a way to have >>>> complete control over what is exposed across a package boundary. We need >>>> this not just for licensing reasons, but also for making a dynamic >>>> library >>>> with a fixed ABI, so it can be upgraded later. >>> I have a really hard time following this. Are you seriously saying >>> that GHC is inlining code from modules _and_ link dynamically at the >>> same time. That seems like a remarkably strange thing to do, or maybe >>> I'm just missing something. >> That's exactly what would happen, if we shipped dynamic linking support with >> GHC as it stands. It's just a linking mechanism, an alternative to static >> linking, and has no impact on the amount or nature of inter-module >> optimisation that GHC does. > > Ah, now I understand. The object for GHC would be to reduce the > system-wide use of memory rather than substitutability of DLLs then, > right? > > Why would it be interesting to have sharable objects without substitutability? It'll make our binary distributions a lot smaller for one thing. Also, the on-disk size of binaries will be a lot smaller - this is something you notice if you run a GHC test suite, for example. Also, the GHCi binary contains the base package, but loads up another complete copy when it starts up. And if you load up the GHC package inside GHCi, then you have two complete copies of GHC in memory. Dynamic linking fixes all this. Cheers, Simon From duncan.coutts at worc.ox.ac.uk Fri Oct 3 11:50:39 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Oct 3 11:47:50 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <48E3AD6B.2010409@gmail.com> <48E60922.2040309@gmail.com> Message-ID: <1223049039.14163.383.camel@dell.linuxdev.us.dell.com> On Fri, 2008-10-03 at 16:25 +0100, Magnus Therning wrote: > Ah, now I understand. The object for GHC would be to reduce the > system-wide use of memory rather than substitutability of DLLs then, > right? > > Why would it be interesting to have sharable objects without substitutability? Hello world and plugins you want to load into foreign programs would be a few k rather than a few hundred or a few thousand k. Being able to substitute is something that may be possible later, at least for some packages. Simon has been mulling over some of the possibilities here. One idea is if you specifically want to build a .so or .dll with a stable ABI then you could declare that's what you want to do, and then not do cross-module inlining by default (except for those functions marked INLINE) then you can guarantee you're not breaking ABI so long as you do not change the types of exported functions or the implementations of functions marked INLINE. Extending the ABI in a compatible way needs more thought about a suitable mechanism. Duncan From allbery at ece.cmu.edu Fri Oct 3 12:26:13 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 12:23:27 2008 Subject: [Haskell-cafe] Alex and Flex In-Reply-To: <48E61CF0.1000901@libero.it> References: <48E53BB9.6060806@libero.it> <48E61CF0.1000901@libero.it> Message-ID: <18EA384C-064F-4813-BF5C-325A3D5041F0@ece.cmu.edu> On Oct 3, 2008, at 09:24 , Manlio Perillo wrote: > Manlio Perillo ha scritto: >> However I have noted that there are some difference in the syntax >> between Alex and Flex? >> What is the rationale? > > By the way, here is the list of differences between Alex and Flex I > have found, for people interested: > > 3) Alex does not support > [_a-z0-9-] > that must be rewritten as > [_a-z0-9\-] The only *reliable* way to write that cset is to put the '-' as the first item. Likewise for ']' (and if you must match both, "[-]...]"). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From fw at deneb.enyo.de Fri Oct 3 12:46:44 2008 From: fw at deneb.enyo.de (Florian Weimer) Date: Fri Oct 3 12:43:24 2008 Subject: [Haskell-cafe] Kind-agnostic type classes In-Reply-To: <7ca3f0160810030649k204e0720r808bec8d79e6380a@mail.gmail.com> (Luke Palmer's message of "Fri, 3 Oct 2008 07:49:38 -0600") References: <87r66y567p.fsf@mid.deneb.enyo.de> <7ca3f0160810030649k204e0720r808bec8d79e6380a@mail.gmail.com> Message-ID: <87ljx5zkwb.fsf@mid.deneb.enyo.de> * Luke Palmer: >> For instance, I've got >> >> class Assignable a where >> assign :: a -> a -> IO () >> >> class Swappable a where >> swap :: a -> a -> IO () >> >> class CopyConstructible a where >> copy :: a -> IO a >> >> class (Assignable a, CopyConstructible a) => ContainerType a >> >> class (Swappable c, Assignable c, CopyConstructible c) => Container c where >> size :: (Num i, ContainerType t) => c t -> IO i > > Which is illegal because the three above classes force c to be kind *, > but you're using it here as kind * -> *. > > What you want is not this informal "kind-agnostic" classes so much as > quantification in constraints, I presume. This, if it were supported, > would solve your problem. > > class (forall t. Swappable (c t), forall t. Assignable (c t), forall > t. CopyConstructible (c t)) => Contanter c where ... In the meantime, I figured out that in ML, it suffices to make the Container type c non-polymorphic (although the syntactic overhead is rather problematic). Trying to the same in Haskell, I learnt something about functional dependencies. I actually ended up with: class (Assignable c, CopyConstructible c, Swappable c, ContainerType t, Num s) => Container c s t | c -> s, c -> t where size :: c -> IO Int empty ::c -> IO Bool empty c = do sz <- size c return (sz == 0) (In fact, I stumbled across "A Comparative Study of Language Support for Generic Programming" by Garcia et al., which contains a very helpful Haskell example with functional dependencies and multi-parameter type classes.) From g9ks157k at acme.softbase.org Fri Oct 3 13:01:06 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Oct 3 12:57:42 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> References: <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> Message-ID: <200810031901.06303.g9ks157k@acme.softbase.org> Am Freitag, 3. Oktober 2008 13:36 schrieben Sie: > [?] > What happens in the C++ world where good chunk of functionnalities are > in header files (templates or inline methods); > is there the same LGPL problem that the one discussed here w.r.t. > static/shared linking ? I've never heard about problems with macros etc. but I think that the LGPL is problematic if you use templates. Best wishes, Wolfgang From jason.dusek at gmail.com Fri Oct 3 13:07:32 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 3 13:04:08 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> Message-ID: <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> Lennart Augustsson wrote: > Let me pick one example. Let's make a class that can convert > between tuples and lists. > > -- XXX This doesn't work, and is just wrong. > -- instance TupleList (a) [a] where > -- tupleToList (a) = [a] > -- listToTuple [a] = (a) It's not clear to me what is so "wrong" about it. If the 1-ary tuple is the 1-ary product, it makes sense. -- _jsn From leimy2k at gmail.com Fri Oct 3 13:08:34 2008 From: leimy2k at gmail.com (David Leimbach) Date: Fri Oct 3 13:05:09 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> Message-ID: <3e1162e60810031008k1037be91q2a581527accdfee0@mail.gmail.com> On Fri, Oct 3, 2008 at 4:36 AM, minh thu wrote: > 2008/10/3 Mitchell, Neil : > > > > Hi > > > > > >> > > You mean shared libraries without the opportunity to > >> inline library code? > >> > > This would result in a huge performance loss, I think. > >> > > >> > Usually _mild_ performance loss, in exchange for major code-size > >> > savings, I would think. C obviously has worked quite fine under > >> > exactly this restraint (though C implementations obviously aren't > >> > built to take as great advantage of inlining library code > >> as Haskell may be). > >> > >> I think that the performance loss is much higher in the case > >> of Haskell because of Lazy Evaluation, massive use of higher > >> order functions and possibly more. > > > > Example 1: > > > > foo x | "test" `isPrefixOf` xs = ... > > | otherwise = ... > > > > If you have cross-module inlining, you get the rather obvious if like > > construct. If you don't, you have to evaluate otherwise and test its > > value. > > > > Example 2: > > > > (a :: Int) + b > > > > If you have cross-module specialisation you get a primitive integer > > arithmetic instruction (possibly with a bit of unboxing, although often > > not). If you don't, you get a dictionary lookup, followed by a higher > > order application. > > > > One reason cross-module inlining is essential is that many Haskell > > functions don't do very much, think of (+), (||), (>>), not, otherwise > > etc. In C these would be built-in's, so are always available to the > > optimiser (and usually just one instruction), in Haskell you need to get > > them from the Prelude. > > What happens in the C++ world where good chunk of functionnalities are > in header files (templates or inline methods); > is there the same LGPL problem that the one discussed here w.r.t. > static/shared linking ? > I don't know what happens on platforms that don't have shared libraries with LGPL. If you build stuff statically, I'm pretty sure you can't claim stuff is loosely coupled. Dave > > Thanks, > Thu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/f716ec44/attachment.htm From jonathanccast at fastmail.fm Fri Oct 3 13:11:49 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 3 13:15:21 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <3e1162e60810031008k1037be91q2a581527accdfee0@mail.gmail.com> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> <33A3F585590A6F4E81E3D45AA4A111C902CD3A88@ELON17P32001A.csfb.cs-group.com> <40a414c20810030436u587e367am7caee25c474957e2@mail.gmail.com> <3e1162e60810031008k1037be91q2a581527accdfee0@mail.gmail.com> Message-ID: <1223053909.3452.11.camel@jcchost> On Fri, 2008-10-03 at 10:08 -0700, David Leimbach wrote: > > > On Fri, Oct 3, 2008 at 4:36 AM, minh thu wrote: > 2008/10/3 Mitchell, Neil : > > > > > Hi > > > > > >> > > You mean shared libraries without the opportunity to > >> inline library code? > >> > > This would result in a huge performance loss, I think. > >> > > >> > Usually _mild_ performance loss, in exchange for major > code-size > >> > savings, I would think. C obviously has worked quite fine > under > >> > exactly this restraint (though C implementations > obviously aren't > >> > built to take as great advantage of inlining library code > >> as Haskell may be). > >> > >> I think that the performance loss is much higher in the > case > >> of Haskell because of Lazy Evaluation, massive use of > higher > >> order functions and possibly more. > > > > Example 1: > > > > foo x | "test" `isPrefixOf` xs = ... > > | otherwise = ... > > > > If you have cross-module inlining, you get the rather > obvious if like > > construct. If you don't, you have to evaluate otherwise and > test its > > value. > > > > Example 2: > > > > (a :: Int) + b > > > > If you have cross-module specialisation you get a primitive > integer > > arithmetic instruction (possibly with a bit of unboxing, > although often > > not). If you don't, you get a dictionary lookup, followed by > a higher > > order application. > > > > One reason cross-module inlining is essential is that many > Haskell > > functions don't do very much, think of (+), (||), (>>), not, > otherwise > > etc. In C these would be built-in's, so are always available > to the > > optimiser (and usually just one instruction), in Haskell you > need to get > > them from the Prelude. > > > What happens in the C++ world where good chunk of > functionnalities are > in header files (templates or inline methods); > is there the same LGPL problem that the one discussed here > w.r.t. > static/shared linking ? > > > I don't know what happens on platforms that don't have shared > libraries with LGPL. If you build stuff statically, I'm pretty sure > you can't claim stuff is loosely coupled. What I've always heard is that in that case you have to distribute object files. This would work for Haskell, except that changing the distributed library is still liable to invalidate the object files, due to cross-module inlining. jcc From andrewcoppin at btinternet.com Fri Oct 3 13:34:26 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 13:30:56 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5439B.9010606@daimi.au.dk> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> Message-ID: <48E657A2.50408@btinternet.com> Tillmann Rendel wrote: > Seriously, what are you talking about? The haddock page for > Control.Applicative hoogle links to begins with > >> This module describes a structure intermediate between a functor and >> a monad: it provides pure expressions and sequencing, but no binding. >> (Technically, a strong lax monoidal functor.) For more details, see >> Applicative Programming with Effects, by Conor McBride and Ross >> Paterson, online at >> http://www.soi.city.ac.uk/~ross/papers/Applicative.html. >> >> This interface was introduced for parsers by Niklas R?jemo, because >> it admits more sharing than the monadic interface. The names here are >> mostly based on recent parsing work by Doaitse Swierstra. >> >> This class is also useful with instances of the Traversable class. > > I agree that this is hard to understand, but it's more then just > "strong lax monoidal functor", isn't it? More importantly, there is a > reference to a wonderful and easy to read paper. (easy in the "easy > for Haskell programmers" sense, not in the "easy for the authors, and > maybe the inventors of Haskell" sense). Just give it a try. > > Just in case you missed the link for some reason, here is it again: > > http://www.soi.city.ac.uk/~ross/papers/Applicative.html You must have a radically different idea of "easy to read paper" than I have. ;-) Anyway, after multiple hours of staring at this paper and watching intricate type signatures swim before my eyes, I simply ended up being highly confused. (I especially like the way that what's described in the paper doesn't quite match what's in the actual Haskell standard libraries...) After many hours of thinking about this, I eventually began to vaguely comprehend what it's saying. (I suspect the problem is that, rather like monads, the concepts it's attempting to explain are just so extremely abstract that it's hard to develop an intuitive notion about them.) So... something that's "applicative" is sort-of like a monad, but where the next action cannot vary depending on the result of some prior action? Is that about the size of it? (If so, why didn't you just *say* so?) But on the other hand, that would seem to imply that every monad is trivially applicative, yet studying the libraries this is not the case. Indeed several of the libraries seem to go out of their way to implement duplicate functionallity for monad and applicative. (Hence the sea of identical and nearly identical type sigantures for functions with totally different names that had me confused for so long.) If you think in terms of containers, then "c x" is a container of "x values". Then, the type signature sequence :: c1 (c2 x) -> c2 (c1 x) kind-of makes sense. (Obviously the two containers are constrained to particular classes.) So that's "traversable", is it? Again, we have "sequence" and "sequenceA", indicating that monads and applicatives aren't actually the same somehow. Also, before you can put anything into Traversable, it has to be in Functor (no hardship there) and Foldable. Foldable seems simplish, except that it refers to some odd "monoid" class that looks suspiciously like "MonadPlus" but isn't... wuh? OK, maybe I should just stop attempting to comprehend this stuff and write the code... At this point learning about applicative and traversable isn't actually solving my problem. From dave at zednenem.com Fri Oct 3 13:36:45 2008 From: dave at zednenem.com (David Menendez) Date: Fri Oct 3 13:33:20 2008 Subject: [Haskell-cafe] Kind-agnostic type classes In-Reply-To: <7ca3f0160810030649k204e0720r808bec8d79e6380a@mail.gmail.com> References: <87r66y567p.fsf@mid.deneb.enyo.de> <7ca3f0160810030649k204e0720r808bec8d79e6380a@mail.gmail.com> Message-ID: <49a77b7a0810031036w207b5fcagea5b80cf23a13031@mail.gmail.com> On Fri, Oct 3, 2008 at 9:49 AM, Luke Palmer wrote: > On Fri, Oct 3, 2008 at 4:22 AM, Florian Weimer wrote: >> I'm trying to encode a well-known, informally-specified type system in >> Haskell. What causes problems for me is that type classes force types >> to be of a specific kind. The system I'm targeting however assumes that >> its equivalent of type classes are kind-agnositic. > > There is no choice of kinds, they are forced by the methods (since the > kind of an actual argument is * by definition). But see below. > >> For instance, I've got >> >> class Assignable a where >> assign :: a -> a -> IO () >> >> class Swappable a where >> swap :: a -> a -> IO () >> >> class CopyConstructible a where >> copy :: a -> IO a >> >> class (Assignable a, CopyConstructible a) => ContainerType a >> >> class (Swappable c, Assignable c, CopyConstructible c) => Container c where >> size :: (Num i, ContainerType t) => c t -> IO i > > Which is illegal because the three above classes force c to be kind *, > but you're using it here as kind * -> *. > > What you want is not this informal "kind-agnostic" classes so much as > quantification in constraints, I presume. This, if it were supported, > would solve your problem. > > class (forall t. Swappable (c t), forall t. Assignable (c t), forall > t. CopyConstructible (c t)) => Contanter c where ... > > Incidentally, you *can* do this if you go to a dictionary passing > style (because then you are providing the proofs, rather than asking > the compiler to infer them, which is probably undecidable (what isn't > ;-)). You don't necessarily need explicit dictionaries. For example, I've occasionally wanted to have a constraint (forall a. Show a => Show (f a)). One fairly simple way to do this to declare a new class. class Show1 f where showsPrec1 :: (Show a) => Int -> f a -> ShowS instance Show1 [] where showsPrec1 = showsPrec The same technique is used in Data.Typeable. -- Dave Menendez From manlio_perillo at libero.it Fri Oct 3 13:37:38 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Oct 3 13:34:20 2008 Subject: [Haskell-cafe] Alex and Flex In-Reply-To: <48E61CF0.1000901@libero.it> References: <48E53BB9.6060806@libero.it> <48E61CF0.1000901@libero.it> Message-ID: <48E65862.8020603@libero.it> Manlio Perillo ha scritto: > Manlio Perillo ha scritto: >> Hi. >> >> I'm starting to write a CSS parser with Alex and Happy. >> The grammar is defined here: >> http://www.w3.org/TR/CSS21/grammar.html >> >> However I have noted that there are some difference in the syntax >> between Alex and Flex? >> What is the rationale? >> >> >> One more thing. >> Here: http://www.haskell.org/alex/doc/html/alex-files.html >> it seems that there is an error with >> macrodef := @smac '=' set >> | @rmac '=' regexp >> >> it should be >> macrodef := $smac '=' set >> | @rmac '=' regexp >> > > Ok, this is not an error, sorry. > > > By the way, here is the list of differences between Alex and Flex I have > found, for people interested: > > [...] Another problem. In this rule: @comment = \/\*[^\*]*\*+([^\/\*][^\*]*\*+)*\/ [^\*] means "all characters except '*'", but Alex seems to not include the new line character. So a comment like /* A comment */ generates a lexical error. Is this true? Thanks Manlio Perillo From andrewcoppin at btinternet.com Fri Oct 3 13:39:08 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 13:35:38 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> Message-ID: <48E658BC.3030705@btinternet.com> David Menendez wrote: > On Thu, Oct 2, 2008 at 3:40 PM, Andrew Coppin > wrote: > >> David Menendez wrote: >> >>> You could try using an exception monad transformer here >>> >> I thought I already was? >> > > No, a monad transformer is a type constructor that takes a monad as an > argument and produces another monad. So, (ErrorT ErrorType) is a monad > transformer, and (ErrorT ErrorType m) is a monad, for any monad m. > Right, OK. > If you look at the type you were using, you see that it breaks down into > (Either ErrorType) (ResultSet State), where Either ErrorType :: * -> * > and ResultSet State :: *. Thus, the monad is Either ErrorType. The > fact that ResultSet is also a monad isn't enough to give you an > equivalent to (>>=), without one of the functions below. > OK, that makes sense. >> Uh... what's Applicative? (I had a look at Control.Applicative, but it just >> tells me that it's "a strong lax monoidal functor". Which isn't very >> helpful, obviously.) >> > > Applicative is a class of functors that are between Functor and Monad > in terms of capabilities. Instead of (>>=), they have an operation > (<*>) :: f (a -> b) -> f a -> f b, which generalizes Control.Monad.ap. > (As an aside, Control.Monad.ap is not a function I've ever heard of. It seems simple enough, but what an unfortunate name...!) > The nice thing about Applicative functors is that they compose. > > With monads, you can't make (Comp m1 m2) a monad without a function > analogous to inner, outer, or swap. > So I see. I'm still not convinced that Applicative helps me in any way though... > From your code examples, it isn't clear to me that applicative > functors are powerful enough, but I can't really say without knowing > what you're trying to do. The whole list-style "multiple inputs/multiple outputs" trip, basically. > The fact that the functions you gave take a > state as an argument and return a state suggests that things could be > refactored further. > If you look at run_or, you'll see that this is _not_ a simple state monad, as in that function I run two actions starting from _the same_ initial state - something which, AFAIK, is impossible (or at least very awkward) with a state monad. Really, it's a function that takes a state and generates a new state, but it may also happen to generate *multiple* new states. It also consumes a Foo or two in the process. From micah at cowan.name Fri Oct 3 13:42:45 2008 From: micah at cowan.name (Micah Cowan) Date: Fri Oct 3 13:39:20 2008 Subject: [Haskell-cafe] Source of 16x16 Sudokus? In-Reply-To: References: <1F72E494C6E94566BCAC4C63F3798252@Euler> Message-ID: <48E65995.3040505@cowan.name> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gianfranco Alongi wrote: > Nice set of games :) > > Truly a source of inspiration for programming. I'm particularly fond of his "Minesweeper" game that has the ability to generate guaranteed-solvable puzzles (every bit as challenging as a regular Mines game, but without the chance that you'll actually be truly forced to guess). Simon Tatham, of course, is also the author of PuTTY. Also, I discovered the "divide-and-conquer" method for counting the number of set bits in a bit-vector by looking through the sources for "Mines". - -- Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer. GNU Maintainer: wget, screen, teseq http://micah.cowan.name/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFI5lmV7M8hyUobTrERAueQAJ9eerZ6V6Klrtr4wVxoT305eBsM2QCeOVpT 6CTeEBsuxYwv0MntiKsnJDM= =v+Lf -----END PGP SIGNATURE----- From jake at pikewerks.com Fri Oct 3 13:43:24 2008 From: jake at pikewerks.com (Jake McArthur) Date: Fri Oct 3 13:39:59 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E657A2.50408@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> Message-ID: <48E659BC.40604@pikewerks.com> Andrew Coppin wrote: > But on the other hand, that would seem to imply that every monad is > trivially applicative, yet studying the libraries this is not the > case. Indeed several of the libraries seem to go out of their way to > implement duplicate functionallity for monad and applicative. (Hence > the sea of identical and nearly identical type sigantures for > functions with totally different names that had me confused for so long.) Actually, it is the case. It is technically possible to write: instance Monad m => Applicative m where pure = return (<*>) = ap We don't include the above definition because it elimimates all possibility of specialization. The reason for the separation of the two for many functions is so that types which are instances of only one of the two can still take advantage of the functionality. > Foldable seems simplish, except that it refers to some odd "monoid" > class that looks suspiciously like "MonadPlus" but isn't... wuh? A Monoid is simply anything that has an identity element (mempty) and an associative binary operation (mappend). It is not necessary for a complete instance of Foldable. - Jake From micah at cowan.name Fri Oct 3 13:47:43 2008 From: micah at cowan.name (Micah Cowan) Date: Fri Oct 3 13:44:18 2008 Subject: [Haskell-cafe] Hmm, what license to use? In-Reply-To: <200810022125.52631.g9ks157k@acme.softbase.org> References: <200810022025.20473.g9ks157k@acme.softbase.org> <48E513F7.7030401@cowan.name> <200810022125.52631.g9ks157k@acme.softbase.org> Message-ID: <48E65ABF.7020903@cowan.name> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Wolfgang Jeltsch wrote: > Am Donnerstag, 2. Oktober 2008 20:33 schrieben Sie: >> Wolfgang Jeltsch wrote: >>> You mean shared libraries without the opportunity to inline library code? >>> This would result in a huge performance loss, I think. >> Usually _mild_ performance loss, in exchange for major code-size >> savings, I would think. C obviously has worked quite fine under exactly >> this restraint (though C implementations obviously aren't built to take >> as great advantage of inlining library code as Haskell may be). > > I think that the performance loss is much higher in the case of Haskell > because of Lazy Evaluation, massive use of higher order functions and > possibly more. Maybe one of the GHC developers could comment on this? Perhaps the best approach currently for creating dynamically loadable modules in Haskell is to expose the interface via FFI, then? (I suspect that in most cases, you'd want to provide that as an option, but of course not as the only means of interfacing with the library, for those who don't want to make the DLL-vs-optimizations tradeoff.) - -- Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer. GNU Maintainer: wget, screen, teseq http://micah.cowan.name/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFI5lq/7M8hyUobTrERAn7aAJwPz4wbu0W4RPNhlgKGmd+2glZDewCfbi9d LQtahiILQg83vkzyfAR2BV4= =mjFe -----END PGP SIGNATURE----- From andrewcoppin at btinternet.com Fri Oct 3 14:01:20 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 13:57:50 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5025B.1040908@btinternet.com> References: <48E5025B.1040908@btinternet.com> Message-ID: <48E65DF0.7090301@btinternet.com> Andrew Coppin wrote: > Consider the following beautiful code: > > run :: State -> Foo -> ResultSet State > > run_and :: State -> Foo -> Foo -> ResultSet State > run_and s0 x y = do > s1 <- run s0 x > s2 <- run s1 y > return s2 > > run_or :: State -> Foo -> Foo -> ResultSet State > run_or s0 x y = merge (run s0 x) (run s0 y) Right, well, it turns out that if I replace every ResultSet State with ErrorT ErrorType ResultSet State then the run_and function still typechecks! (I have no idea whether it still produces the correct result, but it typechecks.) The run_or function now becomes highly problematic. The function runErrorT essentially ends up being runErrorT :: ErrorT ErrorType ResultSet State -> Either ErrorType (ResultSet State) which looks promising. But that means I end up with runErrorT (run s0 x) :: ResultSet (Either ErrorType State) which isn't what I want at all. What *I* want is something more like Either ErrorType (ResultSet State). After much searching (Hoogle rather failed me here), I discover that if ResultSet happened to be in Traversable then I'd have a function called "sequence" which performs the exact type transformation I want. Then, utilising the fact that Either is itself a kind of error monad, I can do run_or s0 x y = let either_rset1 = sequence $ run s0 x either_rset2 = sequence $ run s0 y either_rset3 = do rset1 <- either_rset1; rset2 <- either_rset2; return (merge rset1 rset2) However, now I have a problem. I have either_rset3 :: Either ErrorType (ResultSet State), and I need to somehow get back to ErrorT ErrorType ResultSet State. Well, the first part is easy: case either_rset3 of Left e -> throwError e Right rset -> uh... Now I need some function from ResultSet State to ErrorT ErrorType ResultSet State. It looks like such a function ought to exist, but... uh... well I had to use Hoogle to find it. After some poking, it found a function called "lift" from a module I didn't even know about called Control.Monad.Trans. This has the exact signature I want, so we have run_or s0 x y = let either_rset1 = sequence $ run s0 x either_rset2 = sequence $ run s0 y either_rset3 = do rset1 <- either_rset1; rset2 <- either_rset2; return (merge rset1 rset2) in case either_rset3 of Left e -> throwError e Right rset -> lift rset Again, this now typechecks. I have *no clue* if it behaves correctly. (Most specifically, I've only tried using it with dummy types to see if the type checker will swallow it, so I haven't attempted writing an instance for Traversable yet. Maybe I'll go look at the list definition for this to see how it works...) So, assuming all this stuff does what I *think* it does, it looks like I've got this working. But _damn_, couldn't they have written down instructions somewhere? This has taken me all day...! o_O From manlio_perillo at libero.it Fri Oct 3 14:03:18 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Oct 3 14:00:11 2008 Subject: [Haskell-cafe] Alex and Flex In-Reply-To: <48E65862.8020603@libero.it> References: <48E53BB9.6060806@libero.it> <48E61CF0.1000901@libero.it> <48E65862.8020603@libero.it> Message-ID: <48E65E66.3060505@libero.it> Manlio Perillo ha scritto: > [...] > Another problem. > > In this rule: > @comment = \/\*[^\*]*\*+([^\/\*][^\*]*\*+)*\/ > > [^\*] means "all characters except '*'", but Alex seems to not include > the new line character. > Again sorry. The problem was not here. There was a missing rule for '.', to scan every characters. Regards Manlio Perillo From andrewcoppin at btinternet.com Fri Oct 3 14:09:28 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 14:05:56 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <48E65DF0.7090301@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> Message-ID: <48E65FD8.2030504@btinternet.com> Andrew Coppin wrote: > After much searching (Hoogle rather failed me here), I discover that... I could probably elaborate on that point further. Try doing a Hoogle search for "c1 (c2 x) -> c2 (c1 x)". Hoogle correctly states that Data.Traversable.sequence will do it for you. Now try doing "c1 k (c2 x) -> c2 (c1 k x)". The 'sequence' function will also do this, but now Hoogle returns 0 results. This is puzzling, since AFAIK, the above two type signatures are "equvilent" in some sense. (Specifically, replace every type X with type Y and you get from one to the other.) To me, this looks like a Hoogle bug. (It goes without saying that Hoogle also failed to find anything for the more specific type signature I was searching for, despite the fact that 'sequence' unifies with it.) Is this a known issue? From jake at pikewerks.com Fri Oct 3 14:30:46 2008 From: jake at pikewerks.com (Jake McArthur) Date: Fri Oct 3 14:27:31 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E658BC.3030705@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> Message-ID: <48E664D6.2070406@pikewerks.com> Andrew Coppin wrote: > (As an aside, Control.Monad.ap is not a function I've ever heard of. > It seems simple enough, but what an unfortunate name...!) I think it makes sense. It stands for "apply," or at least that is what I think of when I see it. If we have a function f :: A -> B -> C -> D and values a :: m A, b :: m B, c :: m C, then we can do: f `liftM` a `ap` b `ap` c ... which is the same as (using Applicative): f <$> a <*> b <*> c ... both having type m D. - Jake From mads_lindstroem at yahoo.dk Fri Oct 3 14:33:09 2008 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Fri Oct 3 14:30:32 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <87od24dtg9.fsf@gaura-nitai.no-ip.org> References: <6205bd290809281738o6cbce23dpf3a43bfd7e35a6db@mail.gmail.com> <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <87od24dtg9.fsf@gaura-nitai.no-ip.org> Message-ID: <1223058789.4490.7.camel@localhost.localdomain> Hi Gour wrote: > >>>>> "Don" == Don Stewart writes: > > Don> * Only a small percent of Haskell libarires are LGPL, and > Don> nothing for which we don't have workarounds (e.g. HDBC vs > Don> galois-sqlite3 vs takusen). > > Hmm, Gtk2Hs & wxhaskell - major GUI libs... wxHaskell uses a modified LGPL license (wxWidgets license). One that allows static linking. See http://www.haskell.org/haskellwiki/WxHaskell/License . From the description of the wxWidgets license http://www.wxwidgets.org/about/newlicen.htm : "The wxWindows Licence is essentially the L-GPL (Library General Public Licence), with an exception stating that derived works in binary form may be distributed on the user's own terms. This is a solution that satisfies those who wish to produce GPL'ed software using wxWidgets, and also those producing proprietary software." Greetins, Mads Lindstr?m > > Sincerely, > Gour > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Fri Oct 3 15:10:27 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:06:57 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E659BC.40604@pikewerks.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> Message-ID: <48E66E23.6060306@btinternet.com> Jake McArthur wrote: > Andrew Coppin wrote: >> But on the other hand, that would seem to imply that every monad is >> trivially applicative, yet studying the libraries this is not the case. > Actually, it is the case. It is technically possible to write: > > instance Monad m => Applicative m where > pure = return > (<*>) = ap > > We don't include the above definition because it elimimates all > possibility of specialization. I don't follow. > The reason for the separation of the two for many functions is so that > types which are instances of only one of the two can still take > advantage of the functionality. Well, that makes sense once you assume two seperate, unconnected classes. I'm still fuzzy on that first point though. >> Foldable seems simplish, except that it refers to some odd "monoid" >> class that looks suspiciously like "MonadPlus" but isn't... wuh? > A Monoid is simply anything that has an identity element (mempty) and > an associative binary operation (mappend). It is not necessary for a > complete instance of Foldable. Again, it looks like MonadPlus == Monad + Monoid, except all the method names are different. Why do we have this confusing duplication? From andrewcoppin at btinternet.com Fri Oct 3 15:14:22 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:10:51 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E664D6.2070406@pikewerks.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <48E664D6.2070406@pikewerks.com> Message-ID: <48E66F0E.7010900@btinternet.com> Jake McArthur wrote: > Andrew Coppin wrote: >> (As an aside, Control.Monad.ap is not a function I've ever heard of. >> It seems simple enough, but what an unfortunate name...!) > I think it makes sense. It stands for "apply," or at least that is > what I think of when I see it. There can be little doubt that this is what the designers intended. However, why didn't they name it, say, "apply"? I just think that Haskell already has too many names like "id" and "nub" and "elem" and "Eq" and "Ix". Would it kill anybody to write out more descriptive names? Also, I'm fuzzy on why ap is even a useful function to have in the first place. I can see what it does, but when are you ever going to need a function like that? (I'm not saying we should get rid of it, I'm just puzzled as to why anybody thought to include it to start with.) > If we have a function f :: A -> B -> C -> D and values a :: m A, b :: > m B, c :: m C, then we can do: > > f `liftM` a `ap` b `ap` c > > ... which is the same as (using Applicative): > > f <$> a <*> b <*> c > > ... both having type m D. Again we seem to have two different sets of functions which none the less appear to do exactly the same thing. From dave at zednenem.com Fri Oct 3 15:17:27 2008 From: dave at zednenem.com (David Menendez) Date: Fri Oct 3 15:14:00 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E658BC.3030705@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> Message-ID: <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> On Fri, Oct 3, 2008 at 1:39 PM, Andrew Coppin wrote: > David Menendez wrote: >> >> Applicative is a class of functors that are between Functor and Monad >> in terms of capabilities. Instead of (>>=), they have an operation >> (<*>) :: f (a -> b) -> f a -> f b, which generalizes Control.Monad.ap. >> > > (As an aside, Control.Monad.ap is not a function I've ever heard of. It > seems simple enough, but what an unfortunate name...!) I believe it's short for "apply". "ap" generalizes the liftM* functions, so liftM2 f a b = return f `ap` a `ap` b liftM3 f a b c = return f `ap` a `ap` b `ap` c and so forth. It wasn't until fairly recently that people realized that you could do useful things if you had "return" and "ap", but not (>>=), which why we have some unfortunate limitations in the Haskell prelude, like Applicative not being a superclass of Monad. This leads to all the duplication between Applicative and Monad. In a perfect world, we would only need the Applicative versions. >> The nice thing about Applicative functors is that they compose. >> >> With monads, you can't make (Comp m1 m2) a monad without a function >> analogous to inner, outer, or swap. >> > > So I see. I'm still not convinced that Applicative helps me in any way > though... To be honest, neither am I. But it's a useful thing to be aware of. >> From your code examples, it isn't clear to me that applicative >> functors are powerful enough, but I can't really say without knowing >> what you're trying to do. > > The whole list-style "multiple inputs/multiple outputs" trip, basically. Would you be willing to share the implementation of ResultSet? If you're relying on a list somewhere, then it should be possible to switch the implementation to one of the nondeterminism monad transformers, which would give you the exception behavior you want. >> The fact that the functions you gave take a >> state as an argument and return a state suggests that things could be >> refactored further. >> > > If you look at run_or, you'll see that this is _not_ a simple state monad, > as in that function I run two actions starting from _the same_ initial state > - something which, AFAIK, is impossible (or at least very awkward) with a > state monad. > > Really, it's a function that takes a state and generates a new state, but it > may also happen to generate *multiple* new states. It also consumes a Foo or > two in the process. That's what happens if you apply a state monad transformer to a nondeterminism monad. plusMinusOne :: StateT Int [] () plusMinusOne = get s >>= \s -> mplus (put $ s + 1) (put $ s - 1) execStateT plusMinusOne 0 == [1,-1] execStateT (plusMinusOne >> plusMinusOne) 0 == [2,0,0,-2] (FYI, execStateT is similar to runStateT, except that it discards the return value, which is () in our example.) So it might be possible to rewrite your code along these lines: type M = StateT State [] run :: Foo -> M () runOr :: Foo -> Foo -> M () runOr x y = mplus (run x) (run y) runAnd :: Foo -> Foo -> M () runAnd x y = run x >> run y The type "StateT State [] alpha" is isomorphic to "State -> [(alpha, State)]", which means that each of the computations in mplus gets its own copy of the state. There are a few ways to add exceptions to this, depending on how you want the exceptions to interact with the non-determinism. 1. StateT State (ErrorT ErrorType []) alpha This corresponds to "State -> [(Either ErrorType alpha, State)]". Each branch maintains its own state and is isolated from exceptions in other branches. In other words, catchErr (mplus a b) h == mplus (catchErr a h) (catchErr b h) 2. StateT State (NondetT (Either ErrorType)) alpha (NondetT isn't in the standard libraries, but I can provide code if needed.) This corresponds to "State -> Either ErrorType [(alpha, State)]". Left uncaught, an exception raised in any branch will cause all branches to fail. mplus (throw e) a == throw e -- Dave Menendez From dave at zednenem.com Fri Oct 3 15:31:29 2008 From: dave at zednenem.com (David Menendez) Date: Fri Oct 3 15:28:03 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E66E23.6060306@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> Message-ID: <49a77b7a0810031231s678f416n23fbb89de25189d6@mail.gmail.com> On Fri, Oct 3, 2008 at 3:10 PM, Andrew Coppin wrote: > Jake McArthur wrote: >> >> Andrew Coppin wrote: >>> >>> But on the other hand, that would seem to imply that every monad is >>> trivially applicative, yet studying the libraries this is not the case. >> >> Actually, it is the case. It is technically possible to write: >> >> instance Monad m => Applicative m where >> pure = return >> (<*>) = ap >> >> We don't include the above definition because it elimimates all >> possibility of specialization. > > I don't follow. For some monads, there are implementations of <*> which are more efficient than the one provided by ap. Similarly, there are ways to implement fmap which are more efficient than using liftM. Of course, the *real* reason we don't define the instance given above is that there are instances of Applicative that aren't monads, and we want to avoid overlapping instances. >> The reason for the separation of the two for many functions is so that >> types which are instances of only one of the two can still take advantage of >> the functionality. > > Well, that makes sense once you assume two seperate, unconnected classes. > I'm still fuzzy on that first point though. It's historical. Monad pre-dates Applicative by several years. Because it's part of the Haskell 98 standard, no one is willing to change Monad to make Applicative a superclass. Thus all the duplication. (Also, many of the duplicate functions are found in the Haskell 98 report, so we can't replace them with their more-general Applicative variants.) >>> Foldable seems simplish, except that it refers to some odd "monoid" class >>> that looks suspiciously like "MonadPlus" but isn't... wuh? >> >> A Monoid is simply anything that has an identity element (mempty) and an >> associative binary operation (mappend). It is not necessary for a complete >> instance of Foldable. > > Again, it looks like MonadPlus == Monad + Monoid, except all the method > names are different. Why do we have this confusing duplication? There are at least three reasons why MonadPlus and Monoid are distinct. First, MonadPlus is older than Monoid, even though Monoid is more general. Second, MonadPlus and Monoid have different kinds, * -> * and *, respectively. Instances of MonadPlus are more restricted, because they have to work with any type parameter, whereas instances of Monoid can place constraints. Third, instances of MonadPlus must follow additional laws relating the behavior of mplus and mzero to return and (>>=). -- Dave Menendez From dons at galois.com Fri Oct 3 15:38:35 2008 From: dons at galois.com (Don Stewart) Date: Fri Oct 3 15:35:06 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> Message-ID: <20081003193835.GD26436@scytale.galois.com> wchogg: > On Fri, Oct 3, 2008 at 5:47 AM, Dougal Stanton wrote: > > 2008/10/3 Galchin, Vasili : > >> Hello, > >> > >> One of my interests based on my education is "grand challenge science". > >> Ok .. let's take the CERN Hadrian Accelerator. > >> > >> Where do you think Haskell can fit into the CERN Hadrian effort > >> currently? > >> > >> Where do you think think Haskell currently is lacking and will have to > >> be improved in order to participate in CERN Hadrian? > > > > Is that the experiment where Picts are accelerated to just short of > > the speed of light in order to smash through to the Roman Empire? ;-) > > > > I don't know what the main computational challenges are to the LHC > > researchers. The stuff in the press has mostly been about > > infrastructure --- how to store the gigabytes of data per second that > > they end up keeping, out of the petabytes that are produced in the > > first place (or something). > > Well, with the LHC efforts I don't think a technology like Haskell > really has a place...at least not now. Even just a few years back, > when I worked on this stuff, we were still doing lots of simulation in > preparation for the actual live experiment and Haskell might have been > a good choice for some of the tools. All of the detector simulation > was written in C++, because C++ is the new FORTRAN to physicists, and > you ain't seen nothing till you've seen a jury-rigged form of lazy > evaluation built into a class hierarchy in C++. Now, would the C++ > based simulation have run faster than a Haskell based one? Quite > possibly. On the other hand, I remember how many delays and problems > were caused by the sheer complexity of the codebase. That's where a > more modern programming language might have been extremely helpful. How about EDSLs for producing high assurance controllers, and other robust devices they might need. I imagine the LHC has a good need for verified software components... From dave at zednenem.com Fri Oct 3 15:38:11 2008 From: dave at zednenem.com (David Menendez) Date: Fri Oct 3 15:35:16 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> Message-ID: <49a77b7a0810031238k5a7fb612s14f4f10fa24f2c34@mail.gmail.com> On Fri, Oct 3, 2008 at 3:17 AM, Jason Dusek wrote: > Perhaps I am lacking in imagination, but I still can't see the > value of one tuples. You can use them to defeat seq. undefined `seq` x == undefined OneTuple undefined `seq` x == x That might be useful if a polymorphic function is using seq to force evaluation, and you don't want it to. But I can't imagine that coming up much in practice. -- Dave Menendez From paul at cogito.org.uk Fri Oct 3 15:38:33 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Fri Oct 3 15:35:28 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E133D0.8080702@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> Message-ID: <48E674B9.8040501@cogito.org.uk> Andrew Coppin wrote: > > Oh, no. The entire bar is 2 Kg, I wasn't actually planning to eat the > whole thing! o_O My god, my pancreas would explode or something... My Dad once ate two bars of dark cooking chocolate. He said he got some odd visual distortions; flickering auras around things, and size distortions where small things looked big and big things looked small. Paul. From ryani.spam at gmail.com Fri Oct 3 15:40:46 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Oct 3 15:37:21 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E66E23.6060306@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> Message-ID: <2f9b2d30810031240g327559e7k495aac039d6b8470@mail.gmail.com> On Fri, Oct 3, 2008 at 12:10 PM, Andrew Coppin wrote: > Again, it looks like MonadPlus == Monad + Monoid, except all the method > names are different. Why do we have this confusing duplication? MonadPlus is a class for type constructors, generic over the type of the elements: class MonadPlus m where mzero :: m a mplus :: m a -> m a -> m a (note the lack of "a" in the class signature; the methods have to be defined for ALL possible "a"). whereas monoid is a class for concrete types: class Monoid a where mempty :: a mappend :: a -> a -> a The MonadPlus instance for lists is very constrained: instance MonadPlus [] where mzero = [] -- only possibly definition mplus = (++) There's no other possible fully-defined definition of mzero, and the laws for mplus constrain its definition significantly; the only real change you are allowed to make is to merge the elements of the two input lists in some interesting fashion. Even then you need to keep the relative ordering of the elements within a list the same. The monoid definition is far more open, however; there are many possible monoid definitions for lists. This admits a definition like the following: instance Monoid a => Monoid [a] where mempty = [mempty] mappend xs ys = [x `mappend` y | x <- xs, y <- ys] Of course, other definitions are possible; this one fits the monoid laws: mempty `mappend` a == a a `mappend` mempty == a but there are other choices that do so as well (one based on zipWith, for example, , or drop the "Monoid a" constraint and just use [] and ++) It's similar to Monad vs. Applicative; you can use any Monad definition to create a valid Applicative definition, but it's possible that other definitions exist, or, at the least, are more efficient. -- ryan From andrewcoppin at btinternet.com Fri Oct 3 15:43:22 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:39:51 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> Message-ID: <48E675DA.5050104@btinternet.com> David Menendez wrote: > On Fri, Oct 3, 2008 at 1:39 PM, Andrew Coppin > wrote: > >> (As an aside, Control.Monad.ap is not a function I've ever heard of. It >> seems simple enough, but what an unfortunate name...!) >> > > I believe it's short for "apply". > Yeah, but shame about the name. ;-) > "ap" generalizes the liftM* functions, so > > liftM2 f a b = return f `ap` a `ap` b > liftM3 f a b c = return f `ap` a `ap` b `ap` c > > and so forth. Now that at least makes sense. (It's non-obvious that you can use it for this. If it weren't for curried functions, this wouldn't work at all...) > It wasn't until fairly recently that people realized > that you could do useful things if you had "return" and "ap", but not > (>>=), which why we have some unfortunate limitations in the Haskell > prelude, like Applicative not being a superclass of Monad. > > This leads to all the duplication between Applicative and Monad. In a > perfect world, we would only need the Applicative versions. > OK. So it's broken "for compatibility" then? (Presumably any time you change something from the Prelude, mass breakage ensues!) >> So I see. I'm still not convinced that Applicative helps me in any way >> though... >> > > To be honest, neither am I. But it's a useful thing to be aware of. > OK. (Now that I've figured out what it *is*...) > Would you be willing to share the implementation of ResultSet? If > you're relying on a list somewhere, then it should be possible to > switch the implementation to one of the nondeterminism monad > transformers, which would give you the exception behavior you want. > Consider the following: factorise n = do x <- [1..] y <- [1..] if x*y == n then return (x,y) else fail "not factors" This is a very stupid way to factorise an integer. (But it's also very general...) As you may already be aware, this fails miserably because it tries all possible values for y before trying even one new value for x. And since both lists there are infinite, this causes an endless loop that produces (almost) nothing. My ResultSet monad works the same way as a list, except that the above function discovers all finite solutions in finite time. The result is still infinite, but all the finite solutions are within a finite distance of the beginning. Achieving this was Seriously Non-Trivial. (!) As in, it's several pages of seriously freaky code that took me days to develop. AFAIK, nothing like this already exists in the standard libraries. >> If you look at run_or, you'll see that this is _not_ a simple state monad, >> as in that function I run two actions starting from _the same_ initial state >> - something which, AFAIK, is impossible (or at least very awkward) with a >> state monad. >> >> Really, it's a function that takes a state and generates a new state, but it >> may also happen to generate *multiple* new states. It also consumes a Foo or >> two in the process. >> > > That's what happens if you apply a state monad transformer to a > nondeterminism monad. > > So it might be possible to rewrite your code along these lines: > > type M = StateT State [] > > run :: Foo -> M () > > runOr :: Foo -> Foo -> M () > runOr x y = mplus (run x) (run y) > > runAnd :: Foo -> Foo -> M () > runAnd x y = run x >> run y > > The type "StateT State [] alpha" is isomorphic to "State -> [(alpha, > State)]", which means that each of the computations in mplus gets its > own copy of the state. > What does mplus do in this case? (I know what it does for Maybe, but not for any other monad.) > There are a few ways to add exceptions to this, depending on how you > want the exceptions to interact with the non-determinism. > > 1. StateT State (ErrorT ErrorType []) alpha > > Each branch maintains its own state and is isolated from exceptions in > other branches. > Nope, that's wrong. In this program, Foo is provided by the user, and an "exception" indicates that user entered an invalid expression. Thus all processing should immediately abort and a message should be reported to the wetware for rectification. (That also means that there will never be any need to "catch" exceptions, since they are all inherantly fatal.) > 2. StateT State (NondetT (Either ErrorType)) alpha > > (NondetT isn't in the standard libraries, but I can provide code if needed.) > > Left uncaught, an exception raised in any branch will cause all > branches to fail. > That looks more like it, yes. From andrewcoppin at btinternet.com Fri Oct 3 15:47:36 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:44:05 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <49a77b7a0810031231s678f416n23fbb89de25189d6@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <49a77b7a0810031231s678f416n23fbb89de25189d6@mail.gmail.com> Message-ID: <48E676D8.9000103@btinternet.com> David Menendez wrote: > For some monads, there are implementations of <*> which are more > efficient than the one provided by ap. Similarly, there are ways to > implement fmap which are more efficient than using liftM. > > Of course, the *real* reason we don't define the instance given above > is that there are instances of Applicative that aren't monads, and we > want to avoid overlapping instances. > OK, now I understand. (Of course, if Applicative was already a superclass of Monad, presumably that last wouldn't still stand?) >> Well, that makes sense once you assume two seperate, unconnected classes. >> I'm still fuzzy on that first point though. >> > > It's historical. > Ah. So "brokenness in the name of backwards compatibility"? (Is this why we have "alternate Prelude modules"?) >> Again, it looks like MonadPlus == Monad + Monoid, except all the method >> names are different. Why do we have this confusing duplication? >> > > There are at least three reasons why MonadPlus and Monoid are distinct. > > First, MonadPlus is older than Monoid, even though Monoid is more general. > > Second, MonadPlus and Monoid have different kinds, * -> * and *, > respectively. Instances of MonadPlus are more restricted, because they > have to work with any type parameter, whereas instances of Monoid can > place constraints. > > Third, instances of MonadPlus must follow additional laws relating the > behavior of mplus and mzero to return and (>>=). > OK, good. Also, I notice that the documentation for Monoid mentions that numbers form one. But that's not actually correct. Numbers for *several*! And yet, a given number type can only have *one* Monoid instance. (Or indeed, only one instance for _any_ typeclass.) How do you get round that? From ryani.spam at gmail.com Fri Oct 3 15:48:28 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Oct 3 15:45:03 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E675DA.5050104@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> Message-ID: <2f9b2d30810031248t640911e3rf3f0aeb154e9b94f@mail.gmail.com> On Fri, Oct 3, 2008 at 12:43 PM, Andrew Coppin wrote: > factorise n = do > x <- [1..] > y <- [1..] > if x*y == n then return (x,y) else fail "not factors" > > This is a very stupid way to factorise an integer. (But it's also very > general...) As you may already be aware, this fails miserably because it > tries all possible values for y before trying even one new value for x. And > since both lists there are infinite, this causes an endless loop that > produces (almost) nothing. You should look at LogicT at http://okmij.org/ftp/Computation/monads.html The magic words you are looking for are "fair disjunction" and "fair conjunction". The paper is full of mind-stretching code but it already does everything you want. And it is a monad transformer already, so it's easy to attach Error to it. -- ryan From andrewcoppin at btinternet.com Fri Oct 3 15:50:41 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:47:10 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E674B9.8040501@cogito.org.uk> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> Message-ID: <48E67791.5000305@btinternet.com> Paul Johnson wrote: > Andrew Coppin wrote: >> >> Oh, no. The entire bar is 2 Kg, I wasn't actually planning to eat the >> whole thing! o_O My god, my pancreas would explode or something... > My Dad once ate two bars of dark cooking chocolate. He said he got > some odd visual distortions; flickering auras around things, and size > distortions where small things looked big and big things looked small. I understand that chocolate does contain chemicals which are actually moderately toxic. (It just doesn't contain very much of them - or at least, the normal *milk* chocolate doesn't. Dark chocolate would presumably contain more of these.) For what it's worth, 80% of my diet is cheese, and 10% is chocolate. Apparently that particular combination is supposed to have all sorts of dire effects (including severe headaches). I suffer no such symptoms that I'm aware of. Never have. (But then, people tell me they get a "lift" from caffine, and I find no such effect. Nor do I have severe withdrawal symptoms when I stop taking it.) Maybe I'm just weird? (Oh, wait... I use Haskell!) In other news... apparently chocolate is leathaly toxic to dogs. Random. From asandroq at gmail.com Fri Oct 3 15:53:41 2008 From: asandroq at gmail.com (Alex Sandro Queiroz e Silva) Date: Fri Oct 3 15:50:19 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E67791.5000305@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> Message-ID: <48E67845.7080808@gmail.com> Hallo, Andrew Coppin wrote: > > In other news... apparently chocolate is leathaly toxic to dogs. Random. > Chicolate is extremely toxic to cats. Cheers, -alex http://www.ventonegro.org/ From andrewcoppin at btinternet.com Fri Oct 3 15:56:47 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:53:17 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E65DF0.7090301@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> Message-ID: <48E678FF.2050004@btinternet.com> Andrew Coppin wrote: > run_or s0 x y = > let > either_rset1 = sequence $ run s0 x > either_rset2 = sequence $ run s0 y > either_rset3 = do rset1 <- either_rset1; rset2 <- either_rset2; > return (merge rset1 rset2) > in case either_rset3 of > Left e -> throwError e > Right rset -> lift rset Do you realise, this single snippet of code utilises the ErrorT monad [transformer], the ResultSet monad, *and* the Either monad, all in the space of a few lines?? That's three monads in one function! o_O I scare *myself*, I don't know about you guys... From jonathanccast at fastmail.fm Fri Oct 3 15:52:03 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 3 15:55:35 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E675DA.5050104@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> Message-ID: <1223063523.3452.16.camel@jcchost> On Fri, 2008-10-03 at 20:43 +0100, Andrew Coppin wrote: > David Menendez wrote: > > It wasn't until fairly recently that people realized > > that you could do useful things if you had "return" and "ap", but not > > (>>=), which why we have some unfortunate limitations in the Haskell > > prelude, like Applicative not being a superclass of Monad. > > > > This leads to all the duplication between Applicative and Monad. In a > > perfect world, we would only need the Applicative versions. > > > > OK. So it's broken "for compatibility" then? (Presumably any time you > change something from the Prelude, mass breakage ensues!) I'm not a big fan of backward-compatibility myself, but changing Monad to be a sub-class of Applicative actually would have broken every monad instance in existence (at the time Applicative was added, since it didn't have any instances yet). I don't know what proportion of Haskell programs/libraries/etc. have at least one Monad instance in them, but I would guess it's high. jcc From andrewcoppin at btinternet.com Fri Oct 3 15:59:45 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:56:13 2008 Subject: [Haskell-cafe] Monoids [Stacking monads] In-Reply-To: <2f9b2d30810031251l3bd3b2b0i138c7d2eb196cc03@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <49a77b7a0810031231s678f416n23fbb89de25189d6@mail.gmail.com> <48E676D8.9000103@btinternet.com> <2f9b2d30810031251l3bd3b2b0i138c7d2eb196cc03@mail.gmail.com> Message-ID: <48E679B1.1050304@btinternet.com> Ryan Ingram wrote: > Newtypes is the general (& sadly unsatisfactory) answer: > Oh dear. Well that _is_ pretty unsatisfactory... Given the constraints of the Haskell type system, could we do better in principle? From allbery at ece.cmu.edu Fri Oct 3 16:01:30 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 15:58:06 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E66E23.6060306@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> Message-ID: <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> On Oct 3, 2008, at 15:10 , Andrew Coppin wrote: >> The reason for the separation of the two for many functions is so >> that types which are instances of only one of the two can still >> take advantage of the functionality. > > Well, that makes sense once you assume two seperate, unconnected > classes. I'm still fuzzy on that first point though. > >>> Foldable seems simplish, except that it refers to some odd >>> "monoid" class that looks suspiciously like "MonadPlus" but >>> isn't... wuh? >> A Monoid is simply anything that has an identity element (mempty) >> and an associative binary operation (mappend). It is not necessary >> for a complete instance of Foldable. > > Again, it looks like MonadPlus == Monad + Monoid, except all the > method names are different. Why do we have this confusing duplication? Because typeclasses aren't like OO classes. Specifically: while you can specify what looks like class inheritance (e.g. "this Monad is also a Monoid" you can't override inherited methods (because it's a Monad, you can't specify as part of the Monad instance the definition of a Monoid class function). So if you want to define MonadPlus to look like a Monad and a Monoid, you have to pick one and *duplicate* the other (without using the same names, since they're already taken by the typeclass you *don't* choose). Usually this isn't a problem, because experienced Haskell programmers don't try to use typeclasses for OO. But there are the occasional mathematically-inspired relationships (Functor vs. Monad, MonadPlus vs. Monoid, Applicative vs. Monad, etc.) that can't be expressed "properly" as a result. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From andrewcoppin at btinternet.com Fri Oct 3 16:02:25 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 15:58:54 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <1223063523.3452.16.camel@jcchost> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> <1223063523.3452.16.camel@jcchost> Message-ID: <48E67A51.7030201@btinternet.com> Jonathan Cast wrote: > On Fri, 2008-10-03 at 20:43 +0100, Andrew Coppin wrote: > >> OK. So it's broken "for compatibility" then? (Presumably any time you >> change something from the Prelude, mass breakage ensues!) >> > > I'm not a big fan of backward-compatibility myself, but changing Monad > to be a sub-class of Applicative actually would have broken every monad > instance in existence (at the time Applicative was added, since it > didn't have any instances yet). I don't know what proportion of Haskell > programs/libraries/etc. have at least one Monad instance in them, but I > would guess it's high. > Hmm, that's quite a lot of breakage. So if it had been set up this way from day 1, we wouldn't be having this conversation, but it's now too expensive to change it. Is that basically what it comes down to? From jonathanccast at fastmail.fm Fri Oct 3 15:59:16 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 3 16:02:47 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E67A51.7030201@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> <1223063523.3452.16.camel@jcchost> <48E67A51.7030201@btinternet.com> Message-ID: <1223063956.3452.20.camel@jcchost> On Fri, 2008-10-03 at 21:02 +0100, Andrew Coppin wrote: > Jonathan Cast wrote: > > On Fri, 2008-10-03 at 20:43 +0100, Andrew Coppin wrote: > > > >> OK. So it's broken "for compatibility" then? (Presumably any time you > >> change something from the Prelude, mass breakage ensues!) > >> > > > > I'm not a big fan of backward-compatibility myself, but changing Monad > > to be a sub-class of Applicative actually would have broken every monad > > instance in existence (at the time Applicative was added, since it > > didn't have any instances yet). I don't know what proportion of Haskell > > programs/libraries/etc. have at least one Monad instance in them, but I > > would guess it's high. > > > > Hmm, that's quite a lot of breakage. > > So if it had been set up this way from day 1, we wouldn't be having this > conversation, but it's now too expensive to change it. Is that basically > what it comes down to? Sort of. (Although I note that Monad isn't a sub-class of Functor, either, and I think those are coeval.) It is too expensive to change it during the period between when Applicative was discovered and now. But that could change in the future --- I'm sure a much higher of types with Monad instances happen to have Applicative instances as well now. If that proportion rises by enough, the backward compatibility argument would become less compelling. jcc From lally.singh at gmail.com Fri Oct 3 16:08:00 2008 From: lally.singh at gmail.com (Lally Singh) Date: Fri Oct 3 16:04:35 2008 Subject: [Haskell-cafe] Building gtkhs, OpenSolaris x86 Message-ID: <3b3449e00810031308y7c948932m41f9dd8853cfaff5@mail.gmail.com> Hey folks, I know it seems an obtuse OS to build on, but trust me, it's pretty nice despite the hassles. I'm getting these three errors (repeated a few times) while building gtkhs-0.9.13 on ghc 6.8.3, and was hoping for any suggestions on where to go from here: tools/c2hs/base/general/Map.hs:16:7: Could not find module `Data.Map': it is a member of package containers-0.1.0.2, which is hidden tools/c2hs/base/errors/Errors.hs:44:0: Failed to load interface for `Position': Use -v to see a list of the files searched for. glib/System/Glib.hs:13:0: Failed to load interface for `System.Glib.UTFString': Use -v to see a list of the files searched for. What did I screw up? Is there something else I should load? Maybe an older version of gtkhs? ghc? Thanks for any help! -- H. Lally Singh Ph.D. Candidate, Computer Science Virginia Tech From lennart at augustsson.net Fri Oct 3 16:11:11 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Oct 3 16:07:46 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> Message-ID: But (a) is not a lifted version of a, whereas (a,b) is a lifted version of the a b product. So it's not consistent, and thereby wrong. -- Lennart On Fri, Oct 3, 2008 at 6:07 PM, Jason Dusek wrote: > Lennart Augustsson wrote: >> Let me pick one example. Let's make a class that can convert >> between tuples and lists. >> >> -- XXX This doesn't work, and is just wrong. >> -- instance TupleList (a) [a] where >> -- tupleToList (a) = [a] >> -- listToTuple [a] = (a) > > It's not clear to me what is so "wrong" about it. If the 1-ary > tuple is the 1-ary product, it makes sense. > > -- > _jsn > From andrewcoppin at btinternet.com Fri Oct 3 16:12:23 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 16:08:52 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> Message-ID: <48E67CA7.5000503@btinternet.com> Brandon S. Allbery KF8NH wrote: > On Oct 3, 2008, at 15:10 , Andrew Coppin wrote: >> Again, it looks like MonadPlus == Monad + Monoid, except all the >> method names are different. Why do we have this confusing duplication? > > Because typeclasses aren't like OO classes. Specifically: while you > can specify what looks like class inheritance (e.g. "this Monad is > also a Monoid" you can't override inherited methods (because it's a > Monad, you can't specify as part of the Monad instance the definition > of a Monoid class function). So if you want to define MonadPlus to > look like a Monad and a Monoid, you have to pick one and *duplicate* > the other (without using the same names, since they're already taken > by the typeclass you *don't* choose). I was thinking more, why not just delete MonadPlus completely, and have any function that needs a monad that's also a monoid say so in its context? (Obviously one of the answers to that is "because it would break vast amounts of existing code".) From jonathanccast at fastmail.fm Fri Oct 3 16:05:34 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 3 16:09:05 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <1223063956.3452.20.camel@jcchost> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> <1223063523.3452.16.camel@jcchost> <48E67A51.7030201@btinternet.com> <1223063956.3452.20.camel@jcchost> Message-ID: <1223064334.3452.22.camel@jcchost> On Fri, 2008-10-03 at 12:59 -0700, Jonathan Cast wrote: > On Fri, 2008-10-03 at 21:02 +0100, Andrew Coppin wrote: > > Jonathan Cast wrote: > > > On Fri, 2008-10-03 at 20:43 +0100, Andrew Coppin wrote: > > > > > >> OK. So it's broken "for compatibility" then? (Presumably any time you > > >> change something from the Prelude, mass breakage ensues!) > > >> > > > > > > I'm not a big fan of backward-compatibility myself, but changing Monad > > > to be a sub-class of Applicative actually would have broken every monad > > > instance in existence (at the time Applicative was added, since it > > > didn't have any instances yet). I don't know what proportion of Haskell > > > programs/libraries/etc. have at least one Monad instance in them, but I > > > would guess it's high. > > > > > > > Hmm, that's quite a lot of breakage. > > > > So if it had been set up this way from day 1, we wouldn't be having this > > conversation, but it's now too expensive to change it. Is that basically > > what it comes down to? > > Sort of. (Although I note that Monad isn't a sub-class of Functor, > either, and I think those are coeval.) It is too expensive to change it > during the period between when Applicative was discovered and now. But > that could change in the future --- I'm sure a much higher of types with ^ proportion > Monad instances happen to have Applicative instances as well now. If > that proportion rises by enough, the backward compatibility argument > would become less compelling. jcc From allbery at ece.cmu.edu Fri Oct 3 16:13:19 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 16:09:55 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E674B9.8040501@cogito.org.uk> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> Message-ID: <871AF87B-8DCE-421D-B0BC-0FA5A7943E45@ece.cmu.edu> On Oct 3, 2008, at 15:38 , Paul Johnson wrote: > Andrew Coppin wrote: >> Oh, no. The entire bar is 2 Kg, I wasn't actually planning to eat >> the whole thing! o_O My god, my pancreas would explode or >> something... > My Dad once ate two bars of dark cooking chocolate. He said he got > some odd visual distortions; flickering auras around things, and > size distortions where small things looked big and big things looked > small. Theobromine is interesting stuff. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From jake at pikewerks.com Fri Oct 3 16:26:22 2008 From: jake at pikewerks.com (Jake McArthur) Date: Fri Oct 3 16:22:58 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E67CA7.5000503@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> <48E67CA7.5000503@btinternet.com> Message-ID: <48E67FEE.4000809@pikewerks.com> Andrew Coppin wrote: > I was thinking more, why not just delete MonadPlus completely, and > have any function that needs a monad that's also a monoid say so in > its context? (Obviously one of the answers to that is "because it > would break vast amounts of existing code".) Because they are not the same. MonadPlus has more restrictions than Monoid. For an instance of the form "instance MonadPlus m where", m a _must_ be a Monoid for _all_ a, whereas "instance Monoid (m a) where" may be defined for some specific a instead. - Jake From manlio_perillo at libero.it Fri Oct 3 16:32:23 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Fri Oct 3 16:29:02 2008 Subject: [Haskell-cafe] Alex and Flex In-Reply-To: <18EA384C-064F-4813-BF5C-325A3D5041F0@ece.cmu.edu> References: <48E53BB9.6060806@libero.it> <48E61CF0.1000901@libero.it> <18EA384C-064F-4813-BF5C-325A3D5041F0@ece.cmu.edu> Message-ID: <48E68157.7060102@libero.it> Brandon S. Allbery KF8NH ha scritto: > On Oct 3, 2008, at 09:24 , Manlio Perillo wrote: >> Manlio Perillo ha scritto: >>> However I have noted that there are some difference in the syntax >>> between Alex and Flex? >>> What is the rationale? >> >> By the way, here is the list of differences between Alex and Flex I >> have found, for people interested: >> >> 3) Alex does not support >> [_a-z0-9-] >> that must be rewritten as >> [_a-z0-9\-] > > The only *reliable* way to write that cset is to put the '-' as the > first item. Likewise for ']' (and if you must match both, "[-]...]"). > Escaping the character solve the problem, or at least I have tested and it works. It seems, however, that Alex is quite strict in accepted characters. As an example, this rule [ \t\r\n\f] does not match the space character; this character must be escaped: [\ \t\r\n\f] Flex seems to be more "smart", here. Note that the escaping solve the problem 7): \-?@nmstart@nmchar* Thanks Manlio Perillo From jonathanccast at fastmail.fm Fri Oct 3 16:26:52 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 3 16:30:23 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E67CA7.5000503@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> <48E67CA7.5000503@btinternet.com> Message-ID: <1223065612.3452.33.camel@jcchost> On Fri, 2008-10-03 at 21:12 +0100, Andrew Coppin wrote: > Brandon S. Allbery KF8NH wrote: > > On Oct 3, 2008, at 15:10 , Andrew Coppin wrote: > >> Again, it looks like MonadPlus == Monad + Monoid, except all the > >> method names are different. Why do we have this confusing duplication? > > > > Because typeclasses aren't like OO classes. Specifically: while you > > can specify what looks like class inheritance (e.g. "this Monad is > > also a Monoid" you can't override inherited methods (because it's a > > Monad, you can't specify as part of the Monad instance the definition > > of a Monoid class function). So if you want to define MonadPlus to > > look like a Monad and a Monoid, you have to pick one and *duplicate* > > the other (without using the same names, since they're already taken > > by the typeclass you *don't* choose). > > I was thinking more, why not just delete MonadPlus completely, and have > any function that needs a monad that's also a monoid say so in its > context? This would be clunky. Consider: select as = msum $ do (as0, a:as) <- breaks as return $ do x <- a return (x, as0 ++ as) -- | Divide a list into (snoc-list, cons-list) pairs every possible -- way breaks :: [a] -> [([a], [a])] breaks as = breaks [] as where breaks' as0 [] = [(as0, [])] breaks' as0 (a:as) = (as0, a:as) : breaks' (a:as0) as You can say select :: MonadPlus m => [m a] -> m (a, [m a]) but not select :: (Monad m, Monoid (m a)) => [m a] -> m (a, [m a]) --- for this particular implementation, you need select :: (Monad m, Monoid (m (a, [m a]))) => [m a] -> m (a, [m a]) but then if you want to write select_ = fmap fst . select you have select_ :: (Monad m, Monoid (m (a, [m a]))) => [m a] -> m a . This is a wtf constraint, obviously. You can avoid this by writing select_ :: (Monad m, forall b. Monoid (m b)) => [m a] -> m a but that's somewhat beyond the scope of the existing type class system. Unless you write a new type class that is *explicitly* (Monad m, forall b. Monoid (m b)). Which is what MonadPlus is. jcc From andrewcoppin at btinternet.com Fri Oct 3 16:37:57 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 3 16:34:26 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E67FEE.4000809@pikewerks.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> <48E67CA7.5000503@btinternet.com> <48E67FEE.4000809@pikewerks.com> Message-ID: <48E682A5.7010407@btinternet.com> Jake McArthur wrote: > Andrew Coppin wrote: >> I was thinking more, why not just delete MonadPlus completely, and >> have any function that needs a monad that's also a monoid say so in >> its context? (Obviously one of the answers to that is "because it >> would break vast amounts of existing code".) > Because they are not the same. MonadPlus has more restrictions than > Monoid. For an instance of the form "instance MonadPlus m where", m a > _must_ be a Monoid for _all_ a, whereas "instance Monoid (m a) where" > may be defined for some specific a instead. OK, fair enough then. From dave at zednenem.com Fri Oct 3 16:51:13 2008 From: dave at zednenem.com (David Menendez) Date: Fri Oct 3 16:47:47 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E675DA.5050104@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> Message-ID: <49a77b7a0810031351o1e39ed07ue77aff2d7435e8d9@mail.gmail.com> On Fri, Oct 3, 2008 at 3:43 PM, Andrew Coppin wrote: > David Menendez wrote: >> >> It wasn't until fairly recently that people realized >> that you could do useful things if you had "return" and "ap", but not >> (>>=), which why we have some unfortunate limitations in the Haskell >> prelude, like Applicative not being a superclass of Monad. >> >> This leads to all the duplication between Applicative and Monad. In a >> perfect world, we would only need the Applicative versions. >> > > OK. So it's broken "for compatibility" then? (Presumably any time you change > something from the Prelude, mass breakage ensues!) Exactly. Since the Prelude is specified in the Haskell 98 report, you can't add or subtract things without losing Haskell 98 compatibility. We *could* define a new Prelude that did things more sensibly, but then code either has to pick which Prelude to support or else jump through extra hoops to be cross-compatible. >> Would you be willing to share the implementation of ResultSet? If >> you're relying on a list somewhere, then it should be possible to >> switch the implementation to one of the nondeterminism monad >> transformers, which would give you the exception behavior you want. >> > > Consider the following: > > factorise n = do > x <- [1..] > y <- [1..] > if x*y == n then return (x,y) else fail "not factors" > > This is a very stupid way to factorise an integer. (But it's also very > general...) As you may already be aware, this fails miserably because it > tries all possible values for y before trying even one new value for x. And > since both lists there are infinite, this causes an endless loop that > produces (almost) nothing. > > My ResultSet monad works the same way as a list, except that the above > function discovers all finite solutions in finite time. The result is still > infinite, but all the finite solutions are within a finite distance of the > beginning. Achieving this was Seriously Non-Trivial. (!) As in, it's several > pages of seriously freaky code that took me days to develop. > > AFAIK, nothing like this already exists in the standard libraries. Now I'm even more curious to see how you did it. I spent some time a few months ago developing a monad that does breadth-first search. It would be able to handle the example you gave almost without change. Some other possibilities: (1) logict This defines a backtracking monad transformer (the NondetT I mentioned in my previous message), and provides a "fair" variant of (>>=) that you could use to define factorise. It's not as foolproof as the other options. (2) control-monad-omega This is a monad similar to [] that uses a "diagonal" search pattern. (3) Oleg Kiselyov's fair and backtracking monad This uses a search pattern that I don't fully understand, and only satisfies the Monad and MonadPlus laws if you ignore the order of results, but think it's at least as robust as Omega. >>> If you look at run_or, you'll see that this is _not_ a simple state >>> monad, >>> as in that function I run two actions starting from _the same_ initial >>> state >>> - something which, AFAIK, is impossible (or at least very awkward) with a >>> state monad. >>> >>> Really, it's a function that takes a state and generates a new state, but >>> it >>> may also happen to generate *multiple* new states. It also consumes a Foo >>> or >>> two in the process. >>> >> >> That's what happens if you apply a state monad transformer to a >> nondeterminism monad. >> >> So it might be possible to rewrite your code along these lines: >> >> type M = StateT State [] >> >> run :: Foo -> M () >> >> runOr :: Foo -> Foo -> M () >> runOr x y = mplus (run x) (run y) >> >> runAnd :: Foo -> Foo -> M () >> runAnd x y = run x >> run y >> >> The type "StateT State [] alpha" is isomorphic to "State -> [(alpha, >> State)]", which means that each of the computations in mplus gets its >> own copy of the state. >> > > What does mplus do in this case? (I know what it does for Maybe, but not for > any other monad.) "mplus a b" returns all the results returned by "a" and "b". For lists, it returns all the results of "a" before the results of "b". I suspect it corresponds to "merge" in your code. For true backtracking monads (that is, not Maybe), mplus also has this property: mplus a b >>= f == mplus (a >>= f) (b >>= f) There is a school of thought that Maybe (and Error/ErrorT) should not be instances of MonadPlus because they do not satisfy that law. >> 2. StateT State (NondetT (Either ErrorType)) alpha >> >> (NondetT isn't in the standard libraries, but I can provide code if >> needed.) >> >> Left uncaught, an exception raised in any branch will cause all >> branches to fail. >> > > That looks more like it, yes. That's what I figured. You'll need a transformer, then, which rules out Omega. Since you don't care about catching exceptions, you can just do something like type M = StateT State (LogicT (Either ErrorType)) throwM :: ErrorType -> M a throwM = lift . lift . Left Or, if you want to try my breadth-first monad, I can send you a copy. It supports exception handling out of the box. -- Dave Menendez From derek.a.elkins at gmail.com Fri Oct 3 17:20:48 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Oct 3 17:17:26 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <49a77b7a0810031238k5a7fb612s14f4f10fa24f2c34@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <49a77b7a0810031238k5a7fb612s14f4f10fa24f2c34@mail.gmail.com> Message-ID: <1223068848.6360.5.camel@derek-laptop> On Fri, 2008-10-03 at 15:38 -0400, David Menendez wrote: > On Fri, Oct 3, 2008 at 3:17 AM, Jason Dusek wrote: > > Perhaps I am lacking in imagination, but I still can't see the > > value of one tuples. > > You can use them to defeat seq. > > undefined `seq` x == undefined > OneTuple undefined `seq` x == x > > That might be useful if a polymorphic function is using seq to force > evaluation, and you don't want it to. But I can't imagine that coming > up much in practice. Think element strict polymorphic containers, e.g. data HeadStrictList a = Nil | Cons !a (HeadStrictList a) then type LazyList a = HeadStrictList (OneTuple a) From dons at galois.com Fri Oct 3 17:25:19 2008 From: dons at galois.com (Don Stewart) Date: Fri Oct 3 17:22:14 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <1223068848.6360.5.camel@derek-laptop> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <49a77b7a0810031238k5a7fb612s14f4f10fa24f2c34@mail.gmail.com> <1223068848.6360.5.camel@derek-laptop> Message-ID: <20081003212519.GL27434@scytale.galois.com> derek.a.elkins: > On Fri, 2008-10-03 at 15:38 -0400, David Menendez wrote: > > On Fri, Oct 3, 2008 at 3:17 AM, Jason Dusek wrote: > > > Perhaps I am lacking in imagination, but I still can't see the > > > value of one tuples. > > > > You can use them to defeat seq. > > > > undefined `seq` x == undefined > > OneTuple undefined `seq` x == x > > > > That might be useful if a polymorphic function is using seq to force > > evaluation, and you don't want it to. But I can't imagine that coming > > up much in practice. > > Think element strict polymorphic containers, e.g. > > data HeadStrictList a = Nil | Cons !a (HeadStrictList a) > > then > > type LazyList a = HeadStrictList (OneTuple a) Used in practice to prevent strict state components in list fusion leaking into user's lazy code, data L a = L a -- lazy / lifted newtype S a = S a -- strict / unlifted class Unlifted a where instance Unlifted (L a) where expose (L _) s = s instance Unlifted (S a) where expose (S a) s = seq a s data Stream a = forall s. Unlifted s => Stream !(s -> Step a s) -- ^ a stepper function !s -- ^ an initial state So we can then ensure stream :: [a] -> Stream a stream xs0 = Stream next (L xs0) where next (L []) = Done next (L (x:xs)) = Yield x (L xs) Has the appropriate strictness properties. -- Don From jason.dusek at gmail.com Fri Oct 3 17:29:48 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 3 17:26:23 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> Message-ID: <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> Lennart Augustsson wrote: > But (a) is not a lifted version of a, whereas (a,b) is a lifted > version of the a b product. > So it's not consistent, and thereby wrong. Well, we can't represent the unlifted product in Haskell, right? You have to use some constructor. So if we just say we are using tuples to represent unlifted products, what's so bad about that? At present, tupling doesn't lift values into anything, since we don't have generic operations on tuples. The last two messages in this thread suggests this has more to do with the internals of Haskell than they do with consistent semantics -- so I am perhaps missing the point. -- _jsn From miguelimo38 at yandex.ru Fri Oct 3 18:07:18 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Oct 3 18:04:07 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E67791.5000305@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> Message-ID: On 3 Oct 2008, at 23:50, Andrew Coppin wrote: > For what it's worth, 80% of my diet is cheese, and 10% is chocolate. Remind me not to take food out of your hands, OK? From allbery at ece.cmu.edu Fri Oct 3 19:18:08 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 19:14:46 2008 Subject: [Haskell-cafe] Building gtkhs, OpenSolaris x86 In-Reply-To: <3b3449e00810031308y7c948932m41f9dd8853cfaff5@mail.gmail.com> References: <3b3449e00810031308y7c948932m41f9dd8853cfaff5@mail.gmail.com> Message-ID: <7048B95F-2300-4E33-AFDA-CF3B012E3C64@ece.cmu.edu> On 2008 Oct 3, at 16:08, Lally Singh wrote: > I know it seems an obtuse OS to build on, but trust me, it's pretty > nice despite the hassles. > > I'm getting these three errors (repeated a few times) while building > gtkhs-0.9.13 on ghc 6.8.3, and was hoping for any suggestions on where > to go from here: > > tools/c2hs/base/general/Map.hs:16:7: > Could not find module `Data.Map': > it is a member of package containers-0.1.0.2, which is hidden > tools/c2hs/base/errors/Errors.hs:44:0: > Failed to load interface for `Position': > Use -v to see a list of the files searched for. > glib/System/Glib.hs:13:0: > Failed to load interface for `System.Glib.UTFString': > Use -v to see a list of the files searched for. The first error is the real one; the others happen because the gtk2hs makefile doesn't properly abort when a sub-build fails. (This is probably a bash-ism: setting -e aborts the current iteration of a loop, not the entire script/fragment containing the loop. Supposedly POSIX mandates this braindamage. I'm dubious.) I have no idea what's causing the first one, though; normally it means something is missing from a Cabal configuration file, but last I checked gtk2hs didn't use Cabal and I don't see an obvious candidate in our gtk2hs 0.9.13 source tree. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From vigalchin at gmail.com Fri Oct 3 19:28:28 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Oct 3 19:25:04 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <20081003193835.GD26436@scytale.galois.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> <20081003193835.GD26436@scytale.galois.com> Message-ID: <5ae4f2ba0810031628g69ee08d1u16fd65861e8a12e2@mail.gmail.com> On Fri, Oct 3, 2008 at 2:38 PM, Don Stewart wrote: > wchogg: > > On Fri, Oct 3, 2008 at 5:47 AM, Dougal Stanton > wrote: > > > 2008/10/3 Galchin, Vasili : > > >> Hello, > > >> > > >> One of my interests based on my education is "grand challenge > science". > > >> Ok .. let's take the CERN Hadrian Accelerator. > > >> > > >> Where do you think Haskell can fit into the CERN Hadrian effort > > >> currently? > > >> > > >> Where do you think think Haskell currently is lacking and will > have to > > >> be improved in order to participate in CERN Hadrian? > > > > > > Is that the experiment where Picts are accelerated to just short of > > > the speed of light in order to smash through to the Roman Empire? ;-) > > > > > > I don't know what the main computational challenges are to the LHC > > > researchers. The stuff in the press has mostly been about > > > infrastructure --- how to store the gigabytes of data per second that > > > they end up keeping, out of the petabytes that are produced in the > > > first place (or something). > > > > Well, with the LHC efforts I don't think a technology like Haskell > > really has a place...at least not now. Even just a few years back, > > when I worked on this stuff, we were still doing lots of simulation in > > preparation for the actual live experiment and Haskell might have been > > a good choice for some of the tools. All of the detector simulation > > was written in C++, because C++ is the new FORTRAN to physicists, and > > you ain't seen nothing till you've seen a jury-rigged form of lazy > > evaluation built into a class hierarchy in C++. Now, would the C++ > > based simulation have run faster than a Haskell based one? Quite > > possibly. On the other hand, I remember how many delays and problems > > were caused by the sheer complexity of the codebase. That's where a > > more modern programming language might have been extremely helpful. > > How about EDSLs for producing high assurance controllers, and other > robust devices they might need. I imagine the LHC has a good need for > verified software components... ^^ totally agree on the "verified" Don. Don, by controller do you mean an I/O controller?? Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/b511d72c/attachment.htm From lrpalmer at gmail.com Fri Oct 3 19:30:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 3 19:27:26 2008 Subject: [Haskell-cafe] Re: having fun with GADT's In-Reply-To: References: <49a77b7a0809222003v3ff6fe3bhd25afc4a1f62f73c@mail.gmail.com> <49a77b7a0809222223w5ae08182w4a11fdf1c5e0ccd0@mail.gmail.com> Message-ID: <7ca3f0160810031630s768481cdh2212c18146ede48a@mail.gmail.com> On Tue, Sep 30, 2008 at 6:25 PM, Anatoly Yakovenko wrote: > has the "with" syntax described in > >> > > been replaced with the "where" syntax? > > so > > data Foo a where > FooInt :: FooInt > > the same thing as > > data Foo A = FooInt with a = Int I don't see any such syntax in the aforementioned message. But yes, the where syntax is currently the only way to do GADTs (and I hope that does *not* change, because I love the GADT syntax!): data Foo a where FooInt :: Foo Int Luke From allbery at ece.cmu.edu Fri Oct 3 19:34:24 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 19:31:02 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E67CA7.5000503@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <48E5439B.9010606@daimi.au.dk> <48E657A2.50408@btinternet.com> <48E659BC.40604@pikewerks.com> <48E66E23.6060306@btinternet.com> <2D992DCF-E203-48A9-9DAD-D15D30CB40A1@ece.cmu.edu> <48E67CA7.5000503@btinternet.com> Message-ID: <126B9E92-EF96-4828-9CCE-A80204AEEA0E@ece.cmu.edu> On 2008 Oct 3, at 16:12, Andrew Coppin wrote: > Brandon S. Allbery KF8NH wrote: >> On Oct 3, 2008, at 15:10 , Andrew Coppin wrote: >>> Again, it looks like MonadPlus == Monad + Monoid, except all the >>> method names are different. Why do we have this confusing >>> duplication? >> >> Because typeclasses aren't like OO classes. Specifically: while >> you can specify what looks like class inheritance (e.g. "this Monad >> is also a Monoid" you can't override inherited methods (because >> it's a Monad, you can't specify as part of the Monad instance the >> definition of a Monoid class function). So if you want to define >> MonadPlus to look like a Monad and a Monoid, you have to pick one >> and *duplicate* the other (without using the same names, since >> they're already taken by the typeclass you *don't* choose). > > I was thinking more, why not just delete MonadPlus completely, and > have any function that needs a monad that's also a monoid say so in > its context? (Obviously one of the answers to that is "because it > would break vast amounts of existing code".) It also touches on some Haskell98 braindamage. (Look up "MonadZero".) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From vigalchin at gmail.com Fri Oct 3 19:38:36 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Oct 3 19:35:10 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadrian... In-Reply-To: <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> Message-ID: <5ae4f2ba0810031638r592ae2d8u2bfa88d2c010ef00@mail.gmail.com> I have to write in C++ everyday. I just worked at D*ll .. a total train wreck . software very unstable .. written in C++ .... Maybe a lot of blame can be put at the door of very lazy people; however, in my opinion, the strong/static type checking seriously "corral" lazy "developers". I have found myself almost unconsciously thinking in the Haskell strong type checking Welt Anschauung at work! Totally rocks! Vasili On Fri, Oct 3, 2008 at 8:29 AM, Creighton Hogg wrote: > On Fri, Oct 3, 2008 at 5:47 AM, Dougal Stanton > wrote: > > 2008/10/3 Galchin, Vasili : > >> Hello, > >> > >> One of my interests based on my education is "grand challenge > science". > >> Ok .. let's take the CERN Hadrian Accelerator. > >> > >> Where do you think Haskell can fit into the CERN Hadrian effort > >> currently? > >> > >> Where do you think think Haskell currently is lacking and will have > to > >> be improved in order to participate in CERN Hadrian? > > > > Is that the experiment where Picts are accelerated to just short of > > the speed of light in order to smash through to the Roman Empire? ;-) > > > > I don't know what the main computational challenges are to the LHC > > researchers. The stuff in the press has mostly been about > > infrastructure --- how to store the gigabytes of data per second that > > they end up keeping, out of the petabytes that are produced in the > > first place (or something). > > Well, with the LHC efforts I don't think a technology like Haskell > really has a place...at least not now. Even just a few years back, > when I worked on this stuff, we were still doing lots of simulation in > preparation for the actual live experiment and Haskell might have been > a good choice for some of the tools. All of the detector simulation > was written in C++, because C++ is the new FORTRAN to physicists, and > you ain't seen nothing till you've seen a jury-rigged form of lazy > evaluation built into a class hierarchy in C++. Now, would the C++ > based simulation have run faster than a Haskell based one? Quite > possibly. On the other hand, I remember how many delays and problems > were caused by the sheer complexity of the codebase. That's where a > more modern programming language might have been extremely helpful. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/e7d97473/attachment.htm From allbery at ece.cmu.edu Fri Oct 3 19:38:49 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 19:35:26 2008 Subject: [Haskell-cafe] Health effects In-Reply-To: <48E67791.5000305@btinternet.com> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> Message-ID: <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> On 2008 Oct 3, at 15:50, Andrew Coppin wrote: > Paul Johnson wrote: >> Andrew Coppin wrote: >>> >>> Oh, no. The entire bar is 2 Kg, I wasn't actually planning to eat >>> the whole thing! o_O My god, my pancreas would explode or >>> something... >> My Dad once ate two bars of dark cooking chocolate. He said he got >> some odd visual distortions; flickering auras around things, and >> size distortions where small things looked big and big things >> looked small. > > headaches). I suffer no such symptoms that I'm aware of. Never have. > (But then, people tell me they get a "lift" from caffine, and I find > no such effect. Nor do I have severe withdrawal symptoms when I stop > taking it.) I resemble that. In fact, I have to be careful with caffeine because I won't notice how much I've had until I start having heart palpitations, odd joint aches, and other signs of caffeine overdose. > In other news... apparently chocolate is leathaly toxic to dogs. > Random. And cats. Theobromine is fun stuff, as I said. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From s.clover at gmail.com Fri Oct 3 20:46:31 2008 From: s.clover at gmail.com (Sterling Clover) Date: Fri Oct 3 20:43:08 2008 Subject: [Haskell-cafe] pure Haskell database In-Reply-To: <48E3CAF0.8030606@libero.it> References: <48DAAE4D.9010807@libero.it> <48DBFDF7.1060506@libero.it> <48E2270E.2050604@libero.it> <48E3CAF0.8030606@libero.it> Message-ID: <3C162397-1D4E-48EA-999F-14E2F8F2419E@gmail.com> So the issue is one writer, many readers across processes? Creating an actual mini-db-server might be the proper way to do this. Expose a simple socket by which other processes can query the DB state. If you need persistence between runs of your main server you can always snapshot on shutdown, or for error-tolerance you can also write to a transactional log (probably with a single writer thread that takes input over a chan). Assuming its still in good shape, haxr [http:// www.haskell.org/haxr/] would simplify writing the socket portion. Depending on how you wrote the surrounding server, you might be able to avoid mvars altogether (i.e. if your server was built in an "agent" style with only a single request handler thread, then state could just be passed between recursive calls [or even stashed in a State monad] and the request serialization would handle concurrency issues for you). Regards, S. On Oct 1, 2008, at 3:09 PM, Manlio Perillo wrote: > Graham Fawcett ha scritto: >> [...] >>> Never though about sparse array, what is the advantage? >>> For the complexity, the same of a good hash map. >> Almost certainly worse complexity than a hash map; but the overhead >> could be much smaller. If (for example) you only needed a small >> number >> of key/value pairs (say, hundreds of thousands), you could implement >> your "database" trivially, e.g. a NULL-terminated array of key/value >> structs in shared memory. (Though having separate arrays for keys and >> values might help cache locality and boost performance). Lookup might >> be O(n) but with a small-ish N and with such a low overhead, it could >> perform very, very well. > > > This seems an interesting idea, thanks. > > > Manlio Perillo > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lane at downstairspeople.org Fri Oct 3 21:01:56 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Fri Oct 3 20:58:30 2008 Subject: [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> Message-ID: What /is/ it with haskell-cafe lately? Do we need a haskell-blah mailing list? I would subscribe to that. Hell, I would post to it probably more than I post to haskell-cafe. But I'd also divert it to a separate mailbox for when I have too much free time. Maybe call it haskell-cafe-cafe? not-haskell? --Lane From brianchina60221 at gmail.com Fri Oct 3 21:06:50 2008 From: brianchina60221 at gmail.com (brian) Date: Fri Oct 3 21:03:24 2008 Subject: [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> Message-ID: <22f6a8f70810031806idca14edk7bb93a6b7e18c909@mail.gmail.com> On Fri, Oct 3, 2008 at 8:01 PM, Christopher Lane Hinson wrote: > What /is/ it with haskell-cafe lately? > Do we need a haskell-blah mailing list? Thanks for saying it. +1. From rendel at daimi.au.dk Fri Oct 3 21:15:21 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Fri Oct 3 21:12:04 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E675DA.5050104@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E675DA.5050104@btinternet.com> Message-ID: <48E6C3A9.5000908@daimi.au.dk> Andrew Coppin wrote: >> "ap" generalizes the liftM* functions, so >> >> liftM2 f a b = return f `ap` a `ap` b >> liftM3 f a b c = return f `ap` a `ap` b `ap` c >> >> and so forth. > > Now that at least makes sense. (It's non-obvious that you can use it for > this. If it weren't for curried functions, this wouldn't work at all...) Note that the documentation for ap states: > In many situations, the liftM operations can be replaced by uses of ap, which promotes function application. > > return f `ap` x1 `ap` ... `ap` xn > > is equivalent to > > liftMn f x1 x2 ... xn Tillmann From rendel at daimi.au.dk Fri Oct 3 21:16:20 2008 From: rendel at daimi.au.dk (Tillmann Rendel) Date: Fri Oct 3 21:12:59 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E65DF0.7090301@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> Message-ID: <48E6C3E4.90802@daimi.au.dk> Andrew Coppin wrote: > run_or s0 x y = > let > either_rset1 = sequence $ run s0 x > either_rset2 = sequence $ run s0 y > either_rset3 = do rset1 <- either_rset1; rset2 <- either_rset2; > return (merge rset1 rset2) > in case either_rset3 of > Left e -> throwError e > Right rset -> lift rset Just to expand on that discussion of Control.Monad.ap aka. (Control.Applicative.<*>) in the other half of the thread. The expression do rset1 <- either_rset1 rset2 <- either_rset2 return (merge rset1 rset2) follows exactly the pattern Applicative is made for: We execute some actions, and combine their result using a pure function. Which action we execute is independent from the result of the previous actions. That means that we can write this expression as: return merge `ap` either_rset1 `ap` either_rset2 Note how we avoid to give names to intermediate results just to use them in the very next line. Since return f `ap` x == f `fmap` x, we can write shorter merge `fmap` either_rset1 `ap` either_rset2 Or in Applicative style: merge <$> either_rset1 <*> either_rset2 Now that the expression is somewhat shorter, we can inline the either_rset1, 2 and 3 as follows: case merge <$> sequence (run s0 x) <*> sequence (run s0 y) of Left e -> throwError e Right rset -> lift rset Note how the structure of the code reflects what happens. The structure is merge <$> ... <*> ..., and the meaning is: merge is called on two arguments, which are created by running some actions, and the result is again an action. While we are one it, we can get rid of the pattern matching by employing the either function as follows: either throwError lift (merge <$> sequence (run s0 x) <*> sequence (run s0 y)) > Do you realise, this single snippet of code utilises the ErrorT monad [transformer], the ResultSet monad, *and* the Either monad, all in the space of a few lines?? That's three monads in one function! o_O Now it fits on a single line! Tillmann From catamorphism at gmail.com Fri Oct 3 21:26:26 2008 From: catamorphism at gmail.com (Tim Chevalier) Date: Fri Oct 3 21:23:00 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> Message-ID: <4683d9370810031826u653fbbe3o9720c617011e572c@mail.gmail.com> On Fri, Oct 3, 2008 at 2:29 PM, Jason Dusek wrote: > Lennart Augustsson wrote: >> But (a) is not a lifted version of a, whereas (a,b) is a lifted >> version of the a b product. >> So it's not consistent, and thereby wrong. > > Well, we can't represent the unlifted product in Haskell, > right? You have to use some constructor. So if we just say we > are using tuples to represent unlifted products, what's so bad > about that? > Unless I'm confused, unboxed tuples represent unlifted products. In a sense this is "[using] some constructor", but in a sense not, since an unboxed tuple constructor has no runtime representation. > The last two messages in this thread suggests this has more to > do with the internals of Haskell than they do with consistent > semantics -- so I am perhaps missing the point. I think most Haskellers try their best to keep the first subservient to the second. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "If you don't understand the causes, it is impossible to come up with a solution." -- Joe Biden From vigalchin at gmail.com Fri Oct 3 21:26:30 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Oct 3 21:23:12 2008 Subject: [Haskell-cafe] maybe a goal and challenge for the Haskell in terms of scientific computing Message-ID: <5ae4f2ba0810031826y3d35df87icc9c2f7709c371ad@mail.gmail.com> Hello, Here is a site I discovered a while back for another language ... I guess in the back of my mind this more where I was going vis-a-vis scientific computing .... http://www.enthought.com/ Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/4b6a6d39/attachment.htm From allbery at ece.cmu.edu Fri Oct 3 21:33:33 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 3 21:30:09 2008 Subject: [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> Message-ID: On 2008 Oct 3, at 21:01, Christopher Lane Hinson wrote: > What /is/ it with haskell-cafe lately? > > Do we need a haskell-blah mailing list? I would subscribe to that. > Hell, I would post to it probably more than I post to haskell-cafe. > But I'd also divert it to a separate mailbox for when I have too > much free time. Oddly enough, it seems to me that haskell-*cafe* identifies a list that isn't tightly focused, as compared to haskell@haskell.org. Perhaps we need to rethink names (although any changes will probably hurt). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From ajb at spamcop.net Fri Oct 3 21:39:53 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Fri Oct 3 21:36:29 2008 Subject: [Haskell-cafe] Model-driven development (was: Haskell participting in big science like CERN Hadrian...) In-Reply-To: <20081003193835.GD26436@scytale.galois.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> <20081003193835.GD26436@scytale.galois.com> Message-ID: <20081003213953.1u7cs5qp9ccgk08g-nwo@webmail.spamcop.net> G'day all. Quoting Don Stewart : > How about EDSLs for producing high assurance controllers, and other > robust devices they might need. I imagine the LHC has a good need for > verified software components... On a related topic, I'm curious if anyone apart from me has been secretly using Haskell for model-driven-development-lite. My current boss, not being a programmer, doesn't care where the code comes from, so the following conversation is unlikely to happen. Still. other people must also have thought of doing this: "Well, the reason why I've produced so much C++ lately is because I've been generating all the boilerplate automatically. What with? Glad you asked..." Cheers, Andrew Bromage From jeff at nokrev.com Fri Oct 3 21:40:48 2008 From: jeff at nokrev.com (Jeff Wheeler) Date: Fri Oct 3 21:37:32 2008 Subject: [Haskell-cafe] maybe a goal and challenge for the Haskell in terms of scientific computing In-Reply-To: <5ae4f2ba0810031826y3d35df87icc9c2f7709c371ad@mail.gmail.com> References: <5ae4f2ba0810031826y3d35df87icc9c2f7709c371ad@mail.gmail.com> Message-ID: <6EC8216C-A831-48EC-B613-E3F697E79574@nokrev.com> On Oct 3, 2008, at 8:26 PM, Galchin, Vasili wrote: > Here is a site I discovered a while back for another > language ... I guess in the back of my mind this more where > I was going vis-a-vis scientific computing .... http://www.enthought.com/ I interned at Enthought over this last summer; it's a very cool place. Many of the open-source scientific libraries could be rewritten in Haskell without significant difficulty, and this actually seems like a decent idea. SciPy and NumPy are the two most significant libraries worth thinking about, in my opinion. Some of the other software, e.g. Traits, is less relevant to scientific software in the context of Haskell. Much of their stack, especially Traits, TraitsGUI, and application libraries are designed to help write applications quickly without much programming experience. With these tools, it's easy for scientists, without knowing much Python, to write large programs that work well for most of their purposes. Jeff Wheeler From jvlask at hotmail.com Fri Oct 3 21:47:22 2008 From: jvlask at hotmail.com (john lask) Date: Fri Oct 3 21:43:57 2008 Subject: [Haskell-cafe] New System.Process Message-ID: Something that has irked me in the past about System.Process is the inability to obtain an OS system handle from the haskell Process handle. Such a facility would greatly enhance the interoperabity of c and haskell libraries. Provision is made (although not standardised) to obtain OS specific handles from haskell File Handles which is very useful. The same should be provided for Haskell Process handles. The main barrier to such a facility is the variability between OS representations of such a type (aka windows Handles, unix PID). comments anyone. _________________________________________________________________ From coreyoconnor at gmail.com Fri Oct 3 21:58:26 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Fri Oct 3 21:55:00 2008 Subject: [Haskell-cafe] Simplifying a IsFunction type class using type equality constraints Message-ID: I recently had a need to use the IsFunction typeclass described by Oleg here: http://okmij.org/ftp/Haskell/isFunction.lhs and am wondering if the use of the TypeCast class can be correctly replaced by a type equality constraint. The IsFunction and TypeCast classes were defined as: > data HTrue > data HFalse > > class IsFunction a b | a -> b > instance TypeCast f HTrue => IsFunction (x->y) f > instance TypeCast f HFalse => IsFunction a f > > -- literally lifted from the HList library > class TypeCast a b | a -> b, b->a where typeCast :: a -> b > class TypeCast' t a b | t a -> b, t b -> a where typeCast' :: t->a->b > class TypeCast'' t a b | t a -> b, t b -> a where typeCast'' :: t->a->b > instance TypeCast' () a b => TypeCast a b where typeCast x = typeCast' () x > instance TypeCast'' t a b => TypeCast' t a b where typeCast' = typeCast'' > instance TypeCast'' () a a where typeCast'' _ x = x I found the use of TypeCast in the IsFunction could be replaced by a type family: > class IsFunction a b | a -> b > instance (f ~ TTrue) => IsFunction (x->y) f > instance (f ~ TFalse) => IsFunction a f Which, to me, is easier to understand and appears to function the same. The type equality is a stronger (?) constraint than the TypeCast class, but for the case of IsFunction the use of type equality is correct. Am I correct? Is the second definition of IsFunction actually equivalent to the original? Cheers, -Corey O'Connor From lrpalmer at gmail.com Fri Oct 3 22:24:04 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 3 22:20:38 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <4683d9370810031826u653fbbe3o9720c617011e572c@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> <4683d9370810031826u653fbbe3o9720c617011e572c@mail.gmail.com> Message-ID: <7ca3f0160810031924v7d1a1fdak3d7f702ce3531b24@mail.gmail.com> On Fri, Oct 3, 2008 at 7:26 PM, Tim Chevalier wrote: > On Fri, Oct 3, 2008 at 2:29 PM, Jason Dusek wrote: >> Lennart Augustsson wrote: >>> But (a) is not a lifted version of a, whereas (a,b) is a lifted >>> version of the a b product. >>> So it's not consistent, and thereby wrong. >> >> Well, we can't represent the unlifted product in Haskell, >> right? You have to use some constructor. So if we just say we >> are using tuples to represent unlifted products, what's so bad >> about that? >> > > Unless I'm confused, unboxed tuples represent unlifted products. In a > sense this is "[using] some constructor", but in a sense not, since an > unboxed tuple constructor has no runtime representation. Well, unboxed tuples are not really lifted nor unlifed, since you can't even pass one to a function. I like to pretend tuples are unlifted. Here's how I do it: * Never use seq on tuples (or functions). I could make this precise by putting seq in a typeclass (like it used to be - like it should be), and not having instances for tuples. * Never do a strict pattern match on a tuple. I.e. instead of writing f (x,y) = ..., I will write f ~(x,y) =... everywhere. Then (_|_,_|_) might as well be _|_, we have no way to tell them apart. I like to pretend functions are unlifed the same way; i.e. const _|_ = _|_. There are apparently occasions where lazily matching on a tuple will introduce a space leak. I am not 1337 enough to recognize them yet. Luke From catamorphism at gmail.com Fri Oct 3 22:32:41 2008 From: catamorphism at gmail.com (Tim Chevalier) Date: Fri Oct 3 22:29:14 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <7ca3f0160810031924v7d1a1fdak3d7f702ce3531b24@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810021446o3f5e132bo57fdeb6fbb471c0@mail.gmail.com> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> <4683d9370810031826u653fbbe3o9720c617011e572c@mail.gmail.com> <7ca3f0160810031924v7d1a1fdak3d7f702ce3531b24@mail.gmail.com> Message-ID: <4683d9370810031932t417dbdcg534facf6770389cb@mail.gmail.com> On Fri, Oct 3, 2008 at 7:24 PM, Luke Palmer wrote: > Well, unboxed tuples are not really lifted nor unlifed, since you > can't even pass one to a function. > It's true that unboxed tuples are not first-class. But what I mean by "unlifted" is that the type (# Int, Int #), when interpreted as a set, does not contain _|_ as an element (and I'm purposely conflating the unlifted/liftedness distinction with the unboxed/boxness distinction here). Is that what you mean, or do you mean something else? > I like to pretend tuples are unlifted. Here's how I do it: > Sure. But the compiler won't check that assumption for you. I don't know whether that has anything to do with the original question, though :-) Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt "If you don't understand the causes, it is impossible to come up with a solution." -- Joe Biden From lrpalmer at gmail.com Fri Oct 3 22:34:44 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Oct 3 22:31:19 2008 Subject: [Haskell-cafe] Announcing OneTuple-0.1.0 In-Reply-To: <4683d9370810031932t417dbdcg534facf6770389cb@mail.gmail.com> References: <20081002065608.GA27422@colquitt.org> <42784f260810030017i49b75a54s95c26860be6df8ab@mail.gmail.com> <42784f260810031007me511ccei212e8fdf61b9c5fa@mail.gmail.com> <42784f260810031429s6fd7641dk3a648d96a7682bac@mail.gmail.com> <4683d9370810031826u653fbbe3o9720c617011e572c@mail.gmail.com> <7ca3f0160810031924v7d1a1fdak3d7f702ce3531b24@mail.gmail.com> <4683d9370810031932t417dbdcg534facf6770389cb@mail.gmail.com> Message-ID: <7ca3f0160810031934yc63f9f8lf6eb8a85480fb972@mail.gmail.com> On Fri, Oct 3, 2008 at 8:32 PM, Tim Chevalier wrote: > On Fri, Oct 3, 2008 at 7:24 PM, Luke Palmer wrote: >> Well, unboxed tuples are not really lifted nor unlifed, since you >> can't even pass one to a function. >> > > It's true that unboxed tuples are not first-class. But what I mean by > "unlifted" is that the type (# Int, Int #), when interpreted as a set, > does not contain _|_ as an element (and I'm purposely conflating the > unlifted/liftedness distinction with the unboxed/boxness distinction > here). Is that what you mean, or do you mean something else? Yeah kind of, because if it doesn't contain _|_ as an element, then it's not even a domain! :-) >> I like to pretend tuples are unlifted. Here's how I do it: >> > > Sure. But the compiler won't check that assumption for you. I don't > know whether that has anything to do with the original question, > though :-) Nobody's questions are original. Luke From vigalchin at gmail.com Sat Oct 4 00:37:55 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Oct 4 00:34:28 2008 Subject: [Haskell-cafe] maybe a goal and challenge for the Haskell in terms of scientific computing In-Reply-To: References: <5ae4f2ba0810031826y3d35df87icc9c2f7709c371ad@mail.gmail.com> Message-ID: <5ae4f2ba0810032137o4348bd56u6af7b598c5b105@mail.gmail.com> Let me recuse myself .... What is the nature of the open source license? Vasili On Fri, Oct 3, 2008 at 8:39 PM, Jeff Wheeler wrote: > On Oct 3, 2008, at 8:26 PM, Galchin, Vasili wrote: > > Here is a site I discovered a while back for another language ... I >> guess in the back of my mind this more where >> I was going vis-a-vis scientific computing .... http://www.enthought.com/ >> > > I interned at Enthought over this last summer; it's a very cool place. Many > of the open-source scientific libraries could be rewritten in Haskell > without significant difficulty, and this actually seems like a decent idea. > > SciPy and NumPy are the two most significant libraries worth thinking > about, in my opinion. Some of the other software, e.g. Traits, is less > relevant to scientific software in the context of Haskell. > > Much of their stack, especially Traits, TraitsGUI, and application > libraries are designed to help write applications quickly without much > programming experience. With these tools, it's easy for scientists, without > knowing much Python, to write large programs that work well for most of > their purposes. > > Jeff Wheeler > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081003/188d55ee/attachment.htm From dagit at codersbase.com Sat Oct 4 03:31:25 2008 From: dagit at codersbase.com (Jason Dagit) Date: Sat Oct 4 03:27:58 2008 Subject: [Haskell-cafe] Model-driven development (was: Haskell participting in big science like CERN Hadrian...) In-Reply-To: <20081003213953.1u7cs5qp9ccgk08g-nwo@webmail.spamcop.net> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> <20081003193835.GD26436@scytale.galois.com> <20081003213953.1u7cs5qp9ccgk08g-nwo@webmail.spamcop.net> Message-ID: On Fri, Oct 3, 2008 at 6:39 PM, wrote: > G'day all. > > Quoting Don Stewart : > > How about EDSLs for producing high assurance controllers, and other >> robust devices they might need. I imagine the LHC has a good need for >> verified software components... >> > > On a related topic, I'm curious if anyone apart from me has been secretly > using Haskell for model-driven-development-lite. > > My current boss, not being a programmer, doesn't care where the code > comes from, so the following conversation is unlikely to happen. Still. > other people must also have thought of doing this: > > "Well, the reason why I've produced so much C++ lately is because I've > been generating all the boilerplate automatically. What with? Glad > you asked..." Replace C++ with python and you have what I've been thinking about. I've been of several minds: 1) Write a type checker for python in Haskell 2) Write a Haskell program that reads special "type" comments from python programs and type checks the python 3) Write a python generating EDSL in Haskell 4) Translate Haskell to python Python is what we typically use for various technical reasons, but I'm quite unsatisfied with it. Every time I turn around I'm faced with learning a new facet of the language (or less politely, a limitation it has that I wasn't expecting). I also find that I spend a lot of time trying to figure out ways to hit the various control paths, otherwise I rely on tools like pylint, which don't work so well. When, I'm often just looking for type incorrect statements and misspelled variable names. Really, if I had more static analysis, I'd have to do less of what the compiler could be doing. I think testing is often easier in Haskell too, but maybe that's just my opinion. The problem with #1 is that others have tried it, python just doesn't lend itself to type checking. The problem with #2 is that I'm no longer writing python, I'm writing my version of python and other devs on our team could object, and some of the problems with #1 may apply. None of those are strong arguements against it. The main problem with #3, is that if I share code with other devs they have to learn Haskell and my EDSL since they won't be able to just hack the generated python, similar problem with #4. Also, problem with #4 is that it may be difficult to generate efficient idomatic python code. At my company, the source code is often a deliverable it seems that I can really only do #1 and #2 and I'm not convinced it's worth the effort. I'd probably better off making a tool that can read in a python program and generate test cases to correspond to the work that static analysis would be doing. This is the first time this idea has occured to me, but I like it and I should spend some more time thinking about it. Is it possible to make a test case generator that can generate test cases to hit each execution branch in a program? Oh, but maybe I could use such a program to solve the halting problem? If so, that would be a useful application as well :) Fundamentally, I think I agree with your approach assuming the political and team aspects work out. If you're the only one that is willing to use language X on the team then it seems like bad form to use language X when you know you have a team to work with. Sometimes being a team player is way more important than the technical details, or so I've found. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081004/c205d151/attachment.htm From fw at deneb.enyo.de Sat Oct 4 06:52:57 2008 From: fw at deneb.enyo.de (Florian Weimer) Date: Sat Oct 4 06:49:30 2008 Subject: [Haskell-cafe] Type family oddity Message-ID: <877i8omy2e.fsf@mid.deneb.enyo.de> I can't figure out why the following code doesn't compile with the October 2n GHC 6.10 beta (-XTypeFamilies -XFlexibleContexts) when the type declaration is not commented out. module T where type family RangeTrait c class InputRange r where remaining :: r -> Bool advance :: r -> r class (InputRange (RangeTrait s)) => Sequence s where erase :: RangeTrait s -> IO (RangeTrait s) -- erase_range :: (Sequence s) => RangeTrait s -> IO (RangeTrait s) erase_range r = if remaining r then do r' <- erase r erase_range r' else return r GHCi says the type is precisely as specified in the comment. However, when I activate the type declaration, GHC complains: T.hs:16:22: Couldn't match expected type `RangeTrait s' against inferred type `RangeTrait s2' In the first argument of `erase', namely `r' In a stmt of a 'do' expression: r' <- erase r In the expression: do r' <- erase r erase_range r' T.hs:17:22: Couldn't match expected type `RangeTrait s1' against inferred type `RangeTrait s2' In the first argument of `erase_range', namely `r'' In the expression: erase_range r' In the expression: do r' <- erase r erase_range r' Any suggestions? Is this a bug in GHC? From semanticphilosopher at googlemail.com Sat Oct 4 07:19:13 2008 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat Oct 4 07:15:49 2008 Subject: [Haskell-cafe] Haskell participating in big science like CERN Hadron.... In-Reply-To: <20081003193835.GD26436@scytale.galois.com> References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> <20081003193835.GD26436@scytale.galois.com> Message-ID: <5D12128C-5925-4E2B-BF63-E5999B197012@gmail.com> Gents Too late to get in on that act - that software was designed over the last 10/15 years implemented and trailed over the last 5 and being tuned now. But all is not lost, Haskell is being used! Well in least in helping ATLAS people understand how to the data acquisition system performs (and interacts) - its what the stochastic performance algebra language being used to capture behavioural models is written in. Neil On 3 Oct 2008, at 20:38, Don Stewart wrote: > wchogg: >> On Fri, Oct 3, 2008 at 5:47 AM, Dougal Stanton > > wrote: >>> 2008/10/3 Galchin, Vasili : >>>> Hello, >>>> >>>> One of my interests based on my education is "grand challenge >>>> science". >>>> Ok .. let's take the CERN Hadrian Accelerator. >>>> >>>> Where do you think Haskell can fit into the CERN Hadrian effort >>>> currently? >>>> >>>> Where do you think think Haskell currently is lacking and will >>>> have to >>>> be improved in order to participate in CERN Hadrian? >>> >>> Is that the experiment where Picts are accelerated to just short of >>> the speed of light in order to smash through to the Roman >>> Empire? ;-) >>> >>> I don't know what the main computational challenges are to the LHC >>> researchers. The stuff in the press has mostly been about >>> infrastructure --- how to store the gigabytes of data per second >>> that >>> they end up keeping, out of the petabytes that are produced in the >>> first place (or something). >> >> Well, with the LHC efforts I don't think a technology like Haskell >> really has a place...at least not now. Even just a few years back, >> when I worked on this stuff, we were still doing lots of simulation >> in >> preparation for the actual live experiment and Haskell might have >> been >> a good choice for some of the tools. All of the detector simulation >> was written in C++, because C++ is the new FORTRAN to physicists, and >> you ain't seen nothing till you've seen a jury-rigged form of lazy >> evaluation built into a class hierarchy in C++. Now, would the C++ >> based simulation have run faster than a Haskell based one? Quite >> possibly. On the other hand, I remember how many delays and problems >> were caused by the sheer complexity of the codebase. That's where a >> more modern programming language might have been extremely helpful. > > How about EDSLs for producing high assurance controllers, and other > robust devices they might need. I imagine the LHC has a good need for > verified software components... > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From claus.reinke at talk21.com Sat Oct 4 07:31:41 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Oct 4 07:28:20 2008 Subject: [Haskell-cafe] Type family oddity References: <877i8omy2e.fsf@mid.deneb.enyo.de> Message-ID: > -- erase_range :: (Sequence s) => RangeTrait s -> IO (RangeTrait s) This can't work, as you can see after desugaring: > -- erase_range :: (Sequence s,RangeTrait s~rs) => rs -> IO rs There is nowhere to get 's' from, unless you start applying type families backwards, from results to parameters. > type family RangeTrait c > class (InputRange (RangeTrait s)) => Sequence s where > erase :: RangeTrait s -> IO (RangeTrait s) Perhaps this shouldn't be accepted, or should trigger a warning. In the class declaration, and in any instance definitions, 's' will be bound in the head, so seems to be known locally, but 's' won't be known in any use of 'erase' outside the class declaration/instance definition. The only way to make 's' known to 'erase' would be via '{-# LANGUAGE ScopedTypeVariables #-}'. > -- erase_range :: (Sequence s) => RangeTrait s -> IO (RangeTrait s) > erase_range r = > if remaining r > then do > r' <- erase r > erase_range r' > else return r > > GHCi says the type is precisely as specified in the comment. That (the inference result) does look like a bug, since 's' is bound locally, but not linked to any object that could fix it. The error message should mention the hoped-for type, and the reason why that type won't work. Which 's' did you want 'erase_range' to use to select an instance of 'Sequence'? If you absolutely insist on that type, you could move the function into the class, but then it will be just as difficult to use as 'erase'. Btw, is there a list of common TF pitfalls somewhere? Some example items so far seem to be: 1 'C a => TF a', where 'a' isn't determinable 2 'TF a' is not fully polymorphic 3 'TF a' is not a decomposable type constructor, it stands only for itself, or for its result (in that way it is more like a defined function application) For 1/2, it is helpful to flatten type family applications: - 'C a => TF a' becomes: '(C a,TF a~tfa) => tfa' - 'TF a' becomes: 'TF a~tfa => tfa' For 3, it is helpful to imagine the arity of type families being marked by braces, to distinguish type family parameters from any constructor parameters, in case the type family reduces to a type constructor: - Given 'type family TF2 a :: * -> *', 'TF2 a b' becomes: '{TF2 a} ~ tfa => tfa b' Claus From lane at downstairspeople.org Sat Oct 4 09:54:04 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sat Oct 4 09:50:37 2008 Subject: [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> Message-ID: On Fri, 3 Oct 2008, Brandon S. Allbery KF8NH wrote: > > Oddly enough, it seems to me that haskell-*cafe* identifies a list that isn't > tightly focused, as compared to haskell@haskell.org. Perhaps we need to > rethink names (although any changes will probably hurt). I thought this too. But, I think that haskell-cafe is high traffic, whereas people subscribe just to haskell@haskell.org when they just want announcements and HWN (which has been awesome lately, by the way). But I think a discussion e.g. about providing medical treatment to prisoners of war might benefit both haskell-cafe and the discussion itself to be on another list. Especially as the community is growing rapidly, it might benefit from having an outlet for all of this energy. I think just putting a little note beside the mailing list "high traffic" as opposed to "off topic" before you get to the subscribe step would suffice, without needing to change names. --Lane From mechvel at botik.ru Sat Oct 4 10:57:39 2008 From: mechvel at botik.ru (Serge D. Mechveliani) Date: Sat Oct 4 10:54:44 2008 Subject: [Haskell-cafe] NewLines in string Message-ID: <20081004145739.GA24416@scico.botik.ru> People, Here is a certain naive question about string setting in a Haskell program. I have the functions parseProgram :: String -> Program apply :: Program -> Term -> Term -- interpreter, and try to build the example modules for them as in the following example: ---------------------------------------------------------------- module Main where program = parseProgram " isOrdered nil -> true; isOrdered (X:nil) -> true; isOrdered (X:Y:Ys) -> isOrd (X > Y) (isOrdered (Y:Ys)); isOrd true bo -> false; isOrd false bo -> bo " main = let {data = ... :: Term; res = apply program data} in putStr $ concat ["data = ", shows data "\n", "res = ", shows res "\n"] ---------------------------------------------------------------- -- that is set a string (an object program example), parse it to a program, apply this program and print the result. But in reality, the above string must be set like this: (2) "\ \ isOrdered nil -> true;\ \ isOrdered (X:nil) -> true;\ \ isOrdered (X:Y:Ys) -> \ \ isOrd (X > Y) (isOrdered (Y:Ys));\ \\ \ isOrd true bo -> false;\ \ isOrd false bo -> bo\ \" -- because otherwise Haskell treats the NewLine characters in the above string in an unneeded way. But with (2), the program Main occurs hard to read. One could try to improve this by using readFile. Form the file data.txt -------------------------------- isOrdered nil -> true; isOrdered (X:nil) -> true; isOrdered (X:Y:Ys) -> isOrd (X > Y) (isOrdered (Y:Ys)); isOrd true bo -> false; isOrd false bo -> bo ----------------------------------------- and combine readFile "data.txt", the `do' construct, pearseProgram, apply, putStr. But this needs adding one more file, and this also changes the programming style in defining examples. Now, what is the difference? 1. readFile reads string from file, with treating NewLine as needed. 2. The Haskell compiler reads the expression parseProgram " isOrdered nil > true; ... " from the input Haskell program with treating NewLine in the string in a different way. I wonder: how to remove most of backslashes in the program (2) ? Thank you in advance for your comments. ----------------- Serge Mechveliani mechvel@botik.ru From ketil at malde.org Sat Oct 4 11:02:39 2008 From: ketil at malde.org (Ketil Malde) Date: Sat Oct 4 10:56:08 2008 Subject: [Haskell-cafe] maybe a goal and challenge for the Haskell in terms of scientific computing In-Reply-To: <6EC8216C-A831-48EC-B613-E3F697E79574@nokrev.com> (Jeff Wheeler's message of "Fri\, 3 Oct 2008 20\:40\:48 -0500") References: <5ae4f2ba0810031826y3d35df87icc9c2f7709c371ad@mail.gmail.com> <6EC8216C-A831-48EC-B613-E3F697E79574@nokrev.com> Message-ID: <877i8owghc.fsf@malde.org> FWIW, I always thought that Haskell, and in particular, ghci, would be a great environment for statistics. I've used R a bit, and while it has a functional flavor to it, I find Haskell much nicer for programming. We just need a nice data frame type: a sliceable, labelable? multi-dimensional array. (Of course, the real value in such a package is in the extent of libraries.) -k ?) Please accept my apologies if you are native English speaker. -- If I haven't seen further, it is by standing in the footprints of giants From manlio_perillo at libero.it Sat Oct 4 11:05:51 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Oct 4 11:02:41 2008 Subject: [Haskell-cafe] monadic parser with Happy and Alex Message-ID: <48E7864F.60802@libero.it> Hi. I have completed a draft of a CSS lexer, using Alex. http://hg.mperillo.ath.cx/haskell/webtools/file/tip/src/CSS/Lexer.x The lexer use the posn wrapper. Now I'm starting to write the parser with Happy, however for the final product I would like to: 1) Be able to do I/O in the lexer, for stylesheets inclusion (@import rule) 2) be able to keep state in the parser (or lexer?), for character transcoding (@charset rule) This should be possible with Happy (and there are some example), however I don't find examples that make use of a lexer written with Alex. Should I write a lexer using only the Alex basic interface (without wrappers)? Thanks Manlio Perillo From allbery at ece.cmu.edu Sat Oct 4 12:15:47 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Oct 4 12:12:19 2008 Subject: [Haskell-cafe] NewLines in string In-Reply-To: <20081004145739.GA24416@scico.botik.ru> References: <20081004145739.GA24416@scico.botik.ru> Message-ID: On 2008 Oct 4, at 10:57, Serge D. Mechveliani wrote: > Here is a certain naive question about string setting in a Haskell > program. > I have the functions > parseProgram :: String -> Program > apply :: Program -> Term -> Term -- interpreter, > > and try to build the example modules for them as in the following > example: There are no simple or especially pretty ways to do it, but here's something using Template Haskell to implement something akin to Unix "here documents": http://www.haskell.org/pipermail/haskell-cafe/2007-June/027395.html -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From vag.vagoff at gmail.com Sat Oct 4 12:38:05 2008 From: vag.vagoff at gmail.com (Vag) Date: Sat Oct 4 12:34:37 2008 Subject: [Haskell-cafe] An important question to Simon P. Jones Message-ID: Dear Simon! Can you please give an authoritative explanation, in the nutshell, what is exact relationship between object-oriented programming and proposed lightweight extensible records? Thanks in advance, sincerely yours, Vag. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081004/94bd280d/attachment.htm From kolmodin at dtek.chalmers.se Sat Oct 4 13:10:26 2008 From: kolmodin at dtek.chalmers.se (Lennart Kolmodin) Date: Sat Oct 4 12:53:59 2008 Subject: [Haskell-cafe] announcing darcs 2.1.0pre3 In-Reply-To: <20081002120752.GA56508@Macintosh.local> References: <20081002120752.GA56508@Macintosh.local> Message-ID: <48E7A382.5050007@dtek.chalmers.se> Eric Kow wrote: > The third pre-release of darcs 2.1 is now available at > http://darcs.net/darcs-2.1.0pre3.tar.gz darcs 2.1.0pre3 is now available in Gentoo Linux, hard masked. Update your portage tree and unmask[1] it. Cheers, Lennart Kolmodin [1] http://gentoo-wiki.com/Masked#Hard_Masked From dons at galois.com Sat Oct 4 15:15:47 2008 From: dons at galois.com (Don Stewart) Date: Sat Oct 4 15:12:08 2008 Subject: [Haskell-cafe] Arch Haskell News: Oct 4 2008 Message-ID: <20081004191547.GA1429@scytale.galois.com> A weekly update about Haskell on Arch Linux. Highlights, * Arch now has 609 Haskell packages in AUR. That?s a record increase of 19 new packages in the last 7 days. Noteworthy, * mp3decoder-0.0.1: ?MP3 decoder for teaching.? * yi-0.4.6.2: ?The Haskell-Scriptable Editor? * haskell-haskore-0.0.5.1: ?The Haskore Computer Music System? Full update list, http://archhaskell.wordpress.com/2008/10/04/arch-haskell-news-oct-4-2008/ -- Don From ben.franksen at online.de Sat Oct 4 16:11:52 2008 From: ben.franksen at online.de (Ben Franksen) Date: Sat Oct 4 16:08:40 2008 Subject: [Haskell-cafe] Re: Health effects References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> Message-ID: Simon Brenner wrote: > 2kg of chocolate 'thunks' to 'force' really might 'blow your stack' later > on. Oh my god, this one made me laugh so hard I almost choked on the piece of chocolate I was just eating. It should definitely make it into HWN Quotes of the Week... Cheers Ben From duncan.coutts at worc.ox.ac.uk Sat Oct 4 16:34:10 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Oct 4 16:30:43 2008 Subject: [Haskell-cafe] monadic parser with Happy and Alex In-Reply-To: <48E7864F.60802@libero.it> References: <48E7864F.60802@libero.it> Message-ID: <1223152450.14163.450.camel@dell.linuxdev.us.dell.com> On Sat, 2008-10-04 at 17:05 +0200, Manlio Perillo wrote: > Hi. > > I have completed a draft of a CSS lexer, using Alex. > http://hg.mperillo.ath.cx/haskell/webtools/file/tip/src/CSS/Lexer.x > > The lexer use the posn wrapper. > > Now I'm starting to write the parser with Happy, however for the final > product I would like to: > 1) Be able to do I/O in the lexer, for stylesheets inclusion > (@import rule) > 2) be able to keep state in the parser (or lexer?), for character > transcoding (@charset rule) > > > This should be possible with Happy (and there are some example), however > I don't find examples that make use of a lexer written with Alex. See c2hs or Language.C it uses a monadic lexer. Duncan From byorgey at seas.upenn.edu Sat Oct 4 16:35:39 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Oct 4 16:32:09 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 88 - October 4, 2008 Message-ID: <20081004203539.GA24732@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20081004 Issue 88 - October 04, 2008 --------------------------------------------------------------------------- Welcome to issue 88 of HWN, a newsletter covering developments in the [1]Haskell community. An extra-short HWN this week, so you get an extra ten minutes to do something else during the time you would have normally spent reading the HWN! HWN-editor-approved activities for your ten minutes include eating cookies, playing [2]Fantastic Contraption, and writing a type checker in the type system while eating cookies. Announcements Arch Haskell News: Oct 4 2008. Don Stewart [3]sent out the newest Arch Haskell news --- now with 609 Haskell packages! Announcing OneTuple-0.1.0. John Dorsey [4]announced the release of the ground-breaking [5]OneTuple library, which adds the long neglected one-tuple to Haskell. It also turns out that the denizens of Haskell-cafe are completely unable to refrain from turning jokes into long-winded technical discussions about strictness and lifted types. Haskell protocol-buffers version 0.3.1. Chris Kuklewicz [6]announced the release of [7]protocol-buffers 0.3.1, with some functionality also split off into [8]protocol-buffers-descriptor and [9]hprotoc. The 'hprotoc' compiler for proto files to Haskell source code now takes a "-u" command-line option. When given, this turns on code generation to support loading, storing, and saving unknown fields. Discussion Stacking monads. Andrew Coppin began a long [10]discussion on monads, monad transformers, Applicative, MonadPlus, and related topics. planning for ghc-6.10.1 and hackage. Duncan Coutts began a [11]discussion on how to make the transition to GHC 6.10 as painless as possible, especially as it relates to the new base-4 package and Cabal. Proposal #2629: Data.List: Replace nub; add nubOrd, nubInt, nubWith. Bart Massey [12]proposed refactoring nub into a 'nubWith' function which can be specialized to efficient versions for Int and Ord. Blog noise [13]Haskell news from the [14]blogosphere. * Luke Palmer: [15]Laziness and the monad laws. Luke explains why making a Functor or Monad instance too lazy can be just as bad as making it too strict. * Paul R Brown: [16]The Haskell Platform and Lessons Learned Elsewhere. * Eric Kow (kowey): [17]darcs weekly news #6. * Mads Lindstroem: [18]Overlapping Instances in Haskell. * >>> Bill Six: [19]Dabbling with Haskell. Bill explores palindromic pangrams using Haskell. Quotes of the Week * ozy`: [on RWH] most authors are like "FUNCTIONAL PROGRAMMING IS FUNCTIONAL!!!" whereas these guys are more like "yeah but practical programming is practical. map wash_dish dishes" * BMeph: * wants an "Everything I know about computing I learned from sigfpe" T-shirt * OlegFacts: Oleg can evaluate bottom. With his fists. * quicksilver: my computer starts to play 'Dies Irae' when shapr gets ops, automatically. About the Haskell Weekly News New editions are posted to [20]the Haskell mailing list as well as to [21]the Haskell Sequence and [22]Planet Haskell. [23]RSS is also available, and headlines appear on [24]haskell.org. To help create new editions of this newsletter, please see the information on [25]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [26]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://fantasticcontraption.com/ 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45786 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/45586 5. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple 6. http://article.gmane.org/gmane.comp.lang.haskell.libraries/10134 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers 8. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/protocol-buffers-descriptor 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hprotoc 10. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/45634 11. http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/15339 12. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/10133 13. http://planet.haskell.org/ 14. http://haskell.org/haskellwiki/Blog_articles 15. http://luqui.org/blog/archives/2008/10/03/laziness-and-the-monad-laws/ 16. http://mult.ifario.us/p/the-haskell-platform-and-lessons-learned-elsewhere 17. http://koweycode.blogspot.com/2008/10/darcs-weekly-news-6.html 18. http://lindstroem.wordpress.com/2008/09/27/inheritance-in-composites-and-overlapping-instances/ 19. http://billsix.blogspot.com/2008/10/dabbling-with-haskell.html 20. http://www.haskell.org/mailman/listinfo/haskell 21. http://sequence.complete.org/ 22. http://planet.haskell.org/ 23. http://sequence.complete.org/node/feed 24. http://haskell.org/ 25. http://haskell.org/haskellwiki/HWN 26. http://code.haskell.org/~byorgey/code/hwn/ From dagit at codersbase.com Sat Oct 4 17:41:04 2008 From: dagit at codersbase.com (Jason Dagit) Date: Sat Oct 4 17:37:35 2008 Subject: [Haskell-cafe] Haddock Feature Proposal Message-ID: Hello, I was just thinking about how many devs put "TODO ...", "FIXME ...", or "HACK..." into comments. Do others think this could be nice optional information for Haddock to display? I think it could give people an idea for how mature, stable or clean an api is just by inspecting the above items when they are present. Thoughts? Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081004/f5d454a0/attachment.htm From g9ks157k at acme.softbase.org Sat Oct 4 17:47:52 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sat Oct 4 17:44:25 2008 Subject: [Haskell-cafe] outdated OpenSPARC webpage Message-ID: <200810042347.53091.g9ks157k@acme.softbase.org> Hello, the webpage under ist outdated. There is still the line saying that students can now apply. Who is responsible for this page? Wouldn?t it be better to move this page to the wiki so that keeping it up to date is easier? Best wishes, Wolfgang From allbery at ece.cmu.edu Sat Oct 4 17:51:50 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Oct 4 17:48:23 2008 Subject: [Haskell-cafe] Haddock Feature Proposal In-Reply-To: References: Message-ID: On 2008 Oct 4, at 17:41, Jason Dagit wrote: > I was just thinking about how many devs put "TODO ...", "FIXME ...", > or "HACK..." into comments. > > Do others think this could be nice optional information for Haddock > to display? I think it could give people an idea for how mature, > stable or clean an api is just by inspecting the above items when > they are present. There's also the trailing "XXX" comment, and I personally use 2 or more @s (the number indicating how bletcherous the tagged code is; you do not want to look at code tagged @@@@@@@@@@!). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081004/594da94b/attachment.htm From lemming at henning-thielemann.de Sat Oct 4 18:07:01 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Oct 4 18:04:23 2008 Subject: [Haskell-cafe] Hackage Build Failures In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3A64@ELON17P32001A.csfb.cs-group.com> References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> <48E36928.6090602@chalmers.se> <48E370D0.7040100@web.de> <33A3F585590A6F4E81E3D45AA4A111C902CD3A64@ELON17P32001A.csfb.cs-group.com> Message-ID: On Wed, 1 Oct 2008, Mitchell, Neil wrote: >>> The error comes from using QuickCheck 2, which happens to >> also use the >>> operator (><). I can see two ways to solve the problem: >>> >>> (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. >>> >>> (2) Add "hiding ((><))" after "import Test.QuickCheck" in >>> Data/Hardware/Internal.hs >> >> Emil, >> >> my suggestion is: Please use alternative (2), at least if >> there are no further problems with quickcheck 2! Otherwise, >> depending on quickcheck >> <2 just introduces unnecessary package incompatibilities. > > Note that if you import hiding something that doesn't existing you'll > have a problem. Therefore this fix will require >= 2 for quickcheck, and > introduce incompatibilities either way. That's why I like to import infix operators explicitly instead of hiding some identifiers: http://www.haskell.org/haskellwiki/Import_modules_properly From lemming at henning-thielemann.de Sat Oct 4 18:25:28 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Oct 4 18:21:58 2008 Subject: [Haskell-cafe] Restricted file reading monad In-Reply-To: <1222908981.16905.15.camel@porges-laptop> References: <1222908981.16905.15.camel@porges-laptop> Message-ID: On Thu, 2 Oct 2008, George Pollard wrote: > Hello all, > > I'm currently working on a (toy) ID3 [1] tag reader, which made me think > of a library which might be quite useful. > > The structure of an ID3 tag goes something like this: > > Header: > - total size of tag > - other header info > A series of frames, each with: > - total size of frame > - other header info > - frame data > > Since the ID3 tag as a whole has size information, I need to pass that > into the frame-reading functions to ensure that I never read past the > end of the total header. This exact same requirement is present within > the frame-reading function itself; it must read the frame data without > reading past the end of the frame. I've done exactly this for a MIDI file parser. It uses a State monad transformer which handles the number of remaining bytes in the chunk. http://darcs.haskell.org/midi/src/Sound/MIDI/Parser/Restricted.hs From ben.franksen at online.de Sat Oct 4 18:44:47 2008 From: ben.franksen at online.de (Ben Franksen) Date: Sat Oct 4 18:41:26 2008 Subject: [Haskell-cafe] Re: Hackage Build Failures References: <1ff5dedc0809301804n2b40a823p2e11ec4850b17126@mail.gmail.com> <48E36928.6090602@chalmers.se> <48E370D0.7040100@web.de> <48E37426.9060805@chalmers.se> Message-ID: Emil Axelsson wrote: > Stephan Friedrichs skrev: >> Emil Axelsson wrote: >>> [...] >>> >>> The error comes from using QuickCheck 2, which happens to also use the >>> operator (><). I can see two ways to solve the problem: >>> >>> (1) Add "< 2" after "QuickCheck" in the Wired.cabal file. >>> >>> (2) Add "hiding ((><))" after "import Test.QuickCheck" in >>> Data/Hardware/Internal.hs >> >> Emil, >> >> my suggestion is: Please use alternative (2), at least if there are no >> further problems with quickcheck 2! Otherwise, depending on quickcheck >> <2 just introduces unnecessary package incompatibilities. > > Hi Stephan, > > Option (1) was only meant as a temporary solution for Cetin. It just > occurred that the obvious solution to make both QC1 and QC2 users happy is > to have an explicit import list rather than hiding (><) (there are no > further problems with QC2). I'll do this until QC2 is standard in GHC. I stumbled over the same thing in a project of mine. I must say that I find it very unfortunate that QuickCheck-2 exports this operator, since it clashes with imports of Data.Sequence. Could the decision to use this operator in QuickCheck be revised (and similarly export of .&. which clashes with the one in Data.Bits)? I think these operators should have a 'standard' meaning. Cheers Ben From ben.franksen at online.de Sat Oct 4 19:01:27 2008 From: ben.franksen at online.de (Ben Franksen) Date: Sat Oct 4 18:58:11 2008 Subject: [Haskell-cafe] Re: Job Opportunity References: Message-ID: Michael Bott wrote: > I have been recommended to use this site from a couple of people I have > spoken to. Sorry if this offends anyone but I have an amazing > opportunity for a 2 Functional Programmers based in London. > > Functional Programming - (HASKELL / ERLANG / OCAML) - Financial > > This is an incredible opportunity for a FUNCTIONAL PROGRAMMER (Haskell / > Erlang or Ocaml) to join an expanding London software house who > specialise in Asset Management for top financial clients - they > specialise in providing algorithmic execution solutions for hedge funds. Even the most reliable and mathematically correct financial software cannot protect you if you feed it with overly optimistic assumptions... Sorry couldn't resist. Cheers Ben From wren at freegeek.org Sat Oct 4 19:49:22 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Oct 4 19:45:54 2008 Subject: [Haskell-cafe] Re: Total Functional Programming in Haskell In-Reply-To: <49a77b7a0810021120r4c7c78a6vadff50074ac7683e@mail.gmail.com> References: <48E40D6E.8040009@freegeek.org> <49a77b7a0810021120r4c7c78a6vadff50074ac7683e@mail.gmail.com> Message-ID: <48E80102.4040805@freegeek.org> David Menendez wrote: > On Wed, Oct 1, 2008 at 7:53 PM, wren ng thornton wrote: >> [1] Just like existential types, you can put something in but you can never >> get it back out again. For inescapable monads like IO and ST, this is why >> they have the behavior of sucking your whole program into the existential >> black-hole. > > That's true for IO, but the whole point of ST is that it *is* > escapable. What makes ST (and IO and STM) unusual is that it can't be > implemented in pure Haskell without special support from the run-time > system. I suppose it depends on definitions. Certainly you can runST it to get an end result out, but doing so looses the internal structure (STRefs) which cannot be reclaimed. To me this makes ST a world apart from State, [], Maybe, and other monads which you can freely escape and reenter. Perhaps it would've been better to say that ST is not, er, reentrant. -- Live well, ~wren From dons at galois.com Sat Oct 4 21:25:10 2008 From: dons at galois.com (Don Stewart) Date: Sat Oct 4 21:21:32 2008 Subject: [Haskell-cafe] Interesting new user perspective Message-ID: <20081005012510.GB2331@scytale.galois.com> http://sandersn.com/blog/index.php?title=two_weeks_of_haskell Has some good thoughts on what tripped him up in his first two weeks of Haskell programming. Anything people want to work on there? :-) Worth a read if you're thinking about how to make Haskell yet more accessible. -- Don From wren at freegeek.org Sat Oct 4 23:48:11 2008 From: wren at freegeek.org (wren ng thornton) Date: Sat Oct 4 23:44:49 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5256C.2000305@btinternet.com> References: <48E5025B.1040908@btinternet.com> <20081002180246.GA21590@rwbarton.mit.edu> <48E5256C.2000305@btinternet.com> Message-ID: <48E838FB.6050004@freegeek.org> Andrew Coppin wrote: > Wuh? What's Traversable? > > > In general, one way to make the composition of two > > monads m and n into a monad is to write a function n (m a) -> m (n a); > > this is the sequence method of a Traversable instance for n. > > Oh, *that's* Traversable? > > Mind you, looking at Data.Traversable, it demands instances for > something called "Foldable" first (plus Functor, which I already happen > to have). > > (Looking up Foldable immediately meantions something called "Monoid"... > I'm rapidly getting lost here.) It sounds like you've figured things out now, but just to chime in. The problem is that there are a number of different type classes that all tackle different perspectives on the same thing, or rather, slightly different things. These things ---Foldable, Traversable, Monoid, Functor, Applicative, Monad, MonadPlus, MonadLogic--- they each capture certain basic concepts that apply to the majority of "normal" data structures. In a very real sense, these patterns are the core of what category theory is about. And yet, if you were to try to draw out a venn diagram for them, you'd end up with something that looks more like a lotus[1] than an OO hierarchy. For each of these type classes, having one or two of them implies having many of the rest, regardless of which two you start with. And yet, they are all different and there are examples of reasonable data structures which lack one or more of these properties. This circularity makes it hard to figure out where to even begin. In category theory terminology, a monad is a monoid on the category of endo-functors. Similarly, list is the free monoid on any set. Even if you don't grok the terminology, seeing some of this circularity in definitions should give perspective on why there's such a tangled mess of type classes. Ultimately, each of these classes is trying to answer the question: what is a function? Often it's not helpful to discuss arbitrary functions, but thankfully most of the functions we're interested in are in fact very well behaved, and these classes capture the families of structure we find in those functions. Data structures too can be thought of as functions, and their mathematical structures are often just as well behaved. To start in the middle, every Monad is also an Applicative functor and every Applicative is also a Functor. The situation is actually more complicated than that since a monad can give rise to more than one functor (and I believe applicative functors do the same), but it's a good approximation to start with. If the backwards compatibility issues could be resolved, it'd be nice to clean up these three classes by making a type-class hierarchy out of them. (Doing a good job of it would be helped by some tweaks in how type classes are declared, IMO.) MonadPlus is for Monads which are also monoids. If you're familiar with semirings, you can think of (>>=) as conjunction and `mplus` as representing choice. As others've said, an important distinction is that MonadPlus universally quantifies over the 'elements' in the monad, whereas Monoid doesn't. This means that the monoidal behavior of MonadPlus is a property of the structure of the monad itself, rather than a property of the elements it contains or an interaction between the two. In a similar vein is MonadLogic which is a fancier name for lists or nondeterminism. Foldable and Traversable are more datastructure-oriented, though they can be for abstract types (i.e. functions). Foldable is for structures than can be consumed in an orderly fashion, and Traversable is for structures that can be reconstructed. A minimal definition for Traversable gives you a function |t (f a) -> f (t a)| that lets you distribute the structure over any functor. With that function alone, you can define instances for Foldable and Functor; conversely, with Foldable and Functor you can usually write such a function. In some cases, this is too stringent a requirement since you may be able to distribute particular pairs but not all of them. The category-extras library has mechanisms for dealing with this, similar to how Monoid lets one express special cases where the fully general MonadPlus cannot be defined. [1] http://z.about.com/d/healing/1/0/X/v/art_lotus_12009915A.jpg -- Live well, ~wren From chak at cse.unsw.edu.au Sun Oct 5 06:19:15 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Sun Oct 5 06:15:48 2008 Subject: [Haskell-cafe] Type family oddity In-Reply-To: <877i8omy2e.fsf@mid.deneb.enyo.de> References: <877i8omy2e.fsf@mid.deneb.enyo.de> Message-ID: <1FF4391B-4E6E-4295-BA29-D0EA22260401@cse.unsw.edu.au> Florian Weimer: > I can't figure out why the following code doesn't compile with the > October 2n GHC 6.10 beta (-XTypeFamilies -XFlexibleContexts) when the > type declaration is not commented out. It's a bug that the code is accepted *without* the signature, as the signature is ambiguous: http://hackage.haskell.org/trac/ghc/ticket/1897 This is not because the code fails to be type-safe, but because (a) you can't use the function erase_range anyway and (b) that it is accepted without a signature, but not with the signature leads to confusion, as you experienced. BTW, the method 'erase' in your code has the same problem. Manuel > > > module T where > > type family RangeTrait c > > class InputRange r where > remaining :: r -> Bool > advance :: r -> r > > class (InputRange (RangeTrait s)) => Sequence s where > erase :: RangeTrait s -> IO (RangeTrait s) > > -- erase_range :: (Sequence s) => RangeTrait s -> IO (RangeTrait s) > erase_range r = > if remaining r > then do > r' <- erase r > erase_range r' > else return r > > GHCi says the type is precisely as specified in the comment. However, > when I activate the type declaration, GHC complains: > > T.hs:16:22: > Couldn't match expected type `RangeTrait s' > against inferred type `RangeTrait s2' > In the first argument of `erase', namely `r' > In a stmt of a 'do' expression: r' <- erase r > In the expression: > do r' <- erase r > erase_range r' > > T.hs:17:22: > Couldn't match expected type `RangeTrait s1' > against inferred type `RangeTrait s2' > In the first argument of `erase_range', namely `r'' > In the expression: erase_range r' > In the expression: > do r' <- erase r > erase_range r' > > Any suggestions? Is this a bug in GHC? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From chak at cse.unsw.edu.au Sun Oct 5 06:30:07 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Sun Oct 5 06:26:43 2008 Subject: [Haskell-cafe] Type family oddity In-Reply-To: References: <877i8omy2e.fsf@mid.deneb.enyo.de> Message-ID: Claus Reinke wrote: > Btw, is there a list of common TF pitfalls somewhere? Some example > items so far seem to be: > > 1 'C a => TF a', where 'a' isn't determinable > 2 'TF a' is not fully polymorphic > 3 'TF a' is not a decomposable type constructor, it stands only > for itself, or for its result (in that way it is more like a defined > function application) > > For 1/2, it is helpful to flatten type family applications: > > - 'C a => TF a' becomes: '(C a,TF a~tfa) => tfa' > - 'TF a' becomes: 'TF a~tfa => tfa' > > For 3, it is helpful to imagine the arity of type families being > marked > by braces, to distinguish type family parameters from any > constructor parameters, in case the type family reduces to a type > constructor: > > - Given 'type family TF2 a :: * -> *', 'TF2 a b' becomes: '{TF2 > a} ~ tfa => tfa b' It should rather be a type-level programming FAQ: Re 1: Ambiguous signatures are a general problem. However, they are syntactically harder to recognise with TFs. Re 2: Applies to GADTs as well. Re 3: I have always been wondering whether we want special syntax for the application of synonym families. That would make it syntactically easier to recognise ambiguous signatures and indicarte syntactically were decomposition is admisible. BTW, part of the problem is that H98 is not entirely consistent with its use of upper and lower case identifiers. Strictly speaking, already vanilla type synonyms should have been lower case as they are a simple form of functions on types (you cannot use decomposition on them!) Then, synonym families could be lower-case, too. Manuel From fw at deneb.enyo.de Sun Oct 5 06:43:05 2008 From: fw at deneb.enyo.de (Florian Weimer) Date: Sun Oct 5 06:40:10 2008 Subject: [Haskell-cafe] Type family oddity In-Reply-To: (Claus Reinke's message of "Sat, 4 Oct 2008 12:31:41 +0100") References: <877i8omy2e.fsf@mid.deneb.enyo.de> Message-ID: <87skrbfhl2.fsf@mid.deneb.enyo.de> * Claus Reinke: >> -- erase_range :: (Sequence s) => RangeTrait s -> IO (RangeTrait s) > > This can't work, as you can see after desugaring: > >> -- erase_range :: (Sequence s,RangeTrait s~rs) => rs -> IO rs > > There is nowhere to get 's' from, unless you start applying type families > backwards, from results to parameters. Thanks. Indeed, this is a bug in my reading of the specification (and the original even had that Sequence argument). I was led astray by the fact that the type checker accepted the class declaration, even though there's no really good way to provide a concrete implementation. Another example I encountered is this: class Foo f where foo :: f -> g -- oops, typo It was very difficult for me to spot this one, too. 8-/ From iainspeed at gmail.com Sun Oct 5 07:54:24 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Sun Oct 5 07:51:08 2008 Subject: [Haskell-cafe] Re: Random question In-Reply-To: References: Message-ID: <6254718A-84C6-4DF5-A0C5-89DA179E1927@gmail.com> I just wanted to say thanks to everyone that helped me on this. I'm still reading/cogitating the stuff you gave me, but I did manage to write a Fisher-Yates shuffle using random numbers. I had a lightbulb moment while reading about sequence (so I suppose that might count as my 7th Monad tutorial :). The <- takes values out of monads[1]. So simple! -- let c = [11..18] --shuff (length c) c shuff :: Int -> [a] -> IO [a] shuff 0 xs = return xs shuff (len + 1) xs = (rand 1 (len + 1)) >>= \r -> shuff len $ requeue r xs where requeue = \z xs -> (init $ take z xs) ++ (drop z xs) ++ [last $ take z xs] rand :: Int -> Int -> IO Int rand low high = getStdRandom (randomR (low,high)) Since it's recursive I suspect there may be a way to do this with a fold, but I'll probably work that out at a later lightbulb moment (after more questions:) Thanks again. Iain [1] In a lot of IO tutorials it just seems to be the 'do' syntax for assigning a value to a symbol, but of course, :t getLine getLine :: IO String On 24 Sep 2008, at 10:03 pm, Iain Barnett wrote: > Hi, > > I have a function, that produces a random number between two given > numbers > > rand :: Int -> Int -> IO Int > rand low high = getStdRandom (randomR (low,high)) > > > (Naively) I'd like to write something like > > take (rand 1 10 ) [1..10] > > and see [1,2,3,4] ... or anything but nasty type-error messages. > > > > I'm reading about 6 tutorials on monads simultaneously but still > can't crack this simple task, and won't pain you with all the > permutations of code I've already tried. It's a lot, and it ain't > pretty. > > Would anyone be able to break away from C/C++ vs Haskell to help? > Just a point in the right direction or a good doc to read, anything > that helps will be much appreciated. > > > Regards > Iain From andrewcoppin at btinternet.com Sun Oct 5 08:54:08 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 5 08:50:30 2008 Subject: [Haskell-cafe] Haskell-cafe-cafe? Was: Re: Health effects In-Reply-To: References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> Message-ID: <48E8B8F0.4010209@btinternet.com> Christopher Lane Hinson wrote: > > What /is/ it with haskell-cafe lately? > > Do we need a haskell-blah mailing list? I would subscribe to that. > Hell, I would post to it probably more than I post to haskell-cafe. > But I'd also divert it to a separate mailbox for when I have too much > free time. > > Maybe call it haskell-cafe-cafe? not-haskell? I must admit, I have a bunch of abstract math questions I'd like answers to, and the people round here seem like the kind of folks who might know the answers. But this has nothing at all to do with Haskell, so Cafe doesn't seem like a good place to ask... From manlio_perillo at libero.it Sun Oct 5 10:48:55 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Oct 5 10:45:33 2008 Subject: [Haskell-cafe] monadic parser with Happy and Alex In-Reply-To: <1223152450.14163.450.camel@dell.linuxdev.us.dell.com> References: <48E7864F.60802@libero.it> <1223152450.14163.450.camel@dell.linuxdev.us.dell.com> Message-ID: <48E8D3D7.1090907@libero.it> Duncan Coutts ha scritto: > [...] >> Now I'm starting to write the parser with Happy, however for the final >> product I would like to: >> 1) Be able to do I/O in the lexer, for stylesheets inclusion >> (@import rule) >> 2) be able to keep state in the parser (or lexer?), for character >> transcoding (@charset rule) >> >> >> This should be possible with Happy (and there are some example), however >> I don't find examples that make use of a lexer written with Alex. > > See c2hs or Language.C it uses a monadic lexer. > Thanks. I'm also looking at HJS (unfortunately new versions use Parsec instead of Alex + Happy). > Duncan > Manlio From andrewcoppin at btinternet.com Sun Oct 5 12:32:29 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 5 12:28:52 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> Message-ID: <48E8EC1D.9060203@btinternet.com> David Menendez wrote: > So it might be possible to rewrite your code along these lines: > > type M = StateT State [] > > run :: Foo -> M () > > runOr :: Foo -> Foo -> M () > runOr x y = mplus (run x) (run y) > > runAnd :: Foo -> Foo -> M () > runAnd x y = run x >> run y > > The type "StateT State [] alpha" is isomorphic to "State -> [(alpha, > State)]", which means that each of the computations in mplus gets its > own copy of the state. > > There are a few ways to add exceptions to this, depending on how you > want the exceptions to interact with the non-determinism. > > 2. StateT State (NondetT (Either ErrorType)) alpha > I have some longwinded code that works, but I'm still thinking about how to do this more elegantly. It looks like what I really need is something like type M = StateT State (ResultSetT (ErrorT ErrorType Identity)) Is that the correct ordering? If so, I guess that means I have to somehow construct ResultSetT. Is there an easy way to do that, given that I already have ResultSet? For example, if I put ResultSet into Traversable, would that let me do it? From ivan.miljenovic at gmail.com Sun Oct 5 12:53:43 2008 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Sun Oct 5 12:50:14 2008 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 Message-ID: I've now uploaded my SourceGraph program to Hackage [1]. It's rather simple at the moment, but if you pass in the .cabal file as a parameter (e.g. run it as "SourceGraph Foo.cabal"), it will create in the same directory as the .cabal file a Directory called "SourceGraph" that contains an html report of some basic graph-theoretic analysis of your code. The output format isn't ideal, but it should serve it's purpose for now (I'll fix it up and actually make it usable once my Thesis has been handed in). What I'd appreciate if people could try it out and tell me if there's any code, etc. that it can't parse. At the moment, it ignores all Data-based functions (e.g. class and instance declarations as well as record functions) and only looks at "stand-alone" functions (i.e. normal functions). SourceGraph requires version 0.3 of my Graphalyze library (version 0.2 added the reports in, but had some bugs that 0.3 fixes). [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SourceGraph -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From lemming at henning-thielemann.de Sun Oct 5 13:50:17 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Oct 5 13:47:00 2008 Subject: [Haskell-cafe] Stacking monads In-Reply-To: <48E5025B.1040908@btinternet.com> References: <48E5025B.1040908@btinternet.com> Message-ID: On Thu, 2 Oct 2008, Andrew Coppin wrote: > Consider the following beautiful code: > > run :: State -> Foo -> ResultSet State > > run_and :: State -> Foo -> Foo -> ResultSet State > run_and s0 x y = do > s1 <- run s0 x > s2 <- run s1 y > return s2 > > run_or :: State -> Foo -> Foo -> ResultSet State > run_or s0 x y = merge (run s0 x) (run s0 y) > > That works great. Unfortunately, I made some alterations to the > functionallity the program has, and now it is actually possible for 'run' to > fail. When this happens, a problem should be reported to the user. (By "user" > I mean "the person running my compiled application".) After an insane amount > of time making my head hurt, I disocvered that the type "Either ErrorType > (ResultSet State)" is actually a monad. (Or rather, a monad within a monad.) > Unfortunately, this causes some pretty serious problems: > > run :: State -> Foo -> Either ErrorType (ResultSet State) You may also like to use: http://hackage.haskell.org/packages/archive/explicit-exception/0.0.1/doc/html/Control-Monad-Exception-Synchronous.html From lemming at henning-thielemann.de Sun Oct 5 14:06:03 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Oct 5 14:02:30 2008 Subject: [Haskell-cafe] Re: Random question In-Reply-To: <6254718A-84C6-4DF5-A0C5-89DA179E1927@gmail.com> References: <6254718A-84C6-4DF5-A0C5-89DA179E1927@gmail.com> Message-ID: On Sun, 5 Oct 2008, Iain Barnett wrote: > I just wanted to say thanks to everyone that helped me on this. I'm still > reading/cogitating the stuff you gave me, but I did manage to write a > Fisher-Yates shuffle using random numbers. I had a lightbulb moment while > reading about sequence (so I suppose that might count as my 7th Monad > tutorial :). The <- takes values out of monads[1]. So simple! > > -- let c = [11..18] --shuff (length c) c > shuff :: Int -> [a] -> IO [a] > shuff 0 xs = return xs > shuff (len + 1) xs = (rand 1 (len + 1)) >>= \r -> shuff len $ requeue r xs > where requeue = \z xs -> (init $ take z xs) ++ (drop z xs) ++ [last $ take z xs] Instead of separate calls to 'take' and 'drop' you may prefer 'splitAt': requeue z xs = let (prefix,pivot:suffix) = splitAt (z-1) xs in prefix ++ suffix ++ [pivot] However, accessing list elements by index is pretty inefficient (linear time with respect to index). Is it possible to re-arrange the algorithm? Maybe using more efficient data structures? From gwern0 at gmail.com Sun Oct 5 16:29:05 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Oct 5 16:38:54 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: Message-ID: <20081005202905.GA23306@craft> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081005/2484efb1/attachment-0001.bin From tphyahoo at gmail.com Sun Oct 5 16:44:49 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Oct 5 16:41:25 2008 Subject: [Haskell-cafe] Help me prove macid can scale! (Macid stress tests results for happs-tutorial toy job board disappointing so far.) Message-ID: <910ddf450810051344g1ba965dcpfc1945ce41d9075f@mail.gmail.com> From: tphyahoo Subject: Help me prove macid can scale! (Macid stress tests results for happs-tutorial toy job board disappointing so far.) To: HAppS HAppS is a new, relatively unproven technology. So I am asking myself this question. Will HAppS allow me to scale the toy job board I created for happs-tutorial into a high-volume, high concurrency, large-user count type job board? You know, the kind that might make money? I have done some preliminary testing to answer this question, and so far the results have been disappointing. I am hoping that I am doing something wrong, and that there is a way of using macid effectively for more than just toy applications. If there are solution for the problems I'm experiencing I will definitely be integrating this knowledge into the tutorial, so stay tuned. I am seeking feedback from HAppS experts and educated users on the following questions: * Is building a heavy duty website like monster.com in HAppS a realistic goal -- say, in the next twelve months? * Are there certain types of web apps that are unlikely to work well with the HAppS web architecture? * Are there changes I can make to my toy app's architecture -- be it data structures, buying new hardware, whatever -- that will enable me to get good performance against the stress test described below and in the demo? * Are there other HAppS stress tests in the public domain, and what are the results so far? A complete description of the stress test I did (basically, insert 200 users with 200 jobs apiece) along with a runnable demo, is in the tutorial preview at http://happstutorial.com:5002/tutorial/macid-stress-test. (The actual stress test is disabled in the online demo because I don't want to zap my server.) But the summary is, it's slow, slow to start, and creates a huge events file -- 356M. For around 40000 records. That's like, 8 megabytes per job, which is a few lines of text. OK, happs isn't a database -- but still. This is all is checked into darcs and tagged: darcs get --tag='stress test'http://code.haskell.org/happs-tutorial Thanks in advance for helping make happs usable in the real world! thomas. From simon.clarkstone at gmail.com Sun Oct 5 18:22:03 2008 From: simon.clarkstone at gmail.com (Simon Richard Clarkstone) Date: Sun Oct 5 18:18:36 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <48E93E0B.1060801@gmail.com> John Van Enk wrote: > "You shoot the gun, but the bullet gets trapped in the IO monad." The community points you at the paper "Bang-bang-patterns: expressing lethal weaponry in the Haskell typesystem". Your head explodes. BTW, these could go on the wiki. -- src/ -XIncomprehensibleTypes Equivalent to all of: -fallow-inconvinient-types, -XOmnipotentInstances, -XFunkyFunctors, -XSuperTuringTypes, -XErraticTypeClasses, -XCoAntiRetroHyperArrows From jason.dusek at gmail.com Sun Oct 5 18:57:00 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Oct 5 18:53:28 2008 Subject: [Haskell-cafe] Help me prove macid can scale! (Macid stress tests results for happs-tutorial toy job board disappointing so far.) In-Reply-To: <910ddf450810051344g1ba965dcpfc1945ce41d9075f@mail.gmail.com> References: <910ddf450810051344g1ba965dcpfc1945ce41d9075f@mail.gmail.com> Message-ID: <42784f260810051557p53021c0ft4e50192a5bfa459a@mail.gmail.com> I don't want to be contrarian, but I guess I can't help myself. Does MACID have anything to say about failover and replication? Isn't that more important than volume? -- _jsn From colin.mailinglist at gmail.com Sun Oct 5 19:55:48 2008 From: colin.mailinglist at gmail.com (Colin Fleming) Date: Sun Oct 5 19:52:17 2008 Subject: [Haskell-cafe] Linux binary dist problems Message-ID: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> Hi all, I just joined this list, I'm interested in learning Haskell to complement my day job language (Java). I was interested in trying to make a simple website using Haskell in order to have something to practise on, however in my host's shared environment I can't use the Linux binary packages - I get the same errors that a few people were talking about in September - firstly the "cannot determine current directory", and then after hacking the configure script the "[install] Error 136". It seems that this is probably an old libc, but this is an environment that I have almost no control over so I can't fix that. Are there any building from source options if I don't already have GHC? It looks from the porting guide that I might be able to make 6.6.2 with just a C compiler, can I then use that to build 6.8.3? Thanks for any help. As a few people have commented, it would be great to make all this easier, as it's a pretty big stumbling block to starting with Haskell, and people are likely to get discouraged pretty quickly. Cheers, Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081005/81f1c42a/attachment.htm From chris at cmears.id.au Sun Oct 5 20:16:25 2008 From: chris at cmears.id.au (Chris Mears) Date: Sun Oct 5 20:13:03 2008 Subject: [Haskell-cafe] Linux binary dist problems In-Reply-To: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> (Colin Fleming's message of "Sun, 5 Oct 2008 19:55:48 -0400") References: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> Message-ID: <8763o6d1d2.fsf@loki.cmears.id.au> "Colin Fleming" writes: > It looks from the porting guide that I might be able to make 6.6.2 > with just a C compiler, can I then use that to build 6.8.3? I have the same problem as you -- a hosting environment with an old libc -- and had the same problem with the binary distribution. I think you can do what you have suggested, but I haven't tried. Instead I have decided to build a static binary on a local computer and then put that binary onto the host; maybe this is a solution for you too. From jupdike at gmail.com Sun Oct 5 20:26:12 2008 From: jupdike at gmail.com (Jared Updike) Date: Sun Oct 5 20:22:41 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug Message-ID: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> In order to create an arbitrary precision floating point / drop in replacement for Double, I'm trying to wrap MPFR (http://www.mpfr.org/) using the FFI but despite all my efforts the simplest bit of code doesn't work. It compiles, it runs, but it crashes mockingly after pretending to work for a while. A simple C version of the code happily prints the number "1" to (640 decimal places) a total of 10,000 times. The Haskell version, when asked to do the same, silently corrupts (?) the data after only 289 print outs of "1.0000...0000" and after 385 print outs, it causes an assertion failure and bombs. I'm at a loss for how to proceed in debugging this since it "should work". The code can be perused at http://hpaste.org/10923 (and attached) and downloaded at http://www.updike.org/mpfr-broken.tar.gz I'm using GHC 6.83 on FreeBSD 6 and GHC 6.8.2 on Mac OS X. Note you will need MPFR (tested with 2.3.2) installed with the correct paths (change the Makefile) for libs and header files (along with those from GMP) to successfully compile this. Why does the C version work, but the Haskell version flake out? What else am I missing when approaching the FFI? I tried StablePtrs and had the exact same results. Can someone else verify if this is a Mac/BSD only problem by compiling and running my code? (Does the C executable"works" work? Does the Haskell executable "noworks" not work?) Can anyone on Linux and Windows attempt to compile/run and see if you can get the same results? Jared. P.S. I actually have much more code, having wrapped dozens of functions from the MPFR library and created instances using unsafePerformIO and foreignPtrs and all that useful high level Haskell/pure stuff--- all of which basically works perfectly except that it doesn't work at all since it crashes mysteriously after pretending to work at first. I had to narrow it down to something simple and the "Print "1.00000..." 10,000 times" was the best I could do. If I can get that working, I will then move on to something like the factorial of 1000 (printing intermediate values), which also works in C, but not Haskell, and after that, maybe everything will "just work" and I can use/publish this library! ----------------- works.c #include #include #include #include #include #include "mpfr_ffi.c" int main() { int i; mpfr_ptr one; mpf_set_default_prec_decimal(640); one = mpf_set_signed_int(1); for (i = 0; i < 10000; i++) { printf("%d\n", i); mpf_show(one); } } ---------------- Main.hs --- Doesn't work! module Main where import Foreign.Ptr ( Ptr, FunPtr ) import Foreign.C.Types ( CInt, CLong, CULong, CDouble ) import Foreign.StablePtr ( StablePtr ) data MPFR = MPFR foreign import ccall "mpf_set_default_prec_decimal" c_set_default_prec_decimal :: CInt -> IO () setPrecisionDecimal :: Integer -> IO () setPrecisionDecimal decimal_digits = do c_set_default_prec_decimal (fromInteger decimal_digits) foreign import ccall "mpf_show" c_show :: Ptr MPFR -> IO () foreign import ccall "mpf_set_signed_int" c_set_signed_int :: CLong -> IO (Ptr MPFR) showNums k n = do print n c_show k main = do setPrecisionDecimal 640 one <- c_set_signed_int (fromInteger 1) mapM_ (showNums one) [1..10000] -------------- mpfr_ffi.c // a little bit of wrapper code... this may be where the problem is // but since the (working) C code uses this and has no problems, I don't // understand why the Haskell code appears to be corrupting the limbs (the mantissa) #include #include #include #include #include void mpf_show(mpfr_ptr x) { mpfr_out_str(stdout, 10, 0, x, GMP_RNDN); printf("\n"); } #define LOG2_10 3.3219280948873626 #define IEEE_BITS 53 void mpf_set_default_prec_decimal(int dec_digits) { double bits = LOG2_10 * dec_digits; int ibits = (int)bits; double ddec; int dec; //printf("DEC_DIGITS = %d\n", dec_digits); //printf("IBITS = %d\n", ibits); ddec = ibits / LOG2_10; dec = (int)ddec; //printf("DEC = %d\n", dec); while (dec < dec_digits) { ibits++; //printf("IBITS = %d\n", ibits); ddec = ibits / LOG2_10; dec = (int)ddec; //printf("DEC = %d\n", dec); } mpfr_set_default_prec(ibits); } mpfr_ptr mpf_new_mpfr() { return (mpfr_ptr)malloc(sizeof(__mpfr_struct)); } mpfr_ptr mpf_set_signed_int(int x) { mpfr_ptr result = mpf_new_mpfr(); if (result == NULL) return NULL; mpfr_init_set_si(result, x, GMP_RNDN); return result; } --------------- Makefile CC = gcc HC = ghc INCLUDE = -I/home/private/local/include -I/usr/local/include -I/opt/local/include LIBS = -L/opt/local/lib -L/usr/local/lib all: works noworks works: mpfr_ffi.o works.o $(CC) -o works works.o -lgmp -lmpfr $(INCLUDE) $(LIBS) works.o: works.c $(CC) -c works.c $(INCLUDE) mpfr_ffi.o: mpfr_ffi.c $(CC) -c mpfr_ffi.c $(INCLUDE) noworks: Main.hs mpfr_ffi.o $(HC) mpfr_ffi.o -fffi -lgmp -lmpfr $(LIBS) $(INCLUDE) --make Main -o noworks clean: rm *.o *.hi works noworks From chris at cmears.id.au Sun Oct 5 20:38:37 2008 From: chris at cmears.id.au (Chris Mears) Date: Sun Oct 5 20:35:39 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> (Jared Updike's message of "Sun, 5 Oct 2008 17:26:12 -0700") References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> Message-ID: <871vyud0c2.fsf@loki.cmears.id.au> "Jared Updike" writes: > Can someone else verify if this is a Mac/BSD only problem by compiling > and running my code? (Does the C executable"works" work? Does the > Haskell executable "noworks" not work?) Can anyone on Linux and > Windows attempt to compile/run and see if you can get the same > results? I can't help you fix the problem, but can confirm that it behaves as you describe on my Linux system. The program "works" produces correct output, but noworks gives: ================================================== [...] 290 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 291 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 292 [...] 384 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 385 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892281684860507747503219323326708248193093246881500522519352192987169395899758472958160241015525770811984166890239749344848735134541218 386 ../get_str.c:149: assertion failed: size_s1 >= m Aborted ================================================== All the values from 291-384 are the same, but 385 is slightly different. From alexander.dunlap at gmail.com Sun Oct 5 20:50:45 2008 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Oct 5 20:47:12 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <871vyud0c2.fsf@loki.cmears.id.au> References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> <871vyud0c2.fsf@loki.cmears.id.au> Message-ID: <57526e770810051750v316fa05ar50689a2fd4eea0f4@mail.gmail.com> On Sun, Oct 5, 2008 at 5:38 PM, Chris Mears wrote: > "Jared Updike" writes: > >> Can someone else verify if this is a Mac/BSD only problem by compiling >> and running my code? (Does the C executable"works" work? Does the >> Haskell executable "noworks" not work?) Can anyone on Linux and >> Windows attempt to compile/run and see if you can get the same >> results? > > I can't help you fix the problem, but can confirm that it behaves as you > describe on my Linux system. The program "works" produces correct > output, but noworks gives: > > ================================================== > [...] > 290 > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > 291 > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 > 292 > [...] > 384 > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 > 385 > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892281684860507747503219323326708248193093246881500522519352192987169395899758472958160241015525770811984166890239749344848735134541218 > 386 > ../get_str.c:149: assertion failed: size_s1 >= m > Aborted > ================================================== > > All the values from 291-384 are the same, but 385 is slightly different. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > My results (from Linux i686) are slightly different. I am getting [...] 287 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 288 get_str.c:149: assertion failed: size_s1 >= m Aborted i.e. I never get the random numbers; they are all zeroes but it aborts after 287 successful repetitions. Changing the default heap size (with +RTS -H) changes how far it runs (running with -H32M let it go past 8000 repetitions), so this might be a garbage-collection issue. Hope that is some help to you. Alex From jupdike at gmail.com Sun Oct 5 21:01:12 2008 From: jupdike at gmail.com (Jared Updike) Date: Sun Oct 5 20:57:40 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <57526e770810051750v316fa05ar50689a2fd4eea0f4@mail.gmail.com> References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> <871vyud0c2.fsf@loki.cmears.id.au> <57526e770810051750v316fa05ar50689a2fd4eea0f4@mail.gmail.com> Message-ID: <8b108f950810051801v22ba78feldb67a41112402ad5@mail.gmail.com> Thanks for trying out my code. I'm glad it's not particular to my system. I suspected it had to do with the GHC RTS monkeying around with the heap (lower precisions print more iterations and maybe aren't moving through the heap as fast?) but I think when I added a statement to print out the hex address for each Ptr MPFR that those pointers (to 'one') in particular weren't getting moved. Likely the stuff living in the heap, pointed at in the MPFR struct, specifically the pointer to the limbs (the mantissa or actual digits of the number) are getting kludged.. I don't really understand why this is the case when I don't think I'm allocating a lot of the heap or anything, just printing the same number over and over... Is there a space leak somewhere? (I can also verify that mpf_new_mpfr is only getting called once per program run by appending to a file each time it gets called). How do I tell GHC "leave this mess and anything in the C heap completely alone?" Jared. On 10/5/08, Alexander Dunlap wrote: > On Sun, Oct 5, 2008 at 5:38 PM, Chris Mears wrote: > > "Jared Updike" writes: > > > >> Can someone else verify if this is a Mac/BSD only problem by compiling > >> and running my code? (Does the C executable"works" work? Does the > >> Haskell executable "noworks" not work?) Can anyone on Linux and > >> Windows attempt to compile/run and see if you can get the same > >> results? > > > > I can't help you fix the problem, but can confirm that it behaves as you > > describe on my Linux system. The program "works" produces correct > > output, but noworks gives: > > > > ================================================== > > [...] > > 290 > > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > > 291 > > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 > > 292 > > [...] > > 384 > > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892325510831739618679352919703855747262870175016933079782350322237289103929997053812694251557912158924211585973481445271933347978517620 > > 385 > > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000315821571076304370386829039486164636536120569099678825575157477354990710405658927062619547595122867857873765133026050519075772712996650488675128428778696175272153632855303857710094714398932056909218681833163883482512398576534211955878126971368731378321605715030861892281684860507747503219323326708248193093246881500522519352192987169395899758472958160241015525770811984166890239749344848735134541218 > > 386 > > ../get_str.c:149: assertion failed: size_s1 >= m > > Aborted > > ================================================== > > > > All the values from 291-384 are the same, but 385 is slightly different. > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > My results (from Linux i686) are slightly different. I am getting > > [...] > 287 > 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > 288 > > get_str.c:149: assertion failed: size_s1 >= m > Aborted > > > i.e. I never get the random numbers; they are all zeroes but it aborts > after 287 successful repetitions. > > Changing the default heap size (with +RTS -H) changes how far it > runs (running with -H32M let it go past 8000 repetitions), so this > might be a garbage-collection issue. > > Hope that is some help to you. > > Alex > From ilmari.heikkinen at gmail.com Sun Oct 5 21:48:01 2008 From: ilmari.heikkinen at gmail.com (Ilmari Heikkinen) Date: Sun Oct 5 21:44:29 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: Message-ID: <854c25eb0810051848q502deb12s13ffddcfb6b922f7@mail.gmail.com> On 10/1/08, John Van Enk wrote: > There's the well known "How to shoot your self in the foot" list which I > have it printed and taped on my desk at work. > > http://www-users.cs.york.ac.uk/susan/joke/foot.htm > > I had a co-worker ask me how you'd shoot your self in the foot with > Haskell. You aim the gun at your foot, pull the trigger and remove the clip. When you look at your undamaged foot, the hammer clicks on an empty barrel. From vanenkj at gmail.com Sun Oct 5 23:21:32 2008 From: vanenkj at gmail.com (John Van Enk) Date: Sun Oct 5 23:17:59 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <48E93E0B.1060801@gmail.com> References: <48E93E0B.1060801@gmail.com> Message-ID: I'll see about putting them there. :) On Sun, Oct 5, 2008 at 6:22 PM, Simon Richard Clarkstone < simon.clarkstone@gmail.com> wrote: > > BTW, these could go on the wiki. > > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081005/70eab011/attachment.htm From vanenkj at gmail.com Sun Oct 5 23:38:50 2008 From: vanenkj at gmail.com (John Van Enk) Date: Sun Oct 5 23:35:18 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: <48E93E0B.1060801@gmail.com> Message-ID: http://haskell.org/haskellwiki/Shooting_your_self_in_the_foot This needs to be cleaned up a little (lots of dups, though they are all great). On Sun, Oct 5, 2008 at 11:21 PM, John Van Enk wrote: > I'll see about putting them there. :) > > On Sun, Oct 5, 2008 at 6:22 PM, Simon Richard Clarkstone < > simon.clarkstone@gmail.com> wrote: > >> >> BTW, these could go on the wiki. >> >> > > -- > /jve > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081005/cad3229a/attachment.htm From duncan.coutts at worc.ox.ac.uk Sun Oct 5 22:16:21 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Oct 5 23:41:53 2008 Subject: [Haskell-cafe] Help me prove macid can scale! (Macid stress tests results for happs-tutorial toy job board disappointing so far.) In-Reply-To: <42784f260810051557p53021c0ft4e50192a5bfa459a@mail.gmail.com> References: <910ddf450810051344g1ba965dcpfc1945ce41d9075f@mail.gmail.com> <42784f260810051557p53021c0ft4e50192a5bfa459a@mail.gmail.com> Message-ID: <1223259381.14163.511.camel@dell.linuxdev.us.dell.com> On Sun, 2008-10-05 at 15:57 -0700, Jason Dusek wrote: > I don't want to be contrarian, but I guess I can't help > myself. Does MACID have anything to say about failover and > replication? Isn't that more important than volume? HAppS does failover and replication within a cluster. They're working on sharding, but that's a good deal harder. Duncan From judah.jacobson at gmail.com Sun Oct 5 23:45:35 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Sun Oct 5 23:42:04 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <8b108f950810051801v22ba78feldb67a41112402ad5@mail.gmail.com> References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> <871vyud0c2.fsf@loki.cmears.id.au> <57526e770810051750v316fa05ar50689a2fd4eea0f4@mail.gmail.com> <8b108f950810051801v22ba78feldb67a41112402ad5@mail.gmail.com> Message-ID: <6d74b0d20810052045i6cd6d7di5ea4c0404cc73140@mail.gmail.com> On Sun, Oct 5, 2008 at 6:01 PM, Jared Updike wrote: > Thanks for trying out my code. I'm glad it's not particular to my system. > > I suspected it had to do with the GHC RTS monkeying around with the > heap (lower precisions print more iterations and maybe aren't moving > through the heap as fast?) but I think when I added a statement to > print out the hex address for each Ptr MPFR that those pointers (to > 'one') in particular weren't getting moved. Likely the stuff living in > the heap, pointed at in the MPFR struct, specifically the pointer to > the limbs (the mantissa or actual digits of the number) are getting > kludged.. I don't really understand why this is the case when I don't > think I'm allocating a lot of the heap or anything, just printing the > same number over and over... Is there a space leak somewhere? (I can > also verify that mpf_new_mpfr is only getting called once per program > run by appending to a file each time it gets called). How do I tell > GHC "leave this mess and anything in the C heap completely alone?" > Usually, you can expect GHC to leave the C heap alone. The exception, unfortunately, is GMP (which is used by MPFR). See the following ticket: http://hackage.haskell.org/trac/ghc/ticket/311 I'm guessing that's the cause of the corruption. The relevant note from that ticket: > It's a known problem that you can't use GMP via the FFI from > your Haskell code in GHC, or use a C library that internally > uses GMP. We should really use a private version of GMP > with function names that don't overlap, or better still > replace GMP altogether. The comment in that ticket from Benedict Huber details some possible workarounds. Best, -Judah From DekuDekuplex at Yahoo.com Mon Oct 6 00:48:20 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Oct 6 00:44:54 2008 Subject: [Haskell-cafe] Re: Haskell-cafe-cafe? Was: Re: Health effects References: <48E12FF9.7020301@btinternet.com> <48E133D0.8080702@btinternet.com> <48E674B9.8040501@cogito.org.uk> <48E67791.5000305@btinternet.com> <2EB339B5-EB73-4975-8468-8F0FF44247B4@ece.cmu.edu> <48E8B8F0.4010209@btinternet.com> Message-ID: <9v5je4173npbst29p8mcbd97ljjsarfttl@4ax.com> On Sun, 05 Oct 2008 13:54:08 +0100, Andrew Coppin wrote: >Christopher Lane Hinson wrote: >> >> What /is/ it with haskell-cafe lately? >> >> Do we need a haskell-blah mailing list? I would subscribe to that. >> Hell, I would post to it probably more than I post to haskell-cafe. >> But I'd also divert it to a separate mailbox for when I have too much >> free time. >> >> Maybe call it haskell-cafe-cafe? not-haskell? > >I must admit, I have a bunch of abstract math questions I'd like answers >to, and the people round here seem like the kind of folks who might know >the answers. But this has nothing at all to do with Haskell, so Cafe >doesn't seem like a good place to ask... In that case, how about creating a Haskell-Lounge mailing list, exclusively for topics tangential to Haskell? Either that, or just ensure that most off-topic/tangential topics are prefixed "[OT]?" -- Benjamin L. Russell From vigalchin at gmail.com Mon Oct 6 01:35:38 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Oct 6 01:32:07 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) Message-ID: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> Hello, I am reading some extant Haskell code that uses Posix signals.... I am confused by the motivation of the following ... type Signal= CInt nullSignal:: Signal internalAbort:: Signal sigABRT:: CInt realTimeAlarm:: Signal sigALRM:: CInt busError:: Signal sigBUS:: CInt OK .. "type" is really just a synomym and doesn't invoke type checking like "data" type declarations do .. so why don't we have all the "CInts" substituted by "Signal"? I.e. what did I miss? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/8a4cea9f/attachment.htm From dons at galois.com Mon Oct 6 01:37:01 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 01:33:18 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> Message-ID: <20081006053701.GB7973@scytale.galois.com> vigalchin: > Hello, > > I am reading some extant Haskell code that uses Posix signals.... I am > confused by the motivation of the following ... > > type [1]Signal = [2]CInt > [3]nullSignal :: [4]Signal > [5]internalAbort :: [6]Signal > [7]sigABRT :: [8]CInt > [9]realTimeAlarm :: [10]Signal > [11]sigALRM :: [12]CInt > [13]busError :: [14]Signal > [15]sigBUS :: [16]CInt > > OK .. "type" is really just a synomym and doesn't invoke type checking > like "data" type declarations do .. so why don't we have all the "CInts" > substituted by "Signal"? I.e. what did I miss? Looks like it should all be Signal, and probably should be using a newtype, to prevent funky tricks. The Posix layer is a bit crufty. -- Don From vigalchin at gmail.com Mon Oct 6 01:42:51 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Oct 6 01:39:19 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <20081006053701.GB7973@scytale.galois.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> Message-ID: <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> Thanks Don. Maybe both for me and others in order to take the fight to the Klingons and other Baddies, please explain the "typefulness" protection that "newtype" affords over the "Klingon " "type" ... In the code that I contributed to the library, I like to think that I used "newtype" appropriately but not perhaps with full understanding. Thanks, Vasili On Mon, Oct 6, 2008 at 12:37 AM, Don Stewart wrote: > vigalchin: > > Hello, > > > > I am reading some extant Haskell code that uses Posix signals.... I > am > > confused by the motivation of the following ... > > > > type [1]Signal = [2]CInt > > [3]nullSignal :: [4]Signal > > [5]internalAbort :: [6]Signal > > [7]sigABRT :: [8]CInt > > [9]realTimeAlarm :: [10]Signal > > [11]sigALRM :: [12]CInt > > [13]busError :: [14]Signal > > [15]sigBUS :: [16]CInt > > > > OK .. "type" is really just a synomym and doesn't invoke type checking > > like "data" type declarations do .. so why don't we have all the > "CInts" > > substituted by "Signal"? I.e. what did I miss? > > Looks like it should all be Signal, and probably should be using a > newtype, to prevent funky tricks. The Posix layer is a bit crufty. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/de2e9f55/attachment.htm From dons at galois.com Mon Oct 6 01:47:23 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 01:43:39 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> Message-ID: <20081006054723.GC7973@scytale.galois.com> Used wisely, newtype prevents accidentally constructing illegal values of Signal type, by treating them as CInts. You can restrict the valid values of the Signal type to be just those signals you define, not arbitrary bit patterns that fit in a CInt. vigalchin: > Thanks Don. Maybe both for me and others in order to take the fight to the > Klingons and other Baddies, please explain the "typefulness" protection > that "newtype" affords over the "Klingon " "type" ... In the code that I > contributed to the library, I like to think that I used "newtype" > appropriately but not perhaps with full understanding. > > Thanks, Vasili > > On Mon, Oct 6, 2008 at 12:37 AM, Don Stewart <[1]dons@galois.com> wrote: > > vigalchin: > > Hello, > > > > I am reading some extant Haskell code that uses Posix > signals.... I am > > confused by the motivation of the following ... > > > > type [1]Signal = [2]CInt > > [3]nullSignal :: [4]Signal > > [5]internalAbort :: [6]Signal > > [7]sigABRT :: [8]CInt > > [9]realTimeAlarm :: [10]Signal > > [11]sigALRM :: [12]CInt > > [13]busError :: [14]Signal > > [15]sigBUS :: [16]CInt > > > > OK .. "type" is really just a synomym and doesn't invoke type > checking > > like "data" type declarations do .. so why don't we have all the > "CInts" > > substituted by "Signal"? I.e. what did I miss? > > Looks like it should all be Signal, and probably should be using a > newtype, to prevent funky tricks. The Posix layer is a bit crufty. > -- Don > > References > > Visible links > 1. mailto:dons@galois.com From vigalchin at gmail.com Mon Oct 6 02:04:23 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Oct 6 02:00:49 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <20081006054723.GC7973@scytale.galois.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> Message-ID: <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> ok ... by using "newtype", we are constricting/constraining to a subset of CInt .. e.g. something like a "subtype" of CInt?? (where by "subtype", I mean like the notion of subtype in languages like Ada). For our audience, can you perhaps distinguish (in a typeful way) between the Haskell notion of "type", "newtype" and "data"? Or maybe let's distinguish between these notions not only in a typeful manner, but also in a historical motivation? .. ... motivations are always IMO very, very enlightening! Regards, vasili On Mon, Oct 6, 2008 at 12:47 AM, Don Stewart wrote: > Used wisely, newtype prevents accidentally constructing illegal values > of Signal type, by treating them as CInts. You can restrict the valid > values of the Signal type to be just those signals you define, not > arbitrary bit patterns that fit in a CInt. > > vigalchin: > > Thanks Don. Maybe both for me and others in order to take the fight to > the > > Klingons and other Baddies, please explain the "typefulness" > protection > > that "newtype" affords over the "Klingon " "type" ... In the code > that I > > contributed to the library, I like to think that I used "newtype" > > appropriately but not perhaps with full understanding. > > > > Thanks, Vasili > > > > On Mon, Oct 6, 2008 at 12:37 AM, Don Stewart <[1]dons@galois.com> > wrote: > > > > vigalchin: > > > Hello, > > > > > > I am reading some extant Haskell code that uses Posix > > signals.... I am > > > confused by the motivation of the following ... > > > > > > type [1]Signal = [2]CInt > > > [3]nullSignal :: [4]Signal > > > [5]internalAbort :: [6]Signal > > > [7]sigABRT :: [8]CInt > > > [9]realTimeAlarm :: [10]Signal > > > [11]sigALRM :: [12]CInt > > > [13]busError :: [14]Signal > > > [15]sigBUS :: [16]CInt > > > > > > OK .. "type" is really just a synomym and doesn't invoke type > > checking > > > like "data" type declarations do .. so why don't we have all > the > > "CInts" > > > substituted by "Signal"? I.e. what did I miss? > > > > Looks like it should all be Signal, and probably should be using a > > newtype, to prevent funky tricks. The Posix layer is a bit crufty. > > -- Don > > > > References > > > > Visible links > > 1. mailto:dons@galois.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/d5a78f55/attachment.htm From johan.tibell at gmail.com Mon Oct 6 03:04:16 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Oct 6 03:00:43 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> Message-ID: <90889fe70810060004p7b21c29fxceecd3b4dd116378@mail.gmail.com> 2008/10/6 Galchin, Vasili : > ok ... by using "newtype", we are constricting/constraining to a subset of > CInt .. e.g. something like a "subtype" of CInt?? (where by "subtype", I > mean like the notion of subtype in languages like Ada). For our audience, > can you perhaps distinguish (in a typeful way) between the Haskell notion of > "type", "newtype" and "data"? Or maybe let's distinguish between these > notions not only in a typeful manner, but also in a historical motivation? > .. ... motivations are always IMO very, very enlightening! Here's an example of using newtypes: module Main where newtype Flag = Flag Int -- These are the only legal values: flag1 :: Flag flag1 = Flag 1 flag2 :: Flag flag2 = Flag 2 fun :: Int -> Flag -> Int fun n (Flag f) = undefined -- Implementation goes here. -- Using `fun`. main = do print (fun 10 flag1) -- Oh noes, the programmer messed up and reordered the -- arguments! print (fun flag1 10) Saved by the type checker: /home/tibell/Test.hs:21:13: Couldn't match expected type `Int' against inferred type `Flag' In the first argument of `fun', namely `flag1' In the first argument of `print', namely `(fun flag1 10)' In the expression: print (fun flag1 10) Failed, modules loaded: none. By creating a module that doesn't export the constructor used to create e.g. `Flag` and only the constants `flag1` and `flag2` we can make sure that no one ever calls `fun` with an illegal value. I hope this helps. Cheers, Johan From dagit at codersbase.com Mon Oct 6 03:10:41 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 03:07:06 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> Message-ID: 2008/10/5 Galchin, Vasili > ok ... by using "newtype", we are constricting/constraining to a subset of > CInt .. e.g. something like a "subtype" of CInt?? (where by "subtype", I > mean like the notion of subtype in languages like Ada). For our audience, > can you perhaps distinguish (in a typeful way) between the Haskell notion of > "type", "newtype" and "data"? Or maybe let's distinguish between these > notions not only in a typeful manner, but also in a historical motivation? > .. ... motivations are always IMO very, very enlightening! > If you like historical perspective check out this: http://research.microsoft.com/~simonpj/papers/history-of-haskell/index.htm type is similar to typedef in C. That is, it's more or less just for renaming. I say "more or less" because I'm not sure exactly how the "renaming" works in the presence of rank-2 and higher types. data is essentially for declaring new data structures. As a result of this it also defines a new type. newtype is for reusing existing types or data structures but with a new distinct type. data and newtype vary in one more subtle way, and that's how/when they evaluate to bottom. Most of the time they behave identically, but in the right cases they act sightly differently. newtype is usually regarded as more efficient than data. This is because the compiler can choose to optimize away the newtype so that it only exists at type check time. I think this is also possible with data in some, but not all, uses. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/3ec7357b/attachment.htm From dons at galois.com Mon Oct 6 03:12:20 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 03:08:43 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> Message-ID: <20081006071220.GE7973@scytale.galois.com> dagit: > data and newtype vary in one more subtle way, and that's how/when they > evaluate to bottom. Most of the time they behave identically, but in the > right cases they act sightly differently. newtype is usually regarded as > more efficient than data. This is because the compiler can choose to > optimize away the newtype so that it only exists at type check time. I > think this is also possible with data in some, but not all, uses. The compiler *must* optimise away the use. They're sort of 'virtual' data, guaranteed to have no runtime cost. -- Don From neil.mitchell.2 at credit-suisse.com Mon Oct 6 04:13:38 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Mon Oct 6 04:10:33 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <48E65FD8.2030504@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> Hi > Try doing a Hoogle search for "c1 (c2 x) -> c2 (c1 x)". > Hoogle correctly states that Data.Traversable.sequence will > do it for you. > > Now try doing "c1 k (c2 x) -> c2 (c1 k x)". The 'sequence' > function will also do this, but now Hoogle returns 0 results. > > This is puzzling, since AFAIK, the above two type signatures > are "equvilent" in some sense. (Specifically, replace every > type X with type Y and you get from one to the other.) To me, > this looks like a Hoogle bug. (It goes without saying that > Hoogle also failed to find anything for the more specific > type signature I was searching for, despite the fact that > 'sequence' unifies with it.) Hoogle is not a "unification engine" - since that is very rarely what people want out of a type search engine. What it is is an approximate matcher. Let's compare the two types: Your search :: c1 k (c2 x) -> c2 (c1 k x) sequence :: Monad m => [m a] -> m [a] Are you expecting c1 (:: * -> * -> *) to unify with [] (:: * -> *)? That seems kind incorrect at the very last. Additionally, those types don't look all that close. But, let's briefly consider unification (and why Hoogle doesn't used it). Consider the search: Eq a => [(a,b)] -> a -> b What the user wants is lookup, which sadly doesn't unify. However, undefined unifies perfectly. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From magnus at therning.org Mon Oct 6 05:25:00 2008 From: magnus at therning.org (Magnus Therning) Date: Mon Oct 6 05:21:28 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: <20081005202905.GA23306@craft> References: <20081005202905.GA23306@craft> Message-ID: Ivan, I tried building your tool today and found a few packaging related things: * the dependency on haskell-src-exts says any version should do, but the one shipped in Debian Sid (http://packages.debian.org/sid/libghc6-src-exts-dev) doesn't do, so some extra versioning info seems to be required * I had to add an import of Distribution.Configuration to Main.hs to get it to compile (it failed on the use of condTreeData). /M 2008/10/5 Gwern Branwen : > On 2008.10.06 02:53:43 +1000, Ivan Miljenovic scribbled 1.1K characters: >> I've now uploaded my SourceGraph program to Hackage [1]. It's rather >> simple at the moment, but if you pass in the .cabal file as a >> parameter (e.g. run it as "SourceGraph Foo.cabal"), it will create in >> the same directory as the .cabal file a Directory called "SourceGraph" >> that contains an html report of some basic graph-theoretic analysis of >> your code. >> >> The output format isn't ideal, but it should serve it's purpose for >> now (I'll fix it up and actually make it usable once my Thesis has >> been handed in). What I'd appreciate if people could try it out and >> tell me if there's any code, etc. that it can't parse. At the moment, >> it ignores all Data-based functions (e.g. class and instance >> declarations as well as record functions) and only looks at >> "stand-alone" functions (i.e. normal functions). >> >> SourceGraph requires version 0.3 of my Graphalyze library (version 0.2 >> added the reports in, but had some bugs that 0.3 fixes). >> >> [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SourceGraph >> >> -- >> Ivan Lazar Miljenovic > > SourceGraph looks pretty interesting. I don't think the output is that bad, though. (If anyone is curious, attached is a tarball of what SourceGraph generates for XMonad.) > > But I do have one or two problems: > 1) Didn't mention that it uses some executable 'dot', which Graphviz provides. > 2) Fails on XMonadContrib? While SourceGraph on XMonad finished in 1 or 2 seconds, SourceGraph xmonad-contrib.cabal has been running at 99% CPU (only one CPU - I wonder if it could be parallelized) now for something over 3 hours. I know XMC is a bigger codebase than XM, but it's not thousands of times bigger! :) > > -- > gwern > Chicago ICE NSWG DSD 5926 RSA Chicago UFO MITM Lindows > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEAREKAAYFAkjpI5AACgkQvpDo5Pfl1oKt9ACdEpMMFe7tooMFQXZMNoXrHY8P > +kIAn1ctKk5aj9T8ThQwHIpHTQWiallf > =CNNW > -----END PGP SIGNATURE----- > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From ryani.spam at gmail.com Mon Oct 6 05:53:46 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Oct 6 05:50:14 2008 Subject: [Haskell-cafe] Simplifying a IsFunction type class using type equality constraints In-Reply-To: References: Message-ID: <2f9b2d30810060253w23b7c40ag6f075fdaa5c84f04@mail.gmail.com> On Sat, Oct 4, 2008 at 2:58 AM, Corey O'Connor wrote: > I recently had a need to use the IsFunction typeclass described by Oleg here: > http://okmij.org/ftp/Haskell/isFunction.lhs > > and am wondering if the use of the TypeCast class can be correctly > replaced by a type equality constraint. I noticed this as well; it seemed to work in my tests, although I haven't seen any proof that they are equivalent. The HList paper mentions that the behavior of TypeCast is directly related to type equality coercions in System F(C), GHC's core language. So it's not that surprising that it can be replaced with a type-equality constraint, which is a more direct way of introducing the same core-language code. If you want to know for sure, you can look at the output of ghc -ddump-simpl on each program. -- ryan From colin.mailinglist at gmail.com Mon Oct 6 06:02:05 2008 From: colin.mailinglist at gmail.com (Colin Fleming) Date: Mon Oct 6 05:58:31 2008 Subject: [Haskell-cafe] Linux binary dist problems In-Reply-To: <8763o6d1d2.fsf@loki.cmears.id.au> References: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> <8763o6d1d2.fsf@loki.cmears.id.au> Message-ID: <7c6512110810060302s6332c29dn349e9c05a68a4019@mail.gmail.com> Hi Chris, Unfortunately that's not easy for me, I don't know exactly what the config of the server is, and I use OSX at home. I could probably rig something up using VMWare but that's a lot of work just to install the compiler. Another option might be to create an unregisterised build, as detailed in the porting guide, then use that to bootstrap a proper build. See: http://hackage.haskell.org/trac/ghc/wiki/Building/Porting Cheers, Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/385979a4/attachment.htm From mik at konecny.aow.cz Mon Oct 6 06:52:42 2008 From: mik at konecny.aow.cz (Michal Konecny) Date: Mon Oct 6 06:49:18 2008 Subject: [Haskell-cafe] Re: MPFR / FFI - Nefarious (Simple?) bug Message-ID: <200810061152.47150.mik@konecny.aow.cz> Jared Updike wrote on 6 Oct 02:25: > In order to create an arbitrary precision floating point / drop in > replacement for Double, I'm trying to wrap MPFR > (http://www.mpfr.org/) Have you looked at: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmpfr Michal -- |o| Michal Konecny |o| http://www-users.aston.ac.uk/~konecnym/ |o| office: (+42) (0)121 204 3462 |o| PGP key http://www-users.aston.ac.uk/~konecnym/ki.aow -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/71b6e9b2/attachment.bin From dav.vire+haskell at gmail.com Mon Oct 6 07:02:07 2008 From: dav.vire+haskell at gmail.com (david48) Date: Mon Oct 6 06:58:40 2008 Subject: [Haskell-cafe] Re: Hmm, what license to use? In-Reply-To: <1223058789.4490.7.camel@localhost.localdomain> References: <20080929213933.GF23645@scytale.galois.com> <1222768909.3078.1276703761@webmail.messagingengine.com> <22f6a8f70809301931q65cd9b2fkdb11baa539ee5aff@mail.gmail.com> <20081001182729.GD456@scytale.galois.com> <87od24dtg9.fsf@gaura-nitai.no-ip.org> <1223058789.4490.7.camel@localhost.localdomain> Message-ID: <4c88418c0810060402s46b9792dlfa96dd1ffbf2f532@mail.gmail.com> There's an article on slashdot about a developper that has a dilemna with his BSD-licenced work, I thought that might be relevant to this thread : http://ask.slashdot.org/article.pl?sid=08/10/05/1317252 From tphyahoo at gmail.com Mon Oct 6 07:20:17 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Oct 6 07:16:44 2008 Subject: [Haskell-cafe] Help me prove macid can scale! (Macid stress tests results for happs-tutorial toy job board disappointing so far.) In-Reply-To: <1223259381.14163.511.camel@dell.linuxdev.us.dell.com> References: <910ddf450810051344g1ba965dcpfc1945ce41d9075f@mail.gmail.com> <42784f260810051557p53021c0ft4e50192a5bfa459a@mail.gmail.com> <1223259381.14163.511.camel@dell.linuxdev.us.dell.com> Message-ID: <910ddf450810060420s5ca6538bmae5fcdac39c9522d@mail.gmail.com> There's a thread at happs group about this with good answers http://groups.google.com/group/HAppS/browse_thread/thread/1031809dca26f349 My top post should probably have been a cc, apologies. Looks pretty likely that the issues are solvable. Grokking the answers now. thomas. 2008/10/6 Duncan Coutts : > On Sun, 2008-10-05 at 15:57 -0700, Jason Dusek wrote: >> I don't want to be contrarian, but I guess I can't help >> myself. Does MACID have anything to say about failover and >> replication? Isn't that more important than volume? > > HAppS does failover and replication within a cluster. They're working on > sharding, but that's a good deal harder. > > Duncan > > From niklas.broberg at gmail.com Mon Oct 6 08:19:15 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Mon Oct 6 08:15:41 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: > * the dependency on haskell-src-exts says any version should do, but > the one shipped in Debian Sid > (http://packages.debian.org/sid/libghc6-src-exts-dev) doesn't do, so > some extra versioning info seems to be required Ouch, that one's pretty old. Don't the wheels of debian packaging spin faster than that? But yeah, it should be haskell-src-exts (>= 0.3), to avoid trying to dig up that should-be-long-dead-and-buried 0.2.1 version... Cheers, /Niklas From ivan.miljenovic at gmail.com Mon Oct 6 08:40:21 2008 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Mon Oct 6 08:36:50 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: 2008/10/6 Niklas Broberg : >> * the dependency on haskell-src-exts says any version should do, but >> the one shipped in Debian Sid >> (http://packages.debian.org/sid/libghc6-src-exts-dev) doesn't do, so >> some extra versioning info seems to be required > > Ouch, that one's pretty old. Don't the wheels of debian packaging spin > faster than that? But yeah, it should be haskell-src-exts (>= 0.3), to > avoid trying to dig up that should-be-long-dead-and-buried 0.2.1 > version... > > Cheers, > > /Niklas OK, I'll try and fix those dependency issues in the next couple of days. I didn't specify a version of haskell-src-exts, as I couldn't find any way of telling which versions were compatible (then again, I was only able to work out how to use it and what everything meant by reading the source directly...). Gwern: I think I've found why it never ends on xmonad-contrib (it happens for me here on the Grahpalyze library as well): when doing clique/cycle detection, if a function recurses on itself more than once (e.g. multiple pattern matches, each of which recurses) then the clique detection at the very least goes nuts and tries creating an infinite one-function clique. This probably happens for cycles when there's multiple edges between two functions. I think the way to fix this is to have a function that turns a graph into a simple graph (i.e. no multiple edges or loops; well, maybe _one_ loop) and get the clique detection, etc. routines use the output of that for processing. > -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From magnus at therning.org Mon Oct 6 08:44:16 2008 From: magnus at therning.org (Magnus Therning) Date: Mon Oct 6 08:40:45 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: On Mon, Oct 6, 2008 at 1:19 PM, Niklas Broberg wrote: >> * the dependency on haskell-src-exts says any version should do, but >> the one shipped in Debian Sid >> (http://packages.debian.org/sid/libghc6-src-exts-dev) doesn't do, so >> some extra versioning info seems to be required > > Ouch, that one's pretty old. Don't the wheels of debian packaging spin > faster than that? But yeah, it should be haskell-src-exts (>= 0.3), to > avoid trying to dig up that should-be-long-dead-and-buried 0.2.1 > version... Yeah, I know. I reported a bug against it and if I find the time tonight I'll try to build an updated debian package. Not sure what the policy is ATM for NMUs though. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From cgibbard at gmail.com Mon Oct 6 08:58:20 2008 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Oct 6 08:54:46 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <20081006071220.GE7973@scytale.galois.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> Message-ID: <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> 2008/10/6 Don Stewart : > dagit: >> data and newtype vary in one more subtle way, and that's how/when they >> evaluate to bottom. Most of the time they behave identically, but in the >> right cases they act sightly differently. newtype is usually regarded as >> more efficient than data. This is because the compiler can choose to >> optimize away the newtype so that it only exists at type check time. I >> think this is also possible with data in some, but not all, uses. > > The compiler *must* optimise away the use. They're sort of 'virtual' > data, guaranteed to have no runtime cost. I'm not sure that I'd want to be that emphatic about what an implementation *must* do regarding something so operational. The informal semantics of pattern matching in the Report says: Matching the pattern con pat against a value, where con is a constructor defined by newtype, depends on the value: * If the value is of the form con v, then pat is matched against v. * If the value is _|_, then pat is matched against _|_. That is, constructors associated with newtype serve only to change the type of a value. This clearly has an implementation which introduces no overhead, which one can expect from good implementations of the language. There are obviously implementations of these semantics which do introduce overhead as well though, so I would be hesitant to make any requirement like that. We can say however that newtypes have no additional runtime cost in GHC regardless of the optimisation level you pick. - Cale From arnarbi at gmail.com Mon Oct 6 09:19:30 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Mon Oct 6 09:15:56 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> Message-ID: <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> On Mon, Oct 6, 2008 at 14:58, Cale Gibbard wrote: > 2008/10/6 Don Stewart : >> dagit: >>> data and newtype vary in one more subtle way, and that's how/when they >>> evaluate to bottom. Most of the time they behave identically, but in the >>> right cases they act sightly differently. newtype is usually regarded as >>> more efficient than data. This is because the compiler can choose to >>> optimize away the newtype so that it only exists at type check time. I >>> think this is also possible with data in some, but not all, uses. >> >> The compiler *must* optimise away the use. They're sort of 'virtual' >> data, guaranteed to have no runtime cost. > > I'm not sure that I'd want to be that emphatic about what an > implementation *must* do regarding something so operational. > > The informal semantics of pattern matching in the Report says: > > Matching the pattern con pat against a value, where con is a > constructor defined by newtype, depends on the value: > * If the value is of the form con v, then pat is matched against v. > * If the value is _|_, then pat is matched against _|_. > That is, constructors associated with newtype serve only to change the > type of a value. > > This clearly has an implementation which introduces no overhead, which > one can expect from good implementations of the language. There are > obviously implementations of these semantics which do introduce > overhead as well though, so I would be hesitant to make any > requirement like that. And this requirement is there why? Is it specifically put in so that one is able to create this overhead-less implementation? Given: data A = A Int newtype B = B Int ta (A x) = True tb (B x) = True This happens (not surprisingly given your above comments): *Main GOA> :load test.hs [1 of 1] Compiling Main ( test.hs, interpreted ) Ok, modules loaded: Main. *Main GOA> ta undefined *** Exception: Prelude.undefined *Main GOA> tb undefined True Why is the x evaluated in ta? cheers, Arnar From josef.svenningsson at gmail.com Mon Oct 6 09:23:47 2008 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Mon Oct 6 09:20:11 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> Message-ID: <8dde104f0810060623p1d084036wd298a7b3b5706e98@mail.gmail.com> On Mon, Oct 6, 2008 at 2:58 PM, Cale Gibbard wrote: > 2008/10/6 Don Stewart : >> dagit: >>> data and newtype vary in one more subtle way, and that's how/when they >>> evaluate to bottom. Most of the time they behave identically, but in the >>> right cases they act sightly differently. newtype is usually regarded as >>> more efficient than data. This is because the compiler can choose to >>> optimize away the newtype so that it only exists at type check time. I >>> think this is also possible with data in some, but not all, uses. >> >> The compiler *must* optimise away the use. They're sort of 'virtual' >> data, guaranteed to have no runtime cost. > > I'm not sure that I'd want to be that emphatic about what an > implementation *must* do regarding something so operational. > > [..] > > We can say however that newtypes have no additional runtime cost in > GHC regardless of the optimisation level you pick. > Not even that is true in general. One can in general end up doing unnecessary work just for the sake of converting types. Suppose you have a newtype Price = Price Int and you're given [Int] and want to have [Price]. This is simple to do, just 'map Price'. But since Price and Int are represented the same way this ought to be just the identity function. But it is in general very difficult for a compiler to figure out that this traversal of the list in fact is just the identity function. Simple type conversions like these can unfortunately force you to do some work even though the representation is identical. Cheers, Josef From ryani.spam at gmail.com Mon Oct 6 10:10:36 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Oct 6 10:07:09 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> Message-ID: <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> On Mon, Oct 6, 2008 at 2:19 PM, Arnar Birgisson wrote: > And this requirement is there why? Is it specifically put in so that > one is able to create this overhead-less implementation? > > Given: > > data A = A Int > newtype B = B Int > > ta (A x) = True > tb (B x) = True > > This happens (not surprisingly given your above comments): > > *Main GOA> :load test.hs > [1 of 1] Compiling Main ( test.hs, interpreted ) > Ok, modules loaded: Main. > *Main GOA> ta undefined > *** Exception: Prelude.undefined > *Main GOA> tb undefined > True > > Why is the x evaluated in ta? x isn't evaluated. "undefined" is evaluated to see if it matches the constructor "A". But we don't even get to check, because undefined throws an exception during its evaluation. In the "tb" case, (B x) always matches because B is a newtype. x gets bound to undefined, but never evaluated. -- ryan From arnarbi at gmail.com Mon Oct 6 10:30:00 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Mon Oct 6 10:26:25 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006053701.GB7973@scytale.galois.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> Message-ID: <28012bc60810060730o354830a9od21c5e39aee94c6e@mail.gmail.com> Hi, On Mon, Oct 6, 2008 at 16:10, Ryan Ingram wrote: > On Mon, Oct 6, 2008 at 2:19 PM, Arnar Birgisson wrote: >> And this requirement is there why? Is it specifically put in so that >> one is able to create this overhead-less implementation? >> >> Given: >> >> data A = A Int >> newtype B = B Int >> >> ta (A x) = True >> tb (B x) = True >> >> This happens (not surprisingly given your above comments): >> >> *Main GOA> :load test.hs >> [1 of 1] Compiling Main ( test.hs, interpreted ) >> Ok, modules loaded: Main. >> *Main GOA> ta undefined >> *** Exception: Prelude.undefined >> *Main GOA> tb undefined >> True >> >> Why is the x evaluated in ta? > > x isn't evaluated. Yes, realized my error just after hitting send :/ > "undefined" is evaluated to see if it matches the > constructor "A". But we don't even get to check, because undefined > throws an exception during its evaluation. > > In the "tb" case, (B x) always matches because B is a newtype. x gets > bound to undefined, but never evaluated. And this happens because data values are basically pattern matched at run-time but newtype values are matched at compile-time, effectively turning tb into an Int -> Bool function? That explains pretty well why newtype can have only one constructor. cheers, Arnar From lemming at henning-thielemann.de Mon Oct 6 10:30:07 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Oct 6 10:26:37 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> Message-ID: On Sun, 5 Oct 2008, Jared Updike wrote: > In order to create an arbitrary precision floating point / drop in > replacement for Double, I'm trying to wrap MPFR (http://www.mpfr.org/) > using the FFI but despite all my efforts the simplest bit of code > doesn't work. Don't forget to add it to http://haskell.org/haskellwiki/Libraries_and_tools/Mathematics#Real_and_rational_numbers when you are ready. From manlio_perillo at libero.it Mon Oct 6 10:58:31 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Oct 6 10:55:15 2008 Subject: [Haskell-cafe] editing a Alex and Happy file Message-ID: <48EA2797.8090301@libero.it> Hi. There is support for editing an Alex or Happy file? I have seen some files that make use of tabs for layout (even Alex template files, and examples from both Alex and Happy), however tabs seems to be not recommended in Haskell. Thanks Manlio Perillo From slavomir.kaslev at gmail.com Mon Oct 6 11:38:58 2008 From: slavomir.kaslev at gmail.com (Slavomir Kaslev) Date: Mon Oct 6 11:35:24 2008 Subject: [Haskell-cafe] I want my free (and good looking) parser! Message-ID: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> I am writing a Parsec parser for a C-like language and I have several datas that look more or less like this one: > import Control.Monad( liftM ) > import Text.ParserCombinators.Parsec > data FooBar = Foo | Bar > deriving (Show,Read,Bounded,Enum) Looking at these, it seems that there should be no need to write a parser for this guy by hand. We already know that it is bounded and enumerable, so we can get a list of all possible FooBars: > enumAll :: (Bounded a, Enum a) => [a] > enumAll = enumFromTo minBound maxBound Also, we know how to show and read each FooBar. Therefore, I should get a free parser! > freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a Here is one use of freeParser: > paramMod = option Foo freeParser > test = parseTest $ do { x <- paramMod; eof; return x } Not suprisingly: test "Foo" => Foo test "Bar" => Bar test "" => Foo I had a little hard time figuring out how this parser should look. The best I came up with was: > freeParser = freeParser' minBound > where enumAll' :: (Bounded a, Enum a) => a -> [a] > enumAll' _ = enumAll > freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a > freeParser' x = liftM read $ choice (map (string . show) (enumAll' x)) [Actually, in my code I use reserved' (reserved' x = reserved x >> return x) instead of string, where reserved is from Parsec's builtin tokenizer (which does some neat things behind the curtains). Here string is used just to illustrate the expamle.] The problem is that freeParser, although useful, is far from elegant. It's something that I came up with by trial and error. In short: it's a hack. I would like to hear your suggestions about how it can be beautified. Thank you in advance. Cheers! -- Slavomir Kaslev From iavor.diatchki at gmail.com Mon Oct 6 12:19:03 2008 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Mon Oct 6 12:15:28 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: <5ab17e790810060919w5f23e882ofaea49417f533a18@mail.gmail.com> Hi all, (this message is an ad:-) For people interested in visualizing dependencies between the modules in their project: on Hackage there is another simple tool called "graphmod" that can generate a dot graph from your Haskell source code. -Iavor 2008/10/6 Magnus Therning : > On Mon, Oct 6, 2008 at 1:19 PM, Niklas Broberg wrote: >>> * the dependency on haskell-src-exts says any version should do, but >>> the one shipped in Debian Sid >>> (http://packages.debian.org/sid/libghc6-src-exts-dev) doesn't do, so >>> some extra versioning info seems to be required >> >> Ouch, that one's pretty old. Don't the wheels of debian packaging spin >> faster than that? But yeah, it should be haskell-src-exts (>= 0.3), to >> avoid trying to dig up that should-be-long-dead-and-buried 0.2.1 >> version... > > Yeah, I know. I reported a bug against it and if I find the time > tonight I'll try to build an updated debian package. Not sure what > the policy is ATM for NMUs though. > > /M > > -- > Magnus Therning (OpenPGP: 0xAB4DFBA4) > magnus?therning?org Jabber: magnus?therning?org > http://therning.org/magnus identi.ca|twitter: magthe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ales.bizjak0 at gmail.com Mon Oct 6 12:26:26 2008 From: ales.bizjak0 at gmail.com (=?utf-8?B?QWxlxaEgQml6amFr?=) Date: Mon Oct 6 12:22:58 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> Message-ID: > In order to create an arbitrary precision floating point / drop in > replacement for Double, I'm trying to wrap MPFR (http://www.mpfr.org/) > using the FFI but despite all my efforts the simplest bit of code > doesn't work. It compiles, it runs, but it crashes mockingly after > pretending to work for a while. I've done an interface to MPFR. See Michal's message. It isn't particularly fast but it works. You could improve/suggest improvements there, if you are interested. > Why does the C version work, but the Haskell version flake out? I'm more or less guessing here, but it might have something to do with mpfr calling __gmp_allocate_func in init2.c which is called inside mpfr_init_set_si, coupled with what Judah Jacobson said. This is the only possible problem I can think of because when using custom memory interface and allocating with malloc all the problems seem to disappear. If you substitute your mpfr_set_signed_int for the one below, the noworks should become works. mpfr_ptr mpf_set_signed_int(int x) { mpfr_ptr result = mpf_new_mpfr(); mp_limb_t * limb = malloc(mpfr_custom_get_size(mpfr_get_default_prec())); mpfr_custom_init(limb, mpfr_get_default_prec()); mpfr_custom_init_set(result, MPFR_NAN_KIND, 0, mpfr_get_default_prec(), limb); if (result == NULL) return NULL; mpfr_set_si(result, x, GMP_RNDN); return result; } From ryani.spam at gmail.com Mon Oct 6 12:48:20 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Oct 6 12:44:46 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <28012bc60810060730o354830a9od21c5e39aee94c6e@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <5ae4f2ba0810052242x36f0046amc19c8edf414980d4@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> <28012bc60810060730o354830a9od21c5e39aee94c6e@mail.gmail.com> Message-ID: <2f9b2d30810060948h5b54ce35le19dfad91b0c31b0@mail.gmail.com> On Mon, Oct 6, 2008 at 3:30 PM, Arnar Birgisson wrote: >> "undefined" is evaluated to see if it matches the >> constructor "A". But we don't even get to check, because undefined >> throws an exception during its evaluation. >> >> In the "tb" case, (B x) always matches because B is a newtype. x gets >> bound to undefined, but never evaluated. > > And this happens because data values are basically pattern matched at > run-time but newtype values are matched at compile-time, effectively > turning tb into an Int -> Bool function? Yep, that's exactly it. > That explains pretty well why newtype can have only one constructor. I never thought of it that way, but yes, it really does! Also, you can get the same behavior out of "ta" if you write it like this: ta ~(A x) = True The translation looks something like this: f ~(A x) = e => f a = e where x = case a of (A v) -> v -- a,v fresh variables not mentioned in e (or, equivalently) f a = let (A x) = a in e -- "a" some fresh variable not mentioned in e This delays the pattern-matching (and thus, the evaluation of "a") lazily until "x" is demanded, at which point "a" might throw an exception or infinite loop, or, if the type has more than one constructor, fail to pattern match (which also throws an exception). If "x" is never demanded then neither is "a". -- ryan From Christian.Maeder at dfki.de Mon Oct 6 13:07:39 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Mon Oct 6 13:04:03 2008 Subject: [Haskell-cafe] Re: I want my free (and good looking) parser! In-Reply-To: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> References: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> Message-ID: <48EA45DB.6070101@dfki.de> Slavomir Kaslev wrote: >> freeParser = freeParser' minBound >> where enumAll' :: (Bounded a, Enum a) => a -> [a] >> enumAll' _ = enumAll >> freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a >> freeParser' x = liftM read $ choice (map (string . show) (enumAll' x)) 1. I would use an explicit function argument instead of "Show" to allow strings starting with lower case. 2. Calling read after parsing looks stupid. Just return the value shown as parser result (within map). 3. Instead of the "string" parser, it should be checked if a further alphaNum or '_' follows (for the longest match). And don't forget "try"! Cheers Christian > [Actually, in my code I use reserved' (reserved' x = reserved x >> return x) > instead of string, where reserved is from Parsec's builtin tokenizer (which does > some neat things behind the curtains). Here string is used just to > illustrate the > expamle.] > > The problem is that freeParser, although useful, is far from elegant. It's > something that I came up with by trial and error. In short: it's a hack. > > I would like to hear your suggestions about how it can be beautified. > > Thank you in advance. > > Cheers! > From slavomir.kaslev at gmail.com Mon Oct 6 13:20:57 2008 From: slavomir.kaslev at gmail.com (Slavomir Kaslev) Date: Mon Oct 6 13:17:24 2008 Subject: [Haskell-cafe] Re: I want my free (and good looking) parser! In-Reply-To: <48EA45DB.6070101@dfki.de> References: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> <48EA45DB.6070101@dfki.de> Message-ID: <171dfd0a0810061020h339a531dra6429fd0b176ad54@mail.gmail.com> On Mon, Oct 6, 2008 at 8:07 PM, Christian Maeder wrote: > Slavomir Kaslev wrote: >>> freeParser = freeParser' minBound >>> where enumAll' :: (Bounded a, Enum a) => a -> [a] >>> enumAll' _ = enumAll >>> freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a >>> freeParser' x = liftM read $ choice (map (string . show) (enumAll' x)) > > 1. I would use an explicit function argument instead of "Show" to allow > strings starting with lower case. > You are right. But that was not the problem. The problem was that I wrestled with Haskell's type system quite a bit to make freeParser work. What I want to write is freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a freeParser = liftM read $ choice (map (string . show) enumAll) but it doesn't compile. How can I make this piece code work? > 2. Calling read after parsing looks stupid. Just return the value shown > as parser result (within map). > Good point. It is silly =-) > 3. Instead of the "string" parser, it should be checked if a further > alphaNum or '_' follows (for the longest match). And don't forget "try"! > Sure. I actually use Parsec's reserved, which is kind enough to manage all this stuff for me. > Cheers Christian > >> [Actually, in my code I use reserved' (reserved' x = reserved x >> return x) >> instead of string, where reserved is from Parsec's builtin tokenizer (which does >> some neat things behind the curtains). Here string is used just to >> illustrate the >> expamle.] >> >> The problem is that freeParser, although useful, is far from elegant. It's >> something that I came up with by trial and error. In short: it's a hack. >> >> I would like to hear your suggestions about how it can be beautified. >> >> Thank you in advance. >> >> Cheers! >> > -- Slavomir Kaslev From jeremy at n-heptane.com Mon Oct 6 14:13:30 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon Oct 6 14:02:53 2008 Subject: [Haskell-cafe] Re: I want my free (and good looking) parser! In-Reply-To: <171dfd0a0810061020h339a531dra6429fd0b176ad54@mail.gmail.com> References: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> <48EA45DB.6070101@dfki.de> <171dfd0a0810061020h339a531dra6429fd0b176ad54@mail.gmail.com> Message-ID: <871vytmw1h.wl%jeremy@n-heptane.com> At Mon, 6 Oct 2008 20:20:57 +0300, Slavomir Kaslev wrote: > > On Mon, Oct 6, 2008 at 8:07 PM, Christian Maeder > wrote: > > Slavomir Kaslev wrote: > >>> freeParser = freeParser' minBound > >>> where enumAll' :: (Bounded a, Enum a) => a -> [a] > >>> enumAll' _ = enumAll > >>> freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a > >>> freeParser' x = liftM read $ choice (map (string . show) (enumAll' x)) > > > > 1. I would use an explicit function argument instead of "Show" to allow > > strings starting with lower case. > > > > You are right. But that was not the problem. The problem was that I > wrestled with Haskell's type system quite a bit to make freeParser > work. What I want to write is > > freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a > freeParser = liftM read $ choice (map (string . show) enumAll) > > but it doesn't compile. How can I make this piece code work? I would start by adding this to the top of the file: > {-# LANGUAGE ScopedTypeVariables, FlexibleContexts #-} Then add 'forall a.' to the type signature of freeParser. This causes freeParser' and freeParser to have the same value for 'a'. Now you can add an explicit type signature to (enumAll :: [a]) > freeParser :: forall a. (Enum a, Bounded a, Show a, Read a) => Parser a > freeParser = freeParser' minBound > where freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a > freeParser' x = liftM read $ choice (map (string . show) (enumAll :: [a])) The reseason you have to explicitly type enumAll is because you do a show and then a read. Looking at a simplified case, we can see that the types in this expression are ambigious: read (show 1.0) show :: (Show a) => a -> String read :: (Read a) => String -> a It is perfectly valid typewise to do,: read (show 1.0) :: Char Of course, that will result in a runtime error: *Main> read (show 1.0) :: Char *** Exception: Prelude.read: no parse If we rewrite freeParser like this, then we don't need any special extensions: > freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a > freeParser = freeParser' minBound > where freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a > freeParser' x = choice (map (\x -> string (show x) >> return x) enumAll) Some might consider this prettier: > freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a > freeParser = freeParser' minBound > where freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a > freeParser' x = choice [ string (show x) >> return x | x <- enumAll ] Anyway, there is another problem -- if you extend you datatype with a constructor Foomatic: > data FooBar = Foo | Foomatic | Bar > deriving (Show,Read,Bounded,Enum) you get the error: test "Foomatic" parse error at (line 1, column 4): unexpected "m" expecting end of input This is because the parser wil successfully parse Foo and so it won't even try parsing foomatic. As a cheap hack we can do this: > freeParser :: (Ord a, Enum a, Bounded a, Show a, Read a) => Parser a > freeParser = freeParser' minBound > where freeParser' :: (Ord a, Enum a, Bounded a, Show a, Read a) => a -> Parser a > freeParser' x = choice [ try (string (show x)) >> return x | x <- reverse $ sort enumAll ] We sort the constructors by reverse alphabetical order so that the parser will try Foomatic before trying Foo. We also need to use the 'try' function so that if Foomatic fails it will still try Foo. This is not a particularily efficient fix though. j. From arnarbi at gmail.com Mon Oct 6 14:07:09 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Mon Oct 6 14:03:36 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <2f9b2d30810060948h5b54ce35le19dfad91b0c31b0@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <20081006054723.GC7973@scytale.galois.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> <28012bc60810060730o354830a9od21c5e39aee94c6e@mail.gmail.com> <2f9b2d30810060948h5b54ce35le19dfad91b0c31b0@mail.gmail.com> Message-ID: <28012bc60810061107n11528912i373b7ff6a10492c@mail.gmail.com> On Mon, Oct 6, 2008 at 18:48, Ryan Ingram wrote: > Also, you can get the same behavior out of "ta" if you write it like this: > > ta ~(A x) = True > > The translation looks something like this: > > f ~(A x) = e > => > f a = e > where x = case a of (A v) -> v -- a,v fresh variables not mentioned in e > > (or, equivalently) > > f a = let (A x) = a in e -- "a" some fresh variable not mentioned in e > > This delays the pattern-matching (and thus, the evaluation of "a") > lazily until "x" is demanded, at which point "a" might throw an > exception or infinite loop, or, if the type has more than one > constructor, fail to pattern match (which also throws an exception). > If "x" is never demanded then neither is "a". Ah, that's pretty neat and subtle. Now, say I have a type created with data that has only one constructor. Couldn't the compiler optimize away this unneccessary evaluation during pattern matching? I.e. it would make what you just wrote implicit in that case. Or perhaps data declarations with just one ctor should really be turned into newtypes by the programmer? cheers, Arnar From jupdike at gmail.com Mon Oct 6 14:21:39 2008 From: jupdike at gmail.com (Jared Updike) Date: Mon Oct 6 14:18:04 2008 Subject: [Haskell-cafe] MPFR / FFI - Nefarious (Simple?) bug In-Reply-To: References: <8b108f950810051726r7e0b5578pf6f4504bb7ab8e00@mail.gmail.com> Message-ID: <8b108f950810061121q367c0735p5abdcadd0121befa@mail.gmail.com> > If you substitute your mpfr_set_signed_int for the one below, the noworks > should become works. Yes, this works perfectly. Thank you for saving my project! (Had I known about HMPFR when I started this project, I would have just used that instead of rolling my own, but it looks like HMPFR was uploaded at the end of September though I started rolling my own bindings in June or July... you know how life goes: work, moving, vacation, wife starting grad school, etc.) Last night I was seriously considering dropping work on my current project and joining the effort to replace GMP in GHC as the only solution. But now I Thanks, Jared. From dagit at codersbase.com Mon Oct 6 14:24:10 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 14:20:35 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order Message-ID: Originally I sent this to glasgow-haskell where I was hoping someone by the name of Simon would comment on the error message. No one commented at all, so I'm resending to haskell-cafe. Thanks! I was wondering if someone could help me understand why reordering the case statements changes the type inference for this code. 1) I find the error message a bit confusing. 2) I don't understand why it's a problem in one order and not the other. I've tried to send this as literate haskell in hopes that you can just copy and paste to a file and run the example. This happens with or without GADTs, this version doesn't have them but they don't turn out to make any difference. \begin{code} {-# LANGUAGE ExistentialQuantification, RankNTypes #-} module Main where data Sealed a = forall x. Sealed (a x) -- Or equivalently: -- data Sealed a where -- Sealed :: a x -> Sealed a \end{code} Originally, I noticed this in a monad context...The original was much more complicated. But, we can simplify it even more, so keep reading. goodOrder :: Monad m => (forall y z. p x y -> q y z -> q x z) -> m (Sealed (p x)) -> (forall b. m (Sealed (q b))) -> m (Sealed (q x)) goodOrder f mx my = do Sealed x <- mx Sealed y <- my return (Sealed (f x y)) badOrder :: Monad m => (forall y z. p x y -> q y z -> q x z) -> m (Sealed (p x)) -> (forall b. m (Sealed (q b))) -> m (Sealed (q x)) badOrder f mx my = do Sealed y <- my Sealed x <- mx return (Sealed (f x y)) Several helpful people in #haskell helped me converge on this greatly simplified version below. \begin{code} f :: p x y -> q y z -> q x z f = undefined \end{code} \begin{code} badOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q x)) badOrder sx sy = case sy of Sealed y -> case sx of Sealed x -> Sealed (f x y) \end{code} \begin{code} goodOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q x)) goodOrder sx sy = case sx of Sealed x -> case sy of Sealed y -> Sealed (f x y) \end{code} \begin{code} main = return () \end{code} This gives the error: $ ghc --make Reorder.lhs [1 of 1] Compiling Main ( Reorder.lhs, Reorder.o ) Reorder.lhs:52:29: Inferred type is less polymorphic than expected Quantified type variable `x' is mentioned in the environment: y :: q x x1 (bound at Reorder.lhs:51:24) When checking an existential match that binds x :: p x2 x The pattern(s) have type(s): Sealed (p x2) The body has type: Sealed (q x2) In a case alternative: Sealed x -> Sealed (f x y) In the expression: case sx of Sealed x -> Sealed (f x y) After discussing this a bit, I think what may be happening in the badOrder case is that the existentially bound type of x is bound after the type `b' in the type of y, leading to the error message. I would appreciate help understanding this, even if the help is, "Go read paper X, Y, and Z." Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/839f87d6/attachment.htm From vanenkj at gmail.com Mon Oct 6 14:29:09 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 14:25:35 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server Message-ID: Hello All, I'm working on a Haskell based VPN. I can't think of any good names, so I'm crowd sourcing it. A few details that may help in naming it: 1. It's distributed (doesn't need a "master" or "server"). 2. It's secure (duh) 3. It uses TUN/TAP 4. It's written (mostly) in Haskell! The best I can do is HaskVPN. This name is so bad I'm afraid to admit it. A better suggestion would be much appreciated. -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/23c42e41/attachment.htm From dons at galois.com Mon Oct 6 14:52:05 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 14:48:20 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: <20081006185205.GH9859@scytale.galois.com> vanenkj: > Hello All, > > I'm working on a Haskell based VPN. I can't think of any good names, so > I'm crowd sourcing it. > > A few details that may help in naming it: > 1. It's distributed (doesn't need a "master" or "server"). > 2. It's secure (duh) > 3. It uses TUN/TAP > 4. It's written (mostly) in Haskell! > > The best I can do is HaskVPN. This name is so bad I'm afraid to admit it. > A better suggestion would be much appreciated. Is the code around somewhere? This sounds intriguing. -- Don From 666wman at gmail.com Mon Oct 6 15:00:36 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 14:57:01 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: <20081006185205.GH9859@scytale.galois.com> References: <20081006185205.GH9859@scytale.galois.com> Message-ID: > > The best I can do is HaskVPN. This name is so bad I'm afraid to admit > it. > > A better suggestion would be much appreciated. > How about HaPN (pronounced as happen), obviously standing for Haskell Private Network. Whether it's better is a matter of taste ;-) > > Is the code around somewhere? This sounds intriguing. > > -- Don I second that ... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/a8f02a35/attachment.htm From dagit at codersbase.com Mon Oct 6 15:01:34 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 14:57:59 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: 2008/10/6 John Van Enk > Hello All, > > I'm working on a Haskell based VPN. I can't think of any good names, so I'm > crowd sourcing it. > > A few details that may help in naming it: > 1. It's distributed (doesn't need a "master" or "server"). > 2. It's secure (duh) > 3. It uses TUN/TAP > 4. It's written (mostly) in Haskell! > > The best I can do is HaskVPN. This name is so bad I'm afraid to admit it. A > better suggestion would be much appreciated. > My advice so to find something cute, like an animal, and use that in the name instead of some implementation details like the programming language. So you could be, WaterbearVPN, for example. Okay, that was sort of a joke as waterbears aren't really that cute, but I think you get the idea. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/b580d9c8/attachment.htm From coreyoconnor at gmail.com Mon Oct 6 15:02:14 2008 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Mon Oct 6 14:58:40 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: <20081006185205.GH9859@scytale.galois.com> Message-ID: 2008/10/6 wman <666wman@gmail.com>: > How about HaPN (pronounced as happen), obviously standing for Haskell > Private Network. Whether it's better is a matter of taste ;-) +1 for HaPN Quite catchy IMO. :-) -- -Corey O'Connor From dominic.steinitz at blueyonder.co.uk Mon Oct 6 15:11:21 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Mon Oct 6 15:05:30 2008 Subject: [Haskell-cafe] Darcs / Git Message-ID: <48EA62D9.1020607@blueyonder.co.uk> Not really a Haskell question but I'm not sure where else to go. What's the preferred method of converting a darcs repository to git? And is there a way of converting from git to darcs? The reason I ask is that my colleague cannot get darcs to work on his Windows box. Thanks, Dominic. From 666wman at gmail.com Mon Oct 6 15:15:28 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 15:11:53 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: And to be really original, try to sell some weird adjective with it. The ubuntu crowd didn't buy this, so maybe you could make it Horny Hornet VPN ;-) 2008/10/6 Jason Dagit > > My advice so to find something cute, like an animal, and use that in the > name instead of some implementation details like the programming language. > > So you could be, WaterbearVPN, for example. Okay, that was sort of a joke > as waterbears aren't really that cute, but I think you get the idea. > > Jason > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/4673f316/attachment.htm From vanenkj at gmail.com Mon Oct 6 15:18:55 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 15:15:20 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: <20081006185205.GH9859@scytale.galois.com> References: <20081006185205.GH9859@scytale.galois.com> Message-ID: On Mon, Oct 6, 2008 at 2:52 PM, Don Stewart wrote: > > Is the code around somewhere? This sounds intriguing. > > -- Don > Yes! Though this is the "Works For Me (alpha release)" version. Keep in mind: * It's not cabalized yet, so... we use my quick-and-dirty build scripts to build/clean. * It's throughput runs at about 800KB/s over Wi-Fi (i should be able to get this faster). * Depends on the Data.Binary (binary) * Depends on Network.Socket.ByteString (network-bytestring) * Requires that you have the tun module loaded (make sure the /dev/net/tun device exists) * Needs to run as root (do you trust me?) * UDP port is fixed at 24999 for now (remember, WFM alpha release) * It uses a C file to do the ioctls and setup the IP address, MTU, etc... (any one able to see a way to remove the C file? It's not doing anything all that complex...) Here's how to use it: sudo ./haskvpn [my vpn ip] [address to bind to] [address to connect to] Here's any example: # On machine 1 sudo ./haskvpn 10.0.0.1 0.0.0.0 192.168.128.60 # On machine 2 sudo ./haskvpn 10.0.0.2 0.0.0.0 192.168.128.50 Once that comes up, you should be able to ping, ssh, etc from 10.0.0.1 to 10.0.0.2 and back again. The code is here: http://sw17ch.com/code/haskvpn-1223320484.tar.gz Once the code is downloaded, run ./build.sh and you (should) find the haskvpn binary in the same directory. There are 338 lines of haskell/c (including comments/whitespace), so it shouldn't take too long to read over. Reccomendations/patches/insults are requested! -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/13529f80/attachment.htm From dagit at codersbase.com Mon Oct 6 15:19:12 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 15:15:38 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <48EA62D9.1020607@blueyonder.co.uk> References: <48EA62D9.1020607@blueyonder.co.uk> Message-ID: On Mon, Oct 6, 2008 at 12:11 PM, Dominic Steinitz < dominic.steinitz@blueyonder.co.uk> wrote: > Not really a Haskell question but I'm not sure where else to go. The best place to ask would be the darcs-users mailing list: http://lists.osuosl.org/mailman/listinfo/darcs-users What's the preferred method of converting a darcs repository to git? And > is there a way of converting from git to darcs? Never tried it personally, but I think tailor can do this: http://progetti.arstecnica.it/tailor The reason I ask is that my colleague cannot get darcs to work on his > Windows box. I think there are windows binaries floating around. If you ask on the darcs-users list I think someone can get this squared away for you. Whether you need help building or just getting binary that works. Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/95e382c0/attachment.htm From anton at appsolutions.com Mon Oct 6 15:39:16 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Mon Oct 6 15:19:05 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: <48EA6964.3030008@appsolutions.com> Jason Dagit wrote: > > > 2008/10/6 John Van Enk > ... > The best I can do is HaskVPN. This name is so bad I'm afraid to > admit it. A better suggestion would be much appreciated. > > > My advice so to find something cute, like an animal, and use that in the > name instead of some implementation details like the programming language. Or you could combine both cuteness and implementation details, with "HaVPN", the mascot for which would be a lambdacat[*] saying: "I can HaVPN?" Anton [*] http://arcanux.org/lambdacats.html From vanenkj at gmail.com Mon Oct 6 15:23:23 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 15:19:49 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: <20081006185205.GH9859@scytale.galois.com> Message-ID: Ah, one more thing. It's not secure or distributed or any of the other things I said yet. It's going to be. :) The version I just posted is able to have two clients talk to each other (notice that neither of them is a server). I'll get the encryption and other details hammered in later. :) On Mon, Oct 6, 2008 at 3:18 PM, John Van Enk wrote: > > On Mon, Oct 6, 2008 at 2:52 PM, Don Stewart wrote: > >> >> Is the code around somewhere? This sounds intriguing. >> >> -- Don >> > > Yes! Though this is the "Works For Me (alpha release)" version. > > Keep in mind: > * It's not cabalized yet, so... we use my quick-and-dirty build scripts to > build/clean. > * It's throughput runs at about 800KB/s over Wi-Fi (i should be able to get > this faster). > * Depends on the Data.Binary (binary) > * Depends on Network.Socket.ByteString (network-bytestring) > * Requires that you have the tun module loaded (make sure the /dev/net/tun > device exists) > * Needs to run as root (do you trust me?) > * UDP port is fixed at 24999 for now (remember, WFM alpha release) > * It uses a C file to do the ioctls and setup the IP address, MTU, etc... > (any one able to see a way to remove the C file? It's not doing anything all > that complex...) > > Here's how to use it: > > sudo ./haskvpn [my vpn ip] [address to bind to] [address to connect to] > > Here's any example: > > # On machine 1 > sudo ./haskvpn 10.0.0.1 0.0.0.0 192.168.128.60 > > # On machine 2 > sudo ./haskvpn 10.0.0.2 0.0.0.0 192.168.128.50 > > Once that comes up, you should be able to ping, ssh, etc from 10.0.0.1 to > 10.0.0.2 and back again. > > The code is here: http://sw17ch.com/code/haskvpn-1223320484.tar.gz > > Once the code is downloaded, run ./build.sh and you (should) find the > haskvpn binary in the same directory. > > There are 338 lines of haskell/c (including comments/whitespace), so it > shouldn't take too long to read over. > > Reccomendations/patches/insults are requested! > > -- > /jve > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/2abf9f47/attachment.htm From vanenkj at gmail.com Mon Oct 6 15:24:19 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 15:20:46 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: <48EA6964.3030008@appsolutions.com> References: <48EA6964.3030008@appsolutions.com> Message-ID: This is quite tempting, since my screen saver is a directory full of lambdacats.... On Mon, Oct 6, 2008 at 3:39 PM, Anton van Straaten wrote: > Jason Dagit wrote: > >> >> >> 2008/10/6 John Van Enk > >> > ... > >> The best I can do is HaskVPN. This name is so bad I'm afraid to >> admit it. A better suggestion would be much appreciated. >> >> >> My advice so to find something cute, like an animal, and use that in the >> name instead of some implementation details like the programming language. >> > > Or you could combine both cuteness and implementation details, with > "HaVPN", the mascot for which would be a lambdacat[*] saying: > > "I can HaVPN?" > > Anton > > [*] http://arcanux.org/lambdacats.html > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/1029cfb5/attachment.htm From 666wman at gmail.com Mon Oct 6 15:30:08 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 15:26:36 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: <20081006185205.GH9859@scytale.galois.com> Message-ID: As far as insults go, one simply cannot go wrong with THE Shakespearean insult kit ;-)) http://www.pangloss.com/seidel/shake_rule.html 2008/10/6 John Van Enk > > On Mon, Oct 6, 2008 at 2:52 PM, Don Stewart wrote: > >> >> Is the code around somewhere? This sounds intriguing. >> >> -- Don >> > > Yes! Though this is the "Works For Me (alpha release)" version. > > Keep in mind: > * It's not cabalized yet, so... we use my quick-and-dirty build scripts to > build/clean. > * It's throughput runs at about 800KB/s over Wi-Fi (i should be able to get > this faster). > * Depends on the Data.Binary (binary) > * Depends on Network.Socket.ByteString (network-bytestring) > * Requires that you have the tun module loaded (make sure the /dev/net/tun > device exists) > * Needs to run as root (do you trust me?) > * UDP port is fixed at 24999 for now (remember, WFM alpha release) > * It uses a C file to do the ioctls and setup the IP address, MTU, etc... > (any one able to see a way to remove the C file? It's not doing anything all > that complex...) > > Here's how to use it: > > sudo ./haskvpn [my vpn ip] [address to bind to] [address to connect to] > > Here's any example: > > # On machine 1 > sudo ./haskvpn 10.0.0.1 0.0.0.0 192.168.128.60 > > # On machine 2 > sudo ./haskvpn 10.0.0.2 0.0.0.0 192.168.128.50 > > Once that comes up, you should be able to ping, ssh, etc from 10.0.0.1 to > 10.0.0.2 and back again. > > The code is here: http://sw17ch.com/code/haskvpn-1223320484.tar.gz > > Once the code is downloaded, run ./build.sh and you (should) find the > haskvpn binary in the same directory. > > There are 338 lines of haskell/c (including comments/whitespace), so it > shouldn't take too long to read over. > > Reccomendations/patches/insults are requested! > > -- > /jve > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/dff6d090/attachment.htm From lane at downstairspeople.org Mon Oct 6 15:40:44 2008 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Mon Oct 6 15:37:09 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: I had this problem: lane@biped:~/src/roguestar/rsagl (master)$ SourceGraph rsagl.cabal dot: width (40671 >= 32768) is too large. dot: width (43275 >= 32768) is too large. dot: width (43720 >= 32768) is too large. dot: width (40525 >= 32768) is too large. Unable to generate report lane@biped:~/src/roguestar/rsagl (master)$ dot -V dot - Graphviz version 2.20.2 (Sat Aug 16 05:41:32 UTC 2008) --Lane From bulat.ziganshin at gmail.com Mon Oct 6 15:57:58 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Oct 6 15:55:52 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: <687158145.20081006235758@gmail.com> Hello John, Monday, October 6, 2008, 10:29:09 PM, you wrote: > I'm working on a Haskell based VPN. I can't think of any good names, so I'm crowd sourcing it. octopus? (it was a good serial about italian mafia spreading its palpi all over the country :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From andrewcoppin at btinternet.com Mon Oct 6 16:07:13 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Oct 6 16:03:40 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> Message-ID: <48EA6FF1.6040607@btinternet.com> Mitchell, Neil wrote: > Hi > > >> Try doing a Hoogle search for "c1 (c2 x) -> c2 (c1 x)". >> Hoogle correctly states that Data.Traversable.sequence will >> do it for you. >> >> Now try doing "c1 k (c2 x) -> c2 (c1 k x)". The 'sequence' >> function will also do this, but now Hoogle returns 0 results. >> >> This is puzzling, since AFAIK, the above two type signatures >> are "equvilent" in some sense. (Specifically, replace every >> type X with type Y and you get from one to the other.) To me, >> this looks like a Hoogle bug. (It goes without saying that >> Hoogle also failed to find anything for the more specific >> type signature I was searching for, despite the fact that >> 'sequence' unifies with it.) >> > > Hoogle is not a "unification engine" - since that is very rarely what > people want out of a type search engine. What it is is an approximate > matcher. Let's compare the two types: > > Your search :: c1 k (c2 x) -> c2 (c1 k x) > > sequence :: Monad m => [m a] -> m [a] > Actually, I was thinking more along the lines of Data.Traversable.sequence, which has sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) > Are you expecting c1 (:: * -> * -> *) to unify with [] (:: * -> *)? That > seems kind incorrect at the very last. Additionally, those types don't > look all that close. > Well, as I said, replacing one term with another transforms one signature into the other. I guess you can't curry type constructors as easily as functions - or at least, Hoogle currently doesn't like it. > But, let's briefly consider unification (and why Hoogle doesn't used > it). Consider the search: > > Eq a => [(a,b)] -> a -> b > > What the user wants is lookup, which sadly doesn't unify. However, > undefined unifies perfectly. > I see... I notice that x -> y doesn't unify with y -> x in any way, shape or form, but Hoogle has absolutely no problem with that. What *does* Hoogle actually use for matching? Just a set of huristics and a metric for how "similar" two signatures are so it can order by approximate similarity? Or is it something more scientific than that? From marco-oweber at gmx.de Mon Oct 6 16:08:50 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Mon Oct 6 16:05:17 2008 Subject: [Haskell-cafe] Linux binary dist problems In-Reply-To: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> References: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> Message-ID: <20081006200850.GF22390@gmx.de> Hi Colin, I only know about one other option: Try user mode linux / qemu / anotehr virtualziing software and setup the environment within that which you need... :-( Another thing you could try is installing nix (nixos.org) (software distirbution system).. It bootstraps current ghc via ghc-6.4.2 from binaries / source automatically (Don't think older compilers are supported than 6.4.x) but you'll get a complete copy of each system lib within the store direcotry. So you need some disk space. And I can't guarantee that it works out of the box.. (it works with 2.6.9 kernel.. don't know about older ones) If all you want to do is toying around I can give you an ssh account to my server which has ghc installed. Anyway be prepared that there is no IDE support coming close to what Eclipse provides for the Java language.. Sincerly Marc From slavomir.kaslev at gmail.com Mon Oct 6 16:28:46 2008 From: slavomir.kaslev at gmail.com (Slavomir Kaslev) Date: Mon Oct 6 16:25:11 2008 Subject: [Haskell-cafe] Re: I want my free (and good looking) parser! In-Reply-To: <48EA5AC9.6090304@dfki.de> References: <171dfd0a0810060838o4d87df32y39e7204f45569554@mail.gmail.com> <48EA45DB.6070101@dfki.de> <171dfd0a0810061020h339a531dra6429fd0b176ad54@mail.gmail.com> <48EA5AC9.6090304@dfki.de> Message-ID: <171dfd0a0810061328v60d2b3f6ydc036c6e62c5a048@mail.gmail.com> On Mon, Oct 6, 2008 at 9:36 PM, Christian Maeder wrote: > import Text.ParserCombinators.Parsec > > freeParser :: (Enum a, Bounded a, Show a) => Parser a > freeParser = choice $ map (\ a -> try $ do > string $ show a > notFollowedBy (alphaNum <|> char '_') > return a) [minBound .. maxBound] > This is exactly what I needed. Though I still don't quite understand why this works and mine doesn't. > I see not need for extensions. (And I don't like > Text.ParserCombinators.Parsec.Token) > > Where did you get enumAll from? > Mine definition of enumAll was equiv?lent to [minBound .. maxBound]: enumAll :: (Bounded a, Enum a) => [a] ?numAll = enumFromTo minBound maxBound > The type of the Parser must be deducible from the context (or given by a > type annotation). > > Cheers C. > > Slavomir Kaslev wrote: >> On Mon, Oct 6, 2008 at 8:07 PM, Christian Maeder >> wrote: >>> Slavomir Kaslev wrote: >>>>> freeParser = freeParser' minBound >>>>> where enumAll' :: (Bounded a, Enum a) => a -> [a] >>>>> enumAll' _ = enumAll >>>>> freeParser' :: (Enum a, Bounded a, Show a, Read a) => a -> Parser a >>>>> freeParser' x = liftM read $ choice (map (string . show) (enumAll' x)) >>> 1. I would use an explicit function argument instead of "Show" to allow >>> strings starting with lower case. >>> >> >> You are right. But that was not the problem. The problem was that I >> wrestled with Haskell's type system quite a bit to make freeParser >> work. What I want to write is >> >> freeParser :: (Enum a, Bounded a, Show a, Read a) => Parser a >> freeParser = liftM read $ choice (map (string . show) enumAll) >> >> but it doesn't compile. How can I make this piece code work? >> >>> 2. Calling read after parsing looks stupid. Just return the value shown >>> as parser result (within map). >>> >> >> Good point. It is silly =-) >> >>> 3. Instead of the "string" parser, it should be checked if a further >>> alphaNum or '_' follows (for the longest match). And don't forget "try"! >>> >> >> Sure. I actually use Parsec's reserved, which is kind enough to manage >> all this stuff for me. >> >>> Cheers Christian >>> >>>> [Actually, in my code I use reserved' (reserved' x = reserved x >> return x) >>>> instead of string, where reserved is from Parsec's builtin tokenizer (which does >>>> some neat things behind the curtains). Here string is used just to >>>> illustrate the >>>> expamle.] >>>> >>>> The problem is that freeParser, although useful, is far from elegant. It's >>>> something that I came up with by trial and error. In short: it's a hack. >>>> >>>> I would like to hear your suggestions about how it can be beautified. >>>> >>>> Thank you in advance. >>>> >>>> Cheers! >>>> >> >> >> > -- Slavomir Kaslev From andrewcoppin at btinternet.com Mon Oct 6 16:48:51 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Oct 6 16:45:17 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48E8EC1D.9060203@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> Message-ID: <48EA79B3.9080202@btinternet.com> Andrew Coppin wrote: > I have some longwinded code that works, but I'm still thinking about > how to do this more elegantly. It looks like what I really need is > something like > > type M = StateT State (ResultSetT (ErrorT ErrorType Identity)) > > Is that the correct ordering? > > If so, I guess that means I have to somehow construct ResultSetT. Is > there an easy way to do that, given that I already have ResultSet? For > example, if I put ResultSet into Traversable, would that let me do it? ...and again I'm talking to myself... :-/ So after much experimentation, I have managed to piece together the following facts: - It appears that the outer-most monad transformer represents the inner-most monad. So "StateT Foo ListT" means a list of stateful computations, while "ListT (StateT Foo)" means a stateful list of computations. - Each transformer seems to be defined as a newtype such that we have ListT :: m [x] -> ListT m x and runListT :: ListT m x -> m [x]. - By some magical process that I do not yet understand, I can wrap a StateT in 17 other transformers, and yet "get" and "put" do not require any lifting. (God only knows what happens if you were to use two StateTs in the same monad stack...) What I haven't figured out yet is how to turn ResultSet into ResultSetT. I seem to just spend most of my time being frustrated by the type checker. A useful trick is to say things like :t lift (undefined :: ListT Int) to figure out what type the various parts of a complex multi-monad expression have. (By now I'm seeing things like "return . return . return", which is just far out.) But sometimes I find myself desperately wanting to take some block of code and say "what type does *this* part of the expression have?" or "if I do x >>= y when y has *this* type, what type must x have?" It can be very hard to work this out mentally, and unfortunately there isn't any tool I'm aware of that will help you in this matter. After much testing, it appears that the utopian type definition at the very top of this message is in fact the thing I need. So if I can just figure out how to construct ResultSetT than I'm done. It looks like trying to build it from ResultSet is actually harder than just implementing it directly, so I'm going to try a direct transformer implementation instead. But it's seriously hard work! For reference, I humbly present ResultSet.hs: module Orphi.Kernel.ResultSet (ResultSet (), from_list, to_list, build, limit, cost, union) where data ResultSet x = Pack {unpack :: [[x]]} deriving (Eq) instance (Show x) => Show (ResultSet x) where show (Pack xss) = "from_list " ++ show xss instance Monad ResultSet where fail msg = Pack [] return x = Pack [[x]] (Pack xss) >>= f = Pack $ raw_bind xss (unpack . f) raw_bind :: [[x]] -> (x -> [[y]]) -> [[y]] raw_bind = work [] where work out [] _ = out work out (xs:xss) f = let yss = foldr raw_union out (map f xs) in if null yss then [] : work [] xss f else head yss : work (tail yss) xss f raw_union :: [[x]] -> [[x]] -> [[x]] raw_union [] yss = yss raw_union xss [] = xss raw_union (xs:xss) (ys:yss) = (xs ++ ys) : raw_union xss yss from_list :: [[x]] -> ResultSet x from_list = Pack to_list :: ResultSet x -> [[x]] to_list = unpack build :: [x] -> ResultSet x build = from_list . map return limit :: Int -> ResultSet x -> ResultSet x limit n (Pack xss) = Pack (take n xss) cost :: ResultSet x -> ResultSet x cost (Pack xss) = Pack ([]:xss) union :: ResultSet x -> ResultSet x -> ResultSet x union (Pack xss) (Pack yss) = Pack (raw_union xss yss) From ryani.spam at gmail.com Mon Oct 6 16:56:12 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Oct 6 16:52:37 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order In-Reply-To: References: Message-ID: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> 2008/10/6 Jason Dagit : > \begin{code} > badOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q x)) > badOrder sx sy = case sy of > Sealed y -> case sx of > Sealed x -> Sealed (f x y) > \end{code} > > \begin{code} > goodOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q x)) > goodOrder sx sy = case sx of > Sealed x -> case sy of > Sealed y -> Sealed (f x y) > \end{code} It may help if you transform this a bit closer to System F with existentials & datatypes: /\ = forall @t = type application, with the rule: (a :: forall x. b) @t :: (replace occurrences of x in b with t) -- the quantified type "x" gets packed into the data -- and comes out when you pattern match on it data Sealed s where Sealed :: /\t. s t -> Sealed s goodOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> case sx of (Sealed @y pxy) -> case (sy @y) of (Sealed @z qyz) -> Sealed @z (f pxy qyz) badOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> -- in order to pattern-match on sy, we need to give it a type -- so we just pick an arbitrary type "unknown" or "u" distinct from any other type we know about case (sy @u) of (Sealed @z quz) -> case sx of (Sealed @y pxy) -> Sealed @z (f pxy quz) -- doesn't typecheck! In the good order, you have already unpacked the existential for sx, so you know what type to instantiate sy at. In the bad order, you don't know what type to instantiate sy at. -- ryan From colin.mailinglist at gmail.com Mon Oct 6 17:00:38 2008 From: colin.mailinglist at gmail.com (Colin Fleming) Date: Mon Oct 6 16:57:03 2008 Subject: [Haskell-cafe] Linux binary dist problems In-Reply-To: <20081006200850.GF22390@gmx.de> References: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> <20081006200850.GF22390@gmx.de> Message-ID: <7c6512110810061400o34feea29yee484ceb68e21026@mail.gmail.com> Hi Marc, Great, thanks for the pointer. I'll take a look at nix, that might be an option. Thanks for the offer of server space too, but I'd really like to get it going on my own space since I have domains and whatnot pointed there. I also realise that the IDE support isn't there - it's even worse, I use IntelliJ rather than Eclipse which is positively magical at times. Something similar for a language like Haskell would be amazing. Thanks for the advice! Cheers, Colin 2008/10/6 Marc Weber > Hi Colin, > > I only know about one other option: > Try user mode linux / qemu / anotehr virtualziing software and setup the > environment within that which you need... :-( > Another thing you could try is installing nix (nixos.org) (software > distirbution > system).. It bootstraps current ghc via ghc-6.4.2 from binaries / source > automatically (Don't think older compilers are supported than 6.4.x) but > you'll get a complete copy of each system lib within the store > direcotry. So you need some disk space. And I can't guarantee that it > works out of the box.. (it works with 2.6.9 kernel.. don't know about > older ones) > > If all you want to do is toying around I can give you an ssh account to > my server which has ghc installed. > Anyway be prepared that there is no IDE support coming close to what > Eclipse provides for the Java language.. > > Sincerly > Marc > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/e37787c1/attachment.htm From dagit at codersbase.com Mon Oct 6 17:27:42 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 17:24:07 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order In-Reply-To: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> Message-ID: On Mon, Oct 6, 2008 at 1:56 PM, Ryan Ingram wrote: > 2008/10/6 Jason Dagit : > > \begin{code} > > badOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q > x)) > > badOrder sx sy = case sy of > > Sealed y -> case sx of > > Sealed x -> Sealed (f x y) > > \end{code} > > > > \begin{code} > > goodOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q > x)) > > goodOrder sx sy = case sx of > > Sealed x -> case sy of > > Sealed y -> Sealed (f x y) > > \end{code} > > It may help if you transform this a bit closer to System F with > existentials & datatypes: > /\ = forall Why is useful to replace forall with /\? > > @t = type application, with the rule: > > (a :: forall x. b) @t :: (replace occurrences of x in b with t) How do you know how to apply this rule in general? For example, (a :: forall x y. x -> y) @t, would mean what? > -- the quantified type "x" gets packed into the data > -- and comes out when you pattern match on it > data Sealed s where > Sealed :: /\t. s t -> Sealed s By 'x' you mean 't' right? goodOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> > case sx of (Sealed @y pxy) -> > case (sy @y) of (Sealed @z qyz) -> > Sealed @z (f pxy qyz) You have the expression (Sealed @y pxy), but I don't understand what that signifies. Are you just saying that by doing a pattern match on 'sx' that you're going to bind the existentially quantified variable to 'y'? This notation confuses me, but I can happily accept that we are binding the existential type 'y' somewhere. Assuming, I understand that, correctly, the expression (Sealed @z qyz) is binding 'z' to an existential. Why do you say, (sy @y). What does that mean? That makes 'b' unify with 'y' that was bound in the first case? goodOrder works as I expect, so I'm happy with this. badOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> > -- in order to pattern-match on sy, we need to give it a type > -- so we just pick an arbitrary type "unknown" or "u" distinct > from any other type we know about > case (sy @u) of (Sealed @z quz) -> > case sx of (Sealed @y pxy) -> > Sealed @z (f pxy quz) -- doesn't typecheck! > > In the good order, you have already unpacked the existential for sx, > so you know what type to instantiate sy at. In the bad order, you > don't know what type to instantiate sy at. We instantiate 'u' to be the existential in sy. OK. But, my understanding is that 'u' is unconstrained at this point, we said, forall b. Sealed (q b), afterall. So, when we bind 'y' in the second case, what prevents 'u' from unifying with 'y'? For what it's worth, in my real program where this came up, sy was created by a recursive call like this: foo :: Sealed (p x) -> Sealed (q b) foo = do p <- blah q <- foo return (Sealed (f p q)) Because the b doesn't appear on the LHS of the function arrow, I understand it to have the same polymorphic properties as the 'forall b.' in the type signature of goodOrder and badOrder. Indeed, this example seems to re-enforce that. We had to reorder the binding of p and q to get this to type check. Thanks for the quick response, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/8d356329/attachment.htm From dagit at codersbase.com Mon Oct 6 17:30:42 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 17:27:06 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order In-Reply-To: References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> Message-ID: On Mon, Oct 6, 2008 at 2:27 PM, Jason Dagit wrote: > > For what it's worth, in my real program where this came up, sy was created > by a recursive call like this: > I guess it should have been more like this: blah :: Sealed (p x) foo :: Sealed (q b) foo = do p <- blah q <- foo return (Sealed (f p q)) Sorry for any confusion! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/358d3320/attachment.htm From anton at appsolutions.com Mon Oct 6 18:00:25 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Mon Oct 6 17:40:11 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EA79B3.9080202@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> <48EA79B3.9080202@btinternet.com> Message-ID: <48EA8A79.2020204@appsolutions.com> Andrew Coppin wrote: >> If so, I guess that means I have to somehow construct ResultSetT. Is >> there an easy way to do that, given that I already have ResultSet? I haven't been following this thread closely, so forgive if this was already discussed, but my understanding is that the answer is no, in general. In the paper "Monad Transformers and Modular Interpreters"[*], Section 8 ("Lifting Operations") touches on some of the issues. That's from 1995 - I don't know if any progress on this has been made since then, other than that a standard set of the most common monad transformers is now available. Anton [*] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.17.268 From rwbarton at math.harvard.edu Mon Oct 6 18:40:12 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Mon Oct 6 18:36:31 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EA79B3.9080202@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> <48EA79B3.9080202@btinternet.com> Message-ID: <20081006224012.GA9367@rwbarton.mit.edu> Hi Andrew, On Mon, Oct 06, 2008 at 09:48:51PM +0100, Andrew Coppin wrote: > data ResultSet x = Pack {unpack :: [[x]]} deriving (Eq) Your ResultSet monad is roughly equivalent to newtype Nat = Nat Int instance Monoid Nat where mempty = Nat 0 (Nat x) `mappend` (Nat y) = Nat (x+y) type ResultSet' = WriterT Nat [] -- ResultSet' x = [(x, Nat)] where unpack :: ResultSet' x -> [[x]] gives a list whose nth element is the list of alternatives whose "cost" (Nat data) is n (with trailing [] lists removed). Except that using [[x]] internally lets you be lazy about handling items of high cost. (This is kind of neat actually.) I'd therefore guess that if there is an associated monad transformer ResultSetT, it's similarly equivalent to ResultSetT' m x = WriterT Nat (ListT m x) where ListT is some version of "ListT done right". But on the other hand, as I understand "ListT done right", you can think of ListT m x as a "list" of xs where you have to perform an action in the m monad to get each successive value in the list. The equivalence converting ResultSet' to ResultSet sort of "tears up" the list in a way I'm not sure is compatible with inserting a monad like that. Once again, all this high-falutin' nonsense corresponds to really concrete questions about what you want your code to *actually do*. Consider your original problem > run :: State -> Foo -> Either ErrorType (ResultSet State) > > run_and :: State -> Foo -> Foo -> Either ErrorType (ResultSet State) > {- some Either-ified version of > run_and :: State -> Foo -> Foo -> ResultSet State > run_and s0 x y = do > s1 <- run s0 x > s2 <- run s1 y > return s2 > -} Say run s0 x returns many different possibilities s1 (with varying costs). And suppose run s1 y is a (Left err) for some of these s1 and a (Right whatever) for others. When should the overall result of run_and be a Left and when should it be a Right? And *which error* should you return if there's more than one Left? Do you really want to check whether every run s1 y is a (Right whatever)? In that case you are not gaining much from the laziness of ResultSet and might as well use ResultSet'. Until you decide the answer to questions of this kind, you can't know how to best structure your code. Regards, Reid Barton From briqueabraque at yahoo.com Mon Oct 6 19:55:18 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Mon Oct 6 19:51:53 2008 Subject: [Haskell-cafe] I'll do USB in Haskell - tips? Message-ID: Hi, I'll need to use a lot of USB at work and, after looking around, it seems there's no general USB code done. 'libusb' and 'openusb' do not seem ready enough so that wrapping them would be easier than writing from scratch. (If you think I am wrong until here and have time to write me your opinion, I'll value it a lot.) So: I would like to (try to) write a good implementation of USB access in Haskell. I would like it to be really general, so that we could use all of USB without need to resort to something else; available to all possible environments and operating systems; allow easy testing of USB clients, maybe using "fake" USB devices that could simulate problems; do that using Haskell code to directly access operating system API. I've read the appropriate chapters of USB 2.0 standard reference. I'll greatly appreciate any information you can give me: sugestions on what would be "the Haskell way" of doing USB; good technical information on how USB is implemented in different OSes; warnings on problems I may have; wishes of good luck :) I hope in one year I'll be able to post a message here saying Haskell is the greatest language to interface with USB devices. Thanks, Maur?cio From marco-oweber at gmx.de Mon Oct 6 19:55:44 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Mon Oct 6 19:52:12 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <48EA62D9.1020607@blueyonder.co.uk> References: <48EA62D9.1020607@blueyonder.co.uk> Message-ID: <20081006235544.GG22390@gmx.de> On Mon, Oct 06, 2008 at 08:11:21PM +0100, Dominic Steinitz wrote: > Not really a Haskell question but I'm not sure where else to go. > > What's the preferred method of converting a darcs repository to git? And > is there a way of converting from git to darcs? > > The reason I ask is that my colleague cannot get darcs to work on his > Windows box. If you have trouble you may also want to try the #darcs chat channel on irc.freenode.net.. Those people want to help if they can. You should also be able to find some info on haskell.org/ghc (use the search) because of the recent discussion about switching to git for ghc developement. By the way the cygwin git version did work best for me (due to file permissions.. git gui does'nt work though - maybe I've missed some options as well?) Marc From cgibbard at gmail.com Mon Oct 6 20:06:13 2008 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Oct 6 20:02:38 2008 Subject: [Haskell-cafe] a really juvenile question .. hehehehe ;^) In-Reply-To: <28012bc60810061107n11528912i373b7ff6a10492c@mail.gmail.com> References: <5ae4f2ba0810052235r122ac6f8h13875e7cb231876e@mail.gmail.com> <5ae4f2ba0810052304m7991ee65hb5c9c8313e15b82e@mail.gmail.com> <20081006071220.GE7973@scytale.galois.com> <89ca3d1f0810060558r71703b1ag72e01f4baabfb374@mail.gmail.com> <28012bc60810060619m2dfd208bp86c9b9960905c776@mail.gmail.com> <2f9b2d30810060710u412c54efqf77f7c9f5f02dad3@mail.gmail.com> <28012bc60810060730o354830a9od21c5e39aee94c6e@mail.gmail.com> <2f9b2d30810060948h5b54ce35le19dfad91b0c31b0@mail.gmail.com> <28012bc60810061107n11528912i373b7ff6a10492c@mail.gmail.com> Message-ID: <89ca3d1f0810061706p3601f48rbebf74983f963f5d@mail.gmail.com> 2008/10/6 Arnar Birgisson : > Ah, that's pretty neat and subtle. Now, say I have a type created with > data that has only one constructor. Couldn't the compiler optimize > away this unneccessary evaluation during pattern matching? I.e. it > would make what you just wrote implicit in that case. Or perhaps data > declarations with just one ctor should really be turned into newtypes > by the programmer? Well, the trouble is that because there are differences in the termination behaviour of programs depending on whether something is a newtype or a data with a single constructor, I think automatic conversion of one to the other is avoided. From ajb at spamcop.net Mon Oct 6 20:56:50 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Mon Oct 6 20:53:15 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: Message-ID: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> G'day all. Quoting John Van Enk : > I'm working on a Haskell based VPN. I can't think of any good names, so I'm > crowd sourcing it. The naming of code is a difficult matter, It isn't just one of your LAN party games; You may think at first I'm as mad as a hatter When I tell you, your code must have THREE DIFFERENT NAMES. First of all, there's the name that you use in publicity Such as Functional Forms, Nanocurses and HaRT, Such as Proof General Kit, vector-space, and hinotify, That will roll off the tongue and look good on slashdot. But I tell you, your code needs a name that's evoking, A name that inhabits the package namespace. Such as Text.PrettyPrint.HughesPJ, Data.ByteString, That's easily typed when importing MixedCase. But above and beyond, there's the name that's unique, And that is a name that is carefully picked. The one that's so mangled it may well be Greek; When it sits in slash-bin, it must never conflict. It's the name that will cause most dissent with your peers, Far, far more than the task it is meant to perform. It should work with your fingers, though not with your ears, So de-vowel-ified acronym soup is the norm. When you see a developer miffed and distracted, Tearing hair out in chunks or pacing without aim, They are greatly afflicted by anger protracted, Because somebody, somewhere, did not like the name. The simple, recognizable, Unrealizable, Deep, unattainable, singular Name. OK, having said that, I concur with those who have implicitly admitted that there are too many H's in the names of Haskell programs. I'd be tempted to pick a word starting with "lan" and put a "v" in front of it. My favourite VLANscape in particular. It sounds professional, and can be shortened to vlscape for the name of the executable. Cheers, Andrew Bromage From allbery at ece.cmu.edu Mon Oct 6 21:15:53 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Oct 6 21:12:23 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> References: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> Message-ID: On 2008 Oct 6, at 20:56, ajb@spamcop.net wrote: > Quoting John Van Enk : >> I'm working on a Haskell based VPN. I can't think of any good >> names, so I'm >> crowd sourcing it. > > (elided abuse of Old Possum) > I'd be tempted to pick a word starting with "lan" and put a "v" in > front > of it. My favourite VLANscape in particular. It sounds professional, I would advise against, as a VLAN is a very different beast from a VPN. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From vanenkj at gmail.com Mon Oct 6 21:19:17 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 21:15:42 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> Message-ID: Hmm... I like Securry, but I'm going to go ahead and shorten it to Scurry. I also like HaPN a lot. Any suggestions why either of these would be better than the other? Perhaps a third party candidate would be more appropriate? So... 1. Scurry 2. HaPN 3. ??? (bah, sorry Brandon, reply all, reply all reply all...) On Mon, Oct 6, 2008 at 9:15 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > On 2008 Oct 6, at 20:56, ajb@spamcop.net wrote: > >> Quoting John Van Enk : >> >>> I'm working on a Haskell based VPN. I can't think of any good names, so >>> I'm >>> crowd sourcing it. >>> >> >> (elided abuse of Old Possum) >> I'd be tempted to pick a word starting with "lan" and put a "v" in front >> of it. My favourite VLANscape in particular. It sounds professional, >> > > I would advise against, as a VLAN is a very different beast from a VPN. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/a8a49dc2/attachment.htm From 666wman at gmail.com Mon Oct 6 21:47:15 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 21:43:40 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <20081006235544.GG22390@gmx.de> References: <48EA62D9.1020607@blueyonder.co.uk> <20081006235544.GG22390@gmx.de> Message-ID: the mingw git worked flawlessly for me (and will be certainly a lot less of hassle, if one tries to remain cygwin-free). their version of git-gui also works (i didn't test it extensively). http://code.google.com/p/msysgit/ featuring an installer as well ;-) as for darcs, look here: http://wiki.darcs.net/DarcsWiki/CategoryBinaries#head-c7910dd98302946c671cf63cb62712589b392074 the darcsdir-w32 works fine without cygwin, just supply wget or curl .. On Tue, Oct 7, 2008 at 1:55 AM, Marc Weber wrote: > On Mon, Oct 06, 2008 at 08:11:21PM +0100, Dominic Steinitz wrote: > > Not really a Haskell question but I'm not sure where else to go. > > > > What's the preferred method of converting a darcs repository to git? And > > is there a way of converting from git to darcs? > > > > The reason I ask is that my colleague cannot get darcs to work on his > > Windows box. > If you have trouble you may also want to try the #darcs chat channel on > irc.freenode.net.. Those people want to help if they can. > > You should also be able to find some info on haskell.org/ghc (use the > search) > because of the recent discussion about switching to git for ghc > developement. By the way the cygwin git version did work best for me > (due to file permissions.. git gui does'nt work though - maybe I've > missed some options as well?) > > Marc > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/5fbe5804/attachment.htm From tutufan at gmail.com Mon Oct 6 22:06:37 2008 From: tutufan at gmail.com (Mike Coleman) Date: Mon Oct 6 22:03:02 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) Message-ID: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Hi, I could use a little help. I was looking through the Real World Haskell book and came across a trivial program for summing numbers in a file. They mentioned that that implementation was very slow, as it's based on String's, so I thought I'd try my hand at converting it to use lazy ByteString's. I've made some progress, but now I'm a little stuck because that module doesn't seem to have a 'read' method. There's a readInt method, which I guess I could use, but it returns a Maybe, and I don't see how I can easily strip that off. So: 1. Is there an easy way to strip off the Maybe that would allow an equivalently concise definition for sumFile? I can probably figure out how to do it with pattern matching and a separate function--I'm just wondering if there's a more concise way. 2. Why doesn't ByteString implement 'read'? Is it just that this function (like 'input' in Python) isn't really very useful for real programs? 3. Why doesn't ByteString implement 'readDouble', etc.? That is, why are Int and Integer treated specially? Do I not need readDouble? Thanks, Mike -- lazy version (doesn't compile) -- file: ch08/SumFile.hs import qualified Data.ByteString.Lazy.Char8 as L main = do contents <- L.getContents print (sumFile contents) where sumFile = sum . map read . L.words From dagit at codersbase.com Mon Oct 6 22:21:58 2008 From: dagit at codersbase.com (Jason Dagit) Date: Mon Oct 6 22:18:22 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: On Mon, Oct 6, 2008 at 7:06 PM, Mike Coleman wrote: > Hi, > > I could use a little help. I was looking through the Real World > Haskell book and came across a trivial program for summing numbers in > a file. They mentioned that that implementation was very slow, as > it's based on String's, so I thought I'd try my hand at converting it > to use lazy ByteString's. I've made some progress, but now I'm a > little stuck because that module doesn't seem to have a 'read' method. > > There's a readInt method, which I guess I could use, but it returns a > Maybe, and I don't see how I can easily strip that off. > > So: > > 1. Is there an easy way to strip off the Maybe that would allow an > equivalently concise definition for sumFile? I can probably figure > out how to do it with pattern matching and a separate function--I'm > just wondering if there's a more concise way. I'm not a ByteString expert, but there should be an easy way to solve this issue of Maybe. If you go to hoogle (http://www.haskell.org/hoogle/) and type this: [Maybe a] -> [a] it says: Data.Maybe .catMaybes:: [Maybe a] -> [a] As the top search result. This means that you can convert any list of maybes into a list of what you want. It just tosses out the Nothings. > > 2. Why doesn't ByteString implement 'read'? Is it just that this > function (like 'input' in Python) isn't really very useful for real > programs? I think probably for things more complex than parsing ints it's best to make your own parser? I seem to recall that someone was working on a library of parsing functions based on bytestring? Maybe someone else can comment? 3. Why doesn't ByteString implement 'readDouble', etc.? That is, why > are Int and Integer treated specially? Do I not need readDouble? I think readInt was mostly implemented because integer reading was needed a lot for benchmarks and programming challenge sites and people noticed it was way slower than needed so someone put in the effort it optimize it. Once it was optimized, that must have satisfied the need for fast number reading. I would agree that at least for Prelude types it would be nice to have efficient bytestring based parsers. Do we have Read/Show classes specifically for working in bytestrings? Maybe that's what the world needs in the bytestring api. Then again, I'm not really qualified to comment :) For all I know it already exists. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/707cb9de/attachment.htm From dons at galois.com Mon Oct 6 22:31:56 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 22:28:12 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: <20081007023156.GA13471@scytale.galois.com> dagit: > As the top search result. > > This means that you can convert any list of maybes into a list of what you > want. It just tosses out the Nothings. > > 2. Why doesn't ByteString implement 'read'? Is it just that this > function (like 'input' in Python) isn't really very useful for real > programs? > > I think probably for things more complex than parsing ints it's best to > make your own parser? I seem to recall that someone was working on a > library of parsing functions based on bytestring? Maybe someone else can > comment? > > 3. Why doesn't ByteString implement 'readDouble', etc.? That is, why > are Int and Integer treated specially? Do I not need readDouble? > > I think readInt was mostly implemented because integer reading was needed > a lot for benchmarks and programming challenge sites and people noticed it > was way slower than needed so someone put in the effort it optimize it. > Once it was optimized, that must have satisfied the need for fast number > reading. There's readInt, readInteger and readDouble now, as primitives, because people ask for them. > I would agree that at least for Prelude types it would be nice to have > efficient bytestring based parsers. Do we have Read/Show classes > specifically for working in bytestrings? Maybe that's what the world > needs in the bytestring api. Then again, I'm not really qualified to > comment :) For all I know it already exists. > Data.Binary is the generic parser for bytestrings. A higher level one for parsing text (e.g. atto-parsec), might be worthwhile. -- Don From daniel.is.fischer at web.de Mon Oct 6 22:35:15 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Oct 6 22:29:31 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: <200810070435.15912.daniel.is.fischer@web.de> Am Dienstag, 7. Oktober 2008 04:21 schrieb Jason Dagit: > On Mon, Oct 6, 2008 at 7:06 PM, Mike Coleman wrote: > > Hi, > > > > I could use a little help. I was looking through the Real World > > Haskell book and came across a trivial program for summing numbers in > > a file. They mentioned that that implementation was very slow, as > > it's based on String's, so I thought I'd try my hand at converting it > > to use lazy ByteString's. I've made some progress, but now I'm a > > little stuck because that module doesn't seem to have a 'read' method. > > > > There's a readInt method, which I guess I could use, but it returns a > > Maybe, and I don't see how I can easily strip that off. > > > > So: > > > > 1. Is there an easy way to strip off the Maybe that would allow an > > equivalently concise definition for sumFile? I can probably figure > > out how to do it with pattern matching and a separate function--I'm > > just wondering if there's a more concise way. > > I'm not a ByteString expert, but there should be an easy way to solve this > issue of Maybe. > > If you go to hoogle (http://www.haskell.org/hoogle/) and type this: > [Maybe a] -> [a] > it says: > Data.Maybee.html> > .catMaybese.html#v:catMaybes>:: [Maybe > a] -> > [a]v:catMaybes> > > As the top search result. > > This means that you can convert any list of maybes into a list of what you > want. It just tosses out the Nothings. Since readInt returns a Maybe (Int,ByteString), Data.List.unfoldr would be a better fit for his needs. The bytestring-lexing package (http://hackage.haskell.org/packages/archive/bytestring-lexing/0.1.2/doc/html/Data-ByteString-Lex-Double.html) provides readDouble, which is also pretty fast, I think. > > > 2. Why doesn't ByteString implement 'read'? Is it just that this > > function (like 'input' in Python) isn't really very useful for real > > programs? > > I think probably for things more complex than parsing ints it's best to > make your own parser? I seem to recall that someone was working on a > library of parsing functions based on bytestring? Maybe someone else can > comment? At least parsec 3.0.0 has ByteString parsing modules (I've never used it, so I don't know how well they work). IIRC, there's a plan to expand the bytestring-lexing package, too. > > 3. Why doesn't ByteString implement 'readDouble', etc.? That is, why > > > are Int and Integer treated specially? Do I not need readDouble? > > I think readInt was mostly implemented because integer reading was needed a > lot for benchmarks and programming challenge sites and people noticed it > was way slower than needed so someone put in the effort it optimize it. > Once it was optimized, that must have satisfied the need for fast number > reading. More's underway, readDouble already delivered. > > I would agree that at least for Prelude types it would be nice to have > efficient bytestring based parsers. Do we have Read/Show classes > specifically for working in bytestrings? Maybe that's what the world needs > in the bytestring api. Then again, I'm not really qualified to comment :) > For all I know it already exists. partially. > > Jason From gwern0 at gmail.com Mon Oct 6 22:22:21 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Oct 6 22:29:48 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: References: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> Message-ID: <20081007022221.GA17633@craft> On 2008.10.06 21:19:17 -0400, John Van Enk scribbled 4.3K characters: > Hmm... > > I like Securry, but I'm going to go ahead and shorten it to Scurry. > I also like HaPN a lot. > > Any suggestions why either of these would be better than the other? Perhaps a third party > candidate would be more appropriate? > > So... > 1. Scurry > 2. HaPN > 3. ??? > > (bah, sorry Brandon, reply all, reply all reply all...) Scurry has my vote. It is cute, it implies the software is busy and useful, it has the requisite subtle FP joke, and it doesn't seem to be already used. -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/809f2b21/attachment.bin From 666wman at gmail.com Mon Oct 6 23:07:58 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 23:04:23 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: a slight modification to compile it : change: where sumFile = sum . map read . L.words to : where sumFile = sum . map (read . L.unpack) . L.words but it's actually _slower_ than the non-bytestring version. i did a little test, three versions of the same script and manufactured meself a ~50 MB file containing 1M of ints 0-65535. and replaced the sum with length for obvious reasons. module Main where import qualified Data.ByteString.Lazy.Char8 as L main1 = do contents <- L.getContents print (sumFile contents) where sumFile = length . map L.readInt . L.words main2 = do contents <- getContents print (sumFile contents) where sumFile = length . map (read :: String -> Int) . words main3 = do contents <- L.getContents print (sumFile contents) where sumFile = length . map ((read :: String -> Int) . L.unpack) . L.words time main3 < nums real 0m22.421s user 0m0.031s sys 0m0.000s time main2 < nums real 0m14.296s user 0m0.015s sys 0m0.016s time main1 < nums real 0m22.078s user 0m0.015s sys 0m0.015s i expected the conversions (L.unpack in main3) to kill the performance a little, but not to make it nearly two times as slow. and i certainly did not expect that even the version using the bytestring readInt to be as slow ... did I do something wrong ? On Tue, Oct 7, 2008 at 4:06 AM, Mike Coleman wrote: > Hi, > > I could use a little help. I was looking through the Real World > Haskell book and came across a trivial program for summing numbers in > a file. They mentioned that that implementation was very slow, as > it's based on String's, so I thought I'd try my hand at converting it > to use lazy ByteString's. I've made some progress, but now I'm a > little stuck because that module doesn't seem to have a 'read' method. > > There's a readInt method, which I guess I could use, but it returns a > Maybe, and I don't see how I can easily strip that off. > > So: > > 1. Is there an easy way to strip off the Maybe that would allow an > equivalently concise definition for sumFile? I can probably figure > out how to do it with pattern matching and a separate function--I'm > just wondering if there's a more concise way. > > 2. Why doesn't ByteString implement 'read'? Is it just that this > function (like 'input' in Python) isn't really very useful for real > programs? > > 3. Why doesn't ByteString implement 'readDouble', etc.? That is, why > are Int and Integer treated specially? Do I not need readDouble? > > Thanks, > Mike > > > -- lazy version (doesn't compile) > > -- file: ch08/SumFile.hs > > import qualified Data.ByteString.Lazy.Char8 as L > > main = do > contents <- L.getContents > print (sumFile contents) > where sumFile = sum . map read . L.words > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/6527acb9/attachment-0001.htm From dons at galois.com Mon Oct 6 23:12:23 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 23:08:35 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: <20081007031223.GB13471@scytale.galois.com> 666wman: > a slight modification to compile it : > > change: > where sumFile = sum . map read . L.words > to : > where sumFile = sum . map (read . L.unpack) . L.words > > but it's actually _slower_ than the non-bytestring version. Never unpack a bytestring. import qualified Data.ByteString.Lazy.Char8 as S main = print . go 0 =<< S.getContents where go n s = case S.readInt s of Nothing -> n Just (k,t) -> go (n+k) (S.tail t) Assuming you're reading int, integers or doubles. From tutufan at gmail.com Mon Oct 6 23:14:00 2008 From: tutufan at gmail.com (Mike Coleman) Date: Mon Oct 6 23:10:25 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: <3c6c07c20810062014v6872c7f2gc8991e30a5e16651@mail.gmail.com> Thanks for your replies. Hoogle is pretty cool--I didn't know about that. I ended up with this, which is pretty close to the original (it will also bomb if given non-integer input): import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.Maybe as M main = do contents <- L.getContents print (sumFile contents) where sumFile = sum . map (fst . M.fromJust . L.readInt) . L.words One further problem I've encountered: My Haskell program runs under 'runghc', but I get a link error when compiling it (GHC 6.8.2, latest Ubuntu). Any suggestions? $ ghc -o LazySumFile LazySumFile.hs LazySumFile.o: In function `sOz_info': (.text+0x200): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzyziChar8_readInt_closure' LazySumFile.o: In function `sOF_info': (.text+0x35d): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzyziChar8_words_closure' LazySumFile.o: In function `sRF_info': (.text+0x4d7): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzy_getContents_closure' LazySumFile.o: In function `sRF_info': (.text+0x64f): undefined reference to `__stginit_bytestringzm0zi9zi0zi1_DataziByteStringziLazzyziChar8_' LazySumFile.o: In function `sOF_srt': (.data+0xa0): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzyziChar8_words_closure' LazySumFile.o: In function `sOF_srt': (.data+0xa8): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzyziChar8_readInt_closure' LazySumFile.o: In function `rOh_closure': (.data+0x110): undefined reference to `bytestringzm0zi9zi0zi1_DataziByteStringziLazzy_getContents_closure' collect2: ld returned 1 exit status From magicloud.magiclouds at gmail.com Mon Oct 6 23:16:54 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Mon Oct 6 23:13:48 2008 Subject: [Haskell-cafe] After upgrade bytestring to 0.9.1.3, my program cannot run. Message-ID: <48EAD4A6.5060008@gmail.com> Just a simple text process program. When I runhaskell it. I got: GHCi runtime linker: fatal error: I found a duplicate definition for symbol fps_minimum whilst processing object file ~/.cabal/lib/bytestring-0.9.1.3/ghc-6.8.3/HSbytestring-0.9.1.3.o This could be caused by: * Loading two different object files which export the same symbol * Specifying the same object file twice on the GHCi command line * An incorrect `package.conf' entry, causing some object to be loaded twice. GHCi cannot safely continue in this situation. Exiting now. Sorry. From 666wman at gmail.com Mon Oct 6 23:17:45 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 23:14:09 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <20081007031223.GB13471@scytale.galois.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> Message-ID: the problem is that using readInt is actually _as slow_, at least using my test script :-(( On Tue, Oct 7, 2008 at 5:12 AM, Don Stewart wrote: > 666wman: > > a slight modification to compile it : > > > > change: > > where sumFile = sum . map read . L.words > > to : > > where sumFile = sum . map (read . L.unpack) . L.words > > > > but it's actually _slower_ than the non-bytestring version. > > Never unpack a bytestring. > > import qualified Data.ByteString.Lazy.Char8 as S > > main = print . go 0 =<< S.getContents > where > go n s = case S.readInt s of > Nothing -> n > Just (k,t) -> go (n+k) (S.tail t) > > Assuming you're reading int, integers or doubles. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/6f05f2c4/attachment.htm From dons at galois.com Mon Oct 6 23:19:15 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 23:15:29 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> Message-ID: <20081007031915.GC13471@scytale.galois.com> Hmm. How are you compiling it? Using bytestring 0.9.1.x ? Should be fast, http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all Assuming you're turning on optimisations ( ghc -O2 ) -- Don 666wman: > the problem is that using readInt is actually _as slow_, at least using my > test script :-(( > > On Tue, Oct 7, 2008 at 5:12 AM, Don Stewart <[1]dons@galois.com> wrote: > > 666wman: > > a slight modification to compile it : > > > > change: > > where sumFile = sum . map read . L.words > > to : > > where sumFile = sum . map (read . L.unpack) . L.words > > > > but it's actually _slower_ than the non-bytestring version. > > Never unpack a bytestring. > > import qualified Data.ByteString.Lazy.Char8 as S > > main = print . go 0 =<< S.getContents > where > go n s = case S.readInt s of > Nothing -> n > Just (k,t) -> go (n+k) (S.tail t) > > Assuming you're reading int, integers or doubles. > > References > > Visible links > 1. mailto:dons@galois.com From dons at galois.com Mon Oct 6 23:19:58 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 23:16:13 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <3c6c07c20810062014v6872c7f2gc8991e30a5e16651@mail.gmail.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <3c6c07c20810062014v6872c7f2gc8991e30a5e16651@mail.gmail.com> Message-ID: <20081007031958.GD13471@scytale.galois.com> tutufan: > Thanks for your replies. Hoogle is pretty cool--I didn't know about that. > > I ended up with this, which is pretty close to the original (it will > also bomb if given non-integer input): > > import qualified Data.ByteString.Lazy.Char8 as L > import qualified Data.Maybe as M > > main = do > contents <- L.getContents > print (sumFile contents) > where sumFile = sum . map (fst . M.fromJust . L.readInt) . L.words > > > One further problem I've encountered: My Haskell program runs under > 'runghc', but I get a link error when compiling it (GHC 6.8.2, latest > Ubuntu). Any suggestions? Oh wow, runghc is an interpreter. It is on average about 30x slower than compiled code. To compile, try something like: ghc -O2 --make A.hs And enjoy the native codes. :) -- Don From dons at galois.com Mon Oct 6 23:21:27 2008 From: dons at galois.com (Don Stewart) Date: Mon Oct 6 23:17:39 2008 Subject: [Haskell-cafe] After upgrade bytestring to 0.9.1.3, my program cannot run. In-Reply-To: <48EAD4A6.5060008@gmail.com> References: <48EAD4A6.5060008@gmail.com> Message-ID: <20081007032127.GE13471@scytale.galois.com> magicloud.magiclouds: > Just a simple text process program. When I runhaskell it. I got: > > GHCi runtime linker: fatal error: I found a duplicate definition for symbol > fps_minimum > whilst processing object file > ~/.cabal/lib/bytestring-0.9.1.3/ghc-6.8.3/HSbytestring-0.9.1.3.o > This could be caused by: > * Loading two different object files which export the same symbol > * Specifying the same object file twice on the GHCi command line > * An incorrect `package.conf' entry, causing some object to be > loaded twice. > GHCi cannot safely continue in this situation. Exiting now. Sorry. > This likely means your program is using some package A, that has been compiled against (and loading) old bytestring, but also loading the new bytestring. The solution is to recompile whatever your library 'A' is that is trying to use the old bytestring. Or try compiling it , with ghc --make -- Don From 666wman at gmail.com Mon Oct 6 23:36:22 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 23:32:47 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <20081007031915.GC13471@scytale.galois.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> Message-ID: new figures, after updating bytestring (0.9.0.1.1 -> 0.9.1.2) && using -O2 time Main < nums real 0m2.531s user 0m0.015s sys 0m0.015s time Main2 < nums real 0m13.999s user 0m0.015s sys 0m0.015s time Main3 < nums real 0m2.796s user 0m0.015s sys 0m0.015s thats more like it, even the unpacking didn't hurt so much. the morals: "Thou shalt update your libraries" & "Thou shalt not forget to turn on optimizations" before bitching it's too slow ;-))) thx On Tue, Oct 7, 2008 at 5:19 AM, Don Stewart wrote: > Hmm. How are you compiling it? Using bytestring 0.9.1.x ? > > Should be fast, > > http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all > > Assuming you're turning on optimisations ( ghc -O2 ) > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/cfd7e892/attachment.htm From 666wman at gmail.com Mon Oct 6 23:54:44 2008 From: 666wman at gmail.com (wman) Date: Mon Oct 6 23:51:08 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> Message-ID: just for the kicks i tried the new version of bytestring without -O2 and the results were even worse: time Main1 < nums real 0m40.092s user 0m0.015s sys 0m0.015s time Main3 < nums real 0m41.405s user 0m0.015s sys 0m0.015s it got pwned even by this very naive ruby scipt (which, btw, chewed through some ~600 MB of memory ;-)) File.open("nums","r") do |f| puts((f.read.split.each {|x| x.to_i }).length) end time ruby nums.rb real 0m21.609s user 0m0.015s sys 0m0.015s so it probably can't be stressed enough: repeat "-O2" and now seriously: is there a reason why -O2 shouldn't be made the default (and allowing to turn off optimizations by -O0 perhaps) ? On Tue, Oct 7, 2008 at 5:36 AM, wman <666wman@gmail.com> wrote: > new figures, after updating bytestring (0.9.0.1.1 -> 0.9.1.2) && using -O2 > > time Main < nums > real 0m2.531s > user 0m0.015s > sys 0m0.015s > > time Main2 < nums > real 0m13.999s > user 0m0.015s > sys 0m0.015s > > time Main3 < nums > real 0m2.796s > user 0m0.015s > sys 0m0.015s > > thats more like it, even the unpacking didn't hurt so much. > > the morals: "Thou shalt update your libraries" & "Thou shalt not forget to > turn on optimizations" before bitching it's too slow ;-))) > > thx > > On Tue, Oct 7, 2008 at 5:19 AM, Don Stewart wrote: > >> Hmm. How are you compiling it? Using bytestring 0.9.1.x ? >> >> Should be fast, >> >> http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all >> >> Assuming you're turning on optimisations ( ghc -O2 ) >> >> -- Don >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/97bb534a/attachment.htm From allbery at ece.cmu.edu Mon Oct 6 23:59:06 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Oct 6 23:55:32 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> Message-ID: On 2008 Oct 6, at 23:54, wman wrote: > just for the kicks i tried the new version of bytestring without -O2 > and the results were even worse: Yep, ByteString does a lot of stuff that is really bad when GHC isn't performing stream fusion --- but when it is, the code compiles down to tight machine code that can rival C. > is there a reason why -O2 shouldn't be made the default (and > allowing to turn off optimizations by -O0 perhaps) ? -O2 breaks on some platforms, I think. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081006/e9c9fd8b/attachment.htm From vanenkj at gmail.com Tue Oct 7 00:02:48 2008 From: vanenkj at gmail.com (John Van Enk) Date: Mon Oct 6 23:59:11 2008 Subject: [Haskell-cafe] Name for Haskell based VPN Client/Server In-Reply-To: <20081007022221.GA17633@craft> References: <20081006205650.s244l0e89wk4gow8-nwo@webmail.spamcop.net> <20081007022221.GA17633@craft> Message-ID: I've settled on scurry. Those of you interested in seeing the cabalized "Works For Me Alpha" version can check out the Google Code page below. http://code.google.com/p/scurry/ Again, suggestions/comments/hatemail are encouraged. /jve On Mon, Oct 6, 2008 at 10:22 PM, Gwern Branwen wrote: > On 2008.10.06 21:19:17 -0400, John Van Enk scribbled > 4.3K characters: > > Hmm... > > > > I like Securry, but I'm going to go ahead and shorten it to Scurry. > > I also like HaPN a lot. > > > > Any suggestions why either of these would be better than the other? > Perhaps a third party > > candidate would be more appropriate? > > > > So... > > 1. Scurry > > 2. HaPN > > 3. ??? > > > > (bah, sorry Brandon, reply all, reply all reply all...) > > Scurry has my vote. It is cute, it implies the software is busy and useful, > it has the requisite subtle FP joke, and it doesn't seem to be already used. > > -- > gwern > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEAREKAAYFAkjqx90ACgkQvpDo5Pfl1oL8FwCfTSEW4BtCZM+wuWQiQ98NPCnv > atEAnRXekljUuC9VKqnF+ixX+UiQXNSO > =kk9h > -----END PGP SIGNATURE----- > > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/14fcf761/attachment.htm From tutufan at gmail.com Tue Oct 7 00:17:01 2008 From: tutufan at gmail.com (Mike Coleman) Date: Tue Oct 7 00:14:18 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <20081007031958.GD13471@scytale.galois.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <3c6c07c20810062014v6872c7f2gc8991e30a5e16651@mail.gmail.com> <20081007031958.GD13471@scytale.galois.com> Message-ID: <3c6c07c20810062117t57321538k2bd103f6a81f5bff@mail.gmail.com> On Mon, Oct 6, 2008 at 10:19 PM, Don Stewart wrote: > To compile, try something like: > > ghc -O2 --make A.hs That did the trick--thanks. For input large enough to be a good test, this is I/O-bound on my laptop (the speed of the compiled and interpreted versions are almost identical), so I'll have to try it on a bigger machine tomorrow. Mike From dons at galois.com Tue Oct 7 00:27:52 2008 From: dons at galois.com (Don Stewart) Date: Tue Oct 7 00:24:06 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> Message-ID: <20081007042752.GG13471@scytale.galois.com> 666wman: > just for the kicks i tried the new version of bytestring without -O2 and > the results were even worse: Note that without -O or -O2 no strictness analysis is performed. So that tail recursive loop ... won't be. You could try -Onot -fstrictness just for kicks, to see why strictness analysis is important when writing in a tail recursive style. -- Don From 666wman at gmail.com Tue Oct 7 00:44:48 2008 From: 666wman at gmail.com (wman) Date: Tue Oct 7 00:41:12 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <20081007042752.GG13471@scytale.galois.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> <20081007042752.GG13471@scytale.galois.com> Message-ID: ghc -Onot -fstrictness --make Main1.hs && ghc -Onot -fstrictness --make Main2.hs && ghc -Onot -fstrictness --make Main3.hs time Main1 < nums real 0m39.530s user 0m0.015s sys 0m0.030s time Main2 < nums real 0m14.078s user 0m0.015s sys 0m0.015s time Main3.exe < nums real 0m41.342s user 0m0.015s sys 0m0.015s still, i'm going to google up strictness analysis to at least know what made no difference in this case ;-) btw, why is the example #2 ( http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=ghc&id=2) (which kicks collective asses of all other participants) not considered in the shootout ? Too much optimizations ? On Tue, Oct 7, 2008 at 6:27 AM, Don Stewart wrote: > 666wman: > > just for the kicks i tried the new version of bytestring without -O2 > and > > the results were even worse: > > Note that without -O or -O2 no strictness analysis is performed. So that > tail recursive loop ... won't be. You could try -Onot -fstrictness just > for kicks, to see why strictness analysis is important when writing in a > tail recursive style. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/cca99c9f/attachment.htm From dons at galois.com Tue Oct 7 00:50:35 2008 From: dons at galois.com (Don Stewart) Date: Tue Oct 7 00:46:49 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> <20081007042752.GG13471@scytale.galois.com> Message-ID: <20081007045035.GA13926@scytale.galois.com> 666wman: > ghc -Onot -fstrictness --make Main1.hs && ghc -Onot -fstrictness --make > Main2.hs && ghc -Onot -fstrictness --make Main3.hs > > time Main1 < nums > real 0m39.530s > user 0m0.015s > sys 0m0.030s > > time Main2 < nums > real 0m14.078s > user 0m0.015s > sys 0m0.015s > > time Main3.exe < nums > real 0m41.342s > user 0m0.015s > sys 0m0.015s > > still, i'm going to google up strictness analysis to at least know what > made no difference in this case ;-) Oh, that's interesting. Did they actually recompile? (you used -fforce-recomp). Otherwise, might be an idea to use hpaste.org to paste teh Main1,2,3 source code, since I think people reading don't know what is represented in each program at this point. -- Don From gtener at gmail.com Tue Oct 7 00:52:44 2008 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Tue Oct 7 00:49:09 2008 Subject: [Haskell-cafe] I'll do USB in Haskell - tips? In-Reply-To: References: Message-ID: <220e47b40810062152j5607ba44x8cdcde9b7a2c5ed0@mail.gmail.com> On Tue, Oct 7, 2008 at 01:55, Mauricio wrote: > Hi, > > I'll need to use a lot of USB at work and, after > looking around, it seems there's no general USB > code done. 'libusb' and 'openusb' do not seem > ready enough so that wrapping them would be easier > than writing from scratch. (If you think I am > wrong until here and have time to write me your > opinion, I'll value it a lot.) Have a look at libusb version 1.0 API. It looks pretty promising: http://libusb.wiki.sourceforge.net/Libusb1.0 All best Christopher Skrz?tnicki From 666wman at gmail.com Tue Oct 7 02:34:05 2008 From: 666wman at gmail.com (wman) Date: Tue Oct 7 02:30:29 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <20081007042752.GG13471@scytale.galois.com> <20081007045035.GA13926@scytale.galois.com> <20081007050552.GB13926@scytale.galois.com> <20081007060447.GA14120@scytale.galois.com> Message-ID: as usual, i forgot to use the magical "reply to all" and under the impression I'm still talking to the list had bothered dons personally (heresy/sacrilege/deathwish , i know) to rectify it a bit at least, i'm posting a summary, in hopes someone find it useful. ---------------------------- -- this doesn't work - space leak no matter which optimizations you use, with -O2 it crashes in 5 secs instead in 75 ;-) import qualified Data.ByteString.Lazy.Char8 as S main = print . go 0 =<< S.getContents where go n s = case S.readInt s of Nothing -> n Just (k,t) -> go (n+k) (S.tail t) -- slightly stricter version, notice those ! before parameters in go declaration and the fancy -XBangPatterns option to ghc which it requires ;-) -- let dons_bstr.hs = import qualified Data.ByteString.Lazy.Char8 as S main = print . go 0 =<< S.getContents where go !n !s = case S.readInt s of Nothing -> n Just (k,t) -> go (n+k) (S.tail t) ghc -XBangPatterns --make dons_bstr.hs time dons_bstr < nums real 1m8.686s user 0m0.015s sys 0m0.031s ghc -XBangPatterns -Onot -fstrictness --make dons_bstr.hs time dons_bstr.exe < nums real 1m10.607s user 0m0.031s sys 0m0.015s ghc -XBangPatterns -O2 --make dons_bstr.hs time dons_bstr.exe < nums real 0m1.500s user 0m0.015s sys 0m0.031s so althought the -fstrictness still seems to have no effect in this case, using -O2 the dons version is ~2 times faster then the bytestring/readInt version -O2 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/243932a8/attachment.htm From martindemello at gmail.com Tue Oct 7 02:37:20 2008 From: martindemello at gmail.com (Martin DeMello) Date: Tue Oct 7 02:33:44 2008 Subject: [Haskell-cafe] Model-driven development (was: Haskell participting in big science like CERN Hadrian...) In-Reply-To: References: <5ae4f2ba0810030007w24a1884bya4c0cea7101e1243@mail.gmail.com> <2d3641330810030347k5bd37891sdf506584134ad01a@mail.gmail.com> <814617240810030629w1f1c1e38uc887fd4ee681264a@mail.gmail.com> <20081003193835.GD26436@scytale.galois.com> <20081003213953.1u7cs5qp9ccgk08g-nwo@webmail.spamcop.net> Message-ID: 2008/10/4 Jason Dagit : > 3) Write a python generating EDSL in Haskell > strong arguements against it. The main problem with #3, is that if I share > code with other devs they have to learn Haskell and my EDSL since they won't > be able to just hack the generated python, similar problem with #4. Also, An option is to generate python via an edsl, and use the object oriented trick of overriding the generated code in a separate file. I've done that fairly successfully when generating java from a ruby edsl and some templates, for example. martin From neil.mitchell.2 at credit-suisse.com Tue Oct 7 03:33:43 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Tue Oct 7 03:30:41 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <48EA6FF1.6040607@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> > Actually, I was thinking more along the lines of > Data.Traversable.sequence, which has > > sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) > > > Are you expecting c1 (:: * -> * -> *) to unify with [] (:: * -> *)? > > That seems kind incorrect at the very last. Additionally, > those types > > don't look all that close. > > > > Well, as I said, replacing one term with another transforms > one signature into the other. I guess you can't curry type > constructors as easily as functions - or at least, Hoogle > currently doesn't like it. Yes, currying of type constructors is much less common, and entirely unsupported by Hoogle. Is there a general need for Hoogle to deal with curried type constructors? I'd not really considered it significantly. > > But, let's briefly consider unification (and why Hoogle > doesn't used > > it). Consider the search: > > > > Eq a => [(a,b)] -> a -> b > > > > What the user wants is lookup, which sadly doesn't unify. However, > > undefined unifies perfectly. > > > > I see... > > I notice that x -> y doesn't unify with y -> x in any way, > shape or form, but Hoogle has absolutely no problem with > that. Hoogle has a problem with it, but not a severe problem. If you use the command line version you can type --verbose to get a list of the penalty points Hoogle has applied to a match. > What *does* Hoogle actually use for matching? Just a > set of huristics and a metric for how "similar" two > signatures are so it can order by approximate similarity? > Or is it something more scientific than that? It's more scientific than that, see http://www.wellquite.org/anglohaskell2008/ There will be a paper on Hoogle type matching at some point! Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From kr.angelov at gmail.com Tue Oct 7 04:11:22 2008 From: kr.angelov at gmail.com (Krasimir Angelov) Date: Tue Oct 7 04:07:48 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <48EA62D9.1020607@blueyonder.co.uk> References: <48EA62D9.1020607@blueyonder.co.uk> Message-ID: I use darcs on Windows every day and it works well. The only problem is that it is not very usable if you access your repository via SSH and the authentication is via password. On Mon, Oct 6, 2008 at 9:11 PM, Dominic Steinitz wrote: > Not really a Haskell question but I'm not sure where else to go. > > What's the preferred method of converting a darcs repository to git? And > is there a way of converting from git to darcs? > > The reason I ask is that my colleague cannot get darcs to work on his > Windows box. > > Thanks, Dominic. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue Oct 7 04:13:42 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Oct 7 04:10:06 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order In-Reply-To: References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> Message-ID: <2f9b2d30810070113t45b833a4pa4fd8aa991ff944a@mail.gmail.com> On Mon, Oct 6, 2008 at 10:27 PM, Jason Dagit wrote: > Why is useful to replace forall with /\? To make it look more like a capital lambda, just like \ is notation for lambda. It's a lambda abstraction over a type instead of a value; that's how polymorphism works in GHC's core language. >> @t = type application, with the rule: >> >> (a :: forall x. b) @t :: (replace occurrences of x in b with t) > > How do you know how to apply this rule in general? > > For example, (a :: forall x y. x -> y) @t, would mean what? As written, (a :: forall x y. x -> y) @t :: (forall y. t -> y) But it doesn't matter, as you can write: /\y. /\x. (a :: forall x y. x -> y) @y @x :: forall y x. x -> y which allows you to arbitrarily reorder the foralls; the compiler does this when it wants to instantiate a variable in the middle of a group of foralls. This is similar to flip f x y = f y x which allows you to reorder the arguments of a function. >> -- the quantified type "x" gets packed into the data >> -- and comes out when you pattern match on it >> data Sealed s where >> Sealed :: /\t. s t -> Sealed s > > By 'x' you mean 't' right? Yes, oops. Although it doesn't matter because you can rename bound variables, which is what I did when writing the message; I just forgot to update the documentation! :) >> goodOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> >> case sx of (Sealed @y pxy) -> >> case (sy @y) of (Sealed @z qyz) -> >> Sealed @z (f pxy qyz) > > You have the expression (Sealed @y pxy), but I don't understand what that > signifies. Are you just saying that by doing a pattern match on 'sx' that > you're going to bind the existentially quantified variable to 'y'? This > notation confuses me, but I can happily accept that we are binding the > existential type 'y' somewhere. It's just like any other data constructor/destructor; it's just that the constructor for Sealed takes an additional argument: the type that the existential is bound at. So when you pattern match on it, you get that type back out. > Assuming, I understand that, correctly, the expression (Sealed @z qyz) is > binding 'z' to an existential. Why do you say, (sy @y). What does that > mean? That makes 'b' unify with 'y' that was bound in the first case? Yes, that's correct. > goodOrder works as I expect, so I'm happy with this. > >> badOrder = \sx :: Sealed (p x) -> \sy :: (/\b. Sealed (q b)) -> >> -- in order to pattern-match on sy, we need to give it a type >> -- so we just pick an arbitrary type "unknown" or "u" distinct >> from any other type we know about >> case (sy @u) of (Sealed @z quz) -> >> case sx of (Sealed @y pxy) -> >> Sealed @z (f pxy quz) -- doesn't typecheck! >> >> In the good order, you have already unpacked the existential for sx, >> so you know what type to instantiate sy at. In the bad order, you >> don't know what type to instantiate sy at. > > We instantiate 'u' to be the existential in sy. OK. But, my understanding > is that 'u' is unconstrained at this point, we said, forall b. Sealed (q b), > afterall. So, when we bind 'y' in the second case, what prevents 'u' from > unifying with 'y'? Sort of, but not exactly. Here's an example at the value level: f x = (5 * x, \y -> y + x) g x = case f x of (v, g) -> \y -> (v, g y) h y = case f ?? of (v, g) -> \x -> plug in x to the f above, then (v, g y) Your "badorder" is similar to h; you have to instantiate the type variable before you can evaluate the case statement. You may think it doesn't matter, because you could instantiate it to anything after the fact, but it's possible that the result of the case statement depends on the choice of instantiation for sy; consider if sy had an additional constraint: > Sealed (fromInteger) :: forall t. Num t => Sealed ((->) Integer) Now the result of the case statement is the concrete implementation of fromInteger for whatever type it gets instantiated at. > For what it's worth, in my real program where this came up, sy was created > by a recursive call like this: > foo :: Sealed (p x) -> Sealed (q b) > foo = do > p <- blah > q <- foo > return (Sealed (f p q)) > > Because the b doesn't appear on the LHS of the function arrow, I understand > it to have the same polymorphic properties as the 'forall b.' in the type > signature of goodOrder and badOrder. Indeed, this example seems to > re-enforce that. We had to reorder the binding of p and q to get this to > type check. Yes, that's correct; consider the simpler example of "const" const :: forall a b. a -> b -> a foo = const "hello" which becomes foo :: forall b. b -> String foo = /\b. const @String @b "hello" = /\b. \x :: b. "hello" -- ryan From bulat.ziganshin at gmail.com Tue Oct 7 06:25:24 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Oct 7 06:25:26 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> Message-ID: <86511474.20081007142524@gmail.com> Hello Brandon, Tuesday, October 7, 2008, 7:59:06 AM, you wrote: > is there a reason why -O2 shouldn't be made the default (and > allowing to turn off optimizations by -O0 perhaps) ? it compiles ~2x slower and firces more recompilation (because it does inter-module inlining). so it's not perfect for edit-compile-debug runs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Oct 7 06:28:02 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Oct 7 06:25:45 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> <20081007031223.GB13471@scytale.galois.com> <20081007031915.GC13471@scytale.galois.com> <20081007042752.GG13471@scytale.galois.com> Message-ID: <106780337.20081007142802@gmail.com> Hello wman, Tuesday, October 7, 2008, 8:44:48 AM, you wrote: > btw, why is the example #2 > (http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=ghc&id=2) > (which kicks collective asses of all other participants) not > considered in the shootout ? Too much optimizations ? it's cheating - application code written in low-level style instead of using library functions (if you will write in the same style in C it will probably even several times faster) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From marco-oweber at gmx.de Tue Oct 7 07:12:27 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Tue Oct 7 07:08:53 2008 Subject: [Haskell-cafe] I'll do USB in Haskell - tips? In-Reply-To: References: Message-ID: <20081007111227.GA20482@gmx.de> > Thanks, > Maur?cio Hi Maur?cio, that's good news :-) However I personally would be scared by the amount of work and testing which is needed. I guess I would prefer wiriting some bindings to a nexisting library.. But if you manage to write it I might become a user in the future.. Marc From roly.perera at dynamicaspects.org Tue Oct 7 08:13:25 2008 From: roly.perera at dynamicaspects.org (Roly Perera) Date: Tue Oct 7 08:09:58 2008 Subject: [Haskell-cafe] Type classes question Message-ID: Hi, I'm reasonably well versed in Haskell but fairly new to defining type classes. In particular I don't really understand how to arrange for all instances of X to also be instances of Y. It's quite possibly that my question is ill-posed, so I'll make it as concrete as possible: in the following code, I define a Stream class, with two instances, Stream1 and Stream2. How do I arrange for there to be one implementation of Functor's fmap for all Stream instances? I currently rely on delegation, but in the general case this isn't nice. I guess I'm either misunderstanding what it is I'm trying to achieve, or how to do this kind of thing in Haskell. Any help would be greatly appreciated. many thanks, Roly Perera {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, ExistentialQuantification, FunctionalDependencies #-} module Test where ------------------------------------------------------------------------------- -- Just some helpers. ------------------------------------------------------------------------------- -- Product map. prod :: (a -> b) -> (c -> d) -> (a, c) -> (b, d) f `prod` g = \(a, c) -> (f a, g c) -- Diagonal. diag :: a -> (a, a) diag x = (x, x) -- Mediating morphism into the product. both :: (a -> b) -> (a -> c) -> a -> (b, c) both f g = prod f g . diag ------------------------------------------------------------------------------- -- "Abstract" stream. ------------------------------------------------------------------------------- class Stream s a | s -> a where first :: s -> a next :: s -> s fby :: a -> s -> s -- I want every Stream to be a Functor. fmap_ :: Stream s' b => (a -> b) -> s -> s' fmap_ f = uncurry fby . both (f . first) (fmap_ f . next) ------------------------------------------------------------------------------- -- Implementation 1. ------------------------------------------------------------------------------- data Stream1 a = a :< Stream1 a instance Functor Stream1 where fmap = fmap_ instance Stream (Stream1 a) a where first (x :< _) = x next (_ :< xs) = xs fby = (:<) ------------------------------------------------------------------------------- -- Implementation 2. ------------------------------------------------------------------------------- data Stream2 a = forall b . S b (b -> a) (b -> b) instance Functor Stream2 where fmap = fmap_ instance Stream (Stream2 a) a where first (S x c _) = c x next (S x c i) = S (i x) c i fby y s = S (y, s) fst (uncurry (,) . both first next . snd) From dougal at dougalstanton.net Tue Oct 7 08:58:54 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Tue Oct 7 08:55:17 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EA79B3.9080202@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> <48EA79B3.9080202@btinternet.com> Message-ID: <2d3641330810070558x1afbcbe9qdb077034f1160c75@mail.gmail.com> On Mon, Oct 6, 2008 at 9:48 PM, Andrew Coppin wrote: > Andrew Coppin wrote: >> >> I have some longwinded code that works, but I'm still thinking about how >> to do this more elegantly. It looks like what I really need is something >> like >> >> type M = StateT State (ResultSetT (ErrorT ErrorType Identity)) >> >> Is that the correct ordering? >> >> If so, I guess that means I have to somehow construct ResultSetT. Is there >> an easy way to do that, given that I already have ResultSet? For example, if >> I put ResultSet into Traversable, would that let me do it? > > ...and again I'm talking to myself... :-/ > > So after much experimentation, I have managed to piece together the > following facts: > > - It appears that the outer-most monad transformer represents the inner-most > monad. So "StateT Foo ListT" means a list of stateful computations, while > "ListT (StateT Foo)" means a stateful list of computations. Have you read "Monad Transformers Step by Step" [1] by Martin Grabmueller? It's a fantastic introduction to these beasties, leading the reader through a series of transformations from pure code to using about 4 different monads/transformers for all sorts of extra features. Seriously recommend it. []: Cheers, D From haskell at orangesquash.org.uk Tue Oct 7 09:18:59 2008 From: haskell at orangesquash.org.uk (Iain Lane) Date: Tue Oct 7 09:15:22 2008 Subject: [Haskell-cafe] Re: [darcs-users] announcing darcs 2.1.0pre3 In-Reply-To: <20081002120752.GA56508@Macintosh.local> References: <20081002120752.GA56508@Macintosh.local> Message-ID: On Thu, Oct 2, 2008 at 1:07 PM, Eric Kow wrote: > Hi everybody, > > The third pre-release of darcs 2.1 is now available at > http://darcs.net/darcs-2.1.0pre3.tar.gz > [...] > -- > Eric Kow > PGP Key ID: 08AC04F9 > > _______________________________________________ > darcs-users mailing list > darcs-users@darcs.net > http://lists.osuosl.org/mailman/listinfo/darcs-users > > Hi all, Packages of this release for Ubuntu Hardy and Intrepid are available in my PPA at [0]. Bugs with the packaging to me, bugs with Darcs not to me. ;) Thanks, Iain [0] https://edge.launchpad.net/~laney/+archive From ryani.spam at gmail.com Tue Oct 7 09:21:53 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Oct 7 09:18:16 2008 Subject: [Haskell-cafe] Type classes question In-Reply-To: References: Message-ID: <2f9b2d30810070621m2fa91f27k2817f08e429bc3e0@mail.gmail.com> On Tue, Oct 7, 2008 at 1:13 PM, Roly Perera wrote: > Hi, > > I'm reasonably well versed in Haskell but fairly new to defining type classes. > In particular I don't really understand how to arrange for all instances of X > to also be instances of Y. > > It's quite possibly that my question is ill-posed, so I'll make it as concrete > as possible: in the following code, I define a Stream class, with two > instances, Stream1 and Stream2. How do I arrange for there to be one > implementation of Functor's fmap for all Stream instances? I currently rely on > delegation, but in the general case this isn't nice. With your current implementation, you can't. You get lucky because all of your instance declarations are of the form > instance Stream (X a) a for some type X. But it's just as possible to say > newtype Stream3 = S3 [Int] > instance Stream Stream3 Int where > first (S3 xs) = head xs > next (S3 xs) = tail xs > fby x (S3 xs) = S3 (x:xs) Now the only valid fmap_ is over functions of type (Int -> Int). If you really want all your instances to be type constructors, you should just say so: > class Stream f where > first :: f a -> a > next :: f a -> f a > fby :: a -> f a -> f a Now, with this implementation what you want is at least somewhat possible, but there's a new problem: there's no good way in haskell to define superclasses or default methods for existing classes. There is a standing "class aliases" proposal [1], but nobody has implemented it. The current recommended practice is to define a "default" and leave it to your instances to use it. It's kind of ugly, but thems the breaks: > class Functor f => Stream f where -- you said you want all streams to be functors, so enforce it! > first :: f a -> a > next :: f a -> f a > fby :: a -> f a -> f a > > fmapStreamDefault f = uncurry fby . both (f . first) (fmap_ f . next) > > instance Functor Stream1 where fmap = fmapStreamDefault > instance Stream Stream1 where > first (x :< _) = x > next (_ :< xs) = xs > fby = (:<) Here's another possible solution: > newtype AsFunctor s a = AF { fstream :: (s a) } > instance (Stream f) => Functor (AsFunctor f) where > fmap f (AF s) = AF (fmapStreamDefault f s) Now to use fmap you wrap in AF and unwrap with fstream. None of the existing solutions are really satisfactory, unfortunately. -- ryan [1] http://repetae.net/recent/out/classalias.html From simonmarhaskell at gmail.com Tue Oct 7 09:56:51 2008 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Tue Oct 7 09:53:46 2008 Subject: [Haskell-cafe] Re: New System.Process In-Reply-To: References: Message-ID: <48EB6AA3.9030404@gmail.com> john lask wrote: > > Something that has irked me in the past about System.Process is the inability to obtain an OS system handle from the haskell Process handle. Such a facility would greatly enhance the interoperabity of c and haskell libraries. > > Provision is made (although not standardised) to obtain OS specific handles from haskell File Handles which is very useful. The same should be provided for Haskell Process handles. The main barrier to such a facility is the variability between OS representations of such a type (aka windows Handles, unix PID). > > comments anyone. You can get at the underlying process handle using System.Process.Internals, but that's not a documented interface of course. If you really need to do OS-specific stuff, I suggest using System.Posix or System.Win32 instead. Cheers, Simon From nominolo at googlemail.com Tue Oct 7 10:34:30 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Tue Oct 7 10:30:53 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <48EA62D9.1020607@blueyonder.co.uk> References: <48EA62D9.1020607@blueyonder.co.uk> Message-ID: <916b84820810070734n256fe9c3j5cc8faa3444723e6@mail.gmail.com> GHC uses http://darcs.haskell.org/bin/darcs-to-git which is a fork of http://github.com/purcell/darcs-to-git It's not very fast, but it works well enough. I tried tailor only briefly but it failed on its own test suite and I didn't bother to investigate any further. 2008/10/6 Dominic Steinitz : > Not really a Haskell question but I'm not sure where else to go. > > What's the preferred method of converting a darcs repository to git? And > is there a way of converting from git to darcs? > > The reason I ask is that my colleague cannot get darcs to work on his > Windows box. > > Thanks, Dominic. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From apfelmus at quantentunnel.de Tue Oct 7 11:02:00 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Tue Oct 7 10:58:32 2008 Subject: [Haskell-cafe] Re: Inferred type is less polymorphic than expected, depends on order In-Reply-To: References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> Message-ID: Jason Dagit wrote: > Ryan Ingram wrote: >> Jason Dagit wrote: >>> \begin{code} >>> badOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q >>> x)) >>> badOrder sx sy = case sy of >>> Sealed y -> case sx of >>> Sealed x -> Sealed (f x y) >>> \end{code} >>> >>> \begin{code} >>> goodOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q >>> x)) >>> goodOrder sx sy = case sx of >>> Sealed x -> case sy of >>> Sealed y -> Sealed (f x y) >>> \end{code} >> It may help if you transform this a bit closer to System F with >> existentials & datatypes: >> /\ = forall > > > Why is useful to replace forall with /\? Actually, the forall's should be left alone, the big lambda /\ lives on the value level, not the type level :) But this small typo aside, making all type applications explicit is the right thing to do to see what's going on. In the original System F - the basis for Haskell's type system - http://en.wikipedia.org/wiki/System_F all type applications are explicit. For instance id 'c' in Haskell would be written id Char 'c' in System F the type is an explicit argument to a polymorphic function. The definition of id would be id : ?a. a -> a id = ?a.?x:a.x So, first supply the type and then compute something. In Haskell, the compiler figures out which type argument to apply where and this can get confusing like in Jason's example. (By the way, I found the "Proofs and Types" book references in the wikipedia page to be a very readable introduction to System F and the Curry-Howards isomorphism in general.) In System F, the example reads as follows (for clarity, we prefix type variables with an @ when they are applied) foo : ?p,q,x,y,z.p x y -> q y z -> q x z foo = ... goodOrder : ?p,q,x. Sealed (p x) -> (?b.Sealed (q b)) -> Sealed (q x) goodOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(?b.Sealed (q b)). case sx of Sealed @y (pxy:p x y) -> case sy @y of Sealed @z (qyz:q y z) -> Sealed @z (foo @p @q @x @y @z pxy qyz) badOrder : ... badOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(?b.Sealed (q b)). case sy ??? of Sealed @z (qyz:q ??? z) -> case sx of Sealed @y (pxy:p x y) -> Sealed @z (foo @p @q @x @y @z pxy qyz) In the second case, there's no way to know what type to choose for b unless you evaluate sx first. However, the following would work: badOrder : ?p,q,x. Sealed (p x) -> (Sealed (?b. q b)) -> Sealed (q x) badOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(Sealed (?b.q b)). case sy of Sealed @z (qyz:?b.q b z) -> case sx of Sealed @y (pxy:p x y) -> Sealed @z (foo @p @q @x @y @z pxy (qyz @y)) In other words, (Sealed (?b.q b)) and (?b.Sealed (q b)) are quite different types. But this is not surprising. After all, this "Sealed" thing is the existential quantifier Sealed f = ?x.f x and both types read Sealed (?b.q b) = ?x.?b.q b x ?b.Sealed (q b) = ?b.?x.q b x The latter is broader because it might yield different x for different b while the first one has to produce one x that works for all b at once. Here's an example for natural numbers that illustrates the difference: ?m.?n.n > m -- we can always find a larger number (sure, use n=m+1) ?n.?m.n > m -- we can find a number larger than all the others! Regards, apfelmus PS: The wikibook has a chapter http://en.wikibooks.org/wiki/Haskell/Polymorphism that is intended to explain and detail such issues and the translation from Haskell to System F, but it's currently rather empty. From bulat.ziganshin at gmail.com Tue Oct 7 11:48:16 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Oct 7 11:45:38 2008 Subject: [Haskell-cafe] Type classes question In-Reply-To: References: Message-ID: <957776026.20081007194816@gmail.com> Hello Roly, Tuesday, October 7, 2008, 4:13:25 PM, you wrote: > I'm reasonably well versed in Haskell but fairly new to defining type classes. http://haskell.org/haskellwiki/OOP_vs_type_classes may be useful -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From miguelimo38 at yandex.ru Tue Oct 7 12:16:59 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Oct 7 12:13:29 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: References: <48EA62D9.1020607@blueyonder.co.uk> Message-ID: <8BF4EDFF-6293-4CE7-9208-E54A7374234B@yandex.ru> On 7 Oct 2008, at 12:11, Krasimir Angelov wrote: > I use darcs on Windows every day and it works well. The only problem > is that it is not very usable if you access your repository via SSH > and the authentication is via password. Why not? It worked fine for me. From neil.mitchell.2 at credit-suisse.com Tue Oct 7 12:19:57 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Tue Oct 7 12:19:14 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <8BF4EDFF-6293-4CE7-9208-E54A7374234B@yandex.ru> References: <48EA62D9.1020607@blueyonder.co.uk> <8BF4EDFF-6293-4CE7-9208-E54A7374234B@yandex.ru> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3AD3@ELON17P32001A.csfb.cs-group.com> > > I use darcs on Windows every day and it works well. The > only problem > > is that it is not very usable if you access your repository via SSH > > and the authentication is via password. > > Why not? It worked fine for me. It's never worked for me, I always get a frozen darcs trying to read a password, but not from my console. If you connect with an SSH key its more secure and less typing - it's a better way to go. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From dagit at codersbase.com Tue Oct 7 12:29:11 2008 From: dagit at codersbase.com (Jason Dagit) Date: Tue Oct 7 12:25:34 2008 Subject: [Haskell-cafe] Inferred type is less polymorphic than expected, depends on order In-Reply-To: <2f9b2d30810070113t45b833a4pa4fd8aa991ff944a@mail.gmail.com> References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> <2f9b2d30810070113t45b833a4pa4fd8aa991ff944a@mail.gmail.com> Message-ID: On Tue, Oct 7, 2008 at 1:13 AM, Ryan Ingram wrote: > > You may think it doesn't matter, because you could instantiate it to > anything after the fact, but it's possible that the result of the case > statement depends on the choice of instantiation for sy; consider if > sy had an additional constraint: > > > Sealed (fromInteger) :: forall t. Num t => Sealed ((->) Integer) > > Now the result of the case statement is the concrete implementation of > fromInteger for whatever type it gets instantiated at. Thanks, I was indeed hoping to see examples of things that break if the type checker behaved the way I wanted. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/81661b1f/attachment.htm From dagit at codersbase.com Tue Oct 7 12:35:51 2008 From: dagit at codersbase.com (Jason Dagit) Date: Tue Oct 7 12:32:13 2008 Subject: [Haskell-cafe] Re: Inferred type is less polymorphic than expected, depends on order In-Reply-To: References: <2f9b2d30810061356s55b6adb8x1ec2f32ffa835271@mail.gmail.com> Message-ID: On Tue, Oct 7, 2008 at 8:02 AM, apfelmus wrote: > Jason Dagit wrote: > > Ryan Ingram wrote: > >> Jason Dagit wrote: > >>> \begin{code} > >>> badOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q > >>> x)) > >>> badOrder sx sy = case sy of > >>> Sealed y -> case sx of > >>> Sealed x -> Sealed (f x y) > >>> \end{code} > >>> > >>> \begin{code} > >>> goodOrder :: (Sealed (p x)) -> (forall b. (Sealed (q b))) -> (Sealed (q > >>> x)) > >>> goodOrder sx sy = case sx of > >>> Sealed x -> case sy of > >>> Sealed y -> Sealed (f x y) > >>> \end{code} > >> It may help if you transform this a bit closer to System F with > >> existentials & datatypes: > >> /\ = forall > > > > > > Why is useful to replace forall with /\? > > Actually, the forall's should be left alone, the big lambda /\ lives > on the value level, not the type level :) But this small typo aside, > making all type applications explicit is the right thing to do to see > what's going on. > > In the original System F - the basis for Haskell's type system - > > http://en.wikipedia.org/wiki/System_F Thanks, I'll be reading up on that. > > > all type applications are explicit. For instance > > id 'c' in Haskell > > would be written > > id Char 'c' in System F > > the type is an explicit argument to a polymorphic function. The > definition of id would be > > id : ?a. a -> a > id = ?a.?x:a.x > > So, first supply the type and then compute something. In Haskell, the > compiler figures out which type argument to apply where and this can get > confusing like in Jason's example. Ah, okay, so this rule of first supplying the type is what keeps my example from being confusing about the order of @y. That makes a lot of sense. > > > (By the way, I found the "Proofs and Types" book references in the > wikipedia page to be a very readable introduction to System F and the > Curry-Howards isomorphism in general.) Okay, thanks. > > > > In System F, the example reads as follows (for clarity, we prefix type > variables with an @ when they are applied) > > foo : ?p,q,x,y,z.p x y -> q y z -> q x z > foo = ... > > goodOrder : ?p,q,x. > Sealed (p x) > -> (?b.Sealed (q b)) > -> Sealed (q x) > goodOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(?b.Sealed (q b)). > case sx of > Sealed @y (pxy:p x y) -> case sy @y of > Sealed @z (qyz:q y z) -> > Sealed @z (foo @p @q @x @y @z pxy qyz) > > badOrder : ... > badOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(?b.Sealed (q b)). > case sy ??? of > Sealed @z (qyz:q ??? z) -> case sx of > Sealed @y (pxy:p x y) -> > Sealed @z (foo @p @q @x @y @z pxy qyz) > Thanks, that's quite illustrative. In the second case, there's no way to know what type to choose for b > unless you evaluate sx first. However, the following would work: > > badOrder : ?p,q,x. > Sealed (p x) > -> (Sealed (?b. q b)) > -> Sealed (q x) > badOrder = ?p.?q.?x. ?sx:Sealed (p x).?sy:(Sealed (?b.q b)). > case sy of > Sealed @z (qyz:?b.q b z) -> case sx of > Sealed @y (pxy:p x y) -> > Sealed @z (foo @p @q @x @y @z pxy (qyz @y)) > > In other words, (Sealed (?b.q b)) and (?b.Sealed (q b)) are quite > different types. But this is not surprising. After all, this "Sealed" > thing is the existential quantifier Oh right, but yes this changes things considerably. I think your point with this example is that this more closely matches my expectation, but I know from experience and your explanation that this is not what I want. Therefore, I should accept the behavior I'm seeing from the type checker :) Thank you, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/67ea02ba/attachment.htm From miguelimo38 at yandex.ru Tue Oct 7 12:42:05 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Oct 7 12:38:33 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3AD3@ELON17P32001A.csfb.cs-group.com> References: <48EA62D9.1020607@blueyonder.co.uk> <8BF4EDFF-6293-4CE7-9208-E54A7374234B@yandex.ru> <33A3F585590A6F4E81E3D45AA4A111C902CD3AD3@ELON17P32001A.csfb.cs-group.com> Message-ID: <1598FE3B-5D3A-47EE-862F-DB54C2AC6A69@yandex.ru> Yes, I've used SSH key. Didn't think it would be different with a password. On 7 Oct 2008, at 20:19, Mitchell, Neil wrote: > > >>> I use darcs on Windows every day and it works well. The >> only problem >>> is that it is not very usable if you access your repository via SSH >>> and the authentication is via password. >> >> Why not? It worked fine for me. > > It's never worked for me, I always get a frozen darcs trying to read a > password, but not from my console. > > If you connect with an SSH key its more secure and less typing - > it's a > better way to go. > > Thanks > > Neil > > = > = > = > = > = > = > = > = > ====================================================================== > Please access the attached hyperlink for an important electronic > communications disclaimer: > > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > = > = > = > = > = > = > = > = > ====================================================================== > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Tue Oct 7 01:50:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Oct 7 12:59:37 2008 Subject: [Haskell-cafe] After upgrade bytestring to 0.9.1.3, my program cannot run. In-Reply-To: <20081007032127.GE13471@scytale.galois.com> References: <48EAD4A6.5060008@gmail.com> <20081007032127.GE13471@scytale.galois.com> Message-ID: <1223358622.14163.560.camel@dell.linuxdev.us.dell.com> On Mon, 2008-10-06 at 20:21 -0700, Don Stewart wrote: > magicloud.magiclouds: > > Just a simple text process program. When I runhaskell it. I got: > > > > GHCi runtime linker: fatal error: I found a duplicate definition for symbol > > fps_minimum > > whilst processing object file > > ~/.cabal/lib/bytestring-0.9.1.3/ghc-6.8.3/HSbytestring-0.9.1.3.o > Or try compiling it , with ghc --make The reason is that while the Haskell code uses versioned linker symbols, the C code in the bytestring library does not. That means both versions define fps_minimum and a few other functions. The system linker does not care and just picks one. The GHCi linker is more picky and complains when two object files define the same linker symbol. That's why you get the problem with GHCi and not ghc --make. Duncan From iainspeed at gmail.com Tue Oct 7 13:40:22 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Tue Oct 7 13:36:52 2008 Subject: [Haskell-cafe] Re: Random question In-Reply-To: References: <6254718A-84C6-4DF5-A0C5-89DA179E1927@gmail.com> Message-ID: <54E58339-BA49-4661-803F-426340DA8B3F@gmail.com> On 5 Oct 2008, at 7:06 pm, Henning Thielemann wrote: > > Instead of separate calls to 'take' and 'drop' you may prefer > 'splitAt': > > requeue z xs = > let (prefix,pivot:suffix) = splitAt (z-1) xs > in prefix ++ suffix ++ [pivot] Thanks. Took me a while to get the function to shuffle properly again, but shuffle xs = shuffle' (length xs) xs shuffle' :: Int -> [a] -> IO [a] shuffle' 0 xs = return xs shuffle' (len + 1) xs = rand 0 len >>= \r -> shuffle' len $ requeue r xs where requeue z ys = let (prefix,pivot:suffix) = splitAt z ys in prefix ++ suffix ++ [pivot] *Main> shuffle [11..18] [14,11,13,16,12,15,18,17] *Main> shuffle [11..18] [16,13,12,11,17,14,18,15] Until I master Quickcheck, that will do for me :) > > However, accessing list elements by index is pretty inefficient > (linear time with respect to index). Is it possible to re-arrange > the algorithm? Maybe using more efficient data structures? Perhaps an array? I've not investigated any of the other list-like data structures in Haskell yet. I'll only be using it to try and create a few simple games in the beginning, cards and the like, so the performance aspect isn't high on the list (yet) due to the small sets being shuffled. Just trying to get things to work first! Iain From andrewcoppin at btinternet.com Tue Oct 7 14:09:25 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Oct 7 14:05:50 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> Message-ID: <48EBA5D5.9050503@btinternet.com> Mitchell, Neil wrote: >> Well, as I said, replacing one term with another transforms >> one signature into the other. I guess you can't curry type >> constructors as easily as functions - or at least, Hoogle >> currently doesn't like it. >> > > Yes, currying of type constructors is much less common, and entirely > unsupported by Hoogle. Is there a general need for Hoogle to deal with > curried type constructors? I'd not really considered it significantly. > And I had just "assumed" this would work. If I ask for a function x -> y Hoogle manages to offer my functions like k -> x -> y which can be curried to give me the thing I want, I just assumed that an equivilent type wouldn't phase it. Ah well. >> What *does* Hoogle actually use for matching? Just a >> set of huristics and a metric for how "similar" two >> signatures are so it can order by approximate similarity? >> Or is it something more scientific than that? >> > > It's more scientific than that, see > http://www.wellquite.org/anglohaskell2008/ > I had a look at your slides. Looks like interesting stuff! Irritating as it is that Hoogle didn't help me find the function I wanted on this occasion, I still think it's really neat that a program like Hoogle can actually exist in the first place. And considering that with parametric polymorphism, the type signature "almost" tells you what the function does... very useful stuff. For my current troubles, it would be really useful if there were some program that you could feed some source code to, and it would tell you what the inferred types of each subexpression are. (Ideally it would be nice if you could use this on fragments that don't typecheck; being able to see what types are being inferred where could help explain why the type checker is unhappy, and ultimately where you went wrong. But I'm not sure how you could present the internal state in a digestible way.) I don't know if anybody has ever attempted such a tool...? From byorgey at seas.upenn.edu Tue Oct 7 14:16:15 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue Oct 7 14:12:36 2008 Subject: [Haskell-cafe] Re: Random question In-Reply-To: <54E58339-BA49-4661-803F-426340DA8B3F@gmail.com> References: <6254718A-84C6-4DF5-A0C5-89DA179E1927@gmail.com> <54E58339-BA49-4661-803F-426340DA8B3F@gmail.com> Message-ID: <20081007181615.GA14137@GRW057-25.cis.upenn.edu> On Tue, Oct 07, 2008 at 06:40:22PM +0100, Iain Barnett wrote: > On 5 Oct 2008, at 7:06 pm, Henning Thielemann wrote: >> >> Instead of separate calls to 'take' and 'drop' you may prefer 'splitAt': >> >> requeue z xs = >> let (prefix,pivot:suffix) = splitAt (z-1) xs >> in prefix ++ suffix ++ [pivot] > > Thanks. Took me a while to get the function to shuffle properly again, but > > shuffle xs = shuffle' (length xs) xs > > shuffle' :: Int -> [a] -> IO [a] > shuffle' 0 xs = return xs > shuffle' (len + 1) xs = rand 0 len >>= \r -> shuffle' len $ requeue r xs > where requeue z ys = let (prefix,pivot:suffix) = splitAt z ys > in prefix ++ suffix ++ [pivot] > > *Main> shuffle [11..18] > [14,11,13,16,12,15,18,17] > > *Main> shuffle [11..18] > [16,13,12,11,17,14,18,15] > > > Until I master Quickcheck, that will do for me :) Using QuickCheck is actually pretty easy. It's made more difficult in this particular case since the result of your shuffle function is in the IO monad. But assuming you split out the shuffling functionality into a pureShuffle function which takes a random seed as an extra parameter, you could make a property to test it as follows: prop_shuffle :: Seed -> Seed -> [a] -> Bool prop_shuffle s1 s2 l = sort (pureShuffle s1 l) == sort (pureShuffle s2 l) Then you could test it by evaluating 'quickCheck prop_shuffle' at a ghci prompt. Nice and simple! -Brent From spam at scientician.net Tue Oct 7 14:17:37 2008 From: spam at scientician.net (=?ISO-8859-1?Q?B=E1r=F0ur_=C1rantsson?=) Date: Tue Oct 7 14:14:13 2008 Subject: [Haskell-cafe] Network.URI bug? (2.2.0.0) Message-ID: Hi all, I'm having a bit of difficulty with Network.URI -- unless I misunderstand the documentation, the attached demo program is supposed to produce: http://localhost:9000 http://localhost:9000/d1 http://localhost:9000/d1/d2 but it produces http://localhost:9000 http://localhost:9000/d1 http://localhost:9000/d2 Is this some sort of bug or am I not understanding the documentation correctly? Cheers, -- Bardur Arantsson The thing that's depressing about tennis is that no matter how good I get, I'll never be as good as a wall. Mitch Hedberg -------------- next part -------------- A non-text attachment was scrubbed... Name: Test.hs Type: text/x-haskell Size: 340 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/d1208565/Test.bin From spam at scientician.net Tue Oct 7 14:25:25 2008 From: spam at scientician.net (=?ISO-8859-1?Q?B=E1r=F0ur_=C1rantsson?=) Date: Tue Oct 7 14:21:56 2008 Subject: [Haskell-cafe] Re: Network.URI bug? (2.2.0.0) In-Reply-To: References: Message-ID: B?r?ur ?rantsson wrote: > Hi all, > [--snip--] *Smacks forehead* Apparently you absolutely need a trailing slash on the relative URIs. So base = fromJust $ parseURI "http://localhost:9000" d1 = fromJust $ parseRelativeReference "d1/" d2 = fromJust $ parseRelativeReference "d2/" ... let u = base let u1 = fromJust $ d1 `relativeTo` base let u2 = fromJust $ d2 `relativeTo` u1 works as expected. Apologies for the noise. Cheers, -- Bardur Arantsson - You can't expect to wield supreme executive power just because some watery tart threw a sword at you. Dennis / Monty Python and the Holy Grail From andrewcoppin at btinternet.com Tue Oct 7 14:27:57 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Oct 7 14:24:27 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <20081006224012.GA9367@rwbarton.mit.edu> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> <48EA79B3.9080202@btinternet.com> <20081006224012.GA9367@rwbarton.mit.edu> Message-ID: <48EBAA2D.5050600@btinternet.com> The good news: I managed to turn ResultSet into a monad transformer. Yay, me! The bad news: It generates the entire result set before returning anything to the caller. In other words, it works perfectly for finite result sets, and locks up forever on infinite result sets. Since the entire *point* of the monad is to handle infinite result sets correctly, that's kind-of a problem. And one that I see absolutely no way of fixing. :-( Basically, the core code is something like raw_bind :: (Monad m) => [[x]] -> (x -> m (ResultSet y)) -> m (ResultSet y) raw_bind [] f = return empty raw_bind (xs:xss) f = do rsYs <- mapM f xs rsZ <- raw_bind xss f return (foldr union (cost rsZ) rsYs) As you can see, this generates all of rsZ before attempting to return anything to the caller. And I'm really struggling to see any way to avoid that. From daniel.is.fischer at web.de Tue Oct 7 15:29:20 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Oct 7 15:23:31 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EBAA2D.5050600@btinternet.com> References: <48E5025B.1040908@btinternet.com> <20081006224012.GA9367@rwbarton.mit.edu> <48EBAA2D.5050600@btinternet.com> Message-ID: <200810072129.20286.daniel.is.fischer@web.de> Am Dienstag, 7. Oktober 2008 20:27 schrieb Andrew Coppin: > The good news: I managed to turn ResultSet into a monad transformer. > Yay, me! > > The bad news: It generates the entire result set before returning > anything to the caller. > > In other words, it works perfectly for finite result sets, and locks up > forever on infinite result sets. Since the entire *point* of the monad > is to handle infinite result sets correctly, that's kind-of a problem. > And one that I see absolutely no way of fixing. :-( > > Basically, the core code is something like > > raw_bind :: (Monad m) => [[x]] -> (x -> m (ResultSet y)) -> m > (ResultSet y) > raw_bind [] f = return empty > raw_bind (xs:xss) f = do > rsYs <- mapM f xs > rsZ <- raw_bind xss f > return (foldr union (cost rsZ) rsYs) > > As you can see, this generates all of rsZ before attempting to return > anything to the caller. And I'm really struggling to see any way to > avoid that. > Maybe it is as simple as raw_bind (xs:xss) f = do rsYs <- mapM f xs ~rsZ <- raw_bind xss f return (foldr union (cost rsZ) rsYs) then rsZ should only be evaluated when it's needed From dlb at patriot.net Tue Oct 7 15:50:34 2008 From: dlb at patriot.net (David Barton) Date: Tue Oct 7 15:47:43 2008 Subject: [Haskell-cafe] Cabal: error on configure References: <20080911220622.4205.qmail@s461.sureserver.com> Message-ID: <9C65D914D8884B7EBCDCCD1E9A405530@magenta> OK, I suspect this is a real newbie error, but please have mercy. I have downloaded and installed cabal (at least it responds to the --help command from the command line). Yet when I do, say (to give a real example): cabal configure parameterized_ data (having done he fetch) I get this error: cabal.exe: Using 'build-type" Custom' but there is no Setup.hs or Setup.lhs script.' When I download the package manually and look, there is a perfectly servicable Setup.hs script, which I call manually. So what gives? Dave Barton From dons at galois.com Tue Oct 7 15:54:30 2008 From: dons at galois.com (Don Stewart) Date: Tue Oct 7 15:50:40 2008 Subject: [Haskell-cafe] Cabal: error on configure In-Reply-To: <9C65D914D8884B7EBCDCCD1E9A405530@magenta> References: <20080911220622.4205.qmail@s461.sureserver.com> <9C65D914D8884B7EBCDCCD1E9A405530@magenta> Message-ID: <20081007195430.GD17878@scytale.galois.com> dlb: > OK, I suspect this is a real newbie error, but please have mercy. I have > downloaded and installed cabal (at least it responds to the --help command > from the command line). Yet when I do, say (to give a real example): > > cabal configure parameterized_ data > > (having done he fetch) I get this error: > > cabal.exe: Using 'build-type" Custom' but there is no Setup.hs or > Setup.lhs script.' > > When I download the package manually and look, there is a perfectly > servicable Setup.hs script, which I call manually. > > So what gives? > > Dave Barton $ cabal update Downloading package list from server 'http://hackage.haskell.org/packages/archive' $ cabal install parameterized-data Downloading parameterized-data-0.1.3... Configuring parameterized-data-0.1.3... Preprocessing library parameterized-data-0.1.3... Building parameterized-data-0.1.3... [1 of 2] Compiling Data.Param.FSVec ( src/Data/Param/FSVec.hs, dist/build/Data/Param/FSVec.o ) [2 of 2] Compiling Data.Param ( src/Data/Param.hs, dist/build/Data/Param.o ) /usr/bin/ar: creating dist/build/libHSparameterized-data-0.1.3.a Installing library in /home/dons/.cabal/lib/parameterized-data-0.1.3/ghc-6.8.2 Registering parameterized-data-0.1.3... Reading package info from "dist/installed-pkg-config" ... done. Saving old package config file... done. Writing new package config file... done. Looks ok to me? From andrewcoppin at btinternet.com Tue Oct 7 16:09:28 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Oct 7 16:05:52 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <200810072129.20286.daniel.is.fischer@web.de> References: <48E5025B.1040908@btinternet.com> <20081006224012.GA9367@rwbarton.mit.edu> <48EBAA2D.5050600@btinternet.com> <200810072129.20286.daniel.is.fischer@web.de> Message-ID: <48EBC1F8.3050506@btinternet.com> Daniel Fischer wrote: > Am Dienstag, 7. Oktober 2008 20:27 schrieb Andrew Coppin: > >> Basically, the core code is something like >> >> raw_bind :: (Monad m) => [[x]] -> (x -> m (ResultSet y)) -> m >> (ResultSet y) >> raw_bind [] f = return empty >> raw_bind (xs:xss) f = do >> rsYs <- mapM f xs >> rsZ <- raw_bind xss f >> return (foldr union (cost rsZ) rsYs) >> >> As you can see, this generates all of rsZ before attempting to return >> anything to the caller. And I'm really struggling to see any way to >> avoid that. >> >> > > Maybe it is as simple as > > raw_bind (xs:xss) f = do > rsYs <- mapM f xs > ~rsZ <- raw_bind xss f > return (foldr union (cost rsZ) rsYs) > > then rsZ should only be evaluated when it's needed > Ooo... "lazy pattern matching"? Can somebody explain to me, _very slowy_, exactly what that means? If I'm doing this right, it seems that rsZ <- raw_bind xss f ... desugards to raw_bind xss f >>= \rsZ -> ... If I'm not mistaken, the rsZ variable shouldn't be evaluated until needed *anyway*, so what is lazy pattern matching buying me here? Also, suppose I stack ResultSetT on top of IO. In that case, "f" is allowed to perform externally-visible I/O operations. If there really *is* a way to delay the execution of certain calls until the data is needed... well that doesn't look right somehow. In fact, it looks like what I'm trying to do *should* be impossible. :-/ Oh dear... From daniel.is.fischer at web.de Tue Oct 7 17:07:47 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Oct 7 17:01:59 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EBC1F8.3050506@btinternet.com> References: <48E5025B.1040908@btinternet.com> <200810072129.20286.daniel.is.fischer@web.de> <48EBC1F8.3050506@btinternet.com> Message-ID: <200810072307.48023.daniel.is.fischer@web.de> Am Dienstag, 7. Oktober 2008 22:09 schrieb Andrew Coppin: > Daniel Fischer wrote: > > Am Dienstag, 7. Oktober 2008 20:27 schrieb Andrew Coppin: > >> Basically, the core code is something like > >> > >> raw_bind :: (Monad m) => [[x]] -> (x -> m (ResultSet y)) -> m > >> (ResultSet y) > >> raw_bind [] f = return empty > >> raw_bind (xs:xss) f = do > >> rsYs <- mapM f xs > >> rsZ <- raw_bind xss f > >> return (foldr union (cost rsZ) rsYs) > >> > >> As you can see, this generates all of rsZ before attempting to return > >> anything to the caller. And I'm really struggling to see any way to > >> avoid that. > > > > Maybe it is as simple as > > > > raw_bind (xs:xss) f = do > > rsYs <- mapM f xs > > ~rsZ <- raw_bind xss f > > return (foldr union (cost rsZ) rsYs) > > > > then rsZ should only be evaluated when it's needed > > Ooo... "lazy pattern matching"? Can somebody explain to me, _very > slowy_, exactly what that means? > > If I'm doing this right, it seems that > > rsZ <- raw_bind xss f > ... > > desugards to > > raw_bind xss f >>= \rsZ -> ... > > If I'm not mistaken, the rsZ variable shouldn't be evaluated until > needed *anyway*, so what is lazy pattern matching buying me here? That depends on how your Monad (and union) is implemented, it may or may not make a difference. I must admit that I didn't really look at the code you posted, so I don't know what would be the case here. It was just an easy thing to try which *might* help. I will take a look, can't guarantee any result. > > Also, suppose I stack ResultSetT on top of IO. In that case, "f" is > allowed to perform externally-visible I/O operations. If there really > *is* a way to delay the execution of certain calls until the data is > needed... well that doesn't look right somehow. In fact, it looks like > what I'm trying to do *should* be impossible. :-/ Oh dear... To delay computations in IO until needed, you can use unsafeInterleaveIO: uiSeq :: [IO Int] -> IO [Int] uiSeq [] = do putStrLn "End of list" return [] uiSeq (a:as) = do x <- a putStrLn $ "got the value " ++ show x xs <- unsafeInterleaveIO $ uiSeq as return (x:xs) verbRet :: Int -> IO Int verbRet k = do putStrLn $ "Returning " ++ show k return k *Main> fmap (take 3) $ uiSeq [verbRet k | k <- [1 .. 10]] Returning 1 got the value 1 [1Returning 2 got the value 2 ,2Returning 3 got the value 3 ,3] *Main> fmap (take 3) $ sequence [verbRet k | k <- [1 .. 10]] Returning 1 Returning 2 Returning 3 Returning 4 Returning 5 Returning 6 Returning 7 Returning 8 Returning 9 Returning 10 [1,2,3] But unsafeInterleaveIO doesn't have its first six letters without a reason, so be careful when you want to use it (in general, don't). And of course you can't use it in generic monad transformer code, you might however be able to use class Monad m => LazyMonad m where lazyBind :: m a -> (a -> m b) -> m b lazySequence :: [m a] -> m [a] instance LazyMonad IO where lazyBind ma f = do a <- unsafeInterleaveIO ma f a lazySequence [] = return [] lazySequence (a:as) = do x <- a xs <- unsafeInterleaveIO $ lazySequence as return (x:xs) From porges at porg.es Tue Oct 7 17:19:48 2008 From: porges at porg.es (George Pollard) Date: Tue Oct 7 17:16:14 2008 Subject: [Haskell-cafe] newbie questions (read, etc., with Data.ByteString.Lazy.Char8) In-Reply-To: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> References: <3c6c07c20810061906v72a6196fte5b39a59400d44c8@mail.gmail.com> Message-ID: <1223414388.7792.12.camel@porges-laptop> On Mon, 2008-10-06 at 21:06 -0500, Mike Coleman wrote: > There's a readInt method, which I guess I could use, but it returns a > Maybe, and I don't see how I can easily strip that off. You can use Data.Maybe's 'mapMaybe' function "The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it just Just b, then b is included in the result list." So we change this: > -- lazy version (doesn't compile) > > -- file: ch08/SumFile.hs > > import qualified Data.ByteString.Lazy.Char8 as L > > main = do > contents <- L.getContents > print (sumFile contents) > where sumFile = sum . map read . L.words To this: import qualified Data.ByteString.Lazy.Char8 as B import Data.Maybe (mapMaybe) main = do contents <- B.getContents print (sumFile contents) where sumFile = sum . map fst . mapMaybe B.readInt . B.words Now, there is a problem with this; the original version will not read integers that are followed by garbage, whereas this one will. The difference is between readInt and read: (read "2a") will fail, (readInt "2a") will return Just (2,"a") readInt is really designed with parsers in mind. So, we need to filter out anything readInt returns with a non-empty string in the right part of the tuple. Ending up with this: sumFile = sum . map fst . filter (B.null . snd) . mapMaybe B.readInt . B.words Actually, after saying this, the original version probably just dies when given garbage :P -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/c35ec95b/attachment.bin From dave at zednenem.com Tue Oct 7 17:38:04 2008 From: dave at zednenem.com (David Menendez) Date: Tue Oct 7 17:34:26 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <200810072307.48023.daniel.is.fischer@web.de> References: <48E5025B.1040908@btinternet.com> <200810072129.20286.daniel.is.fischer@web.de> <48EBC1F8.3050506@btinternet.com> <200810072307.48023.daniel.is.fischer@web.de> Message-ID: <49a77b7a0810071438v3c32f1bcu6ed66a6945640882@mail.gmail.com> On Tue, Oct 7, 2008 at 5:07 PM, Daniel Fischer wrote: > Am Dienstag, 7. Oktober 2008 22:09 schrieb Andrew Coppin: >> Daniel Fischer wrote: >> > Maybe it is as simple as >> > >> > raw_bind (xs:xss) f = do >> > rsYs <- mapM f xs >> > ~rsZ <- raw_bind xss f >> > return (foldr union (cost rsZ) rsYs) >> > >> > then rsZ should only be evaluated when it's needed >> >> Ooo... "lazy pattern matching"? Can somebody explain to me, _very >> slowy_, exactly what that means? >> If I'm not mistaken, the rsZ variable shouldn't be evaluated until >> needed *anyway*, so what is lazy pattern matching buying me here? > > That depends on how your Monad (and union) is implemented, it may or may not > make a difference. I must admit that I didn't really look at the code you > posted, so I don't know what would be the case here. It was just an easy > thing to try which *might* help. Unless you're pattern matching against a constructor, which rsZ is not, I think lazy pattern matching is no different from regular pattern matching. -- Dave Menendez From colin.mailinglist at gmail.com Tue Oct 7 17:38:43 2008 From: colin.mailinglist at gmail.com (Colin Fleming) Date: Tue Oct 7 17:35:04 2008 Subject: [Haskell-cafe] Linux binary dist problems In-Reply-To: <7c6512110810061400o34feea29yee484ceb68e21026@mail.gmail.com> References: <7c6512110810051655r6dc85cd4o945aee4606a218f8@mail.gmail.com> <20081006200850.GF22390@gmx.de> <7c6512110810061400o34feea29yee484ceb68e21026@mail.gmail.com> Message-ID: <7c6512110810071438u2527138aheb0a707f14c27761@mail.gmail.com> Ok, I tried nix but I couldn't get it to work. Initially I had a problem since I was trying to get nix to install in my home directory and on the host (Dreamhost) that's actually a symlink, which nix doesn't allow. Then once I got it installed finally it didn't build - I can't remember the details exactly. I then tried to generate hc files for 6.6.1 to install that to bootstrap from, but I couldn't get ghc to build those on my machine - looking around it seems to have a lot of problems building on Leopard. My last resort is now to install Ubuntu in VMWare, install ghc, then generate the hc files on that, get those on my host, bootstrap from that, and then build 6.8.3 from source. As an aside, is there any reason the tar of the hc files isn't available for download for versions that support it? It would make this a lot easier. Cheers, Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/dbb043b2/attachment.htm From daniel.is.fischer at web.de Tue Oct 7 17:54:44 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Oct 7 17:48:54 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <49a77b7a0810071438v3c32f1bcu6ed66a6945640882@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <200810072307.48023.daniel.is.fischer@web.de> <49a77b7a0810071438v3c32f1bcu6ed66a6945640882@mail.gmail.com> Message-ID: <200810072354.44774.daniel.is.fischer@web.de> Am Dienstag, 7. Oktober 2008 23:38 schrieb David Menendez: > On Tue, Oct 7, 2008 at 5:07 PM, Daniel Fischer wrote: > > Am Dienstag, 7. Oktober 2008 22:09 schrieb Andrew Coppin: > >> Daniel Fischer wrote: > >> > Maybe it is as simple as > >> > > >> > raw_bind (xs:xss) f = do > >> > rsYs <- mapM f xs > >> > ~rsZ <- raw_bind xss f > >> > return (foldr union (cost rsZ) rsYs) > >> > > >> > then rsZ should only be evaluated when it's needed > >> > >> Ooo... "lazy pattern matching"? Can somebody explain to me, _very > >> slowy_, exactly what that means? > > > > >> If I'm not mistaken, the rsZ variable shouldn't be evaluated until > >> needed *anyway*, so what is lazy pattern matching buying me here? > > > > That depends on how your Monad (and union) is implemented, it may or may > > not make a difference. I must admit that I didn't really look at the code > > you posted, so I don't know what would be the case here. It was just an > > easy thing to try which *might* help. > > Unless you're pattern matching against a constructor, which rsZ is > not, I think lazy pattern matching is no different from regular > pattern matching. I think you're right, I was being stupid. Oh, well, it's late here From dave at zednenem.com Tue Oct 7 17:53:23 2008 From: dave at zednenem.com (David Menendez) Date: Tue Oct 7 17:49:43 2008 Subject: [Haskell-cafe] Monad transformers [Stacking monads] In-Reply-To: <48EA79B3.9080202@btinternet.com> References: <48E5025B.1040908@btinternet.com> <49a77b7a0810021111r48692fa2lfb81aecad92c6309@mail.gmail.com> <48E523AF.3000903@btinternet.com> <49a77b7a0810021501n4c65b684k3acc87f545f6cad2@mail.gmail.com> <48E658BC.3030705@btinternet.com> <49a77b7a0810031217v7a464e74t561b289e9417258f@mail.gmail.com> <48E8EC1D.9060203@btinternet.com> <48EA79B3.9080202@btinternet.com> Message-ID: <49a77b7a0810071453m44cd7a8bu193b195e11fd3dfa@mail.gmail.com> On Mon, Oct 6, 2008 at 4:48 PM, Andrew Coppin wrote: > Andrew Coppin wrote: >> >> I have some longwinded code that works, but I'm still thinking about how >> to do this more elegantly. It looks like what I really need is something >> like >> >> type M = StateT State (ResultSetT (ErrorT ErrorType Identity)) >> >> Is that the correct ordering? Pretty much. > For reference, I humbly present ResultSet.hs: There are actually several ways to make ResultSetT from ResultSet, depending on how you want to handle the inner monad. There are two popular ways to make a transformer variant of [], of which the easier looks something like this: newtype ListT m a = ListT { unListT :: m (Stream m a) } data Stream m a = Nil | Cons a (m (Stream m a)) Using that and your code as a pattern, I've come up with the guts of a similar transformer, included below. Like your code, it maintains a list of answers at each depth. The effects of each depth are deferred until some code (e.g., to_list) demands it, but the effects associated with any answer at a given depth are linked. The resulting code, I imagine, is not very efficient, but it shouldn't be too awful. I've tried to keep things structurally similar to your code, to hopefully make it clearer what is happening. I also recommend trying alternatives like Oleg's FBackTrackT. In that code, "mplus" corresponds to "union". ==== import Control.Monad newtype ResultSetT m a = Pack { unpack :: m (Stream m a) } data Stream m a = Nil | Cons [a] (m (Stream m a)) -- this is just the important parts, the rest should be fairly straightforward. raw_lift :: (Monad m) => m a -> m (Stream m a) raw_lift = liftM (\x -> Cons [x] (return Nil)) raw_union :: (Monad m) => Stream m a -> Stream m a -> Stream m a raw_union Nil yss = yss raw_union xss Nil = xss raw_union (Cons xs xss) (Cons ys yss) = Cons (xs ++ ys) (liftM2 raw_union xss yss) raw_bind :: (Monad m) => m (Stream m a) -> (a -> m (Stream m b)) -> m (Stream m b) raw_bind xss f = xss >>= work (return Nil) where work out Nil = out work out (Cons xs xss) = do yss <- foldr (liftM2 raw_union) out $ map f xs return undefined case yss of Nil -> return $ Cons [] (xss >>= work (return Nil)) Cons ys yss -> return $ Cons ys (xss >>= work yss) from_list :: (Monad m) => [[a]] -> ResultSetT m a from_list = Pack . foldr (\xs xss -> return $ Cons xs xss) (return Nil) to_list :: (Monad m) => ResultSetT m a -> m [[a]] to_list (Pack m) = m >>= work where work Nil = return [[]] work (Cons xs xss) = liftM (xs:) (xss >>= work) limit :: (Monad m) => Int -> ResultSetT m a -> ResultSetT m a limit n (Pack xss) = Pack (xss >>= work n) where work n (Cons xs xss) | n > 0 = return $ Cons xs (xss >>= work (n-1)) work _ _ = return Nil -- Dave Menendez From lrpalmer at gmail.com Tue Oct 7 20:30:43 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Oct 7 20:27:04 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 Message-ID: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> Several very elegant FRP approaches are emerging, most visibly FRP.Reactive, which rely on blocking on multiple variables at once, continuing when the *first* of them is available. . . inside an unsafePerformIO, so the beautiful STM "orElse" solution is not available. The current solution is to race threads against each other, and have the one that finishes first kill the other one. This is implemented, for example, in Data.Unamb. However, our empirical tests have shown that the GHC scheduler is not *quite* good enough to handle this efficiently, and ends up introducing too much latency and nondeterminacy. The Data.IVarmodule, just uploaded to hackage, provides an alternative to thread racing as a solution to this problem. It provides *write-once* variables which can be blocked on in parallel, without forking any threads or using STM (so it is safe to use in unsafePerformIO). Example usage from the documentation: import qualified Data.IVar as IVar import Control.Concurrent main = do iv <- IVar.new iv' <- IVar.new forkIO $ threadDelay 10000000 >> writeIVar iv' "my spoon is too big" let merger = IVar.read iv `mplus` IVar.read iv' print =<< IVar.nonblocking merger -- most likely "Nothing" print =<< IVar.blocking merger -- waits a while, then prints writeIVar iv' "i am a banana" -- throws error "IVar written twice" Enjoy! Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081007/1375862d/attachment.htm From tim at goddard.net.nz Tue Oct 7 22:36:34 2008 From: tim at goddard.net.nz (Timothy Goddard) Date: Tue Oct 7 22:32:59 2008 Subject: [Haskell-cafe] monadic parser with Happy and Alex In-Reply-To: <48E7864F.60802@libero.it> References: <48E7864F.60802@libero.it> Message-ID: <200810081536.35090.tim@goddard.net.nz> On Sun, 05 Oct 2008 04:05:51 Manlio Perillo wrote: > Hi. > > I have completed a draft of a CSS lexer, using Alex. > http://hg.mperillo.ath.cx/haskell/webtools/file/tip/src/CSS/Lexer.x > > The lexer use the posn wrapper. > > Now I'm starting to write the parser with Happy, however for the final > product I would like to: > 1) Be able to do I/O in the lexer, for stylesheets inclusion > (@import rule) > 2) be able to keep state in the parser (or lexer?), for character > transcoding (@charset rule) > > > This should be possible with Happy (and there are some example), however > I don't find examples that make use of a lexer written with Alex. > > Should I write a lexer using only the Alex basic interface (without > wrappers)? > > > > Thanks Manlio Perillo > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe Hi Manlio, You may be better off separating the parsing from the import process. You would first parse it in to internal data structures (including an option for import) then go through that and replace import statements with the parsed content of those files. Producing a list which is then consumed by an IO procedure is almost exactly equivalent to threading IO through the entire parser and is a lot tidier, more flexible and should be easier to maintain. Cheers, Tim From dons at galois.com Wed Oct 8 02:20:12 2008 From: dons at galois.com (Don Stewart) Date: Wed Oct 8 02:16:21 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 In-Reply-To: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> References: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> Message-ID: <20081008062012.GB20933@scytale.galois.com> lrpalmer: > Several very elegant FRP approaches are emerging, most visibly > FRP.Reactive, which rely on blocking on multiple variables at once, > continuing when the *first* of them is available. . . inside an > unsafePerformIO, so the beautiful STM "orElse" solution is not available. > The current solution is to race threads against each other, and have the > one that finishes first kill the other one. This is implemented, for > example, in Data.Unamb. However, our empirical tests have shown that the > GHC scheduler is not *quite* good enough to handle this efficiently, and > ends up introducing too much latency and nondeterminacy. Cool! Does you IVar implementation have anything in common with previous proposals for things called IVar (or say, 'ports', http://www.cse.unsw.edu.au/~chak/haskell/ports/)? What's the background for this abstraction? -- Don From lrpalmer at gmail.com Wed Oct 8 02:36:22 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Oct 8 02:32:42 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 In-Reply-To: <20081008062012.GB20933@scytale.galois.com> References: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> <20081008062012.GB20933@scytale.galois.com> Message-ID: <7ca3f0160810072336w261e9ffbxdce22dfcf29e38f5@mail.gmail.com> On Wed, Oct 8, 2008 at 12:20 AM, Don Stewart wrote: > lrpalmer: > > Several very elegant FRP approaches are emerging, most visibly > > FRP.Reactive, which rely on blocking on multiple variables at once, > > continuing when the *first* of them is available. . . inside an > > unsafePerformIO, so the beautiful STM "orElse" solution is not > available. > > The current solution is to race threads against each other, and have > the > > one that finishes first kill the other one. This is implemented, for > > example, in Data.Unamb. However, our empirical tests have shown that > the > > GHC scheduler is not *quite* good enough to handle this efficiently, > and > > ends up introducing too much latency and nondeterminacy. > > Cool! Does you IVar implementation have anything in common with previous > proposals for things called IVar (or say, 'ports', > http://www.cse.unsw.edu.au/~chak/haskell/ports/ > )? Yes, I picked up the name from haskell-cafe discussions a while back. Various forms have been popping in and out of the reactive libraries. I hadn't seen ports before. What's the background for this abstraction? > So like I said, I'm not too sure, I just stole the name and vague idea from discussions about it. As is easily noticed from the jive above, it's motivated by the continuous barrage of suboptimal FRP libraries. While I'm working on reactive from the top down, this is the beginning of one I have planned, taking baby steps from the bottom up (and it'll likely get incorporated into reactive too). Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/5cf530e1/attachment.htm From leather at cs.uu.nl Wed Oct 8 03:01:40 2008 From: leather at cs.uu.nl (Sean Leather) Date: Wed Oct 8 02:58:00 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 In-Reply-To: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> References: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> Message-ID: <3c6288ab0810080001h7d76b11ft9bd9421d476f7ee2@mail.gmail.com> > forkIO $ threadDelay 10000000 >> writeIVar iv' "my spoon is too big" > writeIVar iv' "i am a banana" -- throws error "IVar written twice" > Nice Don Hertzfeldt reference. ;) If this means nothing to you, here's the animated film from whence this came: http://www.youtube.com/watch?v=MuOvqeABHvQ Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/c7e03432/attachment.htm From vigalchin at gmail.com Wed Oct 8 03:07:52 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Oct 8 03:04:12 2008 Subject: [Haskell-cafe] RE: I'll do USB in Haskell - tips? Message-ID: <5ae4f2ba0810080007m4e85067cl91b0a73e96c83928@mail.gmail.com> Hello, I am also interested in SCSI, PCI, etc. I think the main problem/issue vis-a-vis USB/SCSI/PCI et. al. for Haskell is does (or will there exist) a Posix API and a Windows API for these buses/protocols? I read one URL but it will only support Linux. Ok .. maybe there API will be implemented for other Posix OS's like solaris, AIX, HP-UX, etc. but I wouldn't "bet the farm on it". I am not trying to be pesimistic but just save Marco some time in his life. Maybe Marco should talk to the people doing the Linux implementation for the "Posix" API and see how viable that API is before spending a year for nothing. Or Marco maybe you can be a trailblazer and come up with a better "Posix/Win32 USB API" and implement in Haskell? ;^) Very kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/01b7da1b/attachment.htm From ryani.spam at gmail.com Wed Oct 8 03:15:23 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Oct 8 03:11:44 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <48EBA5D5.9050503@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> Message-ID: <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> On Tue, Oct 7, 2008 at 7:09 PM, Andrew Coppin wrote: > For my current troubles, it would be really useful if there were some > program that you could feed some source code to, and it would tell you what > the inferred types of each subexpression are. (Ideally it would be nice if > you could use this on fragments that don't typecheck; being able to see what > types are being inferred where could help explain why the type checker is > unhappy, and ultimately where you went wrong. But I'm not sure how you could > present the internal state in a digestible way.) I don't know if anybody has > ever attempted such a tool...? There is such a tool, it's called ghci :) It just takes a bit of massaging to do what you want: ... some module code ... {- function_that_does_not_typecheck = some_expression -} function_that_does_not_typecheck = error "force typechecker to be happy" For now lets assume that you are curious about the type of the subexpression f some_func [a..b] where f, a, and b are locally bound. Then ghci> :set -fglasgow-exts ghci> :t (?f some_func [?a .. ?b]) Here's an example: Prelude> :t ?f map [?a .. ?b] ?f map [?a .. ?b] :: forall t a b t1. (Enum t1, ?b::t1, ?a::t1, ?f::((a -> b) -> [a] -> [b]) -> [t1] -> t) => t This tells you the types the variables have to have, and the type of the expression. Judicious use of (undefined :: type_signature) can also help. -- ryan From neil.mitchell.2 at credit-suisse.com Wed Oct 8 03:21:59 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Wed Oct 8 03:25:55 2008 Subject: [Haskell-cafe] Darcs / Git In-Reply-To: <1598FE3B-5D3A-47EE-862F-DB54C2AC6A69@yandex.ru> References: <48EA62D9.1020607@blueyonder.co.uk> <8BF4EDFF-6293-4CE7-9208-E54A7374234B@yandex.ru> <33A3F585590A6F4E81E3D45AA4A111C902CD3AD3@ELON17P32001A.csfb.cs-group.com> <1598FE3B-5D3A-47EE-862F-DB54C2AC6A69@yandex.ru> Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3AD6@ELON17P32001A.csfb.cs-group.com> > Yes, I've used SSH key. Didn't think it would be different > with a password. It really is! :-) Thanks Neil > > On 7 Oct 2008, at 20:19, Mitchell, Neil wrote: > > > > > > >>> I use darcs on Windows every day and it works well. The > >> only problem > >>> is that it is not very usable if you access your > repository via SSH > >>> and the authentication is via password. > >> > >> Why not? It worked fine for me. > > > > It's never worked for me, I always get a frozen darcs > trying to read a > > password, but not from my console. > > > > If you connect with an SSH key its more secure and less > typing - it's > > a better way to go. > > > > Thanks > > > > Neil > > > > = > > = > > = > > = > > = > > = > > = > > = > > > ====================================================================== > > Please access the attached hyperlink for an important electronic > > communications disclaimer: > > > > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > > = > > = > > = > > = > > = > > = > > = > > = > > > ====================================================================== > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From magnus at therning.org Wed Oct 8 05:12:24 2008 From: magnus at therning.org (Magnus Therning) Date: Wed Oct 8 05:08:44 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? Message-ID: This morning I got tired of my desktop wallpaper (one that ships with Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded a lot of links to wallpapers with Colleen Haskell, while she's a beautiful lady it wasn't exactly what I was hoping to find. Hence this email. Where can I find some nice wallpapers inspired by Haskell, or maybe even created by Haskell code? Oh yes, wallpapers related to XMonad would do, I suppose ;-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From svein.ove at aas.no Wed Oct 8 05:46:54 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Oct 8 05:43:14 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <221b53ab0810080246n20229e85gb3bb3d20eee58fea@mail.gmail.com> 2008/10/8 Magnus Therning : > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? > It's not quite what you asked for, but http://arcanux.org/lambdacats.html does contain my current wallpaper. Close enough? From dougal at dougalstanton.net Wed Oct 8 05:49:05 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Wed Oct 8 05:45:26 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <2d3641330810080249l4c2e3c39nd1cf244475f3c188@mail.gmail.com> 2008/10/8 Magnus Therning : > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? It shouldn't be too difficult to generate some wallpapers. Look at the examples included with the Diagrams package [1]. You could take the Ford circles and have different coloured circles at every startup. You could even have a range of palettes depending on season ;-) [1]: Cheers, D From xj2106 at columbia.edu Wed Oct 8 07:20:27 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Wed Oct 8 07:16:55 2008 Subject: [Haskell-cafe] [hmatrix] build error Message-ID: <87bpxvgwp0.fsf@columbia.edu> Hi, looks like I hit a bug, but I'm not sure which software it belongs to, gcc, ghc or atlas? ---------- error doing "runhaskell Setup build" ---------- Preprocessing library hmatrix-0.4.1.0... /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make ---------- error doing "runhaskell Setup build" ---------- I believe `__powidf2' is a internal symbol in gcc and it is hidden. The system is archlinux x86_64 and the software I used are atlas-lapack 3.8.2-1 gcc 4.3.2-1 Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic Thread model: posix gcc version 4.3.2 (GCC) ghc 6.8.2-2 [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.2") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","YES") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ] I googled but no useful information. Best, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From roly.perera at dynamicaspects.org Wed Oct 8 07:22:59 2008 From: roly.perera at dynamicaspects.org (Roly Perera) Date: Wed Oct 8 07:19:33 2008 Subject: [Haskell-cafe] Re: Type classes question References: <2f9b2d30810070621m2fa91f27k2817f08e429bc3e0@mail.gmail.com> Message-ID: Ryan Ingram gmail.com> writes: > [...] > > Here's another possible solution: > > > newtype AsFunctor s a = AF { fstream :: (s a) } > > instance (Stream f) => Functor (AsFunctor f) where > > fmap f (AF s) = AF (fmapStreamDefault f s) > > Now to use fmap you wrap in AF and unwrap with fstream. > > None of the existing solutions are really satisfactory, unfortunately. Bulat Ziganshin gmail.com> writes: > http://haskell.org/haskellwiki/OOP_vs_type_classes may be useful Many thanks to you both for the clarification and pointers. cheers, Roly From xj2106 at columbia.edu Wed Oct 8 08:14:05 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Wed Oct 8 08:10:31 2008 Subject: [Haskell-cafe] [hmatrix] build error In-Reply-To: <87bpxvgwp0.fsf@columbia.edu> (Xiao-Yong Jin's message of "Wed, 08 Oct 2008 07:20:27 -0400") References: <87bpxvgwp0.fsf@columbia.edu> Message-ID: <877i8jgu7m.fsf@columbia.edu> Xiao-Yong Jin writes: > Hi, looks like I hit a bug, but I'm not sure which software > it belongs to, gcc, ghc or atlas? > > ---------- error doing "runhaskell Setup build" ---------- > Preprocessing library hmatrix-0.4.1.0... > /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO > /usr/bin/ld: final link failed: Nonrepresentable section on output > collect2: ld returned 1 exit status > linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed > command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make > ---------- error doing "runhaskell Setup build" ---------- It might be a problem of atlas. With Intel's MKL, it builds fine. -- c/* __o/* <\ * (__ */\ < From voigt at tcs.inf.tu-dresden.de Wed Oct 8 08:22:12 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Oct 8 08:18:32 2008 Subject: [Haskell-cafe] Call for Contributions - Haskell Communities and Activities Report, November 2008 edition Message-ID: <48ECA5F4.3050801@tcs.inf.tu-dresden.de> Dear Haskellers, so much has happened in the Haskell world in the past months. Therefore, I would very much like to collect contributions for the 15th edition of the ================================================================ Haskell Communities & Activities Report http://www.haskell.org/communities/ Submission deadline: 31 October 2008 (please send your contributions to hcar@haskell.org, in plain text or LaTeX format) ================================================================ This is the short story: * If you are working on any project that is in some way related to Haskell, please write a short entry and submit it. Even if the project is very small or unfinished or you think it is not important enough -- please reconsider and submit an entry anyway! * If you are interested in any project related to Haskell that has not previously been mentioned in the HC&A Report, please tell me, so that I can contact the project leaders and ask them to submit an entry. * Feel free to pass on this call for contributions to others that might be interested. More detailed information: The Haskell Communities & Activities Report is a bi-annual overview of the state of Haskell as well as Haskell-related projects over the last, and possibly the upcoming six months. If you have only recently been exposed to Haskell, it might be a good idea to browse the May 2008 edition -- you will find interesting topics described as well as several starting points and links that may provide answers to many questions. Contributions will be collected until the submission deadline. They will then be compiled into a coherent report that is published online as soon as it is ready. As always, this is a great opportunity to update your webpages, make new releases, announce or even start new projects, or to talk about developments you want every Haskeller to know about! Looking forward to your contributions, Janis (current editor) FAQ: Q: What format should I write in? A: The best format is a LaTeX source file, adhering to the template that is available at: http://haskell.org/communities/11-2008/template.tex There is also a LaTeX style file at http://haskell.org/communities/11-2008/hcar.sty that you can use to preview your entry. If you do not know LaTeX, then use plain text. If you modify an old entry that you have written for an earlier edition of the report, you should have received your old entry as a template already (provided I have your valid email address). Please modify that template, rather than using your own version of the old entry as a template. Do not worry about writing correct LaTeX, I will be able to handle your file. Please do not use HTML or even DOC. Q: Can I include images? A: Yes, you are even encouraged to do so. Please use .jpg format, then. Q: How much should I write? A: Authors are asked to limit entries to about one column of text. This corresponds to approximately one page, or 40 lines of text, with the above style and template. A general introduction is helpful. Apart from that, you should focus on recent or upcoming developments. Pointers to online content can be given for more comprehensive or ``historic'' overviews of a project. Images do not count towards the length limit, so you may want to use this opportunity to pep entries up. There is no minimum length of an entry! The report aims at being as complete as possible, so please consider writing an entry, even if it is only a few lines long. Q: Which topics are relevant? A: All topics which are related to Haskell in some way are relevant. We usually had reports from users of Haskell (private, academic, or commercial), from authors or contributors to projects related to Haskell, from people working on the Haskell language, libraries, on language extensions or variants. We also like reports over distributions of Haskell software, Haskell infrastructure, books and tutorials on Haskell. Reports on past and upcoming events related to Haskell are also relevant. Finally, there might be new topics we do not even think about. As a rule of thumb: if in doubt, then it probably is relevant and has a place in the HCAR. You can also ask the editor. Q: Is unfinished work relevant? Are ideas for projects relevant? A: Yes! You can use the HCAR to talk about projects you are currently working on. You can use it to look for other developers that might help you. You can use it to write ``wishlist'' items for libraries and language features you would like to see implemented. Q: If I do not update my entry, but want to keep it in the report, what should I do? A: Tell the editor that there are no changes. The old entry will be reused in this case, but it might be dropped if it is older than a year, to give more room and more attention to projects that change a lot. Do not resend complete entries if you have not changed them. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From briqueabraque at yahoo.com Wed Oct 8 08:22:15 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Wed Oct 8 08:18:53 2008 Subject: [Haskell-cafe] Re: I'll do USB in Haskell - tips? In-Reply-To: <5ae4f2ba0810080007m4e85067cl91b0a73e96c83928@mail.gmail.com> References: <5ae4f2ba0810080007m4e85067cl91b0a73e96c83928@mail.gmail.com> Message-ID: Looking for "Posix Linux API", I found www.linux-usb.org. It has a lot (I think all I need) to start in Linux. Does anyone knows where can I find related information for Windows, so I can start without writing something that would be difficult to support there? Best, Maur?cio > Hello, > > I am also interested in SCSI, PCI, etc. (...) Maybe Marco > should talk to the people doing the Linux implementation for the "Posix" > API and see how viable that API is before spending a year for nothing. > Or Marco maybe you can be a trailblazer and come up with a better > "Posix/Win32 USB API&quo t; and implement in Haskell? ;^) > > Very kind regards, Vasili From jake at pikewerks.com Wed Oct 8 08:28:12 2008 From: jake at pikewerks.com (Jake Mcarthur) Date: Wed Oct 8 08:24:36 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 In-Reply-To: <7ca3f0160810072336w261e9ffbxdce22dfcf29e38f5@mail.gmail.com> References: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> <20081008062012.GB20933@scytale.galois.com> <7ca3f0160810072336w261e9ffbxdce22dfcf29e38f5@mail.gmail.com> Message-ID: <0A67735C-5A65-4874-BEC1-8B2B07F7953C@pikewerks.com> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/f6e34b96/PGP.bin From tobias.bexelius at avalanchestudios.se Wed Oct 8 08:31:01 2008 From: tobias.bexelius at avalanchestudios.se (Tobias Bexelius) Date: Wed Oct 8 08:27:24 2008 Subject: [Haskell-cafe] Functional dependencies and incoherent instances In-Reply-To: <877i8jgu7m.fsf@columbia.edu> References: <87bpxvgwp0.fsf@columbia.edu> <877i8jgu7m.fsf@columbia.edu> Message-ID: <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> Hi, Im trying to overload a multiplication operator for scalars and vectors, but keep running into the error message "Functional dependencies conflict". What I think is going on is that the dependency check doesn't work with incoherent (or overlapping) instances. In the example below, the two instances of Mult are overlapping. What I want is the vector version to be used for vectors and the scalar version used for numbers, even if a vector-type is an instance of the Num-class (I believe -fallow-incoherent-instances would make that kind of choise for me, right?). Im using the Visual Studio plugin Visual Haskell, and thus GHC version 6.6. Otherwise I think associated types might have worked better for this... Regards Tobias Bexelius {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fallow-incoherent-instances #-} data V2 a = V2 a a class Vec v a where dot :: v a -> v a -> a instance Num a => Vec V2 a where V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2 class Mult a b c | a b -> c where (*.) :: a -> b -> c instance (Num x) => Mult x x x where (*.) = (*) instance (Vec a x) => Mult (a x) (a x) x where (*.) = dot From jake at pikewerks.com Wed Oct 8 08:33:17 2008 From: jake at pikewerks.com (Jake Mcarthur) Date: Wed Oct 8 08:29:39 2008 Subject: [Haskell-cafe] ANNOUNCE: Data.IVar 0.1 In-Reply-To: <0A67735C-5A65-4874-BEC1-8B2B07F7953C@pikewerks.com> References: <7ca3f0160810071730s2f80f9f5nd3db753e368d0dfa@mail.gmail.com> <20081008062012.GB20933@scytale.galois.com> <7ca3f0160810072336w261e9ffbxdce22dfcf29e38f5@mail.gmail.com> <0A67735C-5A65-4874-BEC1-8B2B07F7953C@pikewerks.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 8, 2008, at 7:28 AM, Jake Mcarthur wrote: > I'm attaching one of the more well-known variants in case anybody > is interested, although to be honest I can't remember which one was > actually the best as I have moved on from this approach. I just looked back over it. I had forgotten how far from the original idea I had gone. Perhaps this would be better with a different name now. - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkjsqI4ACgkQye5hVyvIUKm/dQCfbzNfeTZTzmPQa6a2ZwGkqlbp ZZUAn2V5NrX1zR549EsEm8Oj5psU4fl6 =8vsl -----END PGP SIGNATURE----- From joel.bjornson at gmail.com Wed Oct 8 09:50:10 2008 From: joel.bjornson at gmail.com (=?ISO-8859-1?Q?Joel_Bj=F6rnson?=) Date: Wed Oct 8 09:46:31 2008 Subject: [Haskell-cafe] Functional dependencies and incoherent instances In-Reply-To: <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> References: <87bpxvgwp0.fsf@columbia.edu> <877i8jgu7m.fsf@columbia.edu> <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> Message-ID: <658ffcc20810080650vcd4a860s963b16fdd566ed9b@mail.gmail.com> Hi, On Wed, Oct 8, 2008 at 2:31 PM, Tobias Bexelius wrote: > Hi, > > Im trying to overload a multiplication operator for scalars and vectors, > but keep running into the error message "Functional dependencies > conflict". What I think is going on is that the dependency check doesn't > work with incoherent (or overlapping) instances. In the example below, > the two instances of Mult are overlapping. What I want is the vector > version to be used for vectors and the scalar version used for numbers, > even if a vector-type is an instance of the Num-class (I believe > -fallow-incoherent-instances would make that kind of choise for me, > right?). > > Im using the Visual Studio plugin Visual Haskell, and thus GHC version > 6.6. Otherwise I think associated types might have worked better for > this... > > > {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances > -fallow-incoherent-instances #-} > > data V2 a = V2 a a > > class Vec v a where > dot :: v a -> v a -> a > instance Num a => Vec V2 a where > V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2 > > class Mult a b c | a b -> c where > (*.) :: a -> b -> c > instance (Num x) => Mult x x x where (*.) = (*) > instance (Vec a x) => Mult (a x) (a x) x where (*.) = dot According to the definition of Mult the parameter 'c' from above should be uniquely determined by a pair of types 'a' and 'b'. Now, lets say we have a type NumVec that instantiates both the Vec class and the Num as in instance Num (NumVec a) where instance Vec NumVec a where Then according to the instance declaration instance (Num x) => Mult x x x where ... (NumVec a) (NumVec a) (NumVec a) instantiates the class. On the other hand looking at the instance declaration: instance (Vec a x) => Mult (a x) (a x) x where ... (NumVec a) (NumVec a) a , is also an instance why the fun dep (a b -> c) is violated. Regards, Joel From tobias.bexelius at avalanchestudios.se Wed Oct 8 09:59:57 2008 From: tobias.bexelius at avalanchestudios.se (Tobias Bexelius) Date: Wed Oct 8 09:56:19 2008 Subject: [Haskell-cafe] Functional dependencies and incoherent instances In-Reply-To: <658ffcc20810080650vcd4a860s963b16fdd566ed9b@mail.gmail.com> References: <87bpxvgwp0.fsf@columbia.edu> <877i8jgu7m.fsf@columbia.edu> <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> <658ffcc20810080650vcd4a860s963b16fdd566ed9b@mail.gmail.com> Message-ID: <698E8783CC407F4EB0DC9E994B6D4540BA2C72@nut.avalanchestudios.se> Yeah, I realized that. But heres where I would like the undecidable incoherent instances to kick in, i.e. as long as I haven't got any NumVec instances GHC should be able to choose only one of the Mult instances. Or do I have too much faith in the -fallow-incoherent-instances flag now? :/ I would like to be able to write something like > instance (Vec a x, -Num (a x)) => Mult (a x) (a x) x where (*.) = dot where -Num (a x) means that (a x) must not be an instance of Num. Can I express this in some way? Regards Tobias -----Original Message----- From: Joel Bj?rnson [mailto:joel.bjornson@gmail.com] Sent: den 8 oktober 2008 15:50 To: Tobias Bexelius Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Functional dependencies and incoherent instances Hi, On Wed, Oct 8, 2008 at 2:31 PM, Tobias Bexelius wrote: > Hi, > > Im trying to overload a multiplication operator for scalars and > vectors, but keep running into the error message "Functional > dependencies conflict". What I think is going on is that the > dependency check doesn't work with incoherent (or overlapping) > instances. In the example below, the two instances of Mult are > overlapping. What I want is the vector version to be used for vectors > and the scalar version used for numbers, even if a vector-type is an > instance of the Num-class (I believe -fallow-incoherent-instances > would make that kind of choise for me, right?). > > Im using the Visual Studio plugin Visual Haskell, and thus GHC version > 6.6. Otherwise I think associated types might have worked better for > this... > > > {-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances > -fallow-incoherent-instances #-} > > data V2 a = V2 a a > > class Vec v a where > dot :: v a -> v a -> a > instance Num a => Vec V2 a where > V2 a1 a2 `dot` V2 b1 b2 = a1*b1+a2*b2 > > class Mult a b c | a b -> c where > (*.) :: a -> b -> c > instance (Num x) => Mult x x x where (*.) = (*) instance (Vec a x) => > Mult (a x) (a x) x where (*.) = dot According to the definition of Mult the parameter 'c' from above should be uniquely determined by a pair of types 'a' and 'b'. Now, lets say we have a type NumVec that instantiates both the Vec class and the Num as in instance Num (NumVec a) where instance Vec NumVec a where Then according to the instance declaration instance (Num x) => Mult x x x where ... (NumVec a) (NumVec a) (NumVec a) instantiates the class. On the other hand looking at the instance declaration: instance (Vec a x) => Mult (a x) (a x) x where ... (NumVec a) (NumVec a) a , is also an instance why the fun dep (a b -> c) is violated. Regards, Joel From manlio_perillo at libero.it Wed Oct 8 11:10:21 2008 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Oct 8 11:06:45 2008 Subject: [Haskell-cafe] monadic parser with Happy and Alex In-Reply-To: <200810081536.35090.tim@goddard.net.nz> References: <48E7864F.60802@libero.it> <200810081536.35090.tim@goddard.net.nz> Message-ID: <48ECCD5D.1080706@libero.it> Timothy Goddard ha scritto: > On Sun, 05 Oct 2008 04:05:51 Manlio Perillo wrote: >> Hi. >> >> I have completed a draft of a CSS lexer, using Alex. >> http://hg.mperillo.ath.cx/haskell/webtools/file/tip/src/CSS/Lexer.x >> >> The lexer use the posn wrapper. >> >> Now I'm starting to write the parser with Happy, however for the final >> product I would like to: >> 1) Be able to do I/O in the lexer, for stylesheets inclusion >> (@import rule) >> 2) be able to keep state in the parser (or lexer?), for character >> transcoding (@charset rule) >> >> >> This should be possible with Happy (and there are some example), however >> I don't find examples that make use of a lexer written with Alex. >> >> Should I write a lexer using only the Alex basic interface (without >> wrappers)? >> >> >> >> Thanks Manlio Perillo >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > Hi Manlio, > > You may be better off separating the parsing from the import process. You > would first parse it in to internal data structures (including an option for > import) then go through that and replace import statements with the parsed > content of those files. Thanks, this seems the best solution. > Producing a list which is then consumed by an IO > procedure is almost exactly equivalent to threading IO through the entire > parser and is a lot tidier, more flexible and should be easier to maintain. > Regards Manlio From pkeir at dcs.gla.ac.uk Wed Oct 8 11:25:01 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Wed Oct 8 11:21:23 2008 Subject: [Haskell-cafe] Simple Table Update Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> Hi, I'd like to create a new list based on an original list, using information from a second (symbol) list. That second list should be updated as each element in the new list is added. I've been using map a lot, but that's not an option here, and I'm having trouble obtaining a good recursive structure for my function. The minimal "fixpus" function below shows the problem. I have "sts" on both sides of the ":" list construct, but I'd like the second "sts" to be a version modified by the where (singular) function, "fixpu". fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] fixpus [] _ = [] fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts where fixpu pu sts = pu (Below) I tried making "fixpu" return a tuple, and then use "fst", "snd" and "let", but I think it looks strange. I know it's quite basic, but I'd like a strong foundation for what's likely to become a medium-scale project. Can anyone offer advice? fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] fixpus [] _ = [] fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a) where fixpu pu sts = (pu,sts ++ [("",[])]) Regards, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/3719b9a9/attachment.htm From allbery at ece.cmu.edu Wed Oct 8 11:54:11 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Oct 8 11:50:32 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: On Oct 8, 2008, at 05:12 , Magnus Therning wrote: > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? Haskell-created: http://www.frank-buss.de/haskell/OlympicRings.hs.txt http://hackage.haskell.org/cgi-bin/hackage-scripts/package/nymphaea -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From aruiz at um.es Wed Oct 8 12:22:22 2008 From: aruiz at um.es (Alberto Ruiz) Date: Wed Oct 8 12:18:44 2008 Subject: [Haskell-cafe] Re: [hmatrix] build error In-Reply-To: <87bpxvgwp0.fsf@columbia.edu> References: <87bpxvgwp0.fsf@columbia.edu> Message-ID: <48ECDE3E.4010402@um.es> Hi Xiao-Yong, In i686 Arch linux, with the normal blas and lapack, I need: extra-libraries: gsl lapack blas gslcblas gfortran But using atlas-lapack: extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s I don't know how I found that "__powidf2" is in libgcc_s :) I will add these options to hmatrix.cabal. -Alberto Xiao-Yong Jin wrote: > Hi, looks like I hit a bug, but I'm not sure which software > it belongs to, gcc, ghc or atlas? > > ---------- error doing "runhaskell Setup build" ---------- > Preprocessing library hmatrix-0.4.1.0... > /usr/bin/ld: dist/build/Numeric/GSL/Special/Internal_hsc_make: hidden symbol `__powidf2' in /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/libgcc.a(_powidf2.o) isreferenced by DSO > /usr/bin/ld: final link failed: Nonrepresentable section on output > collect2: ld returned 1 exit status > linking dist/build/Numeric/GSL/Special/Internal_hsc_make.o failed > command was: /usr/bin/ghc -optl-lgsl -optl-llapack dist/build/Numeric/GSL/Special/Internal_hsc_make.o -o dist/build/Numeric/GSL/Special/Internal_hsc_make > ---------- error doing "runhaskell Setup build" ---------- > > I believe `__powidf2' is a internal symbol in gcc and it is > hidden. > > The system is archlinux x86_64 and the software I used are > > atlas-lapack 3.8.2-1 > > gcc 4.3.2-1 > Using built-in specs. > Target: x86_64-unknown-linux-gnu > Configured with: ../configure --prefix=/usr --enable-shared --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit --disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu --disable-libstdcxx-pch --with-tune=generic > Thread model: posix > gcc version 4.3.2 (GCC) > > ghc 6.8.2-2 > [("Project name","The Glorious Glasgow Haskell Compilation System") > ,("Project version","6.8.2") > ,("Booter version","6.8.2") > ,("Stage","2") > ,("Interface file version","6") > ,("Have interpreter","YES") > ,("Object splitting","YES") > ,("Have native code generator","YES") > ,("Support SMP","YES") > ,("Unregisterised","NO") > ,("Tables next to code","YES") > ,("Win32 DLLs","") > ,("RTS ways"," debug thr thr_p thr_debug") > ,("Leading underscore","NO") > ] > > I googled but no useful information. > > Best, > Xiao-Yong From wchogg at gmail.com Wed Oct 8 12:41:29 2008 From: wchogg at gmail.com (Creighton Hogg) Date: Wed Oct 8 12:37:47 2008 Subject: [Haskell-cafe] Bluetooth libraries Message-ID: <814617240810080941v1f117d6akf2943cf2e4deacaa@mail.gmail.com> Hello, In the interest of not duplicating any effort, I wanted to ask if anyone was aware of/working on libraries for doing bluetooth programming from Haskell. I didn't find any on hackage nor did The Google indicate that this was a filled niche. Cheers, Creighton From ryani.spam at gmail.com Wed Oct 8 12:58:23 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Oct 8 12:54:44 2008 Subject: [Haskell-cafe] Functional dependencies and incoherent instances In-Reply-To: <698E8783CC407F4EB0DC9E994B6D4540BA2C72@nut.avalanchestudios.se> References: <87bpxvgwp0.fsf@columbia.edu> <877i8jgu7m.fsf@columbia.edu> <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> <658ffcc20810080650vcd4a860s963b16fdd566ed9b@mail.gmail.com> <698E8783CC407F4EB0DC9E994B6D4540BA2C72@nut.avalanchestudios.se> Message-ID: <2f9b2d30810080958m1fa0d916t33ad97b561043c02@mail.gmail.com> On Wed, Oct 8, 2008 at 2:59 PM, Tobias Bexelius wrote: > Or do I have too much faith in the -fallow-incoherent-instances flag now? :/ Overlapping instances are an "instance definition"-time feature; incoherent instances only become applicable at the call site for polymorphic functions in the presence of overlapping instances. As an example, consider the following overlapping instances: {-# LANGUAGE OverlappingInstances #-} class Foo a where foo :: a -> Bool instance Foo a where foo x = False instance Foo Integer where foo x = (x == 3) test1 :: String -> Bool test1 x = foo x -- uses "Foo a" instance test2 :: Integer -> Bool test2 x = foo x -- uses "Foo Integer" instance test3 :: a -> Bool test3 x = foo x -- incoherent! Consider (test3 (3 :: Integer)). This should definitely use the implementation for instance Foo Integer. But it can't, because test3 doesn't know what type its argument is! Incoherent instances still allows test3 to compile, but it may choose the "wrong" instance. In this case, test3 will use the "Foo a" instance no matter what type of argument you pass it. But the incoherency only arises at a call-site for the class method; if you take test3 out of this program, the instances are still overlapping but there is no compile problem (assuming -foverlapping-instances). If you are getting an error because of an instance definition, as opposed to a call site, incoherent instances won't help you. -- ryan From ryani.spam at gmail.com Wed Oct 8 13:03:36 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Oct 8 12:59:56 2008 Subject: [Haskell-cafe] Simple Table Update In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> Message-ID: <2f9b2d30810081003i439eaf05y135cffe368f97849@mail.gmail.com> Prelude> :t Data.List.mapAccumL Data.List.mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y]) I'm sure you can fill in the details :) -- ryan 2008/10/8 Paul Keir : > Hi, > > I'd like to create a new list based on an original list, using information > from a second (symbol) list. That second list should be updated as each > element in the new list is added. I've been using map a lot, but that's not > an option here, and I'm having trouble obtaining a good recursive structure > for my function. > > The minimal "fixpus" function below shows the problem. I have "sts" on both > sides of the ":" list construct, but I'd like the second "sts" to be a > version modified by the where (singular) function, "fixpu". > > fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] > fixpus [] _ = [] > fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts > > where fixpu pu sts = pu > > (Below) I tried making "fixpu" return a tuple, and then use "fst", "snd" and > "let", but I think it looks strange. I know it's quite basic, but I'd like a > strong foundation for what's likely to become a medium-scale project. Can > anyone offer advice? > > fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] > fixpus [] _ = [] > fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a) > > where fixpu pu sts = (pu,sts ++ [("",[])]) > > Regards, > Paul > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From emax at chalmers.se Wed Oct 8 13:16:25 2008 From: emax at chalmers.se (Emil Axelsson) Date: Wed Oct 8 13:12:44 2008 Subject: [Haskell-cafe] Functional dependencies and incoherent instances In-Reply-To: <698E8783CC407F4EB0DC9E994B6D4540BA2C72@nut.avalanchestudios.se> References: <87bpxvgwp0.fsf@columbia.edu> <877i8jgu7m.fsf@columbia.edu> <698E8783CC407F4EB0DC9E994B6D4540BA2C0B@nut.avalanchestudios.se> <658ffcc20810080650vcd4a860s963b16fdd566ed9b@mail.gmail.com> <698E8783CC407F4EB0DC9E994B6D4540BA2C72@nut.avalanchestudios.se> Message-ID: <48ECEAE9.5000903@chalmers.se> I think the technique described at http://haskell.org/haskellwiki/GHC/AdvancedOverlap may give you what you want. I've never tried it myself though. / Emil Tobias Bexelius skrev: > Yeah, I realized that. > > But heres where I would like the undecidable incoherent instances to kick in, i.e. as long as I haven't got any NumVec instances GHC should be able to choose only one of the Mult instances. Or do I have too much faith in the -fallow-incoherent-instances flag now? :/ > > I would like to be able to write something like >> instance (Vec a x, -Num (a x)) => Mult (a x) (a x) x where (*.) = dot > where -Num (a x) means that (a x) must not be an instance of Num. Can I express this in some way? > > Regards > Tobias From moonlite at dtek.chalmers.se Wed Oct 8 14:13:52 2008 From: moonlite at dtek.chalmers.se (Mattias Bengtsson) Date: Wed Oct 8 14:10:12 2008 Subject: [Haskell-cafe] Bluetooth libraries In-Reply-To: <814617240810080941v1f117d6akf2943cf2e4deacaa@mail.gmail.com> References: <814617240810080941v1f117d6akf2943cf2e4deacaa@mail.gmail.com> Message-ID: <1223489632.32728.30.camel@localhost.localdomain> On Wed, 2008-10-08 at 11:41 -0500, Creighton Hogg wrote: > In the interest of not duplicating any effort, I wanted to ask if > anyone was aware of/working on libraries for doing bluetooth > programming from Haskell. I didn't find any on hackage nor did The > Google indicate that this was a filled niche. If it's not on Hackage and you can't find anything on Google... Anyhow, on Linux what you'd probably want to do is to create bindings for BlueZ (http://www.bluez.org/). Good luck! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/d6060399/attachment.bin From andrewcoppin at btinternet.com Wed Oct 8 15:11:05 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Oct 8 15:07:22 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> Message-ID: <48ED05C9.1020907@btinternet.com> Ryan Ingram wrote: > > > There is such a tool, it's called ghci :) > It just takes a bit of massaging to do what you want: > > ghci> :set -fglasgow-exts > ghci> :t (?f some_func [?a .. ?b]) > > Here's an example: > Prelude> :t ?f map [?a .. ?b] > ?f map [?a .. ?b] :: forall t a b t1. > (Enum t1, > ?b::t1, > ?a::t1, > ?f::((a -> b) -> [a] -> [b]) -> [t1] -> t) > => t > > This tells you the types the variables have to have, and the type of > the expression. > > Judicious use of (undefined :: type_signature) can also help. > Using undefined is already a standard technique for me. But what it doesn't let you do is foo (undefined :: Bar x) (undefined) :: Bar y -- What type is the second argument? I'm curios as to how the example you give actually works - I don't recognise that syntax at all... From duncan.coutts at worc.ox.ac.uk Wed Oct 8 13:20:32 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Oct 8 16:05:03 2008 Subject: [Haskell-cafe] Re: [Haskell] Catching error / making library functions monadic (in failure) In-Reply-To: <200810081807.52766.p.k.f.holzenspies@utwente.nl> References: <200810081637.49352.p.k.f.holzenspies@utwente.nl> <200810081658.27953.p.k.f.holzenspies@utwente.nl> <1223479699.14163.661.camel@dell.linuxdev.us.dell.com> <200810081807.52766.p.k.f.holzenspies@utwente.nl> Message-ID: <1223486432.14163.679.camel@dell.linuxdev.us.dell.com> On Wed, 2008-10-08 at 18:07 +0200, Philip K.F. H?lzenspies wrote: > I think this is the core problem I have. Really, error should be implemented > as fail, rather than vice versa. I see why this doesn't work, because it > would type > > error :: Monad m => String -> m a > > even though the whole idea is that it's typed 'a'. Right, that's exactly why it would not work to give error that type. However error should only be being used for programming errors, not for expected runtime errors. > Nonetheless, I would like > it if either IO wasn't the only monad allowing catching, or standard > functions not only being available with 'error' stuff (like !!, head, etc.). Those functions do have safe counterparts for when you cannot guarantee the pre-condition. It typically involves pattern matching, eg instead of head use: case foo of [] -> (x:xs) -> Or for !! you could use take or splitAt and pattern matching. If you want more exact analogues of head, !! etc then see Neil's Safe library. > > If you can report them we can fix them. > > I think I spoke too soon. The error occur in other libraries' functions, so I > unjustly smudged your wonderful gtk2hs work (for which, btw: thanks very, > very much). ok :-) > To be honest; when I write a library, I also don't assume monadic > contexts for stuff that I do in purely functional terms. Sometimes errors > occur only in deeply nested code and "just putting in error" is the easy way > out. Especially, libraries that are not intended for "industrial strength" > production code seem to be prone to this type of coding, when they're not > already monadic. I think it's not as bad as you suggest. In haskell, error is like unchecked exceptions or assertions in Java. They are for cases that really indicate a programmer error, not for bad input or IO failures. Even these kinds of errors can be caught and contained in a sensible way using exception handlers in IO. For example supposing some web server page handler had some programming error and called a function in a way that violated the pre-condition and called error. That need not kill the entire server. The page handler just needs to catch all exceptions and return a 500 internal server error and write the error out to the logs. So it's actually a reasonably robust way of dealing with the inevitable programmer errors. Duncan From xj2106 at columbia.edu Wed Oct 8 16:16:00 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Wed Oct 8 16:12:26 2008 Subject: [Haskell-cafe] Re: [hmatrix] build error References: <87bpxvgwp0.fsf@columbia.edu> <48ECDE3E.4010402@um.es> Message-ID: <87k5cig7wf.fsf@columbia.edu> Alberto Ruiz writes: > Hi Xiao-Yong, > > In i686 Arch linux, with the normal blas and lapack, I need: > > extra-libraries: gsl lapack blas gslcblas gfortran > > But using atlas-lapack: > > extra-libraries: gsl lapack f77blas gslcblas atlas gcc_s I guess you want cblas instead of gslcblas, since atlas has it. > > I don't know how I found that "__powidf2" is in libgcc_s :) > References and bibliography is truly important. > I will add these options to hmatrix.cabal. > > -Alberto Thanks a lot for the excellent work. Xiao-Yong -- c/* __o/* <\ * (__ */\ < From pkeir at dcs.gla.ac.uk Wed Oct 8 16:12:45 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Wed Oct 8 16:13:30 2008 Subject: [Haskell-cafe] Simple Table Update References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> <2f9b2d30810081003i439eaf05y135cffe368f97849@mail.gmail.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C80CCAAA@EX2.ad.dcs.gla.ac.uk> It brings tears to my eyes to see such a beautiful function ;) You've hit the nail on the head Ryan. The new version of my second previous code snippet now no longer requires "fixpu*", and is: typeCheckAST (Program pus) = Program $ snd $ mapAccumL f [] pus where f st pu = (st ++ [("",[])],pu) Many thanks, Paul -----Original Message----- From: Ryan Ingram [mailto:ryani.spam@gmail.com] Sent: Wed 08/10/2008 18:03 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Simple Table Update Prelude> :t Data.List.mapAccumL Data.List.mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y]) I'm sure you can fill in the details :) -- ryan 2008/10/8 Paul Keir : > Hi, > > I'd like to create a new list based on an original list, using information > from a second (symbol) list. That second list should be updated as each > element in the new list is added. I've been using map a lot, but that's not > an option here, and I'm having trouble obtaining a good recursive structure > for my function. > > The minimal "fixpus" function below shows the problem. I have "sts" on both > sides of the ":" list construct, but I'd like the second "sts" to be a > version modified by the where (singular) function, "fixpu". > > fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] > fixpus [] _ = [] > fixpus (pu:pus) sts = fixpu pu sts : fixpus pus sts > > where fixpu pu sts = pu > > (Below) I tried making "fixpu" return a tuple, and then use "fst", "snd" and > "let", but I think it looks strange. I know it's quite basic, but I'd like a > strong foundation for what's likely to become a medium-scale project. Can > anyone offer advice? > > fixpus :: [ProgUnit] -> [ProgUnitSymbolTable] -> [ProgUnit] > fixpus [] _ = [] > fixpus (pu:pus) sts = let a = (fixpu pu sts) in fst a : fixpus pus (snd a) > > where fixpu pu sts = (pu,sts ++ [("",[])]) > > Regards, > Paul > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/824bc77d/attachment.htm From gwern0 at gmail.com Wed Oct 8 17:09:52 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Oct 8 17:06:51 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: References: <20081005202905.GA23306@craft> Message-ID: <20081008210951.GB10262@craft> On 2008.10.06 22:40:21 +1000, Ivan Miljenovic scribbled 1.6K characters: ... > Gwern: I think I've found why it never ends on xmonad-contrib (it > happens for me here on the Grahpalyze library as well): when doing > clique/cycle detection, if a function recurses on itself more than > once (e.g. multiple pattern matches, each of which recurses) then the > clique detection at the very least goes nuts and tries creating an > infinite one-function clique. This probably happens for cycles when > there's multiple edges between two functions. I think the way to fix > this is to have a function that turns a graph into a simple graph > (i.e. no multiple edges or loops; well, maybe _one_ loop) and get the > clique detection, etc. routines use the output of that for processing. > > -- > Ivan Lazar Miljenovic So it'll be fixed for the next release? Cool then; I look forward to seeing my XMC modules' analysis. -- gwern DES DDR -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081008/1a3df3d8/attachment.bin From derek.a.elkins at gmail.com Wed Oct 8 17:23:25 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Wed Oct 8 17:19:48 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <1223501005.13477.1.camel@derek-laptop> On Wed, 2008-10-08 at 10:12 +0100, Magnus Therning wrote: > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? > > Oh yes, wallpapers related to XMonad would do, I suppose ;-) Since I always run xmonad fullscreen and with no borders (i.e. there is absolutely nothing on the screen from the window manager ever,) I've considered having a screen shot of the Windows desktop as my background. From reb at cs.bilgi.edu.tr Wed Oct 8 17:28:33 2008 From: reb at cs.bilgi.edu.tr (=?utf-8?Q?R=2E_Emre_Ba=C5=9Far?=) Date: Wed Oct 8 17:24:57 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <20081008212832.GF3799@terra.galaxy> Hi, I created a wallpaper from The.Monad.Reader logo. You can find two versions here: http://tonguc.name/images/lambda-1280x800.png http://tonguc.name/images/lambda-1024x768.png Magnus Therning der ki: > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? > > Oh yes, wallpapers related to XMonad would do, I suppose ;-) > > /M > > -- > Magnus Therning (OpenPGP: 0xAB4DFBA4) > magnus?therning?org Jabber: magnus?therning?org > http://therning.org/magnus identi.ca|twitter: magthe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- R. Emre Ba?ar ?stanbul Bilgi University Department of Computer Science -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/60309d15/attachment.bin From rogpeppe at gmail.com Wed Oct 8 18:10:39 2008 From: rogpeppe at gmail.com (roger peppe) Date: Wed Oct 8 18:06:59 2008 Subject: [Haskell-cafe] synchronous channels in STM Message-ID: I was wondering if it was possible to implement synchronous channels within STM. In particular, I'd like to have CSP-like send and recv primitives on a channel that each block until the other side arrives to complete the transaction. I think I've convinced myself that it's not possible, but anyone care to differ? cheers, rog. From jason.dusek at gmail.com Wed Oct 8 18:14:35 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 8 18:10:53 2008 Subject: [Haskell-cafe] ghc 6.10 and parsec Message-ID: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or Parsec 3? -- _jsn From jake at pikewerks.com Wed Oct 8 18:15:41 2008 From: jake at pikewerks.com (Jake McArthur) Date: Wed Oct 8 18:11:59 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: Message-ID: <48ED310D.5090101@pikewerks.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 roger peppe wrote: > I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv primitives > on a channel that each block until the other side arrives to complete > the transaction. > > I think I've convinced myself that it's not possible, but > anyone care to differ? This sounds similar to what I once tried for a FRP implementation. I decided that what I was trying to do was impossible (at least without recalculating things all the time whenever something retries), and then constructed an IVar implementation which was working very elegantly (before I decided to change the core ideas behind my FRP implementation). As luck would have it, Luke Palmer recently added his own IVar implementation to Hackage, which you may find a use for. - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkjtMQwACgkQye5hVyvIUKk39QCcDdsFY7z0k2xwkJ/zBK3tVsbT n28An2D9LzUfWiWTpKIU7J7tt/VGs4EB =kQGz -----END PGP SIGNATURE----- From ivan.miljenovic at gmail.com Wed Oct 8 18:42:37 2008 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Wed Oct 8 18:38:55 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: SourceGraph-0.1 and Graphalyze-0.3 In-Reply-To: <20081008210951.GB10262@craft> References: <20081005202905.GA23306@craft> <20081008210951.GB10262@craft> Message-ID: 2008/10/8 Gwern Branwen : > > So it'll be fixed for the next release? Cool then; I look forward to seeing my XMC modules' analysis. > Yeah, I was planning on making a new release some time this week... and then I somehow accidentally uninstalled just about everything on my system, and have to do a reinstall :s -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From tanimoto at arizona.edu Wed Oct 8 19:01:38 2008 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Oct 8 18:57:55 2008 Subject: [Haskell-cafe] ghc 6.10 and parsec In-Reply-To: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> References: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> Message-ID: Jason, If this is representative of what it will be, here's what I have: $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.0.20081007 $ ghc-pkg list parsec /usr/local/lib/ghc-6.10.0.20081007/./package.conf: parsec-2.1.0.1 Paulo On Wed, Oct 8, 2008 at 5:14 PM, Jason Dusek wrote: > Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or > Parsec 3? > > -- > _jsn > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From reiner.pope at gmail.com Wed Oct 8 19:35:12 2008 From: reiner.pope at gmail.com (Reiner Pope) Date: Wed Oct 8 19:31:30 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <48ED05C9.1020907@btinternet.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> <48ED05C9.1020907@btinternet.com> Message-ID: <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> The syntax is for the implicit parameter extension[1]. I think you would write your example as foo (undefined :: Bar x) ?z :: Bar y Then querying the type of that whole expression with :t will list ?z's type in the expression's constraints. (Of course, you should turn off the monomorphism restriction so that ghc doesn't complain if constraints aren't resolved). [1]: http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#implicit-parameters Reiner On Thu, Oct 9, 2008 at 6:11 AM, Andrew Coppin wrote: > Ryan Ingram wrote: > >> >> >> There is such a tool, it's called ghci :) >> It just takes a bit of massaging to do what you want: >> >> ghci> :set -fglasgow-exts >> ghci> :t (?f some_func [?a .. ?b]) >> >> Here's an example: >> Prelude> :t ?f map [?a .. ?b] >> ?f map [?a .. ?b] :: forall t a b t1. >> (Enum t1, >> ?b::t1, >> ?a::t1, >> ?f::((a -> b) -> [a] -> [b]) -> [t1] -> t) >> => t >> >> This tells you the types the variables have to have, and the type of >> the expression. >> >> Judicious use of (undefined :: type_signature) can also help. >> >> > > Using undefined is already a standard technique for me. But what it doesn't > let you do is > > foo (undefined :: Bar x) (undefined) :: Bar y -- What type is the second > argument? > > I'm curios as to how the example you give actually works - I don't > recognise that syntax at all... > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/8d84d050/attachment.htm From claus.reinke at talk21.com Wed Oct 8 19:39:16 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Oct 8 19:35:39 2008 Subject: [Haskell-cafe] synchronous channels in STM References: Message-ID: <8BD0968BF8024A038C741277A58A11FB@cr3lt> >I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv primitives > on a channel that each block until the other side arrives to complete > the transaction. Assuming that retry blocks until something changes, you could associate a channel with a thread that encapsulates the transaction. Somewhat like this? import Control.Concurrent.STM import Control.Concurrent sender write confirm = do atomically $ putTMVar write "hi" atomically $ takeTMVar confirm putStrLn "sender done" receiver read = do r <- atomically $ takeTMVar read putStrLn $ "receiver done: "++r channel read write confirm = atomically $ do w <- takeTMVar write putTMVar read w putTMVar confirm () main = do (read,write,confirm) <- atomically $ do read <- newEmptyTMVar write <- newEmptyTMVar confirm <- newEmptyTMVar return (read,write,confirm) forkIO (channel read write confirm) forkIO (threadDelay 3000000 >> receiver read) threadDelay 5000000 >> sender write confirm You might also be interested in http://hackage.haskell.org/cgi-bin/hackage-scripts/package/chp Claus From levi.stephen at optusnet.com.au Wed Oct 8 20:06:29 2008 From: levi.stephen at optusnet.com.au (Levi Stephen) Date: Wed Oct 8 20:02:48 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <8341e4f40810081704t28d8c5beu5358ecda22cedfe3@mail.gmail.com> References: <8341e4f40810081704t28d8c5beu5358ecda22cedfe3@mail.gmail.com> Message-ID: <8341e4f40810081706h46a9e740sb0faf0daa893e4c1@mail.gmail.com> On Thu, Oct 9, 2008 at 9:40 AM, roger peppe wrote: > I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv > primitives > on a channel that each block until the other side arrives to complete > the transaction. I did experiment with the actors model (in theory a superset of CSP I believe) in haskell at one stage. Hopefully it will be of some use/interest to you. http://lstephen.wordpress.com/2007/09/08/the-actors-model-and-haskell/ Levi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/28bfe4e5/attachment-0001.htm From jason.dusek at gmail.com Wed Oct 8 20:36:29 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 8 20:32:48 2008 Subject: [Haskell-cafe] ghc 6.10 and parsec In-Reply-To: References: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> Message-ID: <42784f260810081736k3c4f3299o625d50f778e17f7e@mail.gmail.com> Aye, I have that as well, but you never know :) -- _jsn From jason.dusek at gmail.com Wed Oct 8 20:53:16 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 8 20:49:33 2008 Subject: [Haskell-cafe] parsec 3 & parsec 2 Message-ID: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> I recently took a look at the new Yi, and it looks neat but I am hesitant to install it -- it require Parsec 3. What will happen to my system, carefully maintained, if I unleash this new Parsec on my programs and the programs of others? Can I expect total breakage, coexistence or...? -- _jsn From agentzh at gmail.com Wed Oct 8 21:03:30 2008 From: agentzh at gmail.com (agentzh) Date: Wed Oct 8 20:59:48 2008 Subject: [Haskell-cafe] ghc 6.10 and parsec In-Reply-To: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> References: <42784f260810081514l5d6d7c77vcf26a981ec72aa88@mail.gmail.com> Message-ID: On Thu, Oct 9, 2008 at 6:14 AM, Jason Dusek wrote: > Which Parsec is GHC 6.10 going to ship with -- Parsec 2 or > Parsec 3? > I do hope it will be 2. Parsec 3 is significantly slower than 2 in my SQL parser. Cheers, -agentzh From 666wman at gmail.com Wed Oct 8 21:05:20 2008 From: 666wman at gmail.com (wman) Date: Wed Oct 8 21:01:38 2008 Subject: [Haskell-cafe] parsec 3 & parsec 2 In-Reply-To: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> References: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> Message-ID: Shouldn't hiding the package stop it from causing possible mayhem, yet it be accessible to those packages depending on the new version explicitly ? On Thu, Oct 9, 2008 at 2:53 AM, Jason Dusek wrote: > I recently took a look at the new Yi, and it looks neat but I > am hesitant to install it -- it require Parsec 3. What will > happen to my system, carefully maintained, if I unleash this > new Parsec on my programs and the programs of others? > > Can I expect total breakage, coexistence or...? > > -- > _jsn > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/0ca4fe4b/attachment.htm From sanzhiyan at gmail.com Wed Oct 8 21:41:12 2008 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Wed Oct 8 21:37:30 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <8BD0968BF8024A038C741277A58A11FB@cr3lt> References: <8BD0968BF8024A038C741277A58A11FB@cr3lt> Message-ID: <8625cd9c0810081841o775cfd49l225248de9d46fd6@mail.gmail.com> 2008/10/9 Claus Reinke > I was wondering if it was possible to implement synchronous channels >> within STM. In particular, I'd like to have CSP-like send and recv >> primitives >> on a channel that each block until the other side arrives to complete >> the transaction. >> > > Assuming that retry blocks until something changes, you could associate > a channel with a thread that encapsulates the transaction. Somewhat like > this? You don't need an additional channel thread: module SyncChan (SyncChan, send, recv, newSyncChan) where import Control.Concurrent.STM import Control.Monad import Control.Concurrent newtype SyncChan a = SC { unSC :: TVar (State a) } data State a = Ready | Sent a | Received newSyncChan :: STM (SyncChan a) newSyncChan = SC `fmap` newTVar Ready send :: SyncChan a -> a -> IO () send (SC chan) x = do atomically $ unsafeSend chan x atomically $ waitReceiver chan recv :: SyncChan a -> STM a recv (SC chan) = do s <- readTVar chan case s of Sent s -> writeTVar chan Received >> return s _ -> retry unsafeSend chan x = do s <- readTVar chan case s of Ready -> writeTVar chan (Sent x) _ -> retry waitReceiver chan = do s <- readTVar chan case s of Received -> writeTVar chan Ready _ -> retry x |> f = fmap f x test b = do (x,y) <- atomically $ liftM2 (,) newSyncChan newSyncChan forkIO $ join $ atomically $ -- since recv is in STM you can wait on multiple channels at the same time (recv x |> print) `mplus` (recv y |> print) if b then send x 'a' else send y 1 as a bonus you can also try to send to the first available among multiple channels: (this formulation uses ExistentialQuantification but it's just a convenience) data Sending a = forall b. Sending (SyncChan b) b a sendMulti :: [Sending a] -> IO a sendMulti [] = fail "empty" sendMulti xs = do (m,r) <- atomically $ msum $ map sending xs atomically m return r sending :: Sending t -> STM (STM (), t) sending (Sending (SC chan) x k) = do unsafeSend chan x return (waitReceiver chan,k) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/6ceac905/attachment.htm From jason.dusek at gmail.com Wed Oct 8 23:53:51 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Oct 8 23:50:09 2008 Subject: [Haskell-cafe] parsec 3 & parsec 2 In-Reply-To: References: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> Message-ID: <42784f260810082053n4227b89ey22a9f86360cf6711@mail.gmail.com> I don't know anything about how to do that. Is this a Cabal thing? A GHC package registration thing? -- _jsn From alfonso.acosta at gmail.com Thu Oct 9 00:15:31 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Thu Oct 9 00:11:50 2008 Subject: [Haskell-cafe] parsec 3 & parsec 2 In-Reply-To: <42784f260810082053n4227b89ey22a9f86360cf6711@mail.gmail.com> References: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> <42784f260810082053n4227b89ey22a9f86360cf6711@mail.gmail.com> Message-ID: <6a7c66fc0810082115m57302618k687be6d1fd3250b7@mail.gmail.com> ghc-pkg hide {pkg-id} On Thu, Oct 9, 2008 at 5:53 AM, Jason Dusek wrote: > I don't know anything about how to do that. Is this a Cabal > thing? A GHC package registration thing? > > -- > _jsn > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From chak at cse.unsw.edu.au Thu Oct 9 00:20:17 2008 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Thu Oct 9 00:16:37 2008 Subject: [Haskell-cafe] Simplifying a IsFunction type class using type equality constraints In-Reply-To: References: Message-ID: <0303F3D2-1CEA-44C4-B3F4-1F7317609758@cse.unsw.edu.au> Corey O'Connor: > I recently had a need to use the IsFunction typeclass described by > Oleg here: > http://okmij.org/ftp/Haskell/isFunction.lhs > > and am wondering if the use of the TypeCast class can be correctly > replaced by a type equality constraint. > > The IsFunction and TypeCast classes were defined as: >> data HTrue >> data HFalse >> >> class IsFunction a b | a -> b >> instance TypeCast f HTrue => IsFunction (x->y) f >> instance TypeCast f HFalse => IsFunction a f >> >> -- literally lifted from the HList library >> class TypeCast a b | a -> b, b->a where typeCast :: a -> b >> class TypeCast' t a b | t a -> b, t b -> a where typeCast' :: t- >> >a->b >> class TypeCast'' t a b | t a -> b, t b -> a where typeCast'' :: t- >> >a->b >> instance TypeCast' () a b => TypeCast a b where typeCast x = >> typeCast' () x >> instance TypeCast'' t a b => TypeCast' t a b where typeCast' = >> typeCast'' >> instance TypeCast'' () a a where typeCast'' _ x = x > > I found the use of TypeCast in the IsFunction could be replaced by a > type family: > >> class IsFunction a b | a -> b >> instance (f ~ TTrue) => IsFunction (x->y) f >> instance (f ~ TFalse) => IsFunction a f Yes, that's a fine way of simplifying the definition. In fact, you should also be able to drop the functional dependency in the IsFunction class. Manuel From jsnow at cs.pdx.edu Thu Oct 9 02:32:18 2008 From: jsnow at cs.pdx.edu (Jim Snow) Date: Thu Oct 9 02:23:30 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <48EDA572.6000901@cs.pdx.edu> Ray tracing about a million spheres in a regular grid with reflections: lattice = let n = 50 :: Flt in bih [sphere (vec x y z) 0.2 | x <- [(-n)..n], y <- [(-n)..n], z <- [(-n)..n]] http://syn.cs.pdx.edu/~jsnow/glome/Glome.hs-lattice-1e6-720p.png I don't remember if I disabled shadows for that particular render. There are some more screenshots on the Glome web page, but most of them were rendered in my Ocaml ray tracer and are low resolution: http://syn.cs.pdx.edu/~jsnow/glome I just now rendered a level 5 sphereflake (a standard benchmark scene from Eric Haine's standard procedural database): http://syn.cs.pdx.edu/~jsnow/glome/sphereflake5-720p.png It took about a minute and a half to parse, sort, and render with about 98k spheres. -jim Magnus Therning wrote: > This morning I got tired of my desktop wallpaper (one that ships with > Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded > a lot of links to wallpapers with Colleen Haskell, while she's a > beautiful lady it wasn't exactly what I was hoping to find. Hence > this email. Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? > > Oh yes, wallpapers related to XMonad would do, I suppose ;-) > > /M > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From cgibbard at gmail.com Thu Oct 9 03:24:04 2008 From: cgibbard at gmail.com (Cale Gibbard) Date: Thu Oct 9 03:20:21 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: <20081008212832.GF3799@terra.galaxy> References: <20081008212832.GF3799@terra.galaxy> Message-ID: <89ca3d1f0810090024t6b7a29e0n60aa24cb6cfd5ac9@mail.gmail.com> Hello! I worked on this for a few minutes in the GIMP. Thought it might look nice spraypainted on asphalt. http://cale.yi.org/LambdaAsphalt.jpg (this one's at 1280x1024) - Cale 2008/10/8 R. Emre Ba?ar : > Hi, > > I created a wallpaper from The.Monad.Reader logo. You can find two > versions here: > > http://tonguc.name/images/lambda-1280x800.png > http://tonguc.name/images/lambda-1024x768.png > > Magnus Therning der ki: >> This morning I got tired of my desktop wallpaper (one that ships with >> Debian's Gnome packages). Typing "haskell desktop wallpaper" yeilded >> a lot of links to wallpapers with Colleen Haskell, while she's a >> beautiful lady it wasn't exactly what I was hoping to find. Hence >> this email. Where can I find some nice wallpapers inspired by >> Haskell, or maybe even created by Haskell code? >> >> Oh yes, wallpapers related to XMonad would do, I suppose ;-) >> >> /M >> >> -- >> Magnus Therning (OpenPGP: 0xAB4DFBA4) >> magnus?therning?org Jabber: magnus?therning?org >> http://therning.org/magnus identi.ca|twitter: magthe > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -- > R. Emre Ba?ar > ?stanbul Bilgi University > Department of Computer Science > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iD8DBQFI7SYA86wLPNcWbrwRAh1rAJ0ZAFf3eI20hf8sfLhUCu6HXjBbLgCfQTwZ > DoHCzU7eWn5xsDwJyNusLzk= > =OMnR > -----END PGP SIGNATURE----- > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ryani.spam at gmail.com Thu Oct 9 04:05:57 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 9 04:02:15 2008 Subject: [Haskell-cafe] Simple Table Update In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C80CCAAA@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> <2f9b2d30810081003i439eaf05y135cffe368f97849@mail.gmail.com> <3CDFB8AFEA98E34CB599475AB11589C80CCAAA@EX2.ad.dcs.gla.ac.uk> Message-ID: <2f9b2d30810090105q13348ee8rb92f71191bfb7758@mail.gmail.com> On Wed, Oct 8, 2008 at 9:12 PM, Paul Keir wrote: > It brings tears to my eyes to see such a beautiful function ;) You've hit > the nail on the head Ryan. The new version of my second previous code > snippet now no longer requires "fixpu*", and is: > > typeCheckAST (Program pus) = Program $ snd $ mapAccumL f [] pus > > where f st pu = (st ++ [("",[])],pu) I'm confused about this. If I'm reading this correctly, snd $ mapAccumL f (undefined) pus == map id pus == pus -- ryan From ryani.spam at gmail.com Thu Oct 9 04:15:57 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 9 04:12:14 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: Message-ID: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> I don't think what you want is possible if both sides are in STM. Other authors have posted solutions where one side or the other of the transaction is in I/O, but wholly inside STM it's not possible. The problem is that in order for synchronization to happen, you need both sides to be able to communicate with each other. But the whole point of STM is that each transaction is atomically isolated from other transactions running concurrently; you can find out what transactions that committed before you have done, but there is no way for you to interact with another transaction in-flight. -- ryan On Wed, Oct 8, 2008 at 11:10 PM, roger peppe wrote: > I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv primitives > on a channel that each block until the other side arrives to complete > the transaction. > > I think I've convinced myself that it's not possible, but > anyone care to differ? > > cheers, > rog. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Thu Oct 9 04:20:28 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 9 04:16:45 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> <48ED05C9.1020907@btinternet.com> <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> Message-ID: <2f9b2d30810090120y25e0b5f2k4a5c980f529c6bbd@mail.gmail.com> 2008/10/9 Reiner Pope : > The syntax is for the implicit parameter extension[1]. I think you would > write your example as > > foo (undefined :: Bar x) ?z :: Bar y > > Then querying the type of that whole expression with :t will list ?z's type > in the expression's constraints. (Of course, you should turn off the > monomorphism restriction so that ghc doesn't complain if constraints aren't > resolved). Oh yeah, I forgot about that. ghci> :set -fno-monomorphism-restriction Although I don't know if that affects the results of the :t command. > [1]: > http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#implicit-parameters > > Reiner There's also a haskell98 way to do the same thing, it's just a bit more wordy at the ghci prompt, and a bit more work to decode the result: ghci> :t \z -> (foo (undefined :: Bar x) z :: Bar y) Now, the type of this expression is clearly type of z -> Bar y So just read the value before the arrow to get your answer. -- ryan From pkeir at dcs.gla.ac.uk Thu Oct 9 04:26:11 2008 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Oct 9 04:22:28 2008 Subject: [Haskell-cafe] Simple Table Update In-Reply-To: <2f9b2d30810090105q13348ee8rb92f71191bfb7758@mail.gmail.com> References: <3CDFB8AFEA98E34CB599475AB11589C80CCAA9@EX2.ad.dcs.gla.ac.uk> <2f9b2d30810081003i439eaf05y135cffe368f97849@mail.gmail.com> <3CDFB8AFEA98E34CB599475AB11589C80CCAAA@EX2.ad.dcs.gla.ac.uk> <2f9b2d30810090105q13348ee8rb92f71191bfb7758@mail.gmail.com> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C6D62@EX2.ad.dcs.gla.ac.uk> Yes, it doesn't do anything yet (apart from update a currently discarded accumulator (symbol table)). -----Original Message----- From: Ryan Ingram [mailto:ryani.spam@gmail.com] Sent: 09 October 2008 09:06 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Simple Table Update On Wed, Oct 8, 2008 at 9:12 PM, Paul Keir wrote: > It brings tears to my eyes to see such a beautiful function ;) You've hit > the nail on the head Ryan. The new version of my second previous code > snippet now no longer requires "fixpu*", and is: > > typeCheckAST (Program pus) = Program $ snd $ mapAccumL f [] pus > > where f st pu = (st ++ [("",[])],pu) I'm confused about this. If I'm reading this correctly, snd $ mapAccumL f (undefined) pus == map id pus == pus -- ryan From rogpeppe at gmail.com Thu Oct 9 04:50:02 2008 From: rogpeppe at gmail.com (roger peppe) Date: Thu Oct 9 04:46:20 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> Message-ID: On Thu, Oct 9, 2008 at 9:15 AM, Ryan Ingram wrote: > I don't think what you want is possible if both sides are in STM. > Other authors have posted solutions where one side or the other of the > transaction is in I/O, but wholly inside STM it's not possible. Thanks, that's what I thought, although I wasn't sure of it, being new to both Haskell and STM. Presumably this result means that it's not possible to implement any bounded-buffer-type interface within (rather than on top of) STM. Isn't that a rather serious restriction? cheers, rog. From sven.panne at aedion.de Thu Oct 9 05:00:28 2008 From: sven.panne at aedion.de (Sven Panne) Date: Thu Oct 9 04:56:45 2008 Subject: [Haskell-cafe] Linker Errors For OpenGL / GLUT 'Hello World' Program. In-Reply-To: References: Message-ID: <200810091100.28483.sven.panne@aedion.de> On Saturday 20 September 2008 19:13:43 Donnie Jones wrote: > [...] > > checking GL/gl.h usability... yes > > checking GL/gl.h presence... yes > > checking for GL/gl.h... yes > > checking OpenGL/gl.h usability... no > > checking OpenGL/gl.h presence... no > > checking for OpenGL/gl.h... no > > checking GL/glu.h usability... yes > > checking GL/glu.h presence... yes > > checking for GL/glu.h... yes > > checking OpenGL/glu.h usability... no > > checking OpenGL/glu.h presence... no > > checking for OpenGL/glu.h... no > > > > That looks like to me that the gl.h and glu.h header files were found and > > are usable (in some cases). I am able to build That's correct, but that's a transcript of configure in the OpenGL package, not the GLUT package. The OpenGL package contains the bindings for the GL and GLU libraries, the GLUT package contains the binding for the, well, GLUT library. > [...] > ### Relevant lines that include "-lGL" or "-lGLU" in config.log ### > [...] This test is again OK, it first checks if we have to link against glu32 (for Windows) or GLU (for the rest of the world) to use GLU features. But again, this excerpt is from the config.log of the OpenGL package, not the GLUT package. > It seems like the OpenGL and GLUT libraries are found (after -lglu32 fails, > I am using Debian Linux). I am not sure what to try now. What you have posted so far indicates that the GL and GLU headers and libraries have been found, but for GLUT only the header has been found. Could you please post the relevant part of the config.log in the GLUT package, i.e. the part for "checking for GLUT library... no"? Where is the GLUT library on your system located? Does anybody else have a similar problem? Cheers, S. From arnarbi at gmail.com Thu Oct 9 05:12:01 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 9 05:08:18 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> Message-ID: <28012bc60810090212u48a7ab9ex5cea81198585e2d0@mail.gmail.com> On Thu, Oct 9, 2008 at 10:50, roger peppe wrote: > On Thu, Oct 9, 2008 at 9:15 AM, Ryan Ingram wrote: >> I don't think what you want is possible if both sides are in STM. >> Other authors have posted solutions where one side or the other of the >> transaction is in I/O, but wholly inside STM it's not possible. > > Thanks, that's what I thought, although I wasn't sure of it, being > new to both Haskell and STM. > > Presumably this result means that it's not possible to implement > any bounded-buffer-type interface within (rather than on top of) STM. > > Isn't that a rather serious restriction? Sorry, I come into this discussion late. One-place buffers, or MVars, are indeed implemented over STM in the orignal paper [1]. Is that what you seek? Copied from the paper, it looks like this: type MVar a = TVar (Maybe a) newEmptyMVar :: STM (MVar a) newEmptyMVar = newTVar Nothing takeMVar :: MVar a -> STM a takeMVar mv = do v <- readTVar mv case v of Nothing -> retry Just val -> do writeTVar mv Nothing return val putMVar :: MVar a -> a -> STM () putMVar mv val = do v <- readTVar mv case v of Nothing -> writeTVar mv (Just val) Just _ -> retry Again, sorry if I'm missing your point. Note that transactions cannot "block" like threads, when they retry - they do block, but when they are unblocked they are retried from the top. This is naturally due to the requirement that a transaction must not be affected by something that happens concurrently. [1] also goes to implement buffered, multi-item, multi-cast channels. [1] Tim Harris, Simon Marlow, Simon Peyton Jones, Maurice Herlihy. Composable Memory Transactions. cheers, Arnar From sanzhiyan at gmail.com Thu Oct 9 05:19:33 2008 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Thu Oct 9 05:15:50 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> Message-ID: <8625cd9c0810090219m7c3ea4c5k588d8c9f1608b782@mail.gmail.com> I'd rather say that STM is intended to be used just for building up transactions, not to model your whole process/thread, simply because in the latter case your process couldn't have any observable intermediate state, or put in another way, between any two transactions the information can only go in one direction. So, since synchronizing two processes needs bidirectional communication, you have to use more than one transaction. In the end you still write processes in IO, but communicate via transactions built in STM. It's a good thing to expose your primitives as STM when you can, so that users can build larger transactions on top of them, but a synchronous send is not a transaction from the start so there's no choice. 2008/10/9 roger peppe > On Thu, Oct 9, 2008 at 9:15 AM, Ryan Ingram wrote: > > I don't think what you want is possible if both sides are in STM. > > Other authors have posted solutions where one side or the other of the > > transaction is in I/O, but wholly inside STM it's not possible. > > Thanks, that's what I thought, although I wasn't sure of it, being > new to both Haskell and STM. > > Presumably this result means that it's not possible to implement > any bounded-buffer-type interface within (rather than on top of) STM. > > Isn't that a rather serious restriction? > > cheers, > rog. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/efb14c10/attachment.htm From abailly at oqube.com Thu Oct 9 04:25:19 2008 From: abailly at oqube.com (Arnaud Bailly) Date: Thu Oct 9 05:18:52 2008 Subject: [Haskell-cafe] Web application from the ground up In-Reply-To: (haskell-cafe-request@haskell.org's message of "Wed\, 08 Oct 2008 13\:55\:02 -0400") References: Message-ID: <87fxn6i39s.fsf@oqube.oqube.com> Hello, I am trying to implement a complete web application from the ground up, with the objective to convince myself and others that 1) it is possible, 2) it is powerful and 3) it is more expressive to do such a thing in Haskell. I managed to get to the point where I can handle users lifecycle with DB handling, and I have a CLI application. I have a World that stores Session objects, containing a "continuation" of possible functions to call. The problem I am facing now is how to handle (Fast)CGI requests, given that each request seems to be served by a dinstinct invocation of a function, and share the World between all connections. I have a vague idea that this could be handled by creating some CGIT transformed monad operating on a TVar World (that's what is hinted at on haskell wiki), but I am not sure how to tackle this. I asked this question on #haskell but had to leave too quickly. Some people there seems to think this is something very common that has been resolved over a hundred times. Once would be enough for me, and I would be very happy if someone could point me to the right direction or provide some sample code for this. Best regards, -- Arnaud Bailly, PhD OQube - Software Engineering http://www.oqube.com From magnus at therning.org Thu Oct 9 05:28:32 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 9 05:24:50 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: <89ca3d1f0810090024t6b7a29e0n60aa24cb6cfd5ac9@mail.gmail.com> References: <20081008212832.GF3799@terra.galaxy> <89ca3d1f0810090024t6b7a29e0n60aa24cb6cfd5ac9@mail.gmail.com> Message-ID: On Thu, Oct 9, 2008 at 8:24 AM, Cale Gibbard wrote: > Hello! > > I worked on this for a few minutes in the GIMP. Thought it might look > nice spraypainted on asphalt. > > http://cale.yi.org/LambdaAsphalt.jpg (this one's at 1280x1024) This one is nice. Any chance of getting it in aspect ration 8x5? (My screen is 1920x1200.) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From magnus at therning.org Thu Oct 9 05:33:09 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Oct 9 05:29:26 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: <48EDA572.6000901@cs.pdx.edu> References: <48EDA572.6000901@cs.pdx.edu> Message-ID: On Thu, Oct 9, 2008 at 7:32 AM, Jim Snow wrote: > Ray tracing about a million spheres in a regular grid with reflections: > > lattice = > let n = 50 :: Flt > in bih [sphere (vec x y z) 0.2 | x <- [(-n)..n], > y <- [(-n)..n], > z <- [(-n)..n]] > > http://syn.cs.pdx.edu/~jsnow/glome/Glome.hs-lattice-1e6-720p.png > I don't remember if I disabled shadows for that particular render. > > There are some more screenshots on the Glome web page, but most of them were > rendered in my Ocaml ray tracer and are low resolution: > > http://syn.cs.pdx.edu/~jsnow/glome > > I just now rendered a level 5 sphereflake (a standard benchmark scene from > Eric Haine's standard procedural database): > > http://syn.cs.pdx.edu/~jsnow/glome/sphereflake5-720p.png Very nice indeed. You don't have any images in aspect 8x5 that don't include the window decorations? ;-) (Yes, I'm lazy!) > It took about a minute and a half to parse, sort, and render with about 98k > spheres. I'm afraid it'd take me considerably longer, since I have to first get all the software compiled and installed and then I'll have to read up on how to generate the graphics. I suspect the latter will take a long time since the closest I've ever come to rendering something is watching Elephants Dream. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From anton.tayanovskyy at gmail.com Thu Oct 9 05:57:36 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Thu Oct 9 05:53:53 2008 Subject: [Haskell-cafe] Web application from the ground up In-Reply-To: <87fxn6i39s.fsf@oqube.oqube.com> References: <87fxn6i39s.fsf@oqube.oqube.com> Message-ID: Hi Arnaud, Here's a simple counter program. I mount this to /ws/ with mod_scgi, and can then do requests http://localhost/ws/ or http://localhost/ws/?amount=19 (increment by 19 not 1). http://hpaste.org/11033 I'm no expert but I'm also working on web applications in Haskell now. If you are like me, not a big fan of monad transformers, the quick and dirty way to share state between threads is through an MVar as demonstrated above. Of course CGI is out of question as handles requests in separate processes. So you would need FastCGI or SCGI or (I guess that's the best) embedding a web server. Right now I am playing with my own little pure Haskell SCGI implementation (http://hpaste.org/11034) which does one forkIO per request, the interface is: runSCGI :: Timeout -> PortID -> CGIT IO CGIResult -> IO () forkProcess is only helpful to daemonize the program on UNIX. Bests, --A On Thu, Oct 9, 2008 at 11:25 AM, Arnaud Bailly wrote: > Hello, > I am trying to implement a complete web application from the ground > up, with the objective to convince myself and others that 1) it is > possible, 2) it is powerful and 3) it is more expressive to do such a > thing in Haskell. > > I managed to get to the point where I can handle users lifecycle > with DB handling, and I have a CLI application. I have a World that > stores Session objects, containing a "continuation" of possible > functions to call. > > The problem I am facing now is how to handle (Fast)CGI requests, given > that each request seems to be served by a dinstinct invocation of a > function, and share the World between all connections. I have a vague > idea that this could be handled by creating some CGIT transformed > monad operating on a TVar World (that's what is hinted at on haskell > wiki), but I am not sure how to tackle this. > > I asked this question on #haskell but had to leave too quickly. Some > people there seems to think this is something very common that has > been resolved over a hundred times. Once would be enough for me, and I > would be very happy if someone could point me to the right direction > or provide some sample code for this. > > Best regards, > -- > Arnaud Bailly, PhD > OQube - Software Engineering > http://www.oqube.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rogpeppe at gmail.com Thu Oct 9 06:29:40 2008 From: rogpeppe at gmail.com (roger peppe) Date: Thu Oct 9 06:25:57 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <28012bc60810090212u48a7ab9ex5cea81198585e2d0@mail.gmail.com> References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> <28012bc60810090212u48a7ab9ex5cea81198585e2d0@mail.gmail.com> Message-ID: On Thu, Oct 9, 2008 at 10:12 AM, Arnar Birgisson wrote: > Sorry, I come into this discussion late. One-place buffers, or MVars, > are indeed implemented over STM in the orignal paper [1]. Yes, I should have remembered that. It's ok just as long as there's a buffer there because then there's a consistent *memory* state that can be awaited. But using an unbuffered channel, we need to await the state of another *process*, so we can rendezvous with it, something that is not possible in principle with STM. > Is that what you seek? It's useful, thanks, but not really what I was originally looking for. Synchronous channels are generally easier to reason about (less states to deal with). On Thu, Oct 9, 2008 at 10:19 AM, Andrea Vezzosi wrote: > I'd rather say that STM is intended to be used just for building up transactions It seems to me then that, despite the existence of the very elegant STM, there's still room for a commonly used set of transactions outside of it, with as many as possible within STM, along the lines of the SyncChan snippet you posted earlier. By the way, where does FRP (which I haven't got my head around yet) sit with respect to STM? cheers, rog. From tphyahoo at gmail.com Thu Oct 9 06:43:20 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Oct 9 06:39:37 2008 Subject: [Haskell-cafe] Web application from the ground up In-Reply-To: <87fxn6i39s.fsf@oqube.oqube.com> References: <87fxn6i39s.fsf@oqube.oqube.com> Message-ID: <910ddf450810090343i1eb95ff8m7168dbabe978db42@mail.gmail.com> Have you seen happstutorial.com? thomas. 2008/10/9 Arnaud Bailly : > Hello, > I am trying to implement a complete web application from the ground > up, with the objective to convince myself and others that 1) it is > possible, 2) it is powerful and 3) it is more expressive to do such a > thing in Haskell. > > I managed to get to the point where I can handle users lifecycle > with DB handling, and I have a CLI application. I have a World that > stores Session objects, containing a "continuation" of possible > functions to call. > > The problem I am facing now is how to handle (Fast)CGI requests, given > that each request seems to be served by a dinstinct invocation of a > function, and share the World between all connections. I have a vague > idea that this could be handled by creating some CGIT transformed > monad operating on a TVar World (that's what is hinted at on haskell > wiki), but I am not sure how to tackle this. > > I asked this question on #haskell but had to leave too quickly. Some > people there seems to think this is something very common that has > been resolved over a hundred times. Once would be enough for me, and I > would be very happy if someone could point me to the right direction > or provide some sample code for this. > > Best regards, > -- > Arnaud Bailly, PhD > OQube - Software Engineering > http://www.oqube.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Thu Oct 9 06:44:34 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Oct 9 06:40:50 2008 Subject: [Haskell-cafe] Web application from the ground up In-Reply-To: <910ddf450810090343i1eb95ff8m7168dbabe978db42@mail.gmail.com> References: <87fxn6i39s.fsf@oqube.oqube.com> <910ddf450810090343i1eb95ff8m7168dbabe978db42@mail.gmail.com> Message-ID: <910ddf450810090344p24ccfac0h9fbd0ed17157e1c0@mail.gmail.com> There's also newer material at http://happstutorial.com:5002 that's in darcs but hasn't been packaged for hackage. 2008/10/9 Thomas Hartman : > Have you seen happstutorial.com? > > thomas. > > > 2008/10/9 Arnaud Bailly : >> Hello, >> I am trying to implement a complete web application from the ground >> up, with the objective to convince myself and others that 1) it is >> possible, 2) it is powerful and 3) it is more expressive to do such a >> thing in Haskell. >> >> I managed to get to the point where I can handle users lifecycle >> with DB handling, and I have a CLI application. I have a World that >> stores Session objects, containing a "continuation" of possible >> functions to call. >> >> The problem I am facing now is how to handle (Fast)CGI requests, given >> that each request seems to be served by a dinstinct invocation of a >> function, and share the World between all connections. I have a vague >> idea that this could be handled by creating some CGIT transformed >> monad operating on a TVar World (that's what is hinted at on haskell >> wiki), but I am not sure how to tackle this. >> >> I asked this question on #haskell but had to leave too quickly. Some >> people there seems to think this is something very common that has >> been resolved over a hundred times. Once would be enough for me, and I >> would be very happy if someone could point me to the right direction >> or provide some sample code for this. >> >> Best regards, >> -- >> Arnaud Bailly, PhD >> OQube - Software Engineering >> http://www.oqube.com >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From marco-oweber at gmx.de Thu Oct 9 06:45:39 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Thu Oct 9 06:41:59 2008 Subject: [Haskell-cafe] Web application from the ground up In-Reply-To: <87fxn6i39s.fsf@oqube.oqube.com> References: <87fxn6i39s.fsf@oqube.oqube.com> Message-ID: <20081009104539.GA18172@gmx.de> Hi Arnaud Bailly, Share the world? *g* is a bit vague.. Fast CGI differs from CGI in one point: your application keeps running. Thus as long as the application is running you can use IORefs (bad for multithreading) MVars (thread safe) STM etc to keep track of your "world" state and of course you can share data on filesystem and in databases.. (you must lookup thread safety in the db lib documentations) I'd like to point you to a) HAppS-State lib providing state with ACID guarantees (-> hackage or happs.org or #happs on freenode) which already does a great job as long as your global data fits within RAM. b) You definitely should also have a look at WASH. This lib already has solved many common problems. It's mainly based on CGI. http://www.informatik.uni-freiburg.de/~thiemann/WASH/ But reading the examples should give an idea about how powerful web developement can be. I'm working on some topics as well. We also have a very low traffic web-dev mailinglist (haskell.org -> mailinglist ..) Have fun Marc Weber From arnarbi at gmail.com Thu Oct 9 06:47:44 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 9 06:44:01 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> <28012bc60810090212u48a7ab9ex5cea81198585e2d0@mail.gmail.com> Message-ID: <28012bc60810090347h6f46ca77see8e96c5a53e6a25@mail.gmail.com> On Thu, Oct 9, 2008 at 12:29, roger peppe wrote: > It's useful, thanks, but not really what I was originally looking for. > Synchronous channels are generally easier to reason about (less states > to deal with). Right, that's very true. Interaction between transactions is naturally forbidden by the I in ACId (small d because that one doesn't really apply to memory transactions), but that does not mean you can't implement bounded buffers as you said. cheers, Arnar From iainspeed at gmail.com Thu Oct 9 09:02:44 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Oct 9 08:59:09 2008 Subject: [Haskell-cafe] Constraints at construction Message-ID: If I were to create an object in C#, for instance, I could add code to the constructor that might limit the type further e.g. public class Car { string model; int wheels; public Car ( string model, int no_of_wheels ) { if ( no_of_wheels <= 2 ) { throw new Exception( "a car must have at least 3 wheels"); } this.model = model; this.no_of_wheels = no_of_wheels; } } or I could specify all sorts of things, like the size of an array could only be a certain length, or whatever. Similarly, when creating a column with SQL I'd be able to specify further constraints on the column than just it's type. I don't see how to do this with Haskell and the data keyword. Is there a tutorial someone could point me to, or an explanation of this? Or is it that I have to wrap the creation in an accessor function that checks the inputs first? type Model = String type Wheels = Int data Car = Car Model Wheels car_maker model wheels = if wheels <= 2 then error ... else Car model wheels ? Most of my programming career (if you can call it that:) has been primarily with C# and SQL, and perhaps this heady mixture of OOP and hacked-functional is confusing me! Iain From neil.mitchell.2 at credit-suisse.com Thu Oct 9 09:05:27 2008 From: neil.mitchell.2 at credit-suisse.com (Mitchell, Neil) Date: Thu Oct 9 09:02:27 2008 Subject: [Haskell-cafe] Constraints at construction In-Reply-To: References: Message-ID: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> Hi Iain, The wiki page has quite a nice article: http://www.haskell.org/haskellwiki/Smart_constructors Thanks Neil > -----Original Message----- > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Iain Barnett > Sent: 09 October 2008 2:03 pm > To: haskell-cafe@haskell.org > Subject: [Haskell-cafe] Constraints at construction > > If I were to create an object in C#, for instance, I could > add code to the constructor that might limit the type further e.g. > > > public class Car > { > string model; > int wheels; > > public Car ( string model, int no_of_wheels ) > { > if ( no_of_wheels <= 2 ) { > throw new Exception( "a car must have > at least 3 wheels"); > } > > this.model = model; > this.no_of_wheels = no_of_wheels; > } > } > > or I could specify all sorts of things, like the size of an > array could only be a certain length, or whatever. Similarly, > when creating a column with SQL I'd be able to specify > further constraints on the column than just it's type. > > I don't see how to do this with Haskell and the data keyword. > Is there a tutorial someone could point me to, or an > explanation of this? Or is it that I have to wrap the > creation in an accessor function that checks the inputs first? > > type Model = String > type Wheels = Int > > data Car = Car Model Wheels > > car_maker model wheels = if wheels <= 2 then error ... > else Car model wheels > > ? > > Most of my programming career (if you can call it that:) has > been primarily with C# and SQL, and perhaps this heady > mixture of OOP and hacked-functional is confusing me! > > > Iain > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From briqueabraque at yahoo.com Thu Oct 9 09:08:41 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Oct 9 09:05:06 2008 Subject: [Haskell-cafe] Libraries in home dir Message-ID: Hi, I want to use a few libraries from hackage and have already download and built them. Can I install those libraries somewhere in my home dir (I want to avoid installing as root) so that ghc can find them? If so, which options should I give to Setup.hs (with main=defaultMain) so that the libraries are going to be copy to that dir? Thanks, Maur?cio From iainspeed at gmail.com Thu Oct 9 09:14:55 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Oct 9 09:11:20 2008 Subject: [Haskell-cafe] Constraints at construction In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> References: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> Message-ID: <6B18E876-9642-45CD-AF09-35F06D18E11F@gmail.com> Thankyou, this is exactly what I was looking for. Iain On 9 Oct 2008, at 2:05 pm, Mitchell, Neil wrote: > Hi Iain, > > The wiki page has quite a nice article: > http://www.haskell.org/haskellwiki/Smart_constructors > > Thanks > > Neil > >> -----Original Message----- >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Iain Barnett >> Sent: 09 October 2008 2:03 pm >> To: haskell-cafe@haskell.org >> Subject: [Haskell-cafe] Constraints at construction >> >> If I were to create an object in C#, for instance, I could >> add code to the constructor that might limit the type further e.g. >> >> >> public class Car >> { >> string model; >> int wheels; >> >> public Car ( string model, int no_of_wheels ) >> { >> if ( no_of_wheels <= 2 ) { >> throw new Exception( "a car must have >> at least 3 wheels"); >> } >> >> this.model = model; >> this.no_of_wheels = no_of_wheels; >> } >> } >> >> or I could specify all sorts of things, like the size of an >> array could only be a certain length, or whatever. Similarly, >> when creating a column with SQL I'd be able to specify >> further constraints on the column than just it's type. >> >> I don't see how to do this with Haskell and the data keyword. >> Is there a tutorial someone could point me to, or an >> explanation of this? Or is it that I have to wrap the >> creation in an accessor function that checks the inputs first? >> >> type Model = String >> type Wheels = Int >> >> data Car = Car Model Wheels >> >> car_maker model wheels = if wheels <= 2 then error ... >> else Car model wheels >> >> ? >> >> Most of my programming career (if you can call it that:) has >> been primarily with C# and SQL, and perhaps this heady >> mixture of OOP and hacked-functional is confusing me! >> >> >> Iain >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > ====================================================================== > ======== > Please access the attached hyperlink for an important electronic > communications disclaimer: > > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > ====================================================================== > ======== > From dougal at dougalstanton.net Thu Oct 9 09:18:46 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Thu Oct 9 09:15:02 2008 Subject: [Haskell-cafe] Libraries in home dir In-Reply-To: References: Message-ID: <2d3641330810090618l5bb0edb0yaf8bc2bfbfadd1f8@mail.gmail.com> On Thu, Oct 9, 2008 at 2:08 PM, Mauricio wrote: > Hi, > > I want to use a few libraries from hackage > and have already download and built them. Can > I install those libraries somewhere in my > home dir (I want to avoid installing as root) > so that ghc can find them? > > If so, which options should I give to Setup.hs > (with main=defaultMain) so that the libraries > are going to be copy to that dir? Dpeending on whether you have (and are using) cabal-install, either $ cabal install diagrams --prefix=$HOME --user or $ runhaskell Setup.lhs configure --prefix=$HOME --user That will (a) put the libraries etc in $HOME/lib and (b) register these packages locally. Hope that helps! D From a.d.clark at ed.ac.uk Thu Oct 9 09:27:50 2008 From: a.d.clark at ed.ac.uk (allan) Date: Thu Oct 9 09:23:31 2008 Subject: [Haskell-cafe] Libraries in home dir In-Reply-To: <2d3641330810090618l5bb0edb0yaf8bc2bfbfadd1f8@mail.gmail.com> References: <2d3641330810090618l5bb0edb0yaf8bc2bfbfadd1f8@mail.gmail.com> Message-ID: <48EE06D6.8040805@ed.ac.uk> Hi, In addition if you want to do this all or most of the time, that is there are few/no cabalised libraries you DO wish to install globally, then you can tell 'cabal' to do this all the time by editing your ~/.cabal/config file. Here is mine: repos: hackage.haskell.org:http://hackage.haskell.org/packages/archive cachedir: "/home//.cabal/packages" hackage-username: "" hackage-password: "" compiler: ghc user-install: True user-prefix: "/home//install/" regards allan Dougal Stanton wrote: > On Thu, Oct 9, 2008 at 2:08 PM, Mauricio wrote: >> Hi, >> >> I want to use a few libraries from hackage >> and have already download and built them. Can >> I install those libraries somewhere in my >> home dir (I want to avoid installing as root) >> so that ghc can find them? >> >> If so, which options should I give to Setup.hs >> (with main=defaultMain) so that the libraries >> are going to be copy to that dir? > > Dpeending on whether you have (and are using) cabal-install, either > > $ cabal install diagrams --prefix=$HOME --user > > or > > $ runhaskell Setup.lhs configure --prefix=$HOME --user > > > That will (a) put the libraries etc in $HOME/lib and (b) register > these packages locally. > > Hope that helps! > > > D > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. From daniel.is.fischer at web.de Thu Oct 9 09:31:54 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Oct 9 09:26:00 2008 Subject: [Haskell-cafe] Libraries in home dir In-Reply-To: References: Message-ID: <200810091531.54998.daniel.is.fischer@web.de> Am Donnerstag, 9. Oktober 2008 15:08 schrieb Mauricio: > Hi, > > I want to use a few libraries from hackage > and have already download and built them. Can > I install those libraries somewhere in my > home dir (I want to avoid installing as root) > so that ghc can find them? runghc ./Setup.hs configure --user --prefix=$HOME runghc ./Setup.hs build runghc ./Setup.hs install I'm afraid you would have to build again to get a correct $TOP/dist/build/autogen/Paths_${library}.hs > > If so, which options should I give to Setup.hs > (with main=defaultMain) so that the libraries > are going to be copy to that dir? > > Thanks, > Maur?cio > From alfonso.acosta at gmail.com Thu Oct 9 09:30:43 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Thu Oct 9 09:26:59 2008 Subject: [Haskell-cafe] Libraries in home dir In-Reply-To: References: Message-ID: <6a7c66fc0810090630t76dbd663s3cca9327a96a29ee@mail.gmail.com> On Thu, Oct 9, 2008 at 3:08 PM, Mauricio wrote: > I want to use a few libraries from hackage > and have already download and built them. Can > I install those libraries somewhere in my > home dir (I want to avoid installing as root) > so that ghc can find them? Sure, just write: runhaskell Setup.hs configure --user --prefix=personal/directory/where/to/install/the/package --user tells cabal to install the package in the user package-database You might want to use cabal-install [1] in order to automatize the insallation of Cabal packages. By default it uses the --user flag and copies the package files under $HOME/.cabal/. Important caveat: Make sure to also supply the --user flag when compiling other packages which depend on your library. Otherwise Cabal will only look for it in the global package-dabatase and won?t be able to find it. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal-install From leimy2k at gmail.com Thu Oct 9 11:28:24 2008 From: leimy2k at gmail.com (David Leimbach) Date: Thu Oct 9 11:24:43 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: Message-ID: <3e1162e60810090828h485bdac2hed0c39a60498fcfe@mail.gmail.com> On Wed, Oct 8, 2008 at 3:10 PM, roger peppe wrote: > I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv > primitives > on a channel that each block until the other side arrives to complete > the transaction. > > I think I've convinced myself that it's not possible, but > anyone care to differ? Hi Rog!! (Plan 9/Inferno Rog?) http://haskell.org/ghc/docs/latest/html/libraries/stm/Control-Concurrent-STM-TChan.html <-- isn't that it? see writeTChan and readTChan. I assume readTChan is synchronous :-). writeTChan may be asynchronous for all I can tell (haven't looked deeply). But I did write a concurrent prime sieve with it: module Main where {-- Haskell Concurrent and sometimes parallel prime sieve of eratosthenes David Leimbach May 19, 2008 Communicates with typed data channels for sieving using the STM monad (Software Transactional Memory) to share data between sparks. Sparks are created by forkIO, which can be scheduled to real OS threads. The algorithm is sloppily contained in sieve :: TChan Int -> TChan Int -> IO () which receives a number in the range of [2 .. 10000]. If this is the first number it has received, that will forever be that spark's number to test for divisibility of subsequent numbers. After this assignment it writes this value to the reader spark which prints it and waits for the next number to fall out of the sieve. (which is why we start with 2) This first sieve running spark will forkIO 1 more sieve spark that will be sent as it's first number, the first number not evenly divisible by the value of the current sieve spark. This process continues until the syncVal is received, which terminates the program and shuts down the reader as well as the main loop. --} import Control.Monad.STM import Control.Monad import Control.Concurrent import Control.Concurrent.STM.TChan import System(getArgs) syncVal :: Int syncVal = -1 sieve :: TChan Int -> TChan Int -> IO () sieve inChan outChan = do value <- atomically $ readTChan inChan atomically $ writeTChan outChan value newchan <- atomically $ newTChan forkIO $ sieve newchan outChan forever value newchan where forever value newchan = do subsequent <- atomically $ readTChan inChan if subsequent `mod` value /= 0 then do atomically $ writeTChan newchan subsequent forever value newchan else if subsequent == syncVal then do atomically $ writeTChan outChan syncVal return () else forever value newchan reader :: TChan Int -> TChan Char -> IO () reader chan syncChan = do x <- atomically $ readTChan chan if x /= syncVal then do -- putStrLn $ show x reader chan syncChan else do atomically $ writeTChan syncChan 'Q' return () main :: IO () main = do wChannel <- atomically $ newTChan rChannel <- atomically $ newTChan sChannel <- atomically $ newTChan forkIO $ reader rChannel sChannel forkIO $ sieve wChannel rChannel x <- getArgs putStrLn ("Searching for primes up to " ++ (head x)) forM_ [2 .. ((read (head x)) ::Int)] $ \i -> atomically $ writeTChan wChannel i atomically $ writeTChan wChannel syncVal atomically $ readTChan sChannel return () > > > cheers, > rog. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/8d26935c/attachment.htm From leimy2k at gmail.com Thu Oct 9 11:36:00 2008 From: leimy2k at gmail.com (David Leimbach) Date: Thu Oct 9 11:32:15 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> Message-ID: <3e1162e60810090836y59f9ede6l780511f16b1430e9@mail.gmail.com> On Thu, Oct 9, 2008 at 1:50 AM, roger peppe wrote: > On Thu, Oct 9, 2008 at 9:15 AM, Ryan Ingram wrote: > > I don't think what you want is possible if both sides are in STM. > > Other authors have posted solutions where one side or the other of the > > transaction is in I/O, but wholly inside STM it's not possible. > > Thanks, that's what I thought, although I wasn't sure of it, being > new to both Haskell and STM. > > Presumably this result means that it's not possible to implement > any bounded-buffer-type interface within (rather than on top of) STM. > > Isn't that a rather serious restriction? I don't know that it's practically-speaking that serious. One can write it in IO, using STM. I think of CSP as I/O anyway, but perhaps my thinking is flawed and dirty from MPI and Erlang "message passing" :-). Then again, I'm not sure why keeping it in STM is even valuable really. IO gets the job done right? > > > cheers, > rog. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/15a035f2/attachment.htm From kowey at darcs.net Thu Oct 9 11:44:53 2008 From: kowey at darcs.net (Eric Kow) Date: Thu Oct 9 11:41:09 2008 Subject: [Haskell-cafe] ANNOUNCE: darcs 2.1.0 Message-ID: <20081009154451.GE20340@brighton.ac.uk> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/5a4eeba6/attachment.bin From arnarbi at gmail.com Thu Oct 9 12:10:18 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 9 12:06:34 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <3e1162e60810090828h485bdac2hed0c39a60498fcfe@mail.gmail.com> References: <3e1162e60810090828h485bdac2hed0c39a60498fcfe@mail.gmail.com> Message-ID: <28012bc60810090910u6b73ac06y1ed55af48e9c2876@mail.gmail.com> Hi there, 2008/10/9 David Leimbach : > see writeTChan and readTChan. I assume readTChan is synchronous :-). > writeTChan may be asynchronous for all I can tell (haven't looked deeply). writeTChan is asynchronous, i.e. channels in this case are unbounded buffers. > But I did write a concurrent prime sieve with it: I did the same, with the one-place-buffers (the MVars implemented over STM). Be warned that there is no stop condition, this just keeps printing primes forever. import Control.Concurrent (forkIO) import Control.Concurrent.STM -- MVars from the STM paper type MVar a = TVar (Maybe a) newEmptyMVar :: STM (MVar a) newEmptyMVar = newTVar Nothing takeMVar :: MVar a -> STM a takeMVar mv = do v <- readTVar mv case v of Nothing -> retry Just val -> do writeTVar mv Nothing return val putMVar :: MVar a -> a -> STM () putMVar mv val = do v <- readTVar mv case v of Nothing -> writeTVar mv (Just val) Just _ -> retry -- Sieve forever a = do a; forever a pfilter :: Int -> MVar Int -> MVar Int -> IO () pfilter p in_ out = forever $ do atomically $ do v <- takeMVar in_ if v `mod` p /= 0 then putMVar out v else return () sieve :: MVar Int -> MVar Int -> IO () sieve in_ out = do p <- atomically $ takeMVar in_ atomically $ putMVar out p ch <- atomically $ newEmptyMVar forkIO $ pfilter p in_ ch sieve ch out feeder :: MVar Int -> IO () feeder out = feed' 2 where feed' i = do atomically $ putMVar out i feed' (i+1) printer :: MVar Int -> IO () printer in_ = forever $ do v <- atomically $ takeMVar in_ putStrLn $ show v main :: IO () main = do in_ <- atomically newEmptyMVar out <- atomically newEmptyMVar forkIO $ feeder in_ forkIO $ printer out forkIO $ sieve in_ out return () cheers, Arnar From kowey at darcs.net Thu Oct 9 12:11:17 2008 From: kowey at darcs.net (Eric Kow) Date: Thu Oct 9 12:07:32 2008 Subject: [Haskell-cafe] ANNOUNCE: darcs 2.1.0 (corrected!) Message-ID: <20081009161116.GG20340@brighton.ac.uk> This is a correction to my previous announcement. I had misgrepped the ChangeLog. There are only 20 bug fixes and 7 new features since 2.0.2. Sorry! ====== Hi all, I am delighted to announce the release of darcs 2.1.0, available at http://darcs.net/darcs-2.1.0.tar.gz What has changed? ----------------- This version provides over 20 bug fixes and 7 new features since darcs 2.0.2. The most notable changes are: * Defaulting to darcs-2. The darcs initialize command now creates darcs-2 format repositories by default. This change will make the the improved conflict handling and merging semantics from darcs 2 available to more users. Note that no action is required on your part. Darcs will continue working with all pre-existing repositories. You can explicitly request an old-fashioned repository if needed. * Better HTTP support. Dmitry Kurochkin has refined our HTTP support and fixed several http-related bugs from darcs 2.0.2. There is also an experimental --http-pipelining feature you can enable on the command line (or in your defaults file) for faster downloading. Note: --http-pipelining is enabled by default for libwww, and also for libcurl 7.19.1 (not yet released at the time of this writing) * Repository correctness. David Roundy has resolved a longstanding 'pending patch' regression (originally reported on 2008-02). Needless to say the offending case has been moved to our regression testing suite See the attached ChangeLog for more details. What should I do? ----------------- Upgrade! Binary versions should be available shortly, either from your favourite package distributor or by third party contributors. Other than installing the new darcs, no action is required on your part to perform this upgrade. Darcs 2, including this particular version, is 100% compatible with your pre-existing repositories. If you have not done so already, you should consider using the hashed repository format in place of your current old-fashioned repositories. This format offers greater protection against accidental corruption, better support for case insensitive file systems. It also provides some very nice performance features, including lazy fetching of patches and a global cache (both optional). If darcs 1 compatibility is not a concern, you could also upgrade your repositories all the way to the darcs 2 format. In addition to the robustness and performance features above, this gives you the improved merging semantics and conflicts handling that give darcs 2 its name. More details about upgrading to darcs 2 here: http://wiki.darcs.net/index.html/DarcsTwo What comes next? ---------------- We will now be shifting to a time based release model, with the next darcs release planned for January 2009. For the next release of darcs, we will be focusing on optimising darcs's day to day performance issues. We want darcs to fetch repositories as fast as it possibly can over a network, and we especially want to rehabilitate known slow commands like darcs annotate. We believe that a few simple and practical changes can really improve the darcs experience for most users. Think you can help? We would love to hear from you. In fact, the first darcs hacking sprint (25-26 October) is fast approaching! We have three venues available: Brighton, Paris and Portland and everybody is invited to come hack. See http://wiki.darcs.net/index.html/Sprints for details. Thanks everybody, and enjoy! -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/bceb1f1b/attachment.bin From arnarbi at gmail.com Thu Oct 9 12:24:59 2008 From: arnarbi at gmail.com (Arnar Birgisson) Date: Thu Oct 9 12:21:15 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <28012bc60810090910u6b73ac06y1ed55af48e9c2876@mail.gmail.com> References: <3e1162e60810090828h485bdac2hed0c39a60498fcfe@mail.gmail.com> <28012bc60810090910u6b73ac06y1ed55af48e9c2876@mail.gmail.com> Message-ID: <28012bc60810090924ic405323n535e115389d2728d@mail.gmail.com> On Thu, Oct 9, 2008 at 18:10, Arnar Birgisson wrote: >> But I did write a concurrent prime sieve with it: > > I did the same, with the one-place-buffers (the MVars implemented over > STM). Be warned that there is no stop condition, this just keeps > printing primes forever. Please forgive me for reposting, but the last one exited quite prematurely :) module Main where import Control.Concurrent (forkIO) import Control.Concurrent.STM import System (getArgs) -- MVars from the STM paper type MVar a = TVar (Maybe a) newEmptyMVar :: STM (MVar a) newEmptyMVar = newTVar Nothing takeMVar :: MVar a -> STM a takeMVar mv = do v <- readTVar mv case v of Nothing -> retry Just val -> do writeTVar mv Nothing return val putMVar :: MVar a -> a -> STM () putMVar mv val = do v <- readTVar mv case v of Nothing -> writeTVar mv (Just val) Just _ -> retry -- Sieve forever a = do a; forever a pfilter :: Int -> MVar Int -> MVar Int -> IO () pfilter p in_ out = forever $ do atomically $ do v <- takeMVar in_ if v `mod` p /= 0 then putMVar out v else return () sieve :: MVar Int -> MVar Int -> IO () sieve in_ out = do p <- atomically $ takeMVar in_ atomically $ putMVar out p ch <- atomically $ newEmptyMVar forkIO $ pfilter p in_ ch sieve ch out feeder :: MVar Int -> IO () feeder out = feed' 2 where feed' i = do atomically $ putMVar out i feed' (i+1) printer :: MVar () -> MVar Int -> Int -> IO () printer stop in_ max = do v <- atomically $ takeMVar in_ putStrLn $ show v if v > max then atomically $ putMVar stop () else printer stop in_ max main :: IO () main = do max:_ <- getArgs in_ <- atomically newEmptyMVar out <- atomically newEmptyMVar stop <- atomically newEmptyMVar forkIO $ feeder in_ forkIO $ printer stop out (read max) forkIO $ sieve in_ out atomically $ takeMVar stop return () From ryani.spam at gmail.com Thu Oct 9 12:36:19 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 9 12:32:36 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: <3e1162e60810090836y59f9ede6l780511f16b1430e9@mail.gmail.com> References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> <3e1162e60810090836y59f9ede6l780511f16b1430e9@mail.gmail.com> Message-ID: <2f9b2d30810090936h1d7bfcd6wedb8ee1317811e53@mail.gmail.com> This seemed like an interesting problem, so I whipped together a quick-and-dirty implementation of transactional CML semantics in Haskell using STM. Example: main = do forkIO chsThread -- administrative thread that manages communication forkIO (synchronize test1 >>= print) synchronize test2 >>= print "synchronize" is like "atomically", except it organizes groups of threads to do communication together before they can exit. Inside of synchronize, you have "readChan" and "writeChan" to communicate across channels. "newChan :: IO (Chan a)" creates a channel to communicate over. You even have "retry" and "orElse"; they are called "mzero" and "mplus", though :) The code is guaranteed to find an interleaving of any currently blocked processes that allows some subset of them to unblock, if there is one. Code is at http://ryani.freeshell.org/haskell/CHS.hs Lots of obvious optimizations present themselves; for one thing, right now, all the computation of the synchronizing threads takes place on the administrative thread. Also, the administrative thread attempts to connect all combinations of blocked threads; only attempting to communicate when a reader and writer meet on a particular channel would be another clear improvement. -- ryan From aeyakovenko at gmail.com Thu Oct 9 12:42:24 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Thu Oct 9 12:38:39 2008 Subject: [Haskell-cafe] is the a way to reinstall a package with cabal install? Message-ID: is the a way to reinstall a package with cabal install? I want to add profiling support to a libarary. Thanks, Anatoly From newsham at lava.net Thu Oct 9 13:02:03 2008 From: newsham at lava.net (Tim Newsham) Date: Thu Oct 9 12:58:23 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: Message-ID: > I was wondering if it was possible to implement synchronous channels > within STM. In particular, I'd like to have CSP-like send and recv primitives > on a channel that each block until the other side arrives to complete > the transaction. > > I think I've convinced myself that it's not possible, but > anyone care to differ? Not quite the same thing, but you can implement synchronous message passing fairly easily with MVars. Here's a small example that builds coroutines, courtesy of ddarius: http://codepad.org/GwtS6wMj you could modify this slightly to have the receiver release the sender as soon as the message is received, if that's what you wanted. Is this close enough for you, or does it have to be in STM? > cheers, > rog. Tim Newsham http://www.thenewsh.com/~newsham/ From alfonso.acosta at gmail.com Thu Oct 9 13:04:38 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Thu Oct 9 13:00:54 2008 Subject: [Haskell-cafe] is the a way to reinstall a package with cabal install? In-Reply-To: References: Message-ID: <6a7c66fc0810091004s4fdef391t7de1960444542492@mail.gmail.com> cabal install --reinstall On Thu, Oct 9, 2008 at 6:42 PM, Anatoly Yakovenko wrote: > is the a way to reinstall a package with cabal install? I want to add > profiling support to a libarary. > > Thanks, > Anatoly > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at worc.ox.ac.uk Thu Oct 9 00:35:00 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Oct 9 13:21:19 2008 Subject: [Haskell-cafe] parsec 3 & parsec 2 In-Reply-To: <6a7c66fc0810082115m57302618k687be6d1fd3250b7@mail.gmail.com> References: <42784f260810081753m2bf1bff6w89e64d2cfe9687b2@mail.gmail.com> <42784f260810082053n4227b89ey22a9f86360cf6711@mail.gmail.com> <6a7c66fc0810082115m57302618k687be6d1fd3250b7@mail.gmail.com> Message-ID: <1223526900.6878.12.camel@dell.linuxdev.us.dell.com> On Thu, 2008-10-09 at 06:15 +0200, Alfonso Acosta wrote: > ghc-pkg hide {pkg-id} This will only make a difference to ghc --make. It makes no difference to anything built using Cabal. > On Thu, Oct 9, 2008 at 5:53 AM, Jason Dusek wrote: > > I don't know anything about how to do that. Is this a Cabal > > thing? A GHC package registration thing? Here's the plan: cabal-install can now apply soft package version preferences. There will be a standard set of package version preferences in the hackage index. The initial global soft version preferences will probably be: base < 4 parsec < 3 HaXml == 1.13.* Soft preferences only apply when there is otherwise a free choice. They do not override constraints specified by packages or by the user. cabal-install will use these preferences for the "cabal install" command, but not for "cabal configure". The "install" command uses a constraint solving algorithm to find a consistent installation plan while the "configure" command still just picks the highest version of each package (like ghc --make does). What it means is that things should work when using "cabal install", but you may need to specify version constraints when using ghc --make, runghc Setup or cabal configure. We're currently testing this stuff and setting up a wiki page to explain the details. Note, if you're testing ghc-6.10 and want to use cabal-install then you need to use the very latest version from darcs as it contains some important changes to the dependency resolver. The changes enable it to work with ghc-6.10 which includes two versions of the base library. Very often both versions of the base library need to be used within a single installation plan. The previous resolver could not cope with that (indeed it was specifically designed to avoid that situation normally). Duncan From duncan.coutts at worc.ox.ac.uk Thu Oct 9 13:08:49 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Oct 9 13:21:33 2008 Subject: [Haskell-cafe] Libraries in home dir In-Reply-To: References: Message-ID: <1223572129.6878.28.camel@dell.linuxdev.us.dell.com> On Thu, 2008-10-09 at 10:08 -0300, Mauricio wrote: > Hi, > > I want to use a few libraries from hackage > and have already download and built them. Can > I install those libraries somewhere in my > home dir (I want to avoid installing as root) > so that ghc can find them? > > If so, which options should I give to Setup.hs > (with main=defaultMain) so that the libraries > are going to be copy to that dir? $ cabal instsll xmonad Does exactly that by default. No other flags are required. By default it stores files under $HOME/.cabal and registers the packages in ghc's per-user db. So no special permissions are required. If you want to change the defaults then you can use command line flags or edit the $HOME/.cabal/config file. Duncan From duncan.coutts at worc.ox.ac.uk Thu Oct 9 13:19:41 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Oct 9 13:21:50 2008 Subject: [Haskell-cafe] is the a way to reinstall a package with cabal install? In-Reply-To: References: Message-ID: <1223572781.6878.35.camel@dell.linuxdev.us.dell.com> On Thu, 2008-10-09 at 09:42 -0700, Anatoly Yakovenko wrote: > is the a way to reinstall a package with cabal install? I want to add > profiling support to a libarary. Yes. With cabal-install-0.5.2 and later: $ cabal install foobar --reinstall --enable-library-profiling If you always want profiling libs you can set that preference in the ~/.cabal/config file. Of course if cabal-install were really clever it'd know that packages were installed without the profiling libs and be able to install just those profiling versions. http://hackage.haskell.org/trac/hackage/ticket/282 Duncan (who should really write a cabal-install user guide) From dmehrtash at gmail.com Thu Oct 9 14:01:55 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu Oct 9 13:58:10 2008 Subject: [Haskell-cafe] how do you deal with mplus? Message-ID: Assuming A, B, C are monadic operation. How do you read the following function: do A 'mplus' B C I expect this to translate to: (A 'mplus' B) >>= C Can I then say it is equivalent to: (A >>=C) mplus (B >>=C) Thanks, Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/5c5f6726/attachment.htm From briqueabraque at yahoo.com Thu Oct 9 14:14:34 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Oct 9 14:11:07 2008 Subject: [Haskell-cafe] Re: Libraries in home dir In-Reply-To: <1223572129.6878.28.camel@dell.linuxdev.us.dell.com> References: <1223572129.6878.28.camel@dell.linuxdev.us.dell.com> Message-ID: >> Hi, >> >> I want to use a few libraries from hackage >> and have already download and built them. Can >> I install those libraries somewhere in my >> home dir (...) > $ cabal instsll xmonad > > Does exactly that by default. No other flags are required. > (...) Nice. Thanks for all tips. Reading them I understood defaultMain works like usual 'configure' scripts, and tried Setup.hs --help, and found the full documentation I needed. About cabal: the fact that the last versions of packages are not available in the pointed place mean I should not use cabal? For instance, utf8-string is using github.com instead of the darcs page pointed in its hackage page. Does that mean the package available in hackage is not the one I should use? Thanks, Maur?cio From apfelmus at quantentunnel.de Thu Oct 9 14:20:04 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Thu Oct 9 14:16:29 2008 Subject: [Haskell-cafe] Re: how do you deal with mplus? In-Reply-To: References: Message-ID: Daryoush Mehrtash wrote: > Assuming A, B, C are monadic operation. How do you read the following > function: > > do > A 'mplus' B > C > > I expect this to translate to: > > (A 'mplus' B) >>= C It translates to (A `mplus` B) >> C > Can I then say it is equivalent to: > > (A >>=C) mplus (B >>=C) Sounds like a desirable law, but it doesn't always hold. See also http://www.haskell.org/haskellwiki/MonadPlus Currently, there's no consensus concerning the laws that MonadPlus should obey. Regards, apfelmus From jonathanccast at fastmail.fm Thu Oct 9 14:15:03 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Oct 9 14:18:46 2008 Subject: [Haskell-cafe] Re: how do you deal with mplus? In-Reply-To: References: Message-ID: <1223576103.28799.7.camel@jcchost> On Thu, 2008-10-09 at 20:20 +0200, apfelmus wrote: > Daryoush Mehrtash wrote: > > Assuming A, B, C are monadic operation. How do you read the following > > function: > > > > do > > A 'mplus' B > > C > > > > I expect this to translate to: > > > > (A 'mplus' B) >>= C > > It translates to > > (A `mplus` B) >> C > > > Can I then say it is equivalent to: > > > > (A >>=C) mplus (B >>=C) > > Sounds like a desirable law, but it doesn't always hold. It holds for a couple of interesting monads, though. In particular, it holds for [] and for back-tracking or parallel parsers. > See also > > http://www.haskell.org/haskellwiki/MonadPlus > > Currently, there's no consensus concerning the laws that MonadPlus > should obey. jcc From ryani.spam at gmail.com Thu Oct 9 14:32:18 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Oct 9 14:28:34 2008 Subject: [Haskell-cafe] Re: how do you deal with mplus? In-Reply-To: <1223576103.28799.7.camel@jcchost> References: <1223576103.28799.7.camel@jcchost> Message-ID: <2f9b2d30810091132w77ffabd0x32168c8fcce8af1b@mail.gmail.com> So, the law under discussion is (m `mplus` n) >>= f == (m >>= f) `mplus` (n >>= f) Definitely holds for lists and other backtracking searches, but it definitely doesn't hold for non-backtracking monads like Maybe. In particular: divide n 0 = mzero divide n x = return (n `div` x) (Just 0 `mplus` Just 1) >>= divide 100 = Just 0 >>= divide 100 -- definition of MonadPlus Maybe = divide 100 0 -- definition of Monad Maybe = Nothing -- definition of divide whereas (Just 0 >>= divide 100) `mplus` (Just 1 >>= divide 100) = divide 100 0 `mplus` (Just 1 >>= divide 100) = Nothing `mplus` (Just 1 >>= divide 100) = Just 1 >>= divide 100 = divide 100 1 = Just 100 -- ryan From duncan.coutts at worc.ox.ac.uk Thu Oct 9 14:39:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Oct 9 14:36:04 2008 Subject: [Haskell-cafe] Re: Libraries in home dir In-Reply-To: References: <1223572129.6878.28.camel@dell.linuxdev.us.dell.com> Message-ID: <1223577587.6878.58.camel@dell.linuxdev.us.dell.com> On Thu, 2008-10-09 at 15:14 -0300, Mauricio wrote: > About cabal: the fact that the last versions of packages > are not available in the pointed place mean I should > not use cabal? For instance, utf8-string is using github.com > instead of the darcs page pointed in its hackage page. Does > that mean the package available in hackage is not the one > I should use? Hackage is for released packages. If you want to use the development version instead then you do have to find where that is hosted, which can be less clear at times (though as of Cabal-1.6 packages can specify a link to darcs/git repos). If the homepage for a package is wrong you can contact the maintainer. Duncan From andrewcoppin at btinternet.com Thu Oct 9 14:51:31 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 9 14:47:44 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> <48ED05C9.1020907@btinternet.com> <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> Message-ID: <48EE52B3.5000405@btinternet.com> Reiner Pope wrote: > The syntax is for the implicit parameter extension[1]. I think you > would write your example as > > foo (undefined :: Bar x) ?z :: Bar y > > Then querying the type of that whole expression with :t will list ?z's > type in the expression's constraints. (Of course, you should turn off > the monomorphism restriction so that ghc doesn't complain if > constraints aren't resolved). > > [1]: > http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#implicit-parameters Woah... that's some pretty crazy stuff, right there. Just wow. It would take me months to comprehend how that works. Heh. Oh well, it's useful for debugging the type system though. ;-) From briqueabraque at yahoo.com Thu Oct 9 14:56:22 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Thu Oct 9 14:52:48 2008 Subject: [Haskell-cafe] Problem (and half solution?) installing cabal-install Message-ID: Hi, After running bootstrap.sh, I got an error related to 'pushd' not beeing available. In fact, when I run 'man sh' I can't find 'pushd' as a command. However, just changing #!/bin/sh to #!/bin/bash (bash do have 'pushd') the installation process went well, except that I got this package versions error: Setup: At least the following dependencies are missing: HTTP >=3000 && <3002, network >=1 && <3 probably when building the executable file itself, since .cabal/lib and .cabal/share were populated with a lot of stuff, but .cabal/bin was not created. Best, Maur?cio From andrewcoppin at btinternet.com Thu Oct 9 14:52:46 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 9 15:16:59 2008 Subject: [Haskell-cafe] Hoogle? [Stacking monads] In-Reply-To: <2f9b2d30810090120y25e0b5f2k4a5c980f529c6bbd@mail.gmail.com> References: <48E5025B.1040908@btinternet.com> <48E65DF0.7090301@btinternet.com> <48E65FD8.2030504@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3AA2@ELON17P32001A.csfb.cs-group.com> <48EA6FF1.6040607@btinternet.com> <33A3F585590A6F4E81E3D45AA4A111C902CD3ABF@ELON17P32001A.csfb.cs-group.com> <48EBA5D5.9050503@btinternet.com> <2f9b2d30810080015m1813d6dt3ae38b7b9107b8cd@mail.gmail.com> <48ED05C9.1020907@btinternet.com> <4cf038ee0810081635g22fbb6eewfd0fe1d7aa8c2426@mail.gmail.com> <2f9b2d30810090120y25e0b5f2k4a5c980f529c6bbd@mail.gmail.com> Message-ID: <48EE52FE.9000503@btinternet.com> Ryan Ingram wrote: > There's also a haskell98 way to do the same thing, it's just a bit > more wordy at the ghci prompt, and a bit more work to decode the > result: > > ghci> :t \z -> (foo (undefined :: Bar x) z :: Bar y) > > Now, the type of this expression is clearly > > type of z -> Bar y > > So just read the value before the arrow to get your answer. > Ah, ingenious! Why did I not think of that...? From jsnow at cs.pdx.edu Thu Oct 9 15:40:35 2008 From: jsnow at cs.pdx.edu (Jim Snow) Date: Thu Oct 9 15:31:41 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: <48EDA572.6000901@cs.pdx.edu> Message-ID: <48EE5E33.2080803@cs.pdx.edu> Magnus Therning wrote: > Very nice indeed. You don't have any images in aspect 8x5 that don't > include the window decorations? ;-) (Yes, I'm lazy!) > > I replaced the sphereflake image with one without window decorations: http://syn.cs.pdx.edu/~jsnow/glome/sphereflake5-720p.png I don't have any sort of image export functionality, so I just do a screen capture. >> It took about a minute and a half to parse, sort, and render with about 98k >> spheres. >> > > I'm afraid it'd take me considerably longer, since I have to first get > all the software compiled and installed and then I'll have to read up > on how to generate the graphics. I suspect the latter will take a > long time since the closest I've ever come to rendering something is > watching Elephants Dream. > > /M > Glome doesn't have any particularly weird dependencies (assuming you have a recent ghc and a working OpenGL setup and GLUT), so it shouldn't be a big deal to compile it. In case you want to give it a try, here's the steps I do to generate a sphereflake from a tarball: tar xvfz glome-hs-0.51.tar.gz cd glome-hs-0.51 runhaskell Setup.lhs configure --prefix=$HOME --user runhaskell Setup.lhs build ./dist/build/glome/glome -n balls3.spd (balls3.spd is included in the glome tarball and is the output of the SPD program "spd/balls -r 1 -s 4". SPD is available from http://tog.acm.org/resources/SPD/ ) If it works, you should see an OpenGL window with a sphereflake in it. Alternatively, if you omit a scene file, Glome will render whatever it finds in TestScene.hs. There is a hastily written and somewhat out-of-date tutorial here: http://www.haskell.org/haskellwiki/Glome_tutorial If you don't get an image (note: the demo scene in TestScene.hs takes a while to render; about 20 seconds on my middle-of-the-road computer) or glome segfaults, try commenting out the line that enables pointSmooth in Glome.hs. If that still doesn't work, send me an email. I'd be interested to know what systems glome does or does not work on. -jim From andrewcoppin at btinternet.com Thu Oct 9 16:33:43 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Oct 9 16:29:55 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <20081005012510.GB2331@scytale.galois.com> References: <20081005012510.GB2331@scytale.galois.com> Message-ID: <48EE6AA7.3090105@btinternet.com> Don Stewart wrote: > http://sandersn.com/blog/index.php?title=two_weeks_of_haskell > > Has some good thoughts on what tripped him up in his first two weeks of > Haskell programming. Anything people want to work on there? :-) > > Worth a read if you're thinking about how to make Haskell yet more > accessible. > Sounds like it was written by somebody who's already used to languages like Lisp and Python. As I wrote a while earlier, I recently convinced an hardent C++ programmer to install GHC and start coding. Aside from the endless stream of "minor" things that trip you over when learning any new language, the biggest thing he sited as being difficult is the "implicitness" of Haskell. C++ is a very explicit language. If you want an integer variable, you say "int x". If you want a vector of integers, you say "std::vector x". And so on. In Haskell, you just say "x" and you've got a variable. Maybe it's type is known at compile-time. Maybe its type is polymorphically determined by the caller. Maybe it's dynamically changable at runtime (e.g., if you're using something like existential quantification). And you can write entire Haskell programs with not a single type signature in sight. (Until you grok how parametric polymorphism and Haskell's non-traditional type syntax work, this is probably the easiest way to program.) If you write a class instance, you define a whole bunch of functions who's types are implicitly fixed by the class definition [which could be somewhere very remote]. Define an algebraic data type using record syntax and you just implicitly defined half a dozen value constructors and projection functions. In short, with a few lines of Haskell, you can do an awful lot of work, and it can be a bit bewildering figuring out where all this "work" is coming from. I for one actually *like* the implicitness of Haskell. It's what enables you to write short, flexible, intuitive code. I think it's just the teaching of the language that needs work, not so much the language itself. That reminds me... I really must check out the draft of Real World Haskell sometime soon! From kili at outback.escape.de Thu Oct 9 17:16:06 2008 From: kili at outback.escape.de (Matthias Kilian) Date: Thu Oct 9 17:16:22 2008 Subject: [Haskell-cafe] ANNOUNCE: darcs 2.1.0 (corrected!) In-Reply-To: <20081009161116.GG20340@brighton.ac.uk> References: <20081009161116.GG20340@brighton.ac.uk> Message-ID: <20081009211606.GA27818@petunia.outback.escape.de> On Thu, Oct 09, 2008 at 05:11:17PM +0100, Eric Kow wrote: > This is a correction to my previous announcement. I had misgrepped the > ChangeLog. There are only 20 bug fixes and 7 new features since 2.0.2. Nevermind. It's way better than 2.0.2, anyway ;-) Ciao, Kili -- the story in pthread_rwlockattr_destory() shoudl be destroyed -- Otto Moerbeek From cgibbard at gmail.com Thu Oct 9 22:00:10 2008 From: cgibbard at gmail.com (Cale Gibbard) Date: Thu Oct 9 21:56:26 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: <20081008212832.GF3799@terra.galaxy> <89ca3d1f0810090024t6b7a29e0n60aa24cb6cfd5ac9@mail.gmail.com> Message-ID: <89ca3d1f0810091900k7c5d8806o6c659ac833ac2f1c@mail.gmail.com> Sure thing: http://cale.yi.org/LambdaAsphalt-1920x1200.jpg cheers! - Cale 2008/10/9 Magnus Therning : > On Thu, Oct 9, 2008 at 8:24 AM, Cale Gibbard wrote: >> Hello! >> >> I worked on this for a few minutes in the GIMP. Thought it might look >> nice spraypainted on asphalt. >> >> http://cale.yi.org/LambdaAsphalt.jpg (this one's at 1280x1024) > > This one is nice. Any chance of getting it in aspect ration 8x5? (My > screen is 1920x1200.) > > /M > > -- > Magnus Therning (OpenPGP: 0xAB4DFBA4) > magnus?therning?org Jabber: magnus?therning?org > http://therning.org/magnus identi.ca|twitter: magthe > From porges at porg.es Thu Oct 9 23:49:18 2008 From: porges at porg.es (George Pollard) Date: Thu Oct 9 23:45:36 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: <89ca3d1f0810091900k7c5d8806o6c659ac833ac2f1c@mail.gmail.com> References: <20081008212832.GF3799@terra.galaxy> <89ca3d1f0810090024t6b7a29e0n60aa24cb6cfd5ac9@mail.gmail.com> <89ca3d1f0810091900k7c5d8806o6c659ac833ac2f1c@mail.gmail.com> Message-ID: <1223610558.6959.7.camel@porges-laptop> Needs text in Haskell's official font ;) http://research.microsoft.com/~simonpj/papers/haskell-tutorial/TasteOfHaskell.pdf http://research.microsoft.com/~simonpj/papers/ndp/NdpSlides.pdf http://research.microsoft.com/~simonpj/papers/marktoberdorf/Marktoberdorf.ppt -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/27d368f9/attachment.bin From dmehrtash at gmail.com Fri Oct 10 00:15:59 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Fri Oct 10 00:12:13 2008 Subject: [Haskell-cafe] [] vs [()] Message-ID: What is the difference between empty list [] and list with one unit element [()]? daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081009/c3069822/attachment.htm From dons at galois.com Fri Oct 10 00:18:51 2008 From: dons at galois.com (Don Stewart) Date: Fri Oct 10 00:15:19 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: References: Message-ID: <20081010041851.GF4128@scytale.galois.com> dmehrtash: > What is the difference between empty list [] and list with one unit > element [()]? Prelude> length [] 0 Prelude> length [()] 1 :-) -- Don From haskell at colquitt.org Fri Oct 10 00:24:08 2008 From: haskell at colquitt.org (John Dorsey) Date: Fri Oct 10 00:20:23 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: <20081010041851.GF4128@scytale.galois.com> References: <20081010041851.GF4128@scytale.galois.com> Message-ID: <20081010042408.GB27422@colquitt.org> > dmehrtash: > > What is the difference between empty list [] and list with one unit > > element [()]? > > Prelude> length [] > 0 > Prelude> length [()] > 1 Also, they differ in type. [()] is a list of unit elements, and happens to contain exactly one of them. [] is a (polymorphic) list of any kind of element, and happens not to contain any of them. Regards, John From samdanielson at gmail.com Fri Oct 10 01:17:31 2008 From: samdanielson at gmail.com (Sam Danielson) Date: Fri Oct 10 01:14:43 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: References: Message-ID: <1223615851.21474.43.camel@wish.bear> > What is the difference between empty list [] and list with one unit element [()]? > The [] constructor takes no arguments and is like Nothing in the Maybe type. The list ":" (cons) infix constructor takes two arguments, an element of type a and a list of type a, to construct a new list. Compare to Maybe. data [] a = [] | a : [a] data Maybe a = Nothing | Just a Another way of saying [()] is ():[] which, comparing with the Maybe type, is similar to saying Just () but Just only takes one argument where (:) takes two. Both List and Maybe are containers that have a null constructor, namely [] and Nothing. "():[]" contains () similar to how "Just ()" contains (). You can make your own list type and put () in it as follows. data List a = Empty | Cons a (List a) deriving (Show, Eq) () `Cons` Empty -- This is ():[] -Sam PS. I'm new on the list and also to Haskell. From DekuDekuplex at Yahoo.com Fri Oct 10 01:18:23 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 10 01:15:02 2008 Subject: [Haskell-cafe] Re: [] vs [()] References: <20081010041851.GF4128@scytale.galois.com> <20081010042408.GB27422@colquitt.org> Message-ID: On Fri, 10 Oct 2008 00:24:08 -0400, John Dorsey wrote: >> dmehrtash: >> > What is the difference between empty list [] and list with one unit >> > element [()]? >> >> Prelude> length [] >> 0 >> Prelude> length [()] >> 1 > >Also, they differ in type. > >[()] is a list of unit elements, and happens to contain exactly one >of them. > >[] is a (polymorphic) list of any kind of element, and happens not to >contain any of them. Prelude> :type [] [] :: [a] Prelude> :type [()] [()] :: [()] In fact, [()] contains an empty tuple, called a "unit" (see "4 Notes and tips" of "Constructor - HaskellWiki" at http://www.haskell.org/haskellwiki/Constructor), whereas [] is just an empty list. -- Benjamin L. Russell From DekuDekuplex at Yahoo.com Fri Oct 10 01:44:32 2008 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Oct 10 01:40:58 2008 Subject: [Haskell-cafe] any estimate on when Liskell will be based on GHC 6.8.3, instead of GHC 6.6? Message-ID: Recently, I had recommended Liskell to somebody in the thread entitled "Closest statically typed FP "cousin" to Scheme?" (on comp.lang.scheme) (see http://groups.google.se/group/comp.lang.scheme/browse_thread/thread/1fa8fb06885cfd8f/a65f73105ef671a1?#a65f73105ef671a1), but then another user replied that a problem with Liskell was that it was based on GHC 6.6, whereas the latest stable version of GHC was 6.8.3 (see http://groups.google.se/group/comp.lang.scheme/msg/a65f73105ef671a1). Does anybody have any estimate on when Liskell will be updated to be based on the current GHC 6.8.3, instead of the old GHC 6.6? I am interested in trying out Liskell myself, but am slightly hesitant because it is based on an older version of GHC. -- Benjamin L. Russell From duncan.coutts at worc.ox.ac.uk Fri Oct 10 02:51:25 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Oct 10 02:48:02 2008 Subject: [Haskell-cafe] Cabal: error on configure In-Reply-To: <9C65D914D8884B7EBCDCCD1E9A405530@magenta> References: <20080911220622.4205.qmail@s461.sureserver.com> <9C65D914D8884B7EBCDCCD1E9A405530@magenta> Message-ID: <1223621485.6878.150.camel@dell.linuxdev.us.dell.com> On Tue, 2008-10-07 at 15:50 -0400, David Barton wrote: > OK, I suspect this is a real newbie error, but please have mercy. I have > downloaded and installed cabal (at least it responds to the --help command > from the command line). Yet when I do, say (to give a real example): > > cabal configure parameterized_ data > > (having done he fetch) I get this error: > > cabal.exe: Using 'build-type" Custom' but there is no Setup.hs or Setup.lhs > script.' > > When I download the package manually and look, there is a perfectly > servicable Setup.hs script, which I call manually. > > So what gives? You mean to run: cabal install parameterized-data "cabal configure" expects to be run inside the build tree. It's looking for a Setup.hs in the current directory. The configure command is for developers working with their own packages locally, rather than for working with released packages directly from hackage. There are basically two sets of commands, those for working with released packages by name, and those for working with a local package in the current directory. I'll tried to make that clearer in the cabal-install README, and perhaps in the --help output in future. Duncan From jon.fairbairn at cl.cam.ac.uk Fri Oct 10 04:51:45 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Fri Oct 10 04:48:08 2008 Subject: [Haskell-cafe] Re: [] vs [()] References: Message-ID: "Daryoush Mehrtash" writes: > What is the difference between empty list [] and list with one unit > element [()]? Prelude> :m + Data.List Prelude Data.List> []\\[()] [] or, for completeness, the difference between a list with one unit element and the empty list: Prelude Data.List> [()]\\[] [()] :-P -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From simonpj at microsoft.com Fri Oct 10 04:54:12 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Oct 10 04:50:44 2008 Subject: [Haskell-cafe] Functional progarmming at JAOO Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32D769C6C95@EA-EXMSG-C334.europe.corp.microsoft.com> Friends Anders Hejlsberg, the chief designer of C# and a very influential person at Microsoft, gave a keynote talk at JAOO Aarhus last week about "Where are programming languages going". Some of you may have mixed feelings about Microsoft but I thought you might still be interested in this talk because he gives a strong plug to functional programming (and F# in particular, although Haskell gets a mention). FP is one of the three major trends he identifies, the others being concurrency and dynamic languages. http://blip.tv/file/1317881 The FP section starts 22 mins in. Simon From robert at strangelights.com Fri Oct 10 05:28:05 2008 From: robert at strangelights.com (Robert Pickering) Date: Fri Oct 10 05:25:45 2008 Subject: [Haskell-cafe] Functional progarmming at JAOO Message-ID: <5616ab70936d4758b84c1fecf59296d0@mx252l.mysite4now.com> Hi Simon, Thanks for link! I attended JAOO and there were some great talks on programminng langauges, I really enjoyed Guy Steele's introduction to Fortres and Eric Meijer's "Fundamentalist Functional Programming", as well as Anders Hejlsberg's talk, and there were also talks on Scala and F#. I've not been to that many confrences but I all the same I judged this to be a unusally high interester in programming languages for an industrial conference. I got a real fealing that people are much more read to look at "alterative" languages for their projects, I think this can only be good for haskell and the wider FP community in general. Thanks,Robert ---------------------------------------- From: Simon Peyton-Jones Sent: 09 October 2008 20:55 To: "haskell-cafe@haskell.org" Subject: [Haskell-cafe] Functional progarmming at JAOO Friends Anders Hejlsberg, the chief designer of C# and a very influential person at Microsoft, gave a keynote talk at JAOO Aarhus last week about "Where are programming languages going". Some of you may have mixed feelings about Microsoft but I thought you might still be interested in this talk because he gives a strong plug to functional programming (and F# in particular, although Haskell gets a mention). FP is one of the three major trends he identifies, the others being concurrency and dynamic languages. http://blip.tv/file/1317881 The FP section starts 22 mins in. Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/98303f90/attachment.htm From jason.dusek at gmail.com Fri Oct 10 06:23:08 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 10 06:19:22 2008 Subject: [Haskell-cafe] ANNOUNCE: maccatcher-1.0.0 Message-ID: <42784f260810100323g3db28a84t6e55576e16a08916@mail.gmail.com> This simple little package obtains a MAC address on *NIX and Windows. It is known to work on Linux, OS X and Windows XP. There is no C fanciness in this package -- it relies on shell commands. The MAC is cached after the first query, using an IORef (I am open to other ideas, but this seemed sufficient). -- _jsn |This simple little package...| http://hackage.haskell.org/cgi-bin/hackage-scripts/package/maccatcher-1.0.0 From jeffzaroyko at gmail.com Fri Oct 10 06:53:32 2008 From: jeffzaroyko at gmail.com (Jeff Zaroyko) Date: Fri Oct 10 06:50:00 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: maccatcher-1.0.0 References: <42784f260810100323g3db28a84t6e55576e16a08916@mail.gmail.com> Message-ID: Jason Dusek gmail.com> writes: > > This simple little package obtains a MAC address on *NIX and Windows. > It is known to work on Linux, OS X and Windows XP. > > There is no C fanciness in this package -- it relies on shell > commands. The MAC is cached after the first query, using an > IORef (I am open to other ideas, but this seemed sufficient). > > -- > _jsn Hi I notice that this only prints one MAC address. Some people have more than one network interface, wouldn't it be better to show all of them? Also, on my system I need to run `ifconfig -a` to show all interfaces since it defaults to showing only interfaces which are up. Jeff From alfonso.acosta at gmail.com Fri Oct 10 07:07:46 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Fri Oct 10 07:03:59 2008 Subject: [Haskell-cafe] Cabal: error on configure In-Reply-To: <9C65D914D8884B7EBCDCCD1E9A405530@magenta> References: <20080911220622.4205.qmail@s461.sureserver.com> <9C65D914D8884B7EBCDCCD1E9A405530@magenta> Message-ID: <6a7c66fc0810100407n64041ad8ga220c9a82cf95f01@mail.gmail.com> On Tue, Oct 7, 2008 at 9:50 PM, David Barton wrote: > OK, I suspect this is a real newbie error, but please have mercy. I have > downloaded and installed cabal (at least it responds to the --help command > from the command line). Yet when I do, say (to give a real example): > > cabal configure parameterized_ data It's great to read that you are using the parameterized-data package. If you have any questions on its use, or have any suggestions, don't hesitate to ask. From briqueabraque at yahoo.com Fri Oct 10 07:10:25 2008 From: briqueabraque at yahoo.com (Mauricio) Date: Fri Oct 10 07:06:46 2008 Subject: [Haskell-cafe] Re: [] vs [()] In-Reply-To: References: Message-ID: > What is the difference between empty list [] and list with one unit > element [()]? > Or, yet: ():[()] --is legal 10:[()] --is not One list can contain elements of a single type. Since the type of () is () (element constructors and types are allowed to have the same name), a list of type [()] can only contain elements of type (), i.e., ()s. Try this is ghci: :t [()] :t [(),(),(),()] Best, Maur?cio From andrew.appleyard at gmail.com Fri Oct 10 08:12:33 2008 From: andrew.appleyard at gmail.com (Andrew Appleyard) Date: Fri Oct 10 08:09:00 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell Message-ID: <48EF46B1.9070500@gmail.com> I'd like to announce the first release of Salsa, an experimental Haskell library that allows Haskell programs to access .NET libraries. Here's a taste: > type Hello.hs import Foreign.Salsa import Bindings main = withCLR $ do _Console # _writeLine ("Hello .NET World!") > type Hello.imports System.Console: WriteLine > msbuild > .\hello Hello .NET World! Salsa operates by loading the .NET runtime into your Haskell process and using the FFI (and run-time code generation) to marshall calls between the .NET and Haskell runtimes. It includes a code generator and a type-level library (which uses type families) to provide type-safe access to .NET libraries in Haskell with C#-style method overload resolution and implicit conversions. The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the darcs repository on code.haskell.org [2], and some (limited) documentation on the Haskell wiki [3]. The library is experimental and by no means complete (refer to the wiki page [3] for some of its limitations). Be prepared to end up with incomprehensible error messages and/or a broken compiler! :-) At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET Framework to use it. Have fun! [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa [2] http://code.haskell.org/Salsa [3] http://haskell.org/haskellwiki/Salsa -- Andrew From aslatter at gmail.com Fri Oct 10 09:31:53 2008 From: aslatter at gmail.com (Antoine Latter) Date: Fri Oct 10 09:28:06 2008 Subject: [Haskell-cafe] Problem with package consistency on Hackage Message-ID: <694519c50810100631o4843ac56hdcaa9147a5ddcd84@mail.gmail.com> Folks, I'm not sure who to email about this, but hopefully someone on the cafe knows: On the machine which builds the Hackage packages the 'binary' package is built against 'bytestring-0.9.1.2', however the package I just uploaded gets built against 'bytestring-0.9.1.3' which leades to typecheck failures (the ByteStrings I get from the 'binary' package are not the same as all the other ByteStrings). See: http://hackage.haskell.org/packages/archive/uuid/1.0.0/logs/failure/ghc-6.8 If I wait will Hackage eventually become consistent? How does this work? Thanks, Antoine From ryani.spam at gmail.com Fri Oct 10 09:33:02 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Oct 10 09:29:15 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: References: Message-ID: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> (This is a literate haskell post, save into SMM.lhs and load in ghci!) Here's one place you might use [()] and []: > guard :: Bool -> [()] > guard True = [()] > guard False = [] You can then use "guard" in monadic list computations to abort the computation on some branches: > sendmoney :: [[Int]] > sendmoney = do > choice@[s,e,n,d,m,o,r,y] <- generate 8 [0..9] > guard (s /= 0) > guard (m /= 0) > guard (val [s,e,n,d] + val [m,o,r,e] == val [m,o,n,e,y]) > return choice (evaluating this in ghci takes a little while, but it does succeed! You can easily optimize by noticing that m must be equal to 1 and therefore s must be 8 or 9.) Using guard in this way works because of the definition of bind on lists: xs >>= f = concatMap f xs = concat (map f xs) Consider a simpler example: > simple = do > x <- [1,2,3] > guard (x /= 2) > return x This is the same as [1,2,3] >>= \x -> guard (x /= 2) >>= \_ -> return x = mapConcat (\x -> mapConcat (\_ -> return x) (guard (x /= 2))) [1,2,3] = concat [ mapConcat (\_ -> return 1) (guard (1 /= 2)) , mapConcat (\_ -> return 2) (guard (2 /= 2)) , mapConcat (\_ -> return 3) (guard (3 /= 2)) ] = concat [ mapConcat (\_ -> return 1) [()] , mapConcat (\_ -> return 2) [] , mapConcat (\_ -> return 3) [()] ] = concat [ concat [ [1] ] , concat [] , concat [ [3] ] ] = concat [ [1], [], [3] ] = [1,3] Another fun example: > double :: [()] > double = [(), ()] > sixteen:: Int > sixteen = length $ do > double > double > double > double Helper code for "send more money" follows... > generate :: Int -> [a] -> [[a]] > generate 0 _ = return [] > generate n as = do > (x,xs) <- select as > rest <- generate (n-1) xs > return (x:rest) > select :: [a] -> [(a,[a])] > select [] = [] > select [x] = return (x,[]) > select (x:xs) = (x,xs) : [ (y, x:ys) | (y,ys) <- select xs ] > val xs = val' 0 xs where > val' v [] = v > val' v (x:xs) = val' (10*v + x) xs From alfonso.acosta at gmail.com Fri Oct 10 09:33:59 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Fri Oct 10 09:30:14 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EF46B1.9070500@gmail.com> References: <48EF46B1.9070500@gmail.com> Message-ID: <6a7c66fc0810100633y5f0c94drcc41a33b72f2a38a@mail.gmail.com> Great! Are there any chances of getting support for non-Win32 platforms with Mono? On Fri, Oct 10, 2008 at 2:12 PM, Andrew Appleyard wrote: > I'd like to announce the first release of Salsa, an experimental Haskell > library that allows Haskell programs to access .NET libraries. > > Here's a taste: > > > type Hello.hs > import Foreign.Salsa > import Bindings > > main = withCLR $ do > _Console # _writeLine ("Hello .NET World!") > > > type Hello.imports > System.Console: WriteLine > > > msbuild > > .\hello > Hello .NET World! > > Salsa operates by loading the .NET runtime into your Haskell process and > using the FFI (and run-time code generation) to marshall calls between the > .NET and Haskell runtimes. It includes a code generator and a type-level > library (which uses type families) to provide type-safe access to .NET > libraries in Haskell with C#-style method overload resolution and implicit > conversions. > > The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the darcs > repository on code.haskell.org [2], and some (limited) documentation on the > Haskell wiki [3]. > > The library is experimental and by no means complete (refer to the wiki page > [3] for some of its limitations). Be prepared to end up with > incomprehensible error messages and/or a broken compiler! :-) > > At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET > Framework to use it. > > Have fun! > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa > [2] http://code.haskell.org/Salsa > [3] http://haskell.org/haskellwiki/Salsa > > -- > Andrew > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haskell at orangesquash.org.uk Fri Oct 10 09:43:03 2008 From: haskell at orangesquash.org.uk (Iain Lane) Date: Fri Oct 10 09:39:17 2008 Subject: [Haskell-cafe] ANNOUNCE: darcs 2.1.0 (corrected!) In-Reply-To: <20081009161116.GG20340@brighton.ac.uk> References: <20081009161116.GG20340@brighton.ac.uk> Message-ID: 2008/10/9 Eric Kow : > Hi all, > > I am delighted to announce the release of darcs 2.1.0, available at > > http://darcs.net/darcs-2.1.0.tar.gz > Yay! Ubuntu packages at the usual place: https://launchpad.net/~laney/+archive Note that I inadvertently messed up the version numbering for the prerelease versions (2.1.0preX > 2.1.0 according to dpkg; I should have used 2.1.0~preX), so apt will not consider the official 2.1.0 packages as being newer than this one. For this reason, I'll attempt to track the official packages with my numbering scheme when they appear until such a time as 2.1.1 is released. My apologies for any inconvenience. Thanks to the Debian team for providing the initial packaging. Iain From marlowsd at gmail.com Fri Oct 10 10:33:22 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Oct 10 10:29:49 2008 Subject: [Haskell-cafe] Re: Problem with package consistency on Hackage In-Reply-To: <694519c50810100631o4843ac56hdcaa9147a5ddcd84@mail.gmail.com> References: <694519c50810100631o4843ac56hdcaa9147a5ddcd84@mail.gmail.com> Message-ID: <48EF67B2.2020706@gmail.com> Antoine Latter wrote: > Folks, > > I'm not sure who to email about this, but hopefully someone on the cafe knows: > > On the machine which builds the Hackage packages the 'binary' package > is built against 'bytestring-0.9.1.2', however the package I just > uploaded gets built against 'bytestring-0.9.1.3' which leades to > typecheck failures (the ByteStrings I get from the 'binary' package > are not the same as all the other ByteStrings). See: > > http://hackage.haskell.org/packages/archive/uuid/1.0.0/logs/failure/ghc-6.8 > > If I wait will Hackage eventually become consistent? How does this work? You can re-compile parsec and binary to depend on bytestring-0.9.1.3. Alternatively, use cabal-install which knows how to rebuild things to avoid consistency problems like this. Cheers, Simon From jason.dusek at gmail.com Fri Oct 10 12:43:06 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 10 12:39:19 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: maccatcher-1.0.0 In-Reply-To: References: <42784f260810100323g3db28a84t6e55576e16a08916@mail.gmail.com> Message-ID: <42784f260810100943t27b13368n1051b62b56c585a6@mail.gmail.com> Jeff Zaroyko wrote: > I notice that this only prints one MAC address. > > Some people have more than one network interface, wouldn't it > be better to show all of them? Also, on my system I need to > run `ifconfig -a` to show all interfaces since it defaults to > showing only interfaces which are up. I can look into this. -- _jsn From duncan.coutts at worc.ox.ac.uk Fri Oct 10 12:19:55 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Oct 10 13:08:03 2008 Subject: [Haskell-cafe] Problem with package consistency on Hackage In-Reply-To: <694519c50810100631o4843ac56hdcaa9147a5ddcd84@mail.gmail.com> References: <694519c50810100631o4843ac56hdcaa9147a5ddcd84@mail.gmail.com> Message-ID: <1223655595.6878.186.camel@dell.linuxdev.us.dell.com> On Fri, 2008-10-10 at 08:31 -0500, Antoine Latter wrote: > Folks, > > I'm not sure who to email about this, but hopefully someone on the cafe knows: > > On the machine which builds the Hackage packages the 'binary' package > is built against 'bytestring-0.9.1.2', however the package I just > uploaded gets built against 'bytestring-0.9.1.3' which leades to > typecheck failures (the ByteStrings I get from the 'binary' package > are not the same as all the other ByteStrings). See: > > http://hackage.haskell.org/packages/archive/uuid/1.0.0/logs/failure/ghc-6.8 > > If I wait will Hackage eventually become consistent? How does this work? It's not a problem for users who use cabal-install because it has a dep planner specifically designed to avoid this problem. The current automated builds on hackage are not nearly so clever and thus hit this problem regularly. The solution in future will be not to do builds on hackage at all but let users and automated build clients upload results of build outcomes. That way they can use tools like cabal-install to generate consistent install plans. Duncan From dons at galois.com Fri Oct 10 13:44:11 2008 From: dons at galois.com (Don Stewart) Date: Fri Oct 10 13:40:11 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EF46B1.9070500@gmail.com> References: <48EF46B1.9070500@gmail.com> Message-ID: <20081010174411.GA6102@scytale.galois.com> This could be a game changer. Great work Andrew!! -- Don andrew.appleyard: > I'd like to announce the first release of Salsa, an experimental Haskell > library that allows Haskell programs to access .NET libraries. > > Here's a taste: > > > type Hello.hs > import Foreign.Salsa > import Bindings > > main = withCLR $ do > _Console # _writeLine ("Hello .NET World!") > > > type Hello.imports > System.Console: WriteLine > > > msbuild > > .\hello > Hello .NET World! > > Salsa operates by loading the .NET runtime into your Haskell process and > using the FFI (and run-time code generation) to marshall calls between > the .NET and Haskell runtimes. It includes a code generator and a > type-level library (which uses type families) to provide type-safe > access to .NET libraries in Haskell with C#-style method overload > resolution and implicit conversions. > > The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the > darcs repository on code.haskell.org [2], and some (limited) > documentation on the Haskell wiki [3]. > > The library is experimental and by no means complete (refer to the wiki > page [3] for some of its limitations). Be prepared to end up with > incomprehensible error messages and/or a broken compiler! :-) > > At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET > Framework to use it. > > Have fun! > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa > [2] http://code.haskell.org/Salsa > [3] http://haskell.org/haskellwiki/Salsa > > -- > Andrew > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dmehrtash at gmail.com Fri Oct 10 13:59:28 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Fri Oct 10 13:55:41 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> References: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> Message-ID: I was in fact trying to figure out how "guard" worked in the "do". The interesting (for a beginner) insight is that: [()] map f = [f] --( just as any list with one element would have been such as [1] map f = [f] ) where as [] map f = [] so if your guard computes to [()] (or any list of one element) the following steps in the do would continue. Where as if it computes to an empty list then following steps are not executed. daryoush On Fri, Oct 10, 2008 at 6:33 AM, Ryan Ingram wrote: > (This is a literate haskell post, save into SMM.lhs and load in ghci!) > > Here's one place you might use [()] and []: > > > guard :: Bool -> [()] > > guard True = [()] > > guard False = [] > > You can then use "guard" in monadic list computations to abort the > computation on some branches: > > > sendmoney :: [[Int]] > > sendmoney = do > > choice@[s,e,n,d,m,o,r,y] <- generate 8 [0..9] > > guard (s /= 0) > > guard (m /= 0) > > guard (val [s,e,n,d] + val [m,o,r,e] == val [m,o,n,e,y]) > > return choice > > (evaluating this in ghci takes a little while, but it does succeed! > You can easily optimize by noticing that m must be equal to 1 and > therefore s must be 8 or 9.) > > Using guard in this way works because of the definition of bind on lists: > > xs >>= f = concatMap f xs = concat (map f xs) > > Consider a simpler example: > > > simple = do > > x <- [1,2,3] > > guard (x /= 2) > > return x > > This is the same as > [1,2,3] >>= \x -> > guard (x /= 2) >>= \_ -> > return x > > = mapConcat (\x -> mapConcat (\_ -> return x) (guard (x /= 2))) [1,2,3] > = concat > [ mapConcat (\_ -> return 1) (guard (1 /= 2)) > , mapConcat (\_ -> return 2) (guard (2 /= 2)) > , mapConcat (\_ -> return 3) (guard (3 /= 2)) > ] > = concat > [ mapConcat (\_ -> return 1) [()] > , mapConcat (\_ -> return 2) [] > , mapConcat (\_ -> return 3) [()] > ] > = concat > [ concat [ [1] ] > , concat [] > , concat [ [3] ] > ] > = concat [ [1], [], [3] ] > = [1,3] > > Another fun example: > > > double :: [()] > > double = [(), ()] > > > sixteen:: Int > > sixteen = length $ do > > double > > double > > double > > double > > Helper code for "send more money" follows... > > > generate :: Int -> [a] -> [[a]] > > generate 0 _ = return [] > > generate n as = do > > (x,xs) <- select as > > rest <- generate (n-1) xs > > return (x:rest) > > > select :: [a] -> [(a,[a])] > > select [] = [] > > select [x] = return (x,[]) > > select (x:xs) = (x,xs) : [ (y, x:ys) | (y,ys) <- select xs ] > > > val xs = val' 0 xs where > > val' v [] = v > > val' v (x:xs) = val' (10*v + x) xs > Weblog: http://perlustration.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/cf968e0f/attachment.htm From jonathanccast at fastmail.fm Fri Oct 10 13:56:01 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 13:59:49 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: References: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> Message-ID: <1223661361.1394.9.camel@jcchost> On Fri, 2008-10-10 at 10:59 -0700, Daryoush Mehrtash wrote: > I was in fact trying to figure out how "guard" worked in the "do". > The interesting (for a beginner) insight is that: > > [()] map f = [f] I don't think any clarity is added by made-up notation. I think you mean map f [()] = [f ()] or [()] >>= f = f () or [()] >> f = f or do [()] f = f or [ f | _ <- [()] ] = [ f ] > --( just as any list with one element would have been such > as [1] map f = [f] ) where as > > [] map f = [] And map f [] = [] or [] >>= f = [] or [] >> f = [] or do [] f = [] or [ f | _ <- [] ] = [] jcc From iainspeed at gmail.com Fri Oct 10 14:08:08 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Fri Oct 10 14:04:28 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EE6AA7.3090105@btinternet.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> Message-ID: <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: > I think it's just the teaching of the language that needs work, > not so much the language itself. As a newer user myself, I'd agree with this statement. I'd like to see far more mundane tasks solved in tutorials. The number of times building a parser or generating prime number is used as an example is out of proportion to the times you'd use these things[1]. Just simple, *really* easy things would be better. Maybe it's just me, but if I wanted to learn perl or ruby or python or C# I'm not sure I'd ever see a _tutorial_ containing a prime number. Haskell is can obviously do some really interesting things, but constantly having wikipedia open so I can look up whatever mathematical doodah has just been mentioned can get draining. Even Real World Haskell suffers a bit from this. Iain [1] In years of programming (other languages) I've never had to generate my own primes or build a compiler or a parser. I may have parsed things, but that's different to building an entire parser, if you get my drift. Actually, tell a lie. I have built a parser, but it's still not stuff for a beginner's tutorial IMHO. From jonathanccast at fastmail.fm Fri Oct 10 14:05:43 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 14:09:31 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> Message-ID: <1223661943.1394.13.camel@jcchost> On Fri, 2008-10-10 at 19:08 +0100, Iain Barnett wrote: > On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: > > > I think it's just the teaching of the language that needs work, > > not so much the language itself. > > > As a newer user myself, I'd agree with this statement. I'd like to > see far more mundane tasks solved in tutorials. The number of times > building a parser or generating prime number is used as an example is > out of proportion to the times you'd use these things[1]. Just > simple, *really* easy things would be better. Maybe it's just me, but > if I wanted to learn perl or ruby or python or C# I'm not sure I'd > ever see a _tutorial_ containing a prime number. > > Haskell is can obviously do some really interesting things, but > constantly having wikipedia open so I can look up whatever > mathematical doodah has just been mentioned can get draining. Even > Real World Haskell suffers a bit from this. > > > Iain > > > [1] In years of programming (other languages) I've never had to > generate my own primes or build a compiler or a parser. I may have > parsed things, but that's different to building an entire parser, if > you get my drift. > > Actually, tell a lie. I have built a parser, but it's still not > stuff for a beginner's tutorial IMHO. In Haskell it is. Parsec makes recursive descent parsers as easy to use in Haskell as regexps are in Perl. No reason not to expose newcomers to Haskell to the thing it does best. jcc From dmehrtash at gmail.com Fri Oct 10 14:14:55 2008 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Fri Oct 10 14:11:09 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: <1223661361.1394.9.camel@jcchost> References: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> <1223661361.1394.9.camel@jcchost> Message-ID: I don't think any clarity is added by made-up notation. I think you mean In fact I was "trying" to be correct on this. Is it wrong to show: [()] >> f = f as was doing: [()] map f = [f] I want to say map function f over a single element list will yield a list of single element, the element being function f. daryoush On Fri, Oct 10, 2008 at 10:56 AM, Jonathan Cast wrote: > On Fri, 2008-10-10 at 10:59 -0700, Daryoush Mehrtash wrote: > > I was in fact trying to figure out how "guard" worked in the "do". > > The interesting (for a beginner) insight is that: > > > > [()] map f = [f] > > I don't think any clarity is added by made-up notation. I think you > mean > > map f [()] = [f ()] > > or > > [()] >>= f = f () > > or > > [()] >> f = f > > or > > do > [()] > f > = f > > or > > [ f | _ <- [()] ] = [ f ] > > > --( just as any list with one element would have been such > > as [1] map f = [f] ) where as > > > > [] map f = [] > > And > > map f [] = [] > > or > > [] >>= f = [] > > or > > [] >> f = [] > > or > > do > [] > f > = [] > > or > > [ f | _ <- [] ] = [] > > jcc > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/4f63126d/attachment.htm From iainspeed at gmail.com Fri Oct 10 14:27:51 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Fri Oct 10 14:24:15 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223661943.1394.13.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> Message-ID: On 10 Oct 2008, at 7:05 pm, Jonathan Cast wrote: > On Fri, 2008-10-10 at 19:08 +0100, Iain Barnett wrote: > In Haskell it is. > > Parsec makes recursive descent parsers as easy to use in Haskell as > regexps are in Perl. No reason not to expose newcomers to Haskell to > the thing it does best. > > jcc > > Regex tends to come after things like basic I/O, even in Perl. I've got a Haskell book here (Hutton, 170 pages) that doesn't even mention how to open a file! Just because it can be done, or it's easy(ier) doesn't mean that's where you should start. Iain From jonathanccast at fastmail.fm Fri Oct 10 14:30:09 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 14:33:55 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: References: <2f9b2d30810100633i27dad906m705618643e62ca4c@mail.gmail.com> <1223661361.1394.9.camel@jcchost> Message-ID: <1223663409.1394.28.camel@jcchost> On Fri, 2008-10-10 at 11:14 -0700, Daryoush Mehrtash wrote: > > I don't think any clarity is added by made-up notation. I > think you > mean > In fact I was "trying" to be correct on this. Great! > Is it wrong to show: > > [()] >> f = f > > as was doing: > > [()] map f = [f] Yes. Juxtaposition is always application in Haskell, and is always left-associative, and binds more tightly than any other operator. So your left-hand side means [()] applied to two arguments, map and f. This is not legal Haskell, because [()] is not a function. You intended to apply the function map to two arguments, f and [()]. The notation for that is map f [()] so, making that change, you get map f [()] = [f] This is still wrong: map :: (a -> b) -> [a] -> [b] so if f :: (() -> b) then map f [()] :: [b] but if f :: (() -> b) then [f] :: [() -> b] Unification of these types (required for an equation between the two terms) proceeds as follows: [b] = [() -> b] so b = () -> b But the unifier doesn't have a rule to solve recursive equations on types like the above; so unification fails; your rule isn't even well-typed. The correct rule is map f [()] = [f ()] where f () :: b so [f ()] :: [b] so everything type-checks. (>>) is different from map in three ways: (1) The arguments are in a different order. It's a minor issue, but of course you have to get it right. (2) >> is an infix operator (syntactically distinct from functions: map and (>>) are functions while `map` and >> are infix operators). So you can use it in the middle of your left-hand side. (2) (>>) has some subtle differences from map. The definitions are, roughly: map f xn = xn >>= \ x -> return (f x) xn >> ys = xn >>= \ x -> ys map does something interesting with the elements of its argument list: it passes them to the function f (it also builds a list of the result, which (>>) leaves to its second argument). (>>) just ignores those elements. This difference is reflected by the types, as well: map :: (a -> b) -> [a] -> [b] The type variable `a' appears twice, so in (map f xn) you know the argument to f and the elements of xn are related (in some way). (>>) :: [a] -> [b] -> [b] The type variable `a' appears only once, so in (xn >> ys) the elements of xn are just ignored; only the list structure matters. > > I want to say map function f over a single element list will yield a > list of single element, the element being function f. Haskell does distinguish between a function and the result of applying that function to an argument, so the element *isn't* actually f --- it's the result of applying f to an argument. jcc From c.chryssochoidis at gmail.com Fri Oct 10 14:45:43 2008 From: c.chryssochoidis at gmail.com (Christos Chryssochoidis) Date: Fri Oct 10 14:42:02 2008 Subject: [Haskell-cafe] Haskell in Artificial Intelligence Message-ID: <48EFA2D7.8050204@gmail.com> Greetings, I'm interested in doing a survey about the use of Haskell in the field of Artificial Intelligence. I searched in Google, and found in the HaskellWiki, at www.haskell.org/haskellwiki/Haskell_in_industry, two organizations that use Haskell and do work related to AI. Besides that, I haven't found much else. Could somebody from the Haskell community give me some pointer to a project or system related to AI that uses Haskell? Thank you very much in advance. - CC From niklas.broberg at gmail.com Fri Oct 10 15:02:20 2008 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Oct 10 14:58:33 2008 Subject: [Haskell] Re: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <20081010174411.GA6102@scytale.galois.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> Message-ID: > This could be a game changer. > > Great work Andrew!! Totally agreed, on both accounts. Really interesting to see. > -- Don What, no Arch Linux port? :-) Cheers, /Niklas From andrewcoppin at btinternet.com Fri Oct 10 15:48:28 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 15:44:36 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <20081010174411.GA6102@scytale.galois.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> Message-ID: <48EFB18C.3030707@btinternet.com> Don Stewart wrote: > This could be a game changer. > In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. Or do you just mean the type system machinery that has been developed could be used for other projects? > Great work Andrew!! > Yes indeed. I'm looking at the thesis now. It looks rather interesting... From vanenkj at gmail.com Fri Oct 10 15:53:38 2008 From: vanenkj at gmail.com (John Van Enk) Date: Fri Oct 10 15:49:51 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EFB18C.3030707@btinternet.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> <48EFB18C.3030707@btinternet.com> Message-ID: > .NET never really caught on and has long since become obsolete. Oh, if only this was the case. :( You wouldn't believe the things I have to make .NET run on (but I can't talk about it... yay for NDAs). /jve On Fri, Oct 10, 2008 at 3:48 PM, Andrew Coppin wrote: > Don Stewart wrote: > >> This could be a game changer. >> >> > > In what way? As far as I'm aware, .NET never really caught on and has long > since become obsolete. Or do you just mean the type system machinery that > has been developed could be used for other projects? > > Great work Andrew!! >> >> > > Yes indeed. I'm looking at the thesis now. It looks rather interesting... > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/4cee20c5/attachment.htm From mcguire at crsr.net Fri Oct 10 16:00:11 2008 From: mcguire at crsr.net (Tommy M. McGuire) Date: Fri Oct 10 15:56:28 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> Message-ID: <48EFB44B.3040402@crsr.net> Iain Barnett wrote: > On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: > >> I think it's just the teaching of the language that needs work, not >> so much the language itself. > > > As a newer user myself, I'd agree with this statement. I'd like to see > far more mundane tasks solved in tutorials. I would agree as well. My own flailings led to Software Tools in Haskell[1], which taught me more about how to actually do things[2] than the textbooks that I have read. > Haskell is can obviously do some really interesting things, but > constantly having wikipedia open so I can look up whatever mathematical > doodah has just been mentioned can get draining. Even Real World Haskell > suffers a bit from this. The mathematical doodahs are *very* useful, much more so than any other language I have used, but it helps to have some kind of foundation to understand how and why. I am frequently reminded of a "How to Draw" page from the Tick[3] comic, which went something like: Step 1: Draw a large oval. Step 2: Draw the Tick holding the oval. On 10 Oct 2008, at 7:05 pm, Jonathan Cast wrote: > Parsec makes recursive descent parsers as easy to use in Haskell as > regexps are in Perl. No reason not to expose newcomers to Haskell to > the thing it does best. Is it wrong to use Parsec to parse regular expressions for a really simple regex engine[4]? [1] http://www.crsr.net/Programming_Languages/SoftwareTools/index.html [2] Even if it is the wrong way. :-) [3] http://en.wikipedia.org/wiki/The_Tick [4] http://www.crsr.net/Programming_Languages/SoftwareTools/ch6.html The engine itself is in Ch. 5. -- Tommy M. McGuire mcguire@crsr.net From anton at appsolutions.com Fri Oct 10 16:43:17 2008 From: anton at appsolutions.com (Anton van Straaten) Date: Fri Oct 10 16:22:07 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EFB18C.3030707@btinternet.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> <48EFB18C.3030707@btinternet.com> Message-ID: <48EFBE65.3070401@appsolutions.com> Andrew Coppin wrote: > Don Stewart wrote: >> This could be a game changer. >> > > In what way? As far as I'm aware, .NET never really caught on and has > long since become obsolete. Wha? Microsoft's programming languages all now depend on and compile to .NET runtime (the CLR), including C#, Managed C++, Visual BASIC, and even things like the Haskell competitor F#. Hence Don's comment. I've heard people at more than one company say that if they could access .NET well from Haskell, they wouldn't be as interested in F#. Anton From jonathanccast at fastmail.fm Fri Oct 10 16:28:07 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 16:31:53 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: <1223670487.1394.34.camel@jcchost> On Fri, 2008-10-10 at 15:00 -0500, Tommy M. McGuire wrote: > On 10 Oct 2008, at 7:05 pm, Jonathan Cast wrote: > > Parsec makes recursive descent parsers as easy to use in Haskell as > > regexps are in Perl. No reason not to expose newcomers to Haskell to > > the thing it does best. > > Is it wrong to use Parsec to parse regular expressions for a really > simple regex engine[4]? That looks about right. And, as you point out, it's easier to understand than a direct parser. I would also re-code the engine itself in Parsec, though (probably using a finite state machine implementation, which (I think; I haven't tried it yet) would end up looking rather like a manual unfolding along the lines of Koen Claessen's parallel parsing process [1]). jcc [1] http://www.cs.chalmers.se/~koen/Papers/parsing-pearl.ps From jgbailey at gmail.com Fri Oct 10 16:38:18 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Oct 10 16:34:30 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: On Fri, Oct 10, 2008 at 1:00 PM, Tommy M. McGuire wrote: > I would agree as well. My own flailings led to Software Tools in > Haskell[1], which taught me more about how to actually do things[2] than the > textbooks that I have read. I found it really hard to just look up the syntax of the language when I had a question (e.g. how does case work?). I haven't advertised it much yet, but I created a PDF cheatsheet to help in those situations. It's on hackage[1], available via 'cabal install cheatsheet' or direct download. I'd be interested to hear what you think. Justin [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet From jason.dusek at gmail.com Fri Oct 10 16:48:05 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 10 16:44:18 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: <42784f260810101348y2376420ek3c274188359a27ee@mail.gmail.com> Tommy M. McGuire wrote: > Is it wrong to use Parsec to parse regular expressions for a > really simple regex engine[4]? I sometimes think it is better, from a maintainability standpoint, to just use Parsec for all that stuff and forget about regular expressions. There are many proficient application programmers and system programmers who are unfamiliar with regexen which, even if they weren't arcane, are still so balkanized. At first, I found writing Parsec for argument/option processing to be almost offensive -- so many lines for so little action! -- but it's clear as day to a lot of people and that is a real mark in its favor. -- _jsn From dons at galois.com Fri Oct 10 16:50:27 2008 From: dons at galois.com (Don Stewart) Date: Fri Oct 10 16:46:31 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <42784f260810101348y2376420ek3c274188359a27ee@mail.gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> <42784f260810101348y2376420ek3c274188359a27ee@mail.gmail.com> Message-ID: <20081010205027.GM6102@scytale.galois.com> jason.dusek: > Tommy M. McGuire wrote: > > Is it wrong to use Parsec to parse regular expressions for a > > really simple regex engine[4]? > > I sometimes think it is better, from a maintainability > standpoint, to just use Parsec for all that stuff and forget > about regular expressions. There are many proficient > application programmers and system programmers who are > unfamiliar with regexen which, even if they weren't arcane, > are still so balkanized. > > At first, I found writing Parsec for argument/option > processing to be almost offensive -- so many lines for so > little action! -- but it's clear as day to a lot of people and > that is a real mark in its favor. > And for true regular expression problems, we have regex libs, dozens. They're just not the only tool for text manipulation, and Haskell makes constructing true parsers just as easy, so may as well do it right, and do it well. -- Don From jules at jellybean.co.uk Thu Oct 9 10:31:42 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Oct 10 16:46:57 2008 Subject: [Haskell-cafe] synchronous channels in STM In-Reply-To: References: <2f9b2d30810090115s6a45bcb5l8cb4b7d5e6e5d26e@mail.gmail.com> <28012bc60810090212u48a7ab9ex5cea81198585e2d0@mail.gmail.com> Message-ID: <48EE15CE.3020000@jellybean.co.uk> roger peppe wrote: > By the way, where does FRP (which I haven't got my head around yet) > sit with respect > to STM? Entirely orthogonal. FRP is not generally thought of as (explicitly) threaded at all. It's more declarative than that. It's also supposed to be deterministic (up to the determinism of input events) which STM is not. However an elegant, efficient, implementation of FRP in pure haskell evades us, so people discuss different ways to implement it which use, possibly, concurrency such as STM or otherwise, under the hood. So STM may or may not be a good tool to implement FRP, but at the level that you *use* FRP, any threading should be entirely implicit. Jules From jason.dusek at gmail.com Fri Oct 10 16:51:01 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Oct 10 16:47:14 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: <42784f260810101351j3546ac7dl8b18eb1abeb8bfab@mail.gmail.com> Tommy M. McGuire wrote: > The mathematical doodahs are *very* useful, much more so than > any other language I have used, but it helps to have some kind > of foundation to understand how and why. I am frequently > reminded of a "How to Draw" page from the Tick[3] comic, which > went something like: http://i36.tinypic.com/wlcghf.jpg -- _jsn From steve at fenestra.com Fri Oct 10 17:13:38 2008 From: steve at fenestra.com (Steve Schafer) Date: Fri Oct 10 17:09:52 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223661943.1394.13.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com><48EE6AA7.3090105@btin ternet.com><81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> Message-ID: <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> On Fri, 10 Oct 2008 11:05:43 -0700, Jonathan Cast wrote: >No reason not to expose newcomers to Haskell to the thing it does best. This is precisely why newcomers flounder. Yes, there certainly should be a "Haskell for experienced Java/C++ programmers : All of the advanced things you can do more easily than you ever thought possible." But that's not the way to attract Joe Programmer, who has never had to write a parser. Joe Programmer needs to be shown how Haskell can solve _his_ problems. That might mean that you need to start with an extremely non-idiomatic Haskell program, one that has some of the "look and feel" of what programmers from other languages are comfortable with. And then transform that program, step-by-step, into something that takes advantage of Haskell's strengths. Steve Schafer Fenestra Technologies Corp. http://www.fenestra.com/ From andrewcoppin at btinternet.com Fri Oct 10 17:20:20 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:16:26 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EFBE65.3070401@appsolutions.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> <48EFB18C.3030707@btinternet.com> <48EFBE65.3070401@appsolutions.com> Message-ID: <48EFC714.7090902@btinternet.com> Anton van Straaten wrote: > I've heard people at more than one company say that if they could > access .NET well from Haskell, they wouldn't be as interested in F#. Mmm, I could see how that would work... ;-) From iainspeed at gmail.com Fri Oct 10 17:24:40 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Fri Oct 10 17:20:59 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: On 10 Oct 2008, at 9:00 pm, Tommy M. McGuire wrote: > Iain Barnett wrote: >> On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: >>> I think it's just the teaching of the language that needs work, >>> not so much the language itself. >> As a newer user myself, I'd agree with this statement. I'd like to >> see far more mundane tasks solved in tutorials. > > I would agree as well. My own flailings led to Software Tools in > Haskell[1], which taught me more about how to actually do things[2] > than the textbooks that I have read. That looks like a really useful resource, thanks. I've just read the introduction and that is the same experience I've been having, (ending up with bits of programs and nothing really practical). I'm currently trying to write some simple games in Haskell, and learning a lot along the way. > >> Haskell is can obviously do some really interesting things, but >> constantly having wikipedia open so I can look up whatever >> mathematical doodah has just been mentioned can get draining. Even >> Real World Haskell suffers a bit from this. > > The mathematical doodahs are *very* useful, much more so than any > other language I have used, but it helps to have some kind of > foundation to understand how and why. I am frequently reminded of > a "How to Draw" page from the Tick[3] comic, which went something > like: > Yep. They're certainly useful, it's just that explanation and knowledge aren't always the fastest route to understanding. Sometimes it's better just to get on with things and just do it - you don't learn how to drive by getting lessons on the combustion engine from a physicist :) On 10 Oct 2008, at 9:50 pm, Don Stewart wrote: > Haskell makes > constructing true parsers just as easy, > You're not speaking for me there! :) I really like regex. It's a domain specific functional language, so why rewrite the wheel? Iain From jonathanccast at fastmail.fm Fri Oct 10 17:26:57 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 17:30:47 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: <1223674017.1394.36.camel@jcchost> On Fri, 2008-10-10 at 22:24 +0100, Iain Barnett wrote: > On 10 Oct 2008, at 9:00 pm, Tommy M. McGuire wrote: > > > Iain Barnett wrote: > >> On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: > >>> I think it's just the teaching of the language that needs work, > >>> not so much the language itself. > >> As a newer user myself, I'd agree with this statement. I'd like to > >> see far more mundane tasks solved in tutorials. > > > > I would agree as well. My own flailings led to Software Tools in > > Haskell[1], which taught me more about how to actually do things[2] > > than the textbooks that I have read. > > That looks like a really useful resource, thanks. I've just read the > introduction and that is the same experience I've been having, > (ending up with bits of programs and nothing really practical). I'm > currently trying to write some simple games in Haskell, and learning > a lot along the way. > > > > >> Haskell is can obviously do some really interesting things, but > >> constantly having wikipedia open so I can look up whatever > >> mathematical doodah has just been mentioned can get draining. Even > >> Real World Haskell suffers a bit from this. > > > > The mathematical doodahs are *very* useful, much more so than any > > other language I have used, but it helps to have some kind of > > foundation to understand how and why. I am frequently reminded of > > a "How to Draw" page from the Tick[3] comic, which went something > > like: > > > > Yep. They're certainly useful, it's just that explanation and > knowledge aren't always the fastest route to understanding. Sometimes > it's better just to get on with things and just do it - you don't > learn how to drive by getting lessons on the combustion engine from a > physicist :) > > > On 10 Oct 2008, at 9:50 pm, Don Stewart wrote: > > Haskell makes > > constructing true parsers just as easy, > > > > You're not speaking for me there! :) I really like regex. It's a > domain specific functional language, so why rewrite the wheel? It's a domain-specific *declarative* language. Turning it into a true functional language makes it something entirely different. jcc From andrewcoppin at btinternet.com Fri Oct 10 17:35:05 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:31:13 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> References: <20081005012510.GB2331@scytale.galois.com><48EE6AA7.3090105@btin ternet.com><81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> Message-ID: <48EFCA89.5050704@btinternet.com> Steve Schafer wrote: > On Fri, 10 Oct 2008 11:05:43 -0700, Jonathan Cast wrote: > > >> No reason not to expose newcomers to Haskell to the thing it does best. >> > > This is precisely why newcomers flounder. Yes, there certainly should be > a "Haskell for experienced Java/C++ programmers : All of the advanced > things you can do more easily than you ever thought possible." But > that's not the way to attract Joe Programmer, who has never had to write > a parser. Joe Programmer needs to be shown how Haskell can solve _his_ > problems. That might mean that you need to start with an extremely > non-idiomatic Haskell program, one that has some of the "look and feel" > of what programmers from other languages are comfortable with. And then > transform that program, step-by-step, into something that takes > advantage of Haskell's strengths. > Seconded. On the one hand, "Haskell makes difficult things easy, and impossible things possible". This is what's cool about the language. On the other hand, an introductory text ought to start with something simpler and _more familiar_ to get people used to the language first. Haskell is a simple language, but there's an awful lot of new stuff to learn - new language rules, and new techniques for structuring your code, and even *thinking about* what code "is". And another problem. I've written a few "intro to Haskell" documents myself. These almost always end up degenerating into an exercise in tripping over myself trying to explain everything all at once. Haskell has a lot of very cool stuff in it. There are lots of things you need to know to use it though. The "things" are all pretty simple, but they're all so inter-related that it's difficult figuring out where to start. Countless times I've written an example to demonstrate feature X, and then realise "oh, wait, that requires features Y, Z, K, W, B, M and J which I haven't mentioned yet..." It seems no matter how many permutations you go through, you always end up with this problem. No matter where you start with the language! Maybe I need to sit down and draw a directed graph of related topics and then perform a topological sort or something. ;-) I sat down to read Real World Haskell today. The introduction was great (although it seems to promise far too much). Chapter 1 is really solid. But then Chapter 2... seemed to be a fairly unstructured tangle of features and concepts all dumped on the reader at once. Like, "this is how if/then/else works, oh, but that example program is recursive, so this is how recursion works, oh, but that's lazy, so this is what thunks are..." I can just imagine anybody reading all this going "wuh? Slow down!" OTOH, it's easy to criticise what somebody else wrote. Much harder to write something better yourself... :-/ PS. I'm curios to see what happens when the book gets to the "interesting stuff". The intro seems to promise that Haskell has libraries for all kinds of cool stuff - database access, sound, etc. But IME it isn't true. I have tried and tried to make accessing a database work from Haskell; the necessary libraries simply refuse to compile. Ditto for sound. I yearn to do intricate DSP stuff in Haskell, but none of the sound-related libraries will compile for me. (The libsdl binding even comes with a specially-prepaired Windows package - which doesn't work.) I want to see what the hell everybody else is doing differently that makes this stuff actually work for them when it fails miserably for me! From jonathanccast at fastmail.fm Fri Oct 10 17:29:54 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 17:33:42 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> Message-ID: <1223674194.1394.40.camel@jcchost> On Fri, 2008-10-10 at 19:27 +0100, Iain Barnett wrote: > On 10 Oct 2008, at 7:05 pm, Jonathan Cast wrote: > > > On Fri, 2008-10-10 at 19:08 +0100, Iain Barnett wrote: > > > In Haskell it is. > > > > Parsec makes recursive descent parsers as easy to use in Haskell as > > regexps are in Perl. No reason not to expose newcomers to Haskell to > > the thing it does best. > > > > jcc > > > > > > Regex tends to come after things like basic I/O, even in Perl. Why would I want to do I/O, when I don't know how to do anything interesting with the input yet, or how to generate interesting output? I think the `I/O comes first' attitude is *precisely* the difference between mainstream programmers and Haskellers. The goal should be to create more Haskellers, not just more people whose code happens to be accepted by GHC. > I've > got a Haskell book here (Hutton, 170 pages) that doesn't even mention > how to open a file! That short, and you expect minor features like that (that not every program even needs) to be squeezed in? jcc From jonathanccast at fastmail.fm Fri Oct 10 17:31:34 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 17:35:19 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btin ternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> Message-ID: <1223674294.1394.43.camel@jcchost> On Fri, 2008-10-10 at 17:13 -0400, Steve Schafer wrote: > On Fri, 10 Oct 2008 11:05:43 -0700, Jonathan Cast wrote: > > >No reason not to expose newcomers to Haskell to the thing it does best. > > This is precisely why newcomers flounder. Newcomers flounder because they expect to keep programming the same way they always have. They should be (and *are*) taught better ways of doing things. > Yes, there certainly should be > a "Haskell for experienced Java/C++ programmers : All of the advanced > things you can do more easily than you ever thought possible." But > that's not the way to attract Joe Programmer, who has never had to write > a parser. Joe Programmer needs to be shown how Haskell can solve _his_ > problems. That might mean that you need to start with an extremely > non-idiomatic Haskell program, one that has some of the "look and feel" > of what programmers from other languages are comfortable with. Try it. I guarantee you, it'll turn people *off* Haskell, and they'll never see your more elegant replacement, because they'll never read the fifth chapter where you stop fighting the language and start working with it. jcc From andrewcoppin at btinternet.com Fri Oct 10 17:40:15 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:36:22 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: <48EFCBBF.3050809@btinternet.com> Iain Barnett wrote: > On 10 Oct 2008, at 9:50 pm, Don Stewart wrote: >> Haskell makes >> constructing true parsers just as easy, >> > > You're not speaking for me there! :) I really like regex. It's a > domain specific functional language, so why rewrite the wheel? Because it's a wheel that looks like the wrong end of a dog? :-} From andrewcoppin at btinternet.com Fri Oct 10 17:43:04 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:39:11 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223674194.1394.40.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <1223674194.1394.40.camel@jcchost> Message-ID: <48EFCC68.9080306@btinternet.com> Jonathan Cast wrote: > Why would I want to do I/O, when I don't know how to do anything > interesting with the input yet, or how to generate interesting output? > I think the `I/O comes first' attitude is *precisely* the difference > between mainstream programmers and Haskellers. The goal should be to > create more Haskellers, not just more people whose code happens to be > accepted by GHC. > So we need to teach these people not just about the syntax of the language, but the high-level game plan for how to use Haskell effectively. (Since it's SO different from normal languages.) Trouble is, as soon as you attempt to write a chapter like that, guess how many people are gonna actually read it? :-/ >> I've >> got a Haskell book here (Hutton, 170 pages) that doesn't even mention >> how to open a file! >> > > That short, and you expect minor features like that (that not every > program even needs) to be squeezed in? > See, now it's things like that which stop more people attempting to learn Haskell. Most programmers would consider this an extremely basic and important thing to know, but Haskellers say "oh, THAT... it's not really important" and the newbies go "wuh? Which planet are you from? I'll go learn something less crazy, thanks." From martindemello at gmail.com Fri Oct 10 17:43:53 2008 From: martindemello at gmail.com (Martin DeMello) Date: Fri Oct 10 17:40:06 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223674294.1394.43.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> Message-ID: On Fri, Oct 10, 2008 at 2:31 PM, Jonathan Cast wrote: > On Fri, 2008-10-10 at 17:13 -0400, Steve Schafer wrote: >> On Fri, 10 Oct 2008 11:05:43 -0700, Jonathan Cast wrote: >> >> >No reason not to expose newcomers to Haskell to the thing it does best. >> >> This is precisely why newcomers flounder. > > Newcomers flounder because they expect to keep programming the same way > they always have. They should be (and *are*) taught better ways of > doing things. http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem is a brilliant example of a common workaday problem found in other languages, and solved elegantly in Haskell martin From simon at joyful.com Fri Oct 10 17:43:59 2008 From: simon at joyful.com (Simon Michael) Date: Fri Oct 10 17:40:25 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <48EFB44B.3040402@crsr.net> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> Message-ID: > [4] http://www.crsr.net/Programming_Languages/SoftwareTools/ch6.html Hi Tommy, I had never seen this before. It nicely fills a gap, and I really like the format and the writing. Bookmarked. Thanks! -Simon From andrewcoppin at btinternet.com Fri Oct 10 17:49:51 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:45:58 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223674294.1394.43.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btin ternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> Message-ID: <48EFCDFF.90203@btinternet.com> Jonathan Cast wrote: > Newcomers flounder because they expect to keep programming the same way > they always have. _Some_ newcommers flounder because they expect Haskell to be just another VB / C++ / Java / whatever. (Do we really want to encourage these people to be learning Haskell in the first place?) Others it seems flounder simply because Haskell completely changes almost all the rules about programming, and they end up not knowing which way is up. I have far more sympathy with these latter people. As I say, teaching the language syntax and the standard library functions it's going to help much on its own. You need to give these people some idea of what the high-level game plan is. I think you need to show people that you can use Haskell to do normal, ordinary stuff before you start showing off the more exotic things. (Obviously, you need to choose your examples carefully. Anything moderately complex is probably going to be approached from a totally different angle in Haskell, so the parallel won't be as helpful.) From jonathanccast at fastmail.fm Fri Oct 10 17:46:36 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 17:50:22 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFCBBF.3050809@btinternet.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> <48EFCBBF.3050809@btinternet.com> Message-ID: <1223675196.1394.59.camel@jcchost> On Fri, 2008-10-10 at 22:40 +0100, Andrew Coppin wrote: > Iain Barnett wrote: > > On 10 Oct 2008, at 9:50 pm, Don Stewart wrote: > >> Haskell makes > >> constructing true parsers just as easy, > >> > > > > You're not speaking for me there! :) I really like regex. It's a > > domain specific functional language, so why rewrite the wheel? > > Because it's a wheel that looks like the wrong end of a dog? :-} identifier = lexeme $ match "[[:lower:]_][[:alphanum:]_]*" (pretending match :: String -> Parser String is a regex engine). vs. identified = lexeme $ do c <- satisfy isLower <|> satisfy (=='_') s <- many $ satisfy isAlphaNum <|> satisfy (=='_') return (c:s) I'm not sure I follow you here... jcc From andrewcoppin at btinternet.com Fri Oct 10 17:57:30 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Oct 10 17:53:37 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> Message-ID: <48EFCFCA.50008@btinternet.com> Martin DeMello wrote: > http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem > is a brilliant example of a common workaday problem found in other > languages, and solved elegantly in Haskell > Oh, hey, that's pretty nice... From jonathanccast at fastmail.fm Fri Oct 10 18:07:43 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 18:11:29 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFCDFF.90203@btinternet.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btin ternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCDFF.90203@btinternet.com> Message-ID: <1223676463.1394.82.camel@jcchost> On Fri, 2008-10-10 at 22:49 +0100, Andrew Coppin wrote: > Jonathan Cast wrote: > > Newcomers flounder because they expect to keep programming the same way > > they always have. > > _Some_ newcommers flounder because they expect Haskell to be just > another VB / C++ / Java / whatever. (Do we really want to encourage > these people to be learning Haskell in the first place?) Absolutely not. That's my point. > Others it seems > flounder simply because Haskell completely changes almost all the rules > about programming, and they end up not knowing which way is up. Are you sure teaching I/O first (or starting with an ugly, unreadable heavily imperative straight translation of C++/Perl/Ruby) is the best way to help these people? The Haskell community *is* committed to teaching people good functional design. You can see it every day on this list. But I don't really see the relevance here. > I have > far more sympathy with these latter people. > > As I say, teaching the language syntax and the standard library > functions it's going to help much on its own. You need to give these > people some idea of what the high-level game plan is. OK, here's the high-level game plan: 1) Figure out what your program's major types are --- just what the names are. 2) Decide what operations you need on them. 3) Pick a domain (or functor) corresponding to each type constant, together with implementations of your selected operations for them. 4) Derive a set of laws governing your operations, that you're going to expect to hold for your implementation. Now, you have an API, and (implicitly) a class of mathematical models of that API. This class comes with a notion of `isomorphism' (or, technically, logical relation), between models that is required to preserve your type constants and operations. You have one model already (step 3); now you need to create another one (step 5) which will be more efficient when translated to machine code or interpreted on the computer. 5) Design a Haskell data type for each type constant, and implement Haskell functions for each operation. These may or may not be similar to your domains and operations from step 3, but there should be an isomorphism or logical relation between them. Now, you have an implementation, and can start work on an interface. 6) Pick an environment to work in (direct X11 programming, wxHaskell, the console, .NET, HTML over HTTP, etc.) 7) Decide what user-level operations you want to provide. 8) Decide, for each operation, what the effect of that operation should be in terms of your underlying state (from steps 1 and 3). 9) Implement each step as a function from the old state to the new one, using your implemented API from step 5. 10) Combine the steps into a comprehensive UI, using whatever composition methods are available in your environment. At each step, feel quite free to go back and revise your work at previous ones (but be sure to continue making progress!) An ideal tutorial would probably guide the user through these steps, in turn; note that I/O *definitely* comes after most of the code has been written. > I think you need > to show people that you can use Haskell to do normal, ordinary stuff Ordinary in the sense that it's common in programming tutorials, of course. *Real* programming mostly doesn't use printf and fget for I/O, even in C. > before you start showing off the more exotic things. (Obviously, you > need to choose your examples carefully. Anything moderately complex Anything at all, really. You can paper this over by just not explaining what this `IO' type constant is doing in their programs, but I don't think that actually helps. jcc From jonathanccast at fastmail.fm Fri Oct 10 18:08:22 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Oct 10 18:12:09 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFCC68.9080306@btinternet.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <1223674194.1394.40.camel@jcchost> <48EFCC68.9080306@btinternet.com> Message-ID: <1223676502.1394.85.camel@jcchost> On Fri, 2008-10-10 at 22:43 +0100, Andrew Coppin wrote: > Jonathan Cast wrote: > > Why would I want to do I/O, when I don't know how to do anything > > interesting with the input yet, or how to generate interesting output? > > I think the `I/O comes first' attitude is *precisely* the difference > > between mainstream programmers and Haskellers. The goal should be to > > create more Haskellers, not just more people whose code happens to be > > accepted by GHC. > So we need to teach these people not just about the syntax of the > language, but the high-level game plan for how to use Haskell > effectively. (Since it's SO different from normal languages.) Right. I think what we're doing now *is* an effective program for doing this --- for programmers who are willing to learn --- and what y'all are proposing *isn't*. I think most programmers, looking at the first chapter of the tutorial you want, would be less inclined to learn Haskell than they are now. If they want to write ugly, unmaintainable code, they can always use C++ or Perl, after all. No need to learn Haskell for that. > Trouble is, as soon as you attempt to write a chapter like that, guess > how many people are gonna actually read it? :-/ Presumably, everyone who knows Haskell now, and programs well in it, *has* read such a chapter. > >> I've > >> got a Haskell book here (Hutton, 170 pages) that doesn't even mention > >> how to open a file! > >> > > > > That short, and you expect minor features like that (that not every > > program even needs) to be squeezed in? > > > > See, now it's things like that which stop more people attempting to > learn Haskell. Most programmers would consider this an extremely basic > and important thing to know, but Haskellers say "oh, THAT... it's not > really important" and the newbies go "wuh? Which planet are you from? > I'll go learn something less crazy, thanks." It's a simple fact of programming, just one most developers don't know or don't think about. Pretending console or file I/O is somehow fundamental won't make GUIs start calling printf, or database clients start opening disk files. jcc From allbery at ece.cmu.edu Fri Oct 10 18:19:23 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Oct 10 18:15:37 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EFB18C.3030707@btinternet.com> References: <48EF46B1.9070500@gmail.com> <20081010174411.GA6102@scytale.galois.com> <48EFB18C.3030707@btinternet.com> Message-ID: <192FF3BE-A99F-46BB-88D0-683D1D972762@ece.cmu.edu> On 2008 Oct 10, at 15:48, Andrew Coppin wrote: > Don Stewart wrote: >> This could be a game changer. > > In what way? As far as I'm aware, .NET never really caught on and > has long since become News to me; lots of people installing VS.NET on campus... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH From dagit at codersbase.com Fri Oct 10 18:23:19 2008 From: dagit at codersbase.com (Jason Dagit) Date: Fri Oct 10 18:19:31 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <48EF46B1.9070500@gmail.com> References: <48EF46B1.9070500@gmail.com> Message-ID: On Fri, Oct 10, 2008 at 5:12 AM, Andrew Appleyard < andrew.appleyard@gmail.com> wrote: > I'd like to announce the first release of Salsa, an experimental Haskell > library that allows Haskell programs to access .NET libraries. Wow, that's really great. I have a .NET friendly employer, so I'm happy to see a tool/library that 'bridges" the gap between my dream of using Haskell on the job and my reality of using .NET on the job. Thank you for releasing this! Salsa operates by loading the .NET runtime into your Haskell process and > using the FFI (and run-time code generation) to marshall calls between the > .NET and Haskell runtimes. It includes a code generator and a type-level > library (which uses type families) to provide type-safe access to .NET > libraries in Haskell with C#-style method overload resolution and implicit > conversions. That's a very pragmatic approach. Nice. But, as I understand it the Haskell you write still lives in Haskell-land and the .NET code you interface with lives in .NET land. So this means, that if we tried this approach with other languagse, say Python and Java, our Haskell code would be a second class citizen there. For example, suppose you embed CPython into an application and then build a Haskell <--> Python bridge. Then my Haskell code I write must be recompiled for each platform and loaded by the python? Similarly for Java, I'm assuming that while the JVM bytecode might get loaded by the security module my Haskell is living in Haskell-land and the JVM can't provide the users with the same guarantees. So, what about translators? I was thinking, maybe a nice way to interoperate would to translate Haskell to language du jour? What if I could type, ghc --make Foo.hs -TPython, and I get Foo.py that can be run in the CPython implementation as just plain python? My understanding is that changing GHC backend is a lot of work. Take projects like lambdaVM, which I don't think has ever been completed, and you see that it involves writing a language specific run-time and some other work. There is yhccore, which has a translator for javascript. What is the way to go here? I like GHC in terms of performance, robustness and language extensions. Would I lose that with custom backends? I imagine the language extensions I'd get to keep and everything else would be subject to how well the backend is written. What do others think? Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081010/0cf21f99/attachment.htm From jgbailey at gmail.com Fri Oct 10 19:08:15 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Oct 10 19:04:27 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 Message-ID: All, I've created a "cheat sheet" for Haskell. It's a PDF that tries to summarize Haskell 98's syntax, keywords and other language elements. It's currently available on hackage[1]. Once downloaded, unpack the archive and you'll see the PDF. A literate source file is also included. If you install with "cabal install cheatsheet", run "cheatsheet" afterwards and the program will tell you where the PDF is located. The audience for this document is beginning to intermediate Haskell programmers. I found it difficult to look up some of the less-used syntax and other language stumbling blocks as I learned Haskell over the last few years, so I hope this document can help others in the future. This is a beta release (which is why I've limited the audience by using hackage) to get feedback before distributing the PDF to a wider audience. With that in mind, I welcome your comments or patches[2]. Justin [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet [2] git://github.com/m4dc4p/cheatsheet.git From jgoerzen at complete.org Fri Oct 10 19:12:12 2008 From: jgoerzen at complete.org (John Goerzen) Date: Fri Oct 10 19:08:29 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <48EFCA89.5050704@btinternet.com> References: <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <48EFCA89.5050704@btinternet.com> Message-ID: <20081010231212.GA18616@complete.org> On Fri, Oct 10, 2008 at 10:35:05PM +0100, Andrew Coppin wrote: > OTOH, it's easy to criticise what somebody else wrote. Much harder to > write something better yourself... :-/ > > PS. I'm curios to see what happens when the book gets to the > "interesting stuff". The intro seems to promise that Haskell has I'm equally curious to see what happens when you get there ;-) > libraries for all kinds of cool stuff - database access, sound, etc. But > IME it isn't true. I have tried and tried to make accessing a database > work from Haskell; the necessary libraries simply refuse to compile. Well, it compiles out of the box for me. Which may or may not be saying much. Have you posted your compile errors here so that we can help you? > work.) I want to see what the hell everybody else is doing differently > that makes this stuff actually work for them when it fails miserably for > me! Start by showing us what exact commands you're running and what errors you get. Also what version of GHC you have and your platform would be helpful. So anyhow... when I started using Haskell, it was *despite* the state of libraries. I found that I was so much more productive in Haskell in the long run that I could sometimes write the library and solve the original problem in less time than it took to just solve the original problem in Python or OCaml. Obviously this doesn't always hold. But this is part of the reason that I wrote HDBC, ConfigFile, MissingH, hslogger, etc. Small things that were just missing but aren't anymore. I can't pretend that the Haskell library set is as full-featured as, say, Python. But it *is* respectable and it most certainly holds its own with database access. Oh, and you can call Python from Haskell. -- John From jgoerzen at complete.org Fri Oct 10 19:13:40 2008 From: jgoerzen at complete.org (John Goerzen) Date: Fri Oct 10 19:10:00 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223674194.1394.40.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <1223674194.1394.40.camel@jcchost> Message-ID: <20081010231340.GB18616@complete.org> On Fri, Oct 10, 2008 at 02:29:54PM -0700, Jonathan Cast wrote: > > I've > > got a Haskell book here (Hutton, 170 pages) that doesn't even mention > > how to open a file! > > That short, and you expect minor features like that (that not every > program even needs) to be squeezed in? Uh... yes. Opening and closing files, command-line parsing, etc -- needed by almost every program. Aside from some very simple stdin-to-stdout filters, it is difficult to imagine a program where you don't need to open a file! From s.clover at gmail.com Fri Oct 10 19:54:28 2008 From: s.clover at gmail.com (Sterling Clover) Date: Fri Oct 10 19:50:50 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <1223675196.1394.59.camel@jcchost> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <48EFB44B.3040402@crsr.net> <48EFCBBF.3050809@btinternet.com> <1223675196.1394.59.camel@jcchost> Message-ID: <2C839F79-CE68-4BB3-A63D-4DE11F61248D@gmail.com> On Oct 10, 2008, at 5:46 PM, Jonathan Cast wrote: > > identifier = lexeme $ match "[[:lower:]_][[:alphanum:]_]*" > > (pretending match :: String -> Parser String is a regex engine). > > vs. > > identified = lexeme $ do > c <- satisfy isLower <|> satisfy (=='_') > s <- many $ satisfy isAlphaNum <|> satisfy (=='_') > return (c:s) lexeme $ (:) <$> (lowerChar <|> char '_') <*> (many $ alphaNum <|> char '_') ? or (since we're not really talking about full fledged parsers that need lexemes here or such, but usually interpreting a single string, otherwise regexes will quickly become atrocious) foo (x:xs) | isLower x || x == '_', (xs', rest) <- break alphaOrUnder xs = Just (x : xs', rest) | otherwise = Nothing where alphaOrUnder = liftM2 (||) isAlphaNum (=='_') foo [] = Nothing A bit more verbose, sure, but operating on text functionally makes it really easy to reason about what your parser is actually doing, unlike the mysteries of a regex. --Sterl. From donn at avvanta.com Fri Oct 10 21:35:54 2008 From: donn at avvanta.com (Donn Cave) Date: Fri Oct 10 21:32:08 2008 Subject: [Haskell-cafe] Interesting new user perspective Message-ID: <20081011013554.68D4E276C44@mail.avvanta.com> Quoth John Goerzen : | Uh... yes. Opening and closing files, command-line parsing, etc -- | needed by almost every program. Aside from some very simple | stdin-to-stdout filters, it is difficult to imagine a program where | you don't need to open a file! That's how it seems to me, too, and moreover maybe the most generally recognizable API. With a GUI or a database, you're going to need to present a fair amount of background to just about everyone, but files, command lines etc. are common to nearly every programming language. If the virtues of Haskell can't be presented in this context, then maybe it isn't such a generally useful language that people ought to be worried about learning it. Donn Cave, donn@avvanta.com From aneumann at inf.fu-berlin.de Sat Oct 11 01:59:30 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sat Oct 11 01:56:00 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: Message-ID: <6B38420B-0B69-4DB6-9CF8-336DB80C65B1@inf.fu-berlin.de> Thank you for your work! I just glanced over it but I'll suggest it to be linked to from the homepage of my university's functional programming course. However, thirteen pages can hardly be called "cheatsheet". It's more like a quick reference. You could add [100,99..] "infinite liste of numbers from 100 downwards" to you "numbers" section, as it is an example where the range does go backward. Adrian Am 11.10.2008 um 01:08 schrieb Justin Bailey: > All, > > I've created a "cheat sheet" for Haskell. It's a PDF that tries to > summarize Haskell 98's syntax, keywords and other language elements. > It's currently available on hackage[1]. Once downloaded, unpack the > archive and you'll see the PDF. A literate source file is also > included. > > If you install with "cabal install cheatsheet", run "cheatsheet" > afterwards and the program will tell you where the PDF is located. > > The audience for this document is beginning to intermediate Haskell > programmers. I found it difficult to look up some of the less-used > syntax and other language stumbling blocks as I learned Haskell over > the last few years, so I hope this document can help others in the > future. > > This is a beta release (which is why I've limited the audience by > using hackage) to get feedback before distributing the PDF to a wider > audience. With that in mind, I welcome your comments or patches[2]. > > Justin > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ > CheatSheet > [2] git://github.com/m4dc4p/cheatsheet.git > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/6c6d7d11/PGP.bin From dagit at codersbase.com Sat Oct 11 03:58:51 2008 From: dagit at codersbase.com (Jason Dagit) Date: Sat Oct 11 03:55:02 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? Message-ID: Hello, I was thinking about translating Haskell to other languages, python being the main one at the moment. Here is my attempt at manually encoding Haskell in Python: \begin{code} import types class thunk: '''Thunks allow us to delay a computation and they also store their value inside themselves once they have been accessed.''' def __init__(self, v): self.v = v def value(self): '''Force the thunk to be calculated by referencing it.''' while self.isReducible(): self.reduce() return self.v def reduce(self): '''Reduces the thunk, by either calling the represented function or reducing the layers of thunk.''' if (type(self.v) == types.FunctionType): self.v = self.v() else: self.v = self.v.value() return self.v def isReducible(self): '''Returns True when the thunk is still callable.''' return isinstance(self.v, thunk) or \ type(self.v) == types.FunctionType class nil: '''Empty list element''' def __init__(self): pass class cons: '''Non-empty lists''' def __init__(self, head, tail): self.head = head self.tail = tail '''Unpack the cons cell''' def uncons(self): return self.head, self.tail def htail(t): '''This function works like Haskell's tail function.''' l = t.value() x, xs = l.uncons() return xs def plus(t1, t2): '''Adds numbers''' i1 = t1.value() i2 = t2.value() return thunk(i1+i2) def zipWith(f, t1, t2): '''This is like Haskell's zipWith function.''' l1 = t1.value() if isinstance(l1, nil): return thunk(nil()) l2 = t2.value() if isinstance(l2, nil): return thunk(nil()) x, xs = l1.uncons() y, ys = l2.uncons() zw = thunk(lambda: zipWith(f, xs, ys)) fxy = thunk(lambda: f(x,y)) return thunk(cons(fxy, zw)) def fibs(): '''This is the classic fibs: fibs = 1 : 1 : zipWith (+) fibs (tail fibs)''' f1 = thunk(1) f2 = thunk(1) fn = thunk(fibs) rest = thunk(lambda: zipWith(plus, fn, htail(fn))) restlist = thunk(cons(f2, rest)) fiblist = thunk(cons(f1, restlist)) return fiblist def hmap(f, t): '''map _ [] = [] map f (x:xs) = f x : map f xs''' l = t.value() if isinstance(l, nil): return thunk(nil()) x, xs = l.uncons() fx = thunk(lambda: f(x)) mapfxs = thunk(lambda: hmap(f, xs)) return thunk(cons(fx, mapfxs)) def show(t): '''show :: a -> String''' v = t.value() return thunk(str(v)) def printList(t): '''This just gives us a way to debug lists.''' v = t.value() print "[", while True: h,t = v.uncons() print "%s" % h.value(), if isinstance(t.value(), nil): break else: print ", ", v = t.value() print "]" def take(tn, tl): '''take n _ | n <= 0 = [] take _ [] = [] take n (x:xs) = x : take (n-1) xs''' n = tn.value() if n <= 0: return thunk(nil()) l = tl.value() if isinstance(l, nil): return thunk(nil()) x,xs = l.uncons() nminusone = thunk(lambda: plus(tn, thunk(-1))) takerec = thunk(lambda: take(nminusone, xs)) return thunk(cons(x, takerec)) \end{code} You can try this out in python with: tenfibs = take(thunk(10), fibs()) printList(tenfibs) This will print the first 10 fibs. Questions: I think the examples above are correctly lazy. Have I missed something? I noticed my thunks can get wrapped in each other, is this to be expected, or am I doing it wrong? Is there an easier encoding using generators? When I started I was using generators instead of thunk, but I found it was complicating my design so I removed it. And yet, since generators are python's version of thunks, it seems like there should be a more natural encoding there. I'm not explicitly using a graph reduction algorithm to reach WHNF, does this mean my translation is wrong? Are there some well known test cases I should try? Anyone know of a paper that discusses making this translation? I am trying to avoid writing an interpreter in Python for Haskell. My goal is to translate Haskell functions into the equivalent Python. I'm also hoping to avoid needing a G-machine. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/4270aa8f/attachment.htm From c.chryssochoidis at gmail.com Sat Oct 11 04:28:53 2008 From: c.chryssochoidis at gmail.com (Chryssochoidis Christos) Date: Sat Oct 11 04:25:09 2008 Subject: [Haskell-cafe] Haskell in Artificial Intelligence In-Reply-To: References: <48EFA2D7.8050204@gmail.com> Message-ID: On 11 ??? 2008, at 10:57 ??, Krasimir Angelov wrote: > Hi Christos > > We use Haskell for natural language processing. See here: > > http://www.cs.chalmers.se/~aarne/GF/ > > Best regards, > Krasimir > Thank you very much for your response Krasimir. Best regards, Christos > On Fri, Oct 10, 2008 at 8:45 PM, Christos Chryssochoidis > wrote: >> Greetings, >> >> I'm interested in doing a survey about the use of Haskell in the >> field of >> Artificial Intelligence. I searched in Google, and found in the >> HaskellWiki, >> at www.haskell.org/haskellwiki/Haskell_in_industry, two >> organizations that >> use Haskell and do work related to AI. Besides that, I haven't >> found much >> else. Could somebody from the Haskell community give me some >> pointer to a >> project or system related to AI that uses Haskell? >> >> Thank you very much in advance. >> >> - CC >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From bartek at sudety.it Sat Oct 11 04:41:32 2008 From: bartek at sudety.it (Bartosz =?iso-8859-1?q?W=F3jcik?=) Date: Sat Oct 11 04:38:10 2008 Subject: [Haskell-cafe] Haskell in Artificial Intelligence In-Reply-To: <48EFA2D7.8050204@gmail.com> References: <48EFA2D7.8050204@gmail.com> Message-ID: <200810111041.32692.bartek@sudety.it> Hi CC, you can find a word about possible usage of functional programming in AI in following paper: http://www.cs.chalmers.se/~rjmh/Papers/whyfp.html . Besides in HackageDB you can find separate category AI. I had pleasure also to write an AI of simple game (http://en.wikipedia.org/wiki/Paper_Soccer): http://hackage.haskell.org/cgi-bin/hackage-scripts/package/foo . Currently I'm working on AI of another game: http://www.educationallearninggames.com/how-to-play-pylos-game-rules.asp . It's not much though. rgds, Bartek On Friday 10 October 2008 20:45:43 Christos Chryssochoidis wrote: > Greetings, > > I'm interested in doing a survey about the use of Haskell in the field > of Artificial Intelligence. I searched in Google, and found in the > HaskellWiki, at www.haskell.org/haskellwiki/Haskell_in_industry, two > organizations that use Haskell and do work related to AI. Besides that, > I haven't found much else. Could somebody from the Haskell community > give me some pointer to a project or system related to AI that uses > Haskell? > > Thank you very much in advance. > > - CC > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ryani.spam at gmail.com Sat Oct 11 06:38:40 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Oct 11 06:34:51 2008 Subject: [Haskell-cafe] Interesting new user perspective In-Reply-To: <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <48EE6AA7.3090105@btinternet.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> Message-ID: <2f9b2d30810110338w5c5858d0kac07f52d3ddaf929@mail.gmail.com> If you want quick examples of idiomatic haskell including stdin/stdout I/O, I like this page: http://www.haskell.org/haskellwiki/Simple_unix_tools -- ryan On Fri, Oct 10, 2008 at 7:08 PM, Iain Barnett wrote: > On 9 Oct 2008, at 9:33 pm, Andrew Coppin wrote: > >> I think it's just the teaching of the language that needs work, not so >> much the language itself. > > > As a newer user myself, I'd agree with this statement. I'd like to see far > more mundane tasks solved in tutorials. The number of times building a > parser or generating prime number is used as an example is out of proportion > to the times you'd use these things[1]. Just simple, *really* easy things > would be better. Maybe it's just me, but if I wanted to learn perl or ruby > or python or C# I'm not sure I'd ever see a _tutorial_ containing a prime > number. > > Haskell is can obviously do some really interesting things, but constantly > having wikipedia open so I can look up whatever mathematical doodah has just > been mentioned can get draining. Even Real World Haskell suffers a bit from > this. > > > Iain > > > [1] In years of programming (other languages) I've never had to generate my > own primes or build a compiler or a parser. I may have parsed things, but > that's different to building an entire parser, if you get my drift. > > Actually, tell a lie. I have built a parser, but it's still not stuff for a > beginner's tutorial IMHO. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Sat Oct 11 07:33:16 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Oct 11 07:29:26 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: Message-ID: <910ddf450810110433j54385aa9xbf3fb9aa0a2ebe13@mail.gmail.com> Very nice! I have my own cheat list, which are haskell commands I find useful but find inconvenient or difficult to look up in the supplied documentation. I actually hardwire my cheats into .bashrc doing something like thartman_haskell_cheatting() { cat << EOF blah blah cheat } so i can quickly see all my haskell cheats using tab completion. but a pdf is even nicer :) ************************** thartman@thartman-laptop:~/Desktop>thartman_haskell_oneliners ghc -e '1+2' thartman@thartman-laptop:~/Desktop>thartman_haskell_regex_hints cabal install pcre-regex Most likely want: Prelude Text.Regex.PCRE> "user123" =~ "^(user)(\d*)$" :: (String,String,String,[String]) ("","user123","",["user","123"]) That is: (before match, match, after match, subgroups) or maybe Prelude Text.Regex.PCRE> "user123 user456" =~ "(u(se)r)(\d*)" :: [[String]] [["user123","user","se","123"],["user456","user","se","456"]] if you need all submatches of all matches since Prelude Text.Regex.PCRE> "user123 user456" =~ "(user)(\d*)" :: (String,String,String,[String]) ("","user123"," user456",["user","123"]) doesn't quite do what I want -- no submatches and there's no instance for :: (String,String,String,[String]) I don't need all submatches of all matches very often though. :: Bool -- did it match :: String -- first match :: [String] -- every match :: :: (String,String,String) -- before, matched, after http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/ thartman@thartman-laptop:~/Desktop>thartman_haskell_testing_things import Data.Test.HUnit runTestTT $ TestCase $ assertEqual "meh" 1 2 runTestTT $ TestList [ TestCase $ assertEqual "meh" 1 2 ] thartman@thartman-laptop:~/Desktop>thartman_haskell_hints offline documentation: ghc-pkg describe bytestring | grep -i doc or probably just haddock-interfaces: /usr/local/share/doc/ghc/libraries/bytestring/bytestring.haddock haddock-html: /usr/local/share/doc/ghc/libraries/bytestring note to self: start using cabal install --global (or whatever the flag is) so all documentation is browsable from one place Use language pragmas, with commas And you can't put LANGUAGE and OPTIONS_GHC in the same pragma {-# LANGUAGE NoMonomorphismRestriction, PatternSignatures #-} {-# OPTIONS -fglasgow-exts #-} Debugging toVal.hs:30:17: Couldn't match expected type 'blee' against inferred type 'bleh' bleh is whatever is at 30:17 blee is something that's wanted by whatever is calling the value at 30:17 If the error is "in the definition of" some function, then probably one function case conflicts with another, you can ignore other functions. In this case you will only get one line:col to look at. If there are more than one line:col to look at, possibly separate functions are in conflict. So, smart to always fix "in the definition of" type errors first. Still baffled? Won't compile? Give top-level functions type signatures. Won't hurt, might help. :set -fwarn-missing-signatures or {-# OPTIONS -fwarn-missing-signatures #-} Start commenting out calling functions until it compiles, and then look at the signatures. And then type the signatures in explicitly... does something look funny? Like, wrong number of args? Maybe currying went wrong. tag and bundle a distribution: darcs tag 0.2 cabal configure cabal sdist cd dist; unzip, verify install does the right thing http://hackage.haskell.org/packages/upload.html check upload, and upload. see also http://en.wikibooks.org/wiki/Haskell/Packaging group module imports from multiple modules in one place: module MyInductiveGraph ( module Data.Graph.Inductive, module EnoughFlow ) where import Data.Graph.Inductive import EnoughFlow ************************** 2008/10/11 Justin Bailey : > All, > > I've created a "cheat sheet" for Haskell. It's a PDF that tries to > summarize Haskell 98's syntax, keywords and other language elements. > It's currently available on hackage[1]. Once downloaded, unpack the > archive and you'll see the PDF. A literate source file is also > included. > > If you install with "cabal install cheatsheet", run "cheatsheet" > afterwards and the program will tell you where the PDF is located. > > The audience for this document is beginning to intermediate Haskell > programmers. I found it difficult to look up some of the less-used > syntax and other language stumbling blocks as I learned Haskell over > the last few years, so I hope this document can help others in the > future. > > This is a beta release (which is why I've limited the audience by > using hackage) to get feedback before distributing the PDF to a wider > audience. With that in mind, I welcome your comments or patches[2]. > > Justin > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet > [2] git://github.com/m4dc4p/cheatsheet.git > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From holgersiegel74 at yahoo.de Sat Oct 11 08:30:50 2008 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Sat Oct 11 08:27:08 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: Message-ID: <200810111430.51035.holgersiegel74@yahoo.de> On Saturday 11 October 2008 01:08:15 Justin Bailey wrote: > This is a beta release (which is why I've limited the audience by > using hackage) to get feedback before distributing the PDF to a wider > audience. With that in mind, I welcome your comments or patches[2]. > > Justin > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet > [2] git://github.com/m4dc4p/cheatsheet.git Looks good! Some minor issues: - sometimes it is a bit verbose for a cheatsheet; for example the reference to language C in the section about the layout rule. - in the section about strings, you give an example of a syntax error; it would be sufficient to show what is right. - in the section about operator precedence you define 'div1' to be right associative. Instead, you could show where right associativity is actually useful (>>=, ...). - The explanation of the layout rule is wrong. If you define more than one value in a let declaration, then it is only required that the identifiers start on the same column. - When I started to learn Haskell, I had problems with the use of (.) and ($). I had learned what function application and lambda abstractions look like, but then I looked at Haskell code written by experienced Haskellers and found expressions like (map (succ . succ) $ 1:xs) that I did not understand. A small section describing how to read such expressions could be useful for beginners. - the section about do-notation is more a mini-tutorial than a cheatsheet. Instead, you could show two or three examples that demonstrate how do- notation, list comprehensions and the operator >>= relate. That is what I had to look up more than once until I got used to it. There is also an example of what is wrong, where showing the right thing would have sufficed. From dino at ui3.info Sat Oct 11 09:43:40 2008 From: dino at ui3.info (Dino Morelli) Date: Sat Oct 11 09:40:21 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: Message-ID: On Fri, 10 Oct 2008, Justin Bailey wrote: > I've created a "cheat sheet" for Haskell. It's a PDF that tries to > summarize Haskell 98's syntax, keywords and other language elements. > It's currently available on hackage[1]. Once downloaded, unpack the > archive and you'll see the PDF. A literate source file is also > included. > .. > The audience for this document is beginning to intermediate Haskell > programmers. I found it difficult to look up some of the less-used > syntax and other language stumbling blocks as I learned Haskell over > the last few years, so I hope this document can help others in the > future. > .. > Justin > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet > [2] git://github.com/m4dc4p/cheatsheet.git > _______________________________________________ Justin (and everyone now contributing to this), thanks. This type of thing is very helpful. There is a well-known one-page cheat-sheet like this for Perl5 (and a newer one for Perl6 too). You can see it by typing `perldoc perlcheat` on a system with Perl. I wonder if we don't need something like that. On a related note, I had come up with this short list to help with how to read the Haskell symbols. I email this out when trying to get new people started: ----- Haskell symbology One thing that I found very difficult at first was how to read a lot of the symbols in the Haskell code. I made up a small cheat-sheet that explains how to read some of it: Some definitions of Haskell symbols: :: "has type" -> "to" The type 'Integer -> Integer' takes Integer as an argument and evaluates to an Integer. We say this type is "Integer to Integer" => "evaluates" or "reduces to" Used in function type signatures, read something like this: foo :: (Bar b) => b -> c For all instances of type class Bar (here referred to as b), foo is a function from b to c. Or foo "has type" b to c. [a] "list of a" The family of types consisting of, for every type a, the type of lists of a. : "cons" List cons operator, adds first argument to the front of second, part of the List monad: (:) :: a -> [a] -> [a] Read: cons has type a to list of a to list of a !! List index operator [ 1, 2, 3 ] !! 1 = 2 (lists are 0-based) (!!) :: [a] -> Int -> a Read: (!!) has type list of a to Int to a | "such that" <- "drawn from" >>= "bind" Part of class Monad >> "then" Part of class Monad ----- -- Dino Morelli email: dino@ui3.info web: http://ui3.info/d/ irc: dino- pubkey: http://ui3.info/d/dino-4AA4F02D-pub.gpg From c.chryssochoidis at gmail.com Sat Oct 11 10:01:27 2008 From: c.chryssochoidis at gmail.com (Chryssochoidis Christos) Date: Sat Oct 11 09:57:45 2008 Subject: [Haskell-cafe] Haskell in Artificial Intelligence In-Reply-To: <200810111041.32692.bartek@sudety.it> References: <48EFA2D7.8050204@gmail.com> <200810111041.32692.bartek@sudety.it> Message-ID: On 11 ??? 2008, at 11:41 ??, Bartosz W?jcik wrote: > Hi CC, > > you can find a word about possible usage of functional programming > in AI in > following paper: > http://www.cs.chalmers.se/~rjmh/Papers/whyfp.html . > Besides in HackageDB you can find separate category AI. > I had pleasure also to write an AI of simple game > (http://en.wikipedia.org/wiki/Paper_Soccer): > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/foo . > Currently I'm working on AI of another game: > http://www.educationallearninggames.com/how-to-play-pylos-game-rules.asp > . > It's not much though. > > rgds, > Bartek > Thanks very much for the very interesting pointers! Best regards, Christos > > On Friday 10 October 2008 20:45:43 Christos Chryssochoidis wrote: >> Greetings, >> >> I'm interested in doing a survey about the use of Haskell in the >> field >> of Artificial Intelligence. I searched in Google, and found in the >> HaskellWiki, at www.haskell.org/haskellwiki/Haskell_in_industry, two >> organizations that use Haskell and do work related to AI. Besides >> that, >> I haven't found much else. Could somebody from the Haskell community >> give me some pointer to a project or system related to AI that uses >> Haskell? >> >> Thank you very much in advance. >> >> - CC >> >> >> >> >> _______________________________________________ >> 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 From tphyahoo at gmail.com Sat Oct 11 10:52:08 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Oct 11 10:48:19 2008 Subject: [Haskell-cafe] External Sort and unsafeInterleaveIO In-Reply-To: <20070718035425.GA6123@cse.unsw.EDU.AU> References: <9157df230707170214q683ed56ctcd9f3f543556c382@mail.gmail.com> <9157df230707170216j2203a612h7d7ae18a4acecb15@mail.gmail.com> <20070718031726.GA5709@cse.unsw.EDU.AU> <9157df230707172046t66f5e1b9pcf90d5b25d4d9408@mail.gmail.com> <20070718035425.GA6123@cse.unsw.EDU.AU> Message-ID: <910ddf450810110752u4a27a3dfy70ac39753a7719cc@mail.gmail.com> I kinda-sorta half-cabalized it at darcs get http://darcsdump.dreamhosters.com/external-sort (untested via cabal install but mostly done) As soon as my project gets approved I'll put it up on hackage. If Ben wants it under his account at hackage of course I'll defer to him. Thomas. 2007/7/18 Donald Bruce Stewart : > midfield: >> hi -- >> >> thanks for the useful comments! i will definitely go through them >> carefully. unfortunately for this code (but fortunately for me) i >> defend my dissertation on monday so i'm a little distracted right >> now..... >> >> i'm more than happy to donate this code or whatever improvements >> happen to it. actually, hGetContentsWithCursor seems like a candidate >> for inclusion with Data.ByteStrings or Data.Binary or something -- it >> seems like it might find other uses. (i think you liked that bit of >> code because i ripped it off of you guys! it's very short hamming > > Can't fault that style ;) > >> distance from the original.) anyhow, all that will have to wait a >> couple weeks or so. also i've never cabalized anything so i may come >> begging for help. > > We have a tutorial for that, luckily: > > http://haskell.org/haskellwiki/How_to_write_a_Haskell_program > > And a tool to automate it, mkcabal, so should be fairly straightforward. > >> >> at some point i thought i saw how to do recursive external sort, to >> keep memory usage truly constant, but with my current lack of sleep i >> have lost that illusion. i'm also curious about the performance >> characteristics of this vs Prelude sort vs the version using the >> tournament mergesort apfelmus suggested. i need to find a computer >> with a lot more RAM than my weakling laptop. finally, it would be >> good to be able to have the blocksize controlled by Kb of RAM rather >> than # of elements, not sure how to get that information. >> >> ultimately this was part of my project to write lucene for haskell. i >> think with this out of the way, plus all the Data.Binary / ByteString >> goodness, it shouldn't take too long. keep writing good libraries for >> me! >> > > Great. Good to see things working. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mfn-haskell-cafe at cs.york.ac.uk Sat Oct 11 11:55:05 2008 From: mfn-haskell-cafe at cs.york.ac.uk (Matthew Naylor) Date: Sat Oct 11 11:54:46 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? In-Reply-To: References: Message-ID: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Hi Jason, I don't know Python, but let me share some thoughts that you might find useful. First, a few questions about your manual translations. Are your functions curried? For example, can I partially apply zipWith? Also, you put a "thunk" around things like "cons(...)" --- should it not be the arguments to "cons" that are thunked? Now, on to an automatic translation. As you may know already, Haskell programs can be transformed to "combinator programs" which are quite simple and easy to work with. Here is what I mean by a "combinator program": p ::= d* (a program is a list of combinator definitions) d ::= c v* = e (combinator definition) e ::= e e (application) | v (variable/argument) | c (constant: integer literal, combinator name, etc.) As an example of a combinator program, here is one that reverses the list [0,1,2]. rev v acc = v acc (rev2 acc) rev2 acc x xs = rev xs (cons x acc) cons x xs n c = c x xs nil n c = n main = rev (cons 0 (cons 1 (cons 2 nil))) nil This program does not type-check in Haskell! But Python, being dynamically typed, doesn't suffer from this problem. :-) A translation scheme, D[], from a combinator definition to a Python definition might look as follows. D[c v* = e] = def c() : return (lambda v1: ... lambda vn: E[e]) E[e0 e1] = E[e0] (E[e1]) E[v] = v E[c] = c() Here is the result of (manually) applying D to the list-reversing program. def nil() : return (lambda n: lambda c: n) def cons() : return (lambda x: lambda xs: lambda n: lambda c: c(x)(xs)) def rev2() : return (lambda acc: lambda x: lambda xs: rev()(xs)(cons()(x)(acc))) def rev() : return (lambda v: lambda acc: v(acc)(rev2()(acc))) def main() : return (rev() (cons()(0)( cons()(1)( cons()(2)( nil()))))(nil())) The result of main() is a partially-applied function, which python won't display. But using the helper def list(f) : return (f([])(lambda x: lambda xs: [x] + list(xs))) we can see the result of main(): >>> list(main()) [2, 1, 0] Of course, Python is a strict language, so we have lost Haskell's non-strictness during the translation. However, there exists a transformation which, no matter how a combinator program is evaluated (strictly, non-strictly, or lazily), the result will be just as if it had been evaluated non-strictly. Let's call it N, for "Non-strict" or "call-by-Name". N[e0 e1] = N[e0] (\x. N[e1]) N[v] = v (\x. x) N[f] = f I've cheekily introduced lambdas on the RHS here --- they are not valid combinator expressions! But since Python supports lambdas, this is not a big worry. NOTE 1: We can't remove the lambdas above by introducing combinators because the arguments to the combinator would be evaluated and that would defeat the purpose of the transformation! NOTE 2: "i" could be replaced with anything above --- it is never actually inspected. For the sake of interest, there is also a "dual" transformation which gives a program that enforces strict evaluation, no matter how it is evaluated. Let's call it S for "Strict". S[e0 e1] = \k. S[e0] (\f. S[e1] (\x. k (f x))) S[v] = \k. k v S[f] = \k. k f I believe this is commonly referred to as the CPS (continuation-passing style) transformation. Now, non-strict evaluation is all very well, but what we really want is lazy evaluation. Let's take the N transformation, rename it to L for "Lazy", and indulge in a side-effecting reference, ML style. L[e0 e1] = L[e0] (let r = ref None in \x. match !r with None -> let b = L[e1] in r := Some b ; b | Some b -> b) L[v] = v (\x. x) L[f] = f I don't know enough to define L w.r.t Python. I haven't tried too hard to fully understand your translation, and likewise, you may not try to fully understand mine! But I thought I'd share my view, and hope that it might be useful (and correct!) in some way. Matthew. From leimy2k at gmail.com Sat Oct 11 12:07:28 2008 From: leimy2k at gmail.com (David Leimbach) Date: Sat Oct 11 12:03:38 2008 Subject: [Haskell-cafe] Haskell on the JVM Message-ID: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> Are there, or have there been Haskell ports to the JVM? Are any of them alive and well? Is there an interest in hosting GHC on the JVM (besides my own). I know I don't have time to tackle such a project but I'd be extremely interested in using such a thing. Especially in my day to day work. I currently do a lot of Java <-> Erlang via JInterface, and have been for months, yet there's many tasks I could do better in a language like Haskell. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/e9cc2433/attachment.htm From sdh33 at cornell.edu Sat Oct 11 12:33:50 2008 From: sdh33 at cornell.edu (Stephen Hicks) Date: Sat Oct 11 12:29:59 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: Message-ID: <50b5ae760810110933s5e1f5da9r3a39c13851227bf9@mail.gmail.com> On Fri, Oct 10, 2008 at 7:08 PM, Justin Bailey wrote: > I've created a "cheat sheet" for Haskell. It's a PDF that tries to > summarize Haskell 98's syntax, keywords and other language elements. > It's currently available on hackage[1]. Once downloaded, unpack the > archive and you'll see the PDF. A literate source file is also > included. It looks very nice, if a bit verbose. One minor comment is that on page 4 you give a "type signature" for if-then-else. I would contend that it should be Bool -> a -> a -> a, instead. steve From john at n-brain.net Sat Oct 11 12:45:39 2008 From: john at n-brain.net (John A. De Goes) Date: Sat Oct 11 12:41:52 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> Message-ID: LamdaVM was the only full-fledged effort to port Haskell to the JVM, and like most graduate school projects, the project is now dead. I have strong interest in hosting GHC on the JVM. And I suspect it would be good for the Haskell community, as the JVM already runs on nearly every machine known to man, has a wealth of cross-platform libraries, and is getting improved support for dynamic and functional languages (method handles, tail call). Regards, John A. De Goes N-BRAIN, Inc. http://www.n-brain.net [n minds are better than n-1] On Oct 11, 2008, at 10:07 AM, David Leimbach wrote: > Are there, or have there been Haskell ports to the JVM? Are any of > them alive and well? > > Is there an interest in hosting GHC on the JVM (besides my own). > > I know I don't have time to tackle such a project but I'd be > extremely interested in using such a thing. Especially in my day to > day work. I currently do a lot of Java <-> Erlang via JInterface, > and have been for months, yet there's many tasks I could do better > in a language like Haskell. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From allbery at ece.cmu.edu Sat Oct 11 13:08:22 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Oct 11 13:04:42 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> Message-ID: <16CDD8BC-8B27-4BFA-B748-0A10D4B54968@ece.cmu.edu> On 2008 Oct 11, at 12:07, David Leimbach wrote: > Are there, or have there been Haskell ports to the JVM? Are any of > them alive and well? YHC, last I heard, was alive and well and there's a YHC Core backend for the JVM. > Is there an interest in hosting GHC on the JVM (besides my own). There's interest but my understanding is that the GHC backend architecture is not at all friendly to work with. That said, I hear in the next release (I think 6.12, not the 6.10 that's in beta) will have a redesigned backend architecture that is supposed to be much easier to work with, which will make it easier to provide native code generators for many currently poorly-served platforms --- including the JVM if anyone is so inclined. You might want to ask on glasgow-haskell-users to get the people who really know. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/591ae44f/attachment.htm From john at n-brain.net Sat Oct 11 13:30:39 2008 From: john at n-brain.net (John A. De Goes) Date: Sat Oct 11 13:26:51 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: <16CDD8BC-8B27-4BFA-B748-0A10D4B54968@ece.cmu.edu> References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> <16CDD8BC-8B27-4BFA-B748-0A10D4B54968@ece.cmu.edu> Message-ID: <7F9BEADB-D807-48F7-9DA3-4EF3824912CE@n-brain.net> There's a YHC that can compile to JavaScript, and JavaScript can be run on Java... Which means, practically speaking, there is no YHC backend for the JVM. Regards, John A. De Goes N-BRAIN, Inc. http://www.n-brain.net [n minds are better than n-1] On Oct 11, 2008, at 11:08 AM, Brandon S. Allbery KF8NH wrote: > On 2008 Oct 11, at 12:07, David Leimbach wrote: >> Are there, or have there been Haskell ports to the JVM? Are any of >> them alive and well? > > YHC, last I heard, was alive and well and there's a YHC Core backend > for the JVM. > >> Is there an interest in hosting GHC on the JVM (besides my own). > > There's interest but my understanding is that the GHC backend > architecture is not at all friendly to work with. That said, I hear > in the next release (I think 6.12, not the 6.10 that's in beta) will > have a redesigned backend architecture that is supposed to be much > easier to work with, which will make it easier to provide native > code generators for many currently poorly-served platforms --- > including the JVM if anyone is so inclined. > > You might want to ask on glasgow-haskell-users to get the people who > really know. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university > KF8NH > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/68739324/attachment.htm From apfelmus at quantentunnel.de Sat Oct 11 13:34:56 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Sat Oct 11 13:31:17 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <48EFCFCA.50008@btinternet.com> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> Message-ID: Andrew Coppin wrote: > Martin DeMello wrote: >> http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem >> >> is a brilliant example of a common workaday problem found in other >> languages, and solved elegantly in Haskell >> > > Oh, hey, that's pretty nice... ... and a solution to a problem that you souldn't have in the first place. I mean, if you want to construct XML or SQL statements, you ought to use an abstract data type that ensures proper nesting etc. and not a simple string. Regards, apfelmus From derek.a.elkins at gmail.com Sat Oct 11 14:09:13 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Oct 11 14:05:25 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? In-Reply-To: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> References: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Message-ID: <1223748553.15352.9.camel@derek-laptop> On Sat, 2008-10-11 at 16:55 +0100, Matthew Naylor wrote: > Hi Jason, > > I don't know Python, but let me share some thoughts that you might > find useful. > > First, a few questions about your manual translations. Are your > functions curried? For example, can I partially apply zipWith? Also, > you put a "thunk" around things like "cons(...)" --- should it not be > the arguments to "cons" that are thunked? > > Now, on to an automatic translation. As you may know already, Haskell > programs can be transformed to "combinator programs" which are quite > simple and easy to work with. Here is what I mean by a "combinator > program": > > p ::= d* (a program is a list of combinator definitions) > d ::= c v* = e (combinator definition) > e ::= e e (application) > | v (variable/argument) > | c (constant: integer literal, combinator name, etc.) > > As an example of a combinator program, here is one that reverses the > list [0,1,2]. > > rev v acc = v acc (rev2 acc) > rev2 acc x xs = rev xs (cons x acc) > cons x xs n c = c x xs > nil n c = n > > main = rev (cons 0 (cons 1 (cons 2 nil))) nil > > This program does not type-check in Haskell! But Python, being > dynamically typed, doesn't suffer from this problem. :-) > > A translation scheme, D[], from a combinator definition to a Python > definition might look as follows. > > D[c v* = e] = def c() : return (lambda v1: ... lambda vn: E[e]) > E[e0 e1] = E[e0] (E[e1]) > E[v] = v > E[c] = c() > > Here is the result of (manually) applying D to the list-reversing program. > > def nil() : return (lambda n: lambda c: n) > def cons() : return (lambda x: lambda xs: lambda n: lambda c: c(x)(xs)) > def rev2() : return (lambda acc: lambda x: lambda xs: > rev()(xs)(cons()(x)(acc))) > def rev() : return (lambda v: lambda acc: v(acc)(rev2()(acc))) > > def main() : return (rev() (cons()(0)( > cons()(1)( > cons()(2)( > nil()))))(nil())) > > The result of main() is a partially-applied function, which python > won't display. But using the helper > > def list(f) : return (f([])(lambda x: lambda xs: [x] + list(xs))) > > we can see the result of main(): > > >>> list(main()) > [2, 1, 0] > > Of course, Python is a strict language, so we have lost Haskell's > non-strictness during the translation. However, there exists a > transformation which, no matter how a combinator program is evaluated > (strictly, non-strictly, or lazily), the result will be just as if it > had been evaluated non-strictly. Let's call it N, for "Non-strict" or > "call-by-Name". > > N[e0 e1] = N[e0] (\x. N[e1]) > N[v] = v (\x. x) > N[f] = f > > I've cheekily introduced lambdas on the RHS here --- they are not > valid combinator expressions! But since Python supports lambdas, this > is not a big worry. > > NOTE 1: We can't remove the lambdas above by introducing combinators > because the arguments to the combinator would be evaluated and that > would defeat the purpose of the transformation! > > NOTE 2: "i" could be replaced with anything above --- it is never > actually inspected. > > For the sake of interest, there is also a "dual" transformation which > gives a program that enforces strict evaluation, no matter how it is > evaluated. Let's call it S for "Strict". > > S[e0 e1] = \k. S[e0] (\f. S[e1] (\x. k (f x))) > S[v] = \k. k v > S[f] = \k. k f > > I believe this is commonly referred to as the CPS > (continuation-passing style) transformation. This is indeed a CPS transform. Specifically, a call-by-value CPS transform. There is also a call-by-name one. N[e0 e1] = \k. N[e0] (\f. f N[e1] k) N[v] = v N[c] = \k. k c From leather at cs.uu.nl Sat Oct 11 14:21:57 2008 From: leather at cs.uu.nl (Sean Leather) Date: Sat Oct 11 14:18:06 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> Message-ID: <3c6288ab0810111121t63af303clbf36d61c6685dfaa@mail.gmail.com> > > Are there, or have there been Haskell ports to the JVM? Are any of them > alive and well? > See the thread started 9 September on "Haskell and Java": http://thread.gmane.org/gmane.comp.lang.haskell.cafe/44252 Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/d6b8be92/attachment.htm From iainspeed at gmail.com Sat Oct 11 15:30:25 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Sat Oct 11 15:26:40 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> Message-ID: <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> On 11 Oct 2008, at 6:34 pm, apfelmus wrote: > Andrew Coppin wrote: >> Martin DeMello wrote: >>> http://blog.moertel.com/articles/2006/10/18/a-type-based-solution- >>> to-the-strings-problem >>> >>> is a brilliant example of a common workaday problem found in other >>> languages, and solved elegantly in Haskell >>> >> >> Oh, hey, that's pretty nice... > > ... and a solution to a problem that you souldn't have in the first > place. I mean, if you want to construct XML or SQL statements, you > ought > to use an abstract data type that ensures proper nesting etc. and > not a > simple string. Do you have an example of what you mean? Personally, I use stored procedures with a database as they protect from sql injection attacks (unless you write some really stupid procedures). Iain From bit at mutantlemon.com Sat Oct 11 15:54:22 2008 From: bit at mutantlemon.com (Bit Connor) Date: Sat Oct 11 15:50:32 2008 Subject: [Haskell-cafe] Constraints at construction In-Reply-To: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> References: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> Message-ID: <6205bd290810111254i3c479097k8744f8880901033f@mail.gmail.com> On Thu, Oct 9, 2008 at 3:05 PM, Mitchell, Neil wrote: > Hi Iain, > > The wiki page has quite a nice article: > http://www.haskell.org/haskellwiki/Smart_constructors Smart constructors are nice but if your module doesn't also export the regular constructor then you can't pattern match against it. It would be cool if there was a way to export constructors from a module, but only for use in pattern matching and not constructing new values. Peace, Bit From jake at pikewerks.com Sat Oct 11 16:00:19 2008 From: jake at pikewerks.com (Jake McArthur) Date: Sat Oct 11 15:56:29 2008 Subject: [Haskell-cafe] Constraints at construction In-Reply-To: <6205bd290810111254i3c479097k8744f8880901033f@mail.gmail.com> References: <33A3F585590A6F4E81E3D45AA4A111C902CD3AF1@ELON17P32001A.csfb.cs-group.com> <6205bd290810111254i3c479097k8744f8880901033f@mail.gmail.com> Message-ID: <7E4AA005-B4CC-41D1-890B-C57DBF71E60A@pikewerks.com> On Oct 11, 2008, at 2:54 PM, Bit Connor wrote: > Smart constructors are nice but if your module doesn't also export the > regular constructor then you can't pattern match against it. > > It would be cool if there was a way to export constructors from a > module, but only for use in pattern matching and not constructing new > values. I suppose you could make a new data type to pattern match against. For example, say you have data Foo A B = foo :: A -> B -> Foo A B -- smart constructor You could introduce and export data FooView = Foo A B | fooView :: Foo A B -> FooView A B You could even redefine the smart constructor as foo : FooView A B -> Foo A B ... if you wanted. - Jake From svein.ove at aas.no Sat Oct 11 16:02:47 2008 From: svein.ove at aas.no (Svein Ove Aas) Date: Sat Oct 11 15:58:58 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> Message-ID: <221b53ab0810111302t563cdb89pd3a9bb1fbad52a35@mail.gmail.com> On Sat, Oct 11, 2008 at 9:30 PM, Iain Barnett wrote: > > Personally, I use stored procedures with a database as they protect from sql > injection attacks (unless you write some really stupid procedures). > Isn't this what parametrized queries are for? From iainspeed at gmail.com Sat Oct 11 16:15:56 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Sat Oct 11 16:12:12 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <221b53ab0810111302t563cdb89pd3a9bb1fbad52a35@mail.gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> <221b53ab0810111302t563cdb89pd3a9bb1fbad52a35@mail.gmail.com> Message-ID: <05DBE812-5333-4E7D-B594-672325C66067@gmail.com> On 11 Oct 2008, at 9:02 pm, Svein Ove Aas wrote: > On Sat, Oct 11, 2008 at 9:30 PM, Iain Barnett > wrote: >> >> Personally, I use stored procedures with a database as they >> protect from sql >> injection attacks (unless you write some really stupid procedures). >> > Isn't this what parametrized queries are for? they will also work (at least in MS SQL Server), but you'd lose some of the performance and organisational benefits. And it stops people littering code with badly written SQL statements - at least I can keep track of the procedures! :) Iain From dagit at codersbase.com Sat Oct 11 17:23:43 2008 From: dagit at codersbase.com (Jason Dagit) Date: Sat Oct 11 17:19:51 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? In-Reply-To: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> References: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Message-ID: On Sat, Oct 11, 2008 at 8:55 AM, Matthew Naylor < mfn-haskell-cafe@cs.york.ac.uk> wrote: > Hi Jason, > > I don't know Python, but let me share some thoughts that you might > find useful. > > First, a few questions about your manual translations. Are your > functions curried? For example, can I partially apply zipWith? Also, > you put a "thunk" around things like "cons(...)" --- should it not be > the arguments to "cons" that are thunked? I don't recall if I mentioned this in my original email. My goal is to do automatic translations. So, no you can't partially apply zipWith, but then that's because Python doesn't support partial application. On the other hand, you can easily use a lambda to get around this. So in an automatic translation I would replace partial application with lambdas. This shouldn't be a problem right? My rule was to put a thunk around any "Haskell value". So I put cons cells in thunks and I even wrapped functions in thunks. The exception was that there were quite a few places where I could tell by inspection that a particular value would already be in a thunk. For example, since I require in my translation that putting a value in a cons requires the value to be a thunk then when I pull values out of a cons I already know they are thunks so no need to rewrap them. Now, on to an automatic translation. As you may know already, Haskell > programs can be transformed to "combinator programs" which are quite > simple and easy to work with. Here is what I mean by a "combinator > program": > > p ::= d* (a program is a list of combinator definitions) > d ::= c v* = e (combinator definition) > e ::= e e (application) > | v (variable/argument) > | c (constant: integer literal, combinator name, etc.) > > As an example of a combinator program, here is one that reverses the > list [0,1,2]. > > rev v acc = v acc (rev2 acc) > rev2 acc x xs = rev xs (cons x acc) > cons x xs n c = c x xs > nil n c = n > > main = rev (cons 0 (cons 1 (cons 2 nil))) nil > > This program does not type-check in Haskell! But Python, being > dynamically typed, doesn't suffer from this problem. :-) I plan to exploit this in my translations as well. I will assume type checked Haskell programs as input to the translator. > > > A translation scheme, D[], from a combinator definition to a Python > definition might look as follows. > > D[c v* = e] = def c() : return (lambda v1: ... lambda vn: E[e]) > E[e0 e1] = E[e0] (E[e1]) > E[v] = v > E[c] = c() > > Here is the result of (manually) applying D to the list-reversing program. > If nil() corresponds to [] in Haskell, then how did you arrive at this definition? As Derek Elkins points out your transformation is a CPS based. So I'm going to guess that c is the continuation and n represents the nil? > > def nil() : return (lambda n: lambda c: n) This one makes a little bit of sense to me. I see the components of the list, the x and xs, and you apply the continuation to them. What's going on with n? def cons() : return (lambda x: lambda xs: lambda n: lambda c: c(x)(xs)) Now, now this is a getting a bit hard to read :) > > def rev2() : return (lambda acc: lambda x: lambda xs: > rev()(xs)(cons()(x)(acc))) > def rev() : return (lambda v: lambda acc: v(acc)(rev2()(acc))) > I'm glad I don't have to maintain code that looks like this :) def main() : return (rev() (cons()(0)( > cons()(1)( > cons()(2)( > nil()))))(nil())) > > The result of main() is a partially-applied function, which python > won't display. But using the helper > > def list(f) : return (f([])(lambda x: lambda xs: [x] + list(xs))) > > we can see the result of main(): > > >>> list(main()) > [2, 1, 0] Cool! So, supposing I went with a translation scheme like what you gave. I think I would end up with deeply nested function calls, this is probably very bad for the python run-time. Also, how do I allow Python to then access the Haskell values? I guess your definition of list above is an example of that, but I'm not sure how I'd pull that off in general. > > Of course, Python is a strict language, so we have lost Haskell's > non-strictness during the translation. However, there exists a > transformation which, no matter how a combinator program is evaluated > (strictly, non-strictly, or lazily), the result will be just as if it > had been evaluated non-strictly. Let's call it N, for "Non-strict" or > "call-by-Name". Interesting. > > > N[e0 e1] = N[e0] (\x. N[e1]) > N[v] = v (\x. x) > N[f] = f > > I've cheekily introduced lambdas on the RHS here --- they are not > valid combinator expressions! But since Python supports lambdas, this > is not a big worry. Right, not so bad. My translation was doing the same thing actually. A common thing to see in my code is, x = thunk(lambda: y). > > NOTE 1: We can't remove the lambdas above by introducing combinators > because the arguments to the combinator would be evaluated and that > would defeat the purpose of the transformation! Okay, I get that. > > NOTE 2: "i" could be replaced with anything above --- it is never > actually inspected. What "i" are you referring to? > Now, non-strict evaluation is all very well, but what we really want > is lazy evaluation. Let's take the N transformation, rename it to L > for "Lazy", and indulge in a side-effecting reference, ML style. Could you explain this a bit more. I don't know ML, so the code is a bit hard for me to read, but also I was wondering why you introduced a side-effecting reference? Is that basically the same as my thunk type? > > > L[e0 e1] = L[e0] (let r = ref None in > \x. match !r with > None -> let b = L[e1] in r := Some b ; b > | Some b -> b) > L[v] = v (\x. x) > L[f] = f > > I don't know enough to define L w.r.t Python. > > I haven't tried too hard to fully understand your translation, and > likewise, you may not try to fully understand mine! But I thought I'd > share my view, and hope that it might be useful (and correct!) in some > way. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081011/3f7f8686/attachment-0001.htm From andrewcoppin at btinternet.com Sat Oct 11 17:56:32 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 11 17:52:35 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <221b53ab0810111302t563cdb89pd3a9bb1fbad52a35@mail.gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> <221b53ab0810111302t563cdb89pd3a9bb1fbad52a35@mail.gmail.com> Message-ID: <48F12110.30101@btinternet.com> Svein Ove Aas wrote: > On Sat, Oct 11, 2008 at 9:30 PM, Iain Barnett wrote: > >> Personally, I use stored procedures with a database as they protect from sql >> injection attacks (unless you write some really stupid procedures). >> >> > Isn't this what parametrized queries are for? > Yes. (And it also improves DB performance since it doesn't have to continually reparse the query and rebuild the query plan.) Now consider dynamically constructing HTML and avoiding HTML injection attacks. There isn't an easy machine fix for that one. From andrewcoppin at btinternet.com Sat Oct 11 17:57:23 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Oct 11 17:53:27 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> Message-ID: <48F12143.8050608@btinternet.com> apfelmus wrote: > ... and a solution to a problem that you souldn't have in the first > place. I mean, if you want to construct XML or SQL statements, you ought > to use an abstract data type that ensures proper nesting etc. and not a > simple string. > Right. And if you have 25 KB of HTML data, you're *really* going to transform all of that into an abstract data type just to avoid injection problems, right? From dave at zednenem.com Sat Oct 11 18:09:33 2008 From: dave at zednenem.com (David Menendez) Date: Sat Oct 11 18:05:41 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? In-Reply-To: References: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Message-ID: <49a77b7a0810111509x1f99a62dqf6e2d4d9d1185331@mail.gmail.com> 2008/10/11 Jason Dagit : > > On Sat, Oct 11, 2008 at 8:55 AM, Matthew Naylor > wrote: >> Here is the result of (manually) applying D to the list-reversing program. > > If nil() corresponds to [] in Haskell, then how did you arrive at this > definition? As Derek Elkins points out your transformation is a CPS based. > So I'm going to guess that c is the continuation and n represents the nil? >> >> def nil() : return (lambda n: lambda c: n) I think this is known as the Church encoding. The parameters n and c describe what to do with lists that are constructed with [] and (:), respectively. You can do this in Haskell, as well: newtype List a = List { unList :: forall b. b -> (a -> List a -> b) -> b } nil :: List a nil = List (\n c -> n) cons :: a -> List a -> List a cons x xs = List (\n c -> c x xs) foldListR :: (a -> b -> b) -> b -> List a -> b foldListR f z l = unList l z (\x xs -> f x (foldListR f z xs)) compare foldListR with foldr: foldr f z [] = z foldr f z (x:xs) = f x (foldr f z xs) Essentially, it represents the data in terms of how you pattern match on it. You can in principle pull this off for any Haskell type, but the resulting code isn't anything you'd want to work on manually. -- Dave Menendez From jgbailey at gmail.com Sat Oct 11 18:31:22 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Sat Oct 11 18:27:31 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: <910ddf450810110433j54385aa9xbf3fb9aa0a2ebe13@mail.gmail.com> References: <910ddf450810110433j54385aa9xbf3fb9aa0a2ebe13@mail.gmail.com> Message-ID: Thanks to everyone for their feedback. I've made some updates and posted the PDF to my blog: http://blog.codeslower.com/2008/10/The-Haskell-Cheatsheet On Sat, Oct 11, 2008 at 4:33 AM, Thomas Hartman wrote: > Very nice! > > I have my own cheat list, which are haskell commands I find useful but > find inconvenient or difficult to look up in the supplied > documentation. I actually hardwire my cheats into .bashrc doing > something like > > thartman_haskell_cheatting() { > > cat << EOF > blah blah > cheat > > } > > so i can quickly see all my haskell cheats using tab completion. but a > pdf is even nicer :) > > ************************** > > thartman@thartman-laptop:~/Desktop>thartman_haskell_oneliners > ghc -e '1+2' > > thartman@thartman-laptop:~/Desktop>thartman_haskell_regex_hints > cabal install pcre-regex > > Most likely want: > > Prelude Text.Regex.PCRE> "user123" =~ "^(user)(\d*)$" :: > (String,String,String,[String]) > ("","user123","",["user","123"]) > That is: (before match, match, after match, subgroups) > > or maybe > Prelude Text.Regex.PCRE> "user123 user456" =~ "(u(se)r)(\d*)" :: [[String]] > [["user123","user","se","123"],["user456","user","se","456"]] > if you need all submatches of all matches > > since > Prelude Text.Regex.PCRE> "user123 user456" =~ "(user)(\d*)" :: > (String,String,String,[String]) > ("","user123"," user456",["user","123"]) > doesn't quite do what I want -- no submatches > and there's no instance for :: (String,String,String,[String]) > I don't need all submatches of all matches very often though. > > :: Bool -- did it match > :: String -- first match > :: [String] -- every match > :: :: (String,String,String) -- before, matched, after > > http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/ > > thartman@thartman-laptop:~/Desktop>thartman_haskell_testing_things > import Data.Test.HUnit > runTestTT $ TestCase $ assertEqual "meh" 1 2 > runTestTT $ TestList [ TestCase $ assertEqual "meh" 1 2 ] > > thartman@thartman-laptop:~/Desktop>thartman_haskell_hints > offline documentation: > ghc-pkg describe bytestring | grep -i doc > or probably just > haddock-interfaces: > /usr/local/share/doc/ghc/libraries/bytestring/bytestring.haddock > haddock-html: /usr/local/share/doc/ghc/libraries/bytestring > note to self: > start using cabal install --global (or whatever the flag is) > so all documentation is browsable from one place > > Use language pragmas, with commas > And you can't put LANGUAGE and OPTIONS_GHC in the same pragma > {-# LANGUAGE NoMonomorphismRestriction, PatternSignatures #-} > {-# OPTIONS -fglasgow-exts #-} > > Debugging > > toVal.hs:30:17: > Couldn't match expected type 'blee' > against inferred type 'bleh' > bleh is whatever is at 30:17 > blee is something that's wanted by whatever is calling the value at 30:17 > > If the error is "in the definition of" some function, > then probably one function case conflicts with another, you can > ignore other functions. > In this case you will only get one line:col to look at. > If there are more than one line:col to look at, possibly separate > functions are in conflict. > So, smart to always fix "in the definition of" type errors first. > > Still baffled? Won't compile? > Give top-level functions type signatures. Won't hurt, might help. > :set -fwarn-missing-signatures > or {-# OPTIONS -fwarn-missing-signatures #-} > Start commenting out calling functions until it compiles, and then > look at the signatures. > And then type the signatures in explicitly... does something look funny? > Like, wrong number of args? Maybe currying went wrong. > > tag and bundle a distribution: > darcs tag 0.2 > cabal configure > cabal sdist > cd dist; unzip, verify install does the right thing > http://hackage.haskell.org/packages/upload.html > check upload, and upload. > see also http://en.wikibooks.org/wiki/Haskell/Packaging > > group module imports from multiple modules in one place: > module MyInductiveGraph ( > module Data.Graph.Inductive, > module EnoughFlow > ) > where > import Data.Graph.Inductive > import EnoughFlow > > > > ************************** > 2008/10/11 Justin Bailey : >> All, >> >> I've created a "cheat sheet" for Haskell. It's a PDF that tries to >> summarize Haskell 98's syntax, keywords and other language elements. >> It's currently available on hackage[1]. Once downloaded, unpack the >> archive and you'll see the PDF. A literate source file is also >> included. >> >> If you install with "cabal install cheatsheet", run "cheatsheet" >> afterwards and the program will tell you where the PDF is located. >> >> The audience for this document is beginning to intermediate Haskell >> programmers. I found it difficult to look up some of the less-used >> syntax and other language stumbling blocks as I learned Haskell over >> the last few years, so I hope this document can help others in the >> future. >> >> This is a beta release (which is why I've limited the audience by >> using hackage) to get feedback before distributing the PDF to a wider >> audience. With that in mind, I welcome your comments or patches[2]. >> >> Justin >> >> [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/CheatSheet >> [2] git://github.com/m4dc4p/cheatsheet.git >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From jgbailey at gmail.com Sat Oct 11 18:32:54 2008 From: jgbailey at gmail.com (Justin Bailey) Date: Sat Oct 11 18:29:04 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: <200810111430.51035.holgersiegel74@yahoo.de> References: <200810111430.51035.holgersiegel74@yahoo.de> Message-ID: On Sat, Oct 11, 2008 at 5:30 AM, Holger Siegel wrote: > > - The explanation of the layout rule is wrong. If you define more than one > value in a let declaration, then it is only required that the identifiers > start on the same column. Thank you - updated. > > - When I started to learn Haskell, I had problems with the use of (.) and ($). > I had learned what function application and lambda abstractions look like, but > then I looked at Haskell code written by experienced Haskellers and found > expressions like (map (succ . succ) $ 1:xs) that I did not understand. > A small section describing how to read such expressions could be useful for > beginners. Me too. I had a section on that originally but cut it due to time. Patches are always welcome :) > > - the section about do-notation is more a mini-tutorial than a cheatsheet. > Instead, you could show two or three examples that demonstrate how do- > notation, list comprehensions and the operator >>= relate. That is what I had > to look up more than once until I got used to it. There is also an example of > what is wrong, where showing the right thing would have sufficed. > True, but I think it's helpful. That stuff really confused me at first. Justin From trebla at vex.net Sat Oct 11 19:15:27 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Sat Oct 11 19:11:37 2008 Subject: [Haskell-cafe] OT: Haskell desktop wallpaper? In-Reply-To: References: Message-ID: <48F1338F.6090503@vex.net> Magnus Therning wrote: > Where can I find some nice wallpapers inspired by > Haskell, or maybe even created by Haskell code? I once suggested a futuristic feature for xmonad or xmonad plugin: screensaver that randomly picks a haskell lecture video to play or a haskell tutorial page to display. The idea is that your colleagues do not know haskell yet, but they pass by your screen and learn haskell. Perhaps it can be extended to wallpaper as well. From dons at galois.com Sat Oct 11 21:45:17 2008 From: dons at galois.com (Don Stewart) Date: Sat Oct 11 21:41:15 2008 Subject: [Haskell-cafe] Congrats. to wxHaskell Message-ID: <20081012014517.GM11641@scytale.galois.com> I just want to congratulate the wxHaskell team on their new release. With GHC 6.10 RC, cabal 1.6, and cabal-install 0.6, I was able to simply, cabal install wxcore wx And it all worked. Well done! -- Don From simon.clarkstone at gmail.com Sat Oct 11 22:10:16 2008 From: simon.clarkstone at gmail.com (Simon Richard Clarkstone) Date: Sat Oct 11 22:06:18 2008 Subject: [Haskell-cafe] [] vs [()] In-Reply-To: <1223615851.21474.43.camel@wish.bear> References: <1223615851.21474.43.camel@wish.bear> Message-ID: <48F15C88.3000400@gmail.com> Sam Danielson wrote: > The [] constructor takes no arguments and is like Nothing in the Maybe > type. The list ":" (cons) infix constructor takes two arguments, an > element of type a and a list of type a, to construct a new list. Compare > to Maybe. > > data [] a = [] | a : [a] > data Maybe a = Nothing | Just a > > Another way of saying [()] is > > ():[] > > which, comparing with the Maybe type, is similar to saying > > Just () > > but Just only takes one argument where (:) takes two. > > Both List and Maybe are containers that have a null constructor, namely > [] and Nothing. "():[]" contains () similar to how "Just ()" contains > (). You can make your own list type and put () in it as follows. Or, in Monad terms: "[()]" and "Just ()" are both "return ()" in their respective Monads. "[]" and "Nothing" are both "mzero" in their respective MonadsPluses. (Both are also "fail" in their respective Monads, but I find "fail"'s presence in Monad a bit inelegant, though handy.) -- src/ From ashley at semantic.org Sat Oct 11 22:12:14 2008 From: ashley at semantic.org (Ashley Yakeley) Date: Sat Oct 11 22:08:25 2008 Subject: [Haskell-cafe] Ubuntu Haskell In-Reply-To: <20081004191547.GA1429@scytale.galois.com> References: <20081004191547.GA1429@scytale.galois.com> Message-ID: <48F15CFE.9000106@semantic.org> Don Stewart wrote: > * Arch now has 609 Haskell packages in AUR. Have you thought about doing this for Ubuntu? If you know how to automatically generate packages, you could set up a PPA (private package archive) on Launchpad. -- Ashley Yakeley From dons at galois.com Sat Oct 11 22:16:22 2008 From: dons at galois.com (Don Stewart) Date: Sat Oct 11 22:12:19 2008 Subject: [Haskell-cafe] Re: Ubuntu Haskell In-Reply-To: <48F15CFE.9000106@semantic.org> References: <20081004191547.GA1429@scytale.galois.com> <48F15CFE.9000106@semantic.org> Message-ID: <20081012021622.GO11641@scytale.galois.com> ashley: > Don Stewart wrote: > > * Arch now has 609 Haskell packages in AUR. > > Have you thought about doing this for Ubuntu? If you know how to > automatically generate packages, you could set up a PPA (private package > archive) on Launchpad. I've spoken with Jeremy Shaw, who has similar systems in place, based also on Cabal (and cabal-install), for generating native packages for Debian & Ubuntu. However, we do need some Ubuntu champions who can work incrementally, over a long time, to keep packages up to date on their systems. Automation makes this a *lot* easier, so you may only need one or two people, motivated to work on their distro. -- Don From simon.clarkstone at gmail.com Sat Oct 11 22:32:19 2008 From: simon.clarkstone at gmail.com (Simon Richard Clarkstone) Date: Sat Oct 11 22:28:14 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: References: <48E93E0B.1060801@gmail.com> Message-ID: <48F161B3.40400@gmail.com> John Van Enk wrote: > On Sun, Oct 5, 2008 at 11:21 PM, John Van Enk > wrote: > >> On Sun, Oct 5, 2008 at 6:22 PM, Simon Richard Clarkstone >> > wrote: >>> BTW, these could go on the wiki. >> I'll see about putting them there. :) > > http://haskell.org/haskellwiki/Shooting_your_self_in_the_foot > > This needs to be cleaned up a little (lots of dups, though they are all > great). You missed my one, though I think the "ballistics algebra" one is better. ISTR that the point of the original list was originally to show that, though you can screw up with C, with every other language you can screw up in far more complicated and inscrutable ways. Ballistics algebra is indeed a way to screw up that is not possible in C. (Darnit Thunderbird, why don't you DWIM when I hit reply or reply-all?) -- src/ From mail at justinbogner.com Sat Oct 11 18:19:56 2008 From: mail at justinbogner.com (mail@justinbogner.com) Date: Sat Oct 11 23:51:13 2008 Subject: [Haskell-cafe] Re: How to translate Haskell to other languages? References: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Message-ID: <87ljwu79rw.fsf@justinbogner.com> "Jason Dagit" writes: > I don't recall if I mentioned this in my original email. My goal is to do automatic > translations. So, no you can't partially apply zipWith, but then that's because Python doesn't > support partial application. On the other hand, you can easily use a lambda to get around this. > So in an automatic translation I would replace partial application with lambdas. This shouldn't > be a problem right? Partial application can be done in python, though somewhat awkwardly. Take a look at functools.partial. -- Green's Law of Debate: Anything is possible if you don't know what you're talking about. From vigalchin at gmail.com Sun Oct 12 02:21:42 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Oct 12 02:17:51 2008 Subject: [Haskell-cafe] Real World Haskell Chapter 11 ... Testing Message-ID: <5ae4f2ba0810112321n46dd8f09tf46843c4ab66de5d@mail.gmail.com> Hi, Testing of "pure" code ... . way cool ... I am sure there literature from the first order logic, model theory, categorical logic viewpoint?? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081012/697863d8/attachment.htm From valgarv at gmx.net Sun Oct 12 03:13:23 2008 From: valgarv at gmx.net (Ariel J. Birnbaum) Date: Sun Oct 12 03:09:34 2008 Subject: [Haskell-cafe] Re: Ubuntu Haskell In-Reply-To: <20081012021622.GO11641@scytale.galois.com> References: <20081004191547.GA1429@scytale.galois.com> <48F15CFE.9000106@semantic.org> <20081012021622.GO11641@scytale.galois.com> Message-ID: <200810120913.23906.valgarv@gmx.net> > > Have you thought about doing this for Ubuntu? If you know how to > > automatically generate packages, you could set up a PPA (private package > > archive) on Launchpad. > > I've spoken with Jeremy Shaw, who has similar systems in place, based > also on Cabal (and cabal-install), for generating native packages for > Debian & Ubuntu. > > However, we do need some Ubuntu champions who can work incrementally, > over a long time, to keep packages up to date on their systems. Pray tell, what kind of feats are expected of such a champion? -- Ariel J. Birnbaum From andrew.appleyard at gmail.com Sun Oct 12 04:33:01 2008 From: andrew.appleyard at gmail.com (Andrew Appleyard) Date: Sun Oct 12 04:29:20 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: <6a7c66fc0810100633y5f0c94drcc41a33b72f2a38a@mail.gmail.com> References: <48EF46B1.9070500@gmail.com> <6a7c66fc0810100633y5f0c94drcc41a33b72f2a38a@mail.gmail.com> Message-ID: <48F1B63D.8000200@gmail.com> Alfonso Acosta wrote: > Great! Are there any chances of getting support for non-Win32 > platforms with Mono? Yep, I believe it's possible. The interoperability layer is centered around two .NET methods: - Marshal.GetDelegateForFunctionPointer and - Marshal.GetFunctionPointerForDelegate As long as Mono correctly implements these methods (I haven't tested them, but Mono appears to implement them), it shouldn't be too difficult to get Salsa going. Most of the work involves extending the runtime hosting code to use the Mono API to load the Mono runtime and then load the driver assembly. Everything after that point is relatively platform independent. It'd be worth implementing this just to see how long it takes Don to get an Arch Linux port out for it... :-) Regards, Andrew From andrew.appleyard at gmail.com Sun Oct 12 04:51:38 2008 From: andrew.appleyard at gmail.com (Andrew Appleyard) Date: Sun Oct 12 04:47:52 2008 Subject: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell In-Reply-To: References: <48EF46B1.9070500@gmail.com> Message-ID: <48F1BA9A.9020404@gmail.com> Jason Dagit wrote: > Thank you for releasing this! No worries. I might never have got around to releasing it if it wasn't for the encouragement of Manuel Chakravarty, Don Stewart, and others. Thanks guys! > [...] as I understand it the Haskell you write still lives in > Haskell-land and the .NET code you interface with lives in .NET land. Yep, that's correct. Compiling Haskell to .NET IL is a significantly more adventurous project! I wouldn't have managed to acheive a practical result in the time I had for my thesis if I had taken that route. Salsa's approach to type system mapping could be useful in such a project though. Regards, Andrew From andrewcoppin at btinternet.com Sun Oct 12 04:57:57 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 12 04:53:57 2008 Subject: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0 In-Reply-To: References: <910ddf450810110433j54385aa9xbf3fb9aa0a2ebe13@mail.gmail.com> Message-ID: <48F1BC15.6000302@btinternet.com> Justin Bailey wrote: > Thanks to everyone for their feedback. I've made some updates and > posted the PDF to my blog: > > http://blog.codeslower.com/2008/10/The-Haskell-Cheatsheet > I was wondering why there isn't a PDF directly downloadable anywhere... ;-) FWIW, I just learned something by looking at this. I was under the impression that a literal number can have *any* type, and therefore "1" and "1.0" are completely equivilent. Apparently this is untrue. (!) Your "numbers" section is actually mostly list comprehensions. While it's interesting that you need a space between ".." and "-" for negative numbers, this wasn't immediately clear from reading your text. Maybe it would be better to write that as a sentence? (Or just format the correct syntax in monotype so the space is more obvious.) From lrpalmer at gmail.com Sun Oct 12 05:06:35 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Oct 12 05:02:43 2008 Subject: [Haskell-cafe] Shooting your self in the foot with Haskell In-Reply-To: <48F161B3.40400@gmail.com> References: <48E93E0B.1060801@gmail.com> <48F161B3.40400@gmail.com> Message-ID: <7ca3f0160810120206i6519e9c7w3d289bc4e2930c03@mail.gmail.com> On Sat, Oct 11, 2008 at 8:32 PM, Simon Richard Clarkstone wrote: > (Darnit Thunderbird, why don't you DWIM when I hit reply or reply-all?) You're not writing about Perl, you're writing about Haskell! It should have been a type error. Luke From jonathandeanharrop at googlemail.com Sun Oct 12 06:19:55 2008 From: jonathandeanharrop at googlemail.com (Jon Harrop) Date: Sun Oct 12 05:14:49 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> Message-ID: <200810121119.55602.jon@ffconsultancy.com> On Saturday 11 October 2008 17:45:39 John A. De Goes wrote: > I have strong interest in hosting GHC on the JVM. And I suspect it > would be good for the Haskell community, as the JVM already runs on > nearly every machine known to man, has a wealth of cross-platform > libraries, and is getting improved support for dynamic and functional > languages (method handles, tail call). The JVM has been about to get basic features like tail calls for several years now. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From andrewcoppin at btinternet.com Sun Oct 12 06:21:45 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 12 06:17:47 2008 Subject: [Haskell-cafe] Pandoc questions Message-ID: <48F1CFB9.2020901@btinternet.com> There doesn't seem to be any option to make Pandoc produce actual MathML output. Is there a reason for this? (The only option I can see is to spit out raw LaTeX plus a 70KB JavaScript program to transform this into MathML at the client end --- which seems a little silly to me. There's also no way to style the raw LaTeX differently in case JavaScript is unavailable.) Also, while Markdown *almost* does what I want, there are a few small constructs it doesn't have. For example, I'd like to have some way to denote a "term" the first time I use it. I could just use italics, but I'd prefer some way to visually indicate that this isn't just an emphasised word, it's a new technical term. In HTML, I'd use a style class, and in LaTeX I'd define a new command. But I can't see a way to do something that will still allow Pandoc to generate correct LaTeX *and* correct HTML from a single Markdown source... Any hints? From mfn-haskell-cafe at cs.york.ac.uk Sun Oct 12 08:07:24 2008 From: mfn-haskell-cafe at cs.york.ac.uk (Matthew) Date: Sun Oct 12 08:04:44 2008 Subject: [Haskell-cafe] How to translate Haskell to other languages? In-Reply-To: References: <20081011155504.GA3991@pc149.staff.cs.york.ac.uk> Message-ID: <20081012120724.GA4025@pc149.staff.cs.york.ac.uk> Hi Jason, > So in an automatic translation I would replace partial application > with lambdas. This shouldn't be a problem right? suppose f is a 3-argument function, and you encounter the application f x. One possible translation would be to replace f x with (\y. \z. f (x,y,z)) I don't know if this is what you mean. Anyway, the problem is that f might not be a function name; it could be the argument of a higher-order function, in which case we don't know how many lambda-bound variables to introduce. It's easiest just to define f as f() = \x. \y. \z. e rather than f (x,y,z) = e, I think. > > A translation scheme, D[], from a combinator definition to a Python > > definition might look as follows. > > > > D[c v* = e] = def c() : return (lambda v1: ... lambda vn: E[e]) > > E[e0 e1] = E[e0] (E[e1]) > > E[v] = v > > E[c] = c() > > > > Here is the result of (manually) applying D to the list-reversing program. > > > > If nil() corresponds to [] in Haskell, then how did you arrive at this > definition? As Derek Elkins points out your transformation is a CPS based. > So I'm going to guess that c is the continuation and n represents the nil? Regarding terminology: be careful not to confuse the CPS transformation with the transformation that encodes data as functions. I've made this mistake in the past. To my knowledge, the "CPS transformation" refers to the transformation that enforces strict evaluation in a program. Encoding data as functions removes data constructors and case expressions from a program (albeit using continuations). I think the latter is known by at least two names: Scott's encoding, and Berarducci and Bohm's encoding. It is not the same as the Church encoding. I first read about it in a paper by Jan Martin Jansen. Jan Martin Jansen, Pieter Koopman and Rinus Plasmeijer. Efficient Interpretation by Transforming Data Types and Patterns to Functions. Trends in Functional Programming, Volume 7, Intellect, 2007. (Googling the title should reveal a PDF.) But since then, I've noticed the transformation used (anonamously) in several old texts about compiling functional languages. > Also, how do I allow Python to then access the Haskell values? I > guess your definition of list above is an example of that, but I'm > not sure how I'd pull that off in general. Converting data to function-encoded data: this can be done with a fold, e.g. "foldr cons nil" should do the trick for lists. Converting function-encoded data back to data: it should be possible to generate a function like my "list(xs)" (which returns a Python represention of a function-encoded Haskell list xs) for any given data type. Alternatively, you could just add constructors and case expressions to the syntax I gave for "combinator programs", and deal with them explicitly in the translation. > > N[e0 e1] = N[e0] (\x. N[e1]) > > N[v] = v (\x. x) > > N[f] = f > > What "i" are you referring to? Woops, "i" refers to the combinator representing the function \x. x. (I wrote NOTE 2 before realising NOTE 1!) Basically, the (\x. x) above can be replaced with any expression that terminates, but preferrably one that will be cheap to evaluate. > > Now, non-strict evaluation is all very well, but what we really want > > is lazy evaluation. Let's take the N transformation, rename it to L > > for "Lazy", and indulge in a side-effecting reference, ML style. > > > > > > > L[e0 e1] = L[e0] (let r = ref None in > > \x. match !r with > > None -> let b = L[e1] in r := Some b ; b > > | Some b -> b) > > L[v] = v (\x. x) > > L[f] = f > Could you explain this a bit more. I don't know ML, so the code is a bit > hard for me to read, but also I was wondering why you introduced a > side-effecting reference? Generally: a reference is created for every argument in a function-call. The first time that argument is evaluated, the reference is updated to store the result of the evaluation, so that it is never performed again. More specifically: * "ref" creates a mutable reference. In ML, bindings of a let are evaluated before the body of the let. * !r gets the value at a reference r, and "r := e" updates the value at reference r. * None and Some are the ML equivalents to Nothing and Just. * e0 ; e1 evaluates e0 before e1 and then returns the value of e1. > Is that basically the same as my thunk type? I imagine it is very similar to your thunk type, but I don't know enough Python to say for sure. > So, supposing I went with a translation scheme like what you gave. > I think I would end up with deeply nested function calls, this is > probably very bad for the python run-time. There are some optimisations to the translation. For example, if a function is applied to an argument, and that argument is not referenced more than once in the body of f, then there is no need to create a reference for said argument. Matthew. From jmaessen at alum.mit.edu Sun Oct 12 09:19:48 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Sun Oct 12 09:15:57 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: <200810121119.55602.jon@ffconsultancy.com> References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> <200810121119.55602.jon@ffconsultancy.com> Message-ID: On Oct 12, 2008, at 6:19 AM, Jon Harrop wrote: > On Saturday 11 October 2008 17:45:39 John A. De Goes wrote: >> I have strong interest in hosting GHC on the JVM. And I suspect it >> would be good for the Haskell community, as the JVM already runs on >> nearly every machine known to man, has a wealth of cross-platform >> libraries, and is getting improved support for dynamic and functional >> languages (method handles, tail call). > > The JVM has been about to get basic features like tail calls for > several years > now. As a gentle correction of fact, while folks have been *asking* for tail calls in the JVM for over 10 years, it's only in the last year or two that there's actually been support from VM implementors for their inclusion. I've had specific discussions with JVM folks on this very topic on numerous occasions over the last 5 years. [I can't speak to what other "basic features" might have been slated for inclusion "several years ago"; I'll note that invokedynamic has been slated for inclusion for much longer, but required some wrangling between competing VM implementors and language designers to actually settle on an implementable spec. The result looks nothing at all like my memory of the original proposal.] Back to your regularly scheduled Haskell discussion. -Jan > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ivan.miljenovic at gmail.com Sun Oct 12 09:54:44 2008 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sun Oct 12 09:51:02 2008 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.4 and SourceGraph-0.2 Message-ID: <20081012235444.18600479@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'd like to announce version 0.4 of my Graphalyze library [1] and 0.2 of my SourceGraph programme [2]. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SourceGraph This should fix the bugs reported by Gwern Branwen, Magnus Therning (thanks to Niklas Broberg for stating the correct version for Haskell-Src-Exts) and Christopher Hinson. No really new features are included in this release. I was planning on fixing this and releasing it sooner but - to utilise what seems to be a current meme [3] - "I accidentally my Gentoo" on Tuesday night and only fixed it yesterday. [3] http://encyclopediadramatica.com/I_accidentally_X Since I'm more awake now than I was when I made the initial release, here's a run-down of what SourceGraph is: SourceGraph is a programme designed to help you analyse the static complexity of your Haskell code when represented as a graph. At the moment, it does the following (M == for each module, I = for imports, C = the whole codebase): * Visualise it {M,I,C} * See a "collapsed" visualisation {M} * Proposed module/directory layout using two different algorithms {I,C} * See the "core" visualisation (recursively strip off roots/leaves) {M} * Calculate the Cyclomatic complexity [4] {M,I,C} * Root analysis (compare what's exported to what actually is a root) {M,I,C} * Determine how many components you have, to see if you should split {M,I,C} * Clique Analysis (find co-recursive functions) {M,C} * Cycle analysis (non-cliques) {M,I,C} * Chain detection (e.g. "straight-line" functions/imports) {M,I,C} [4] http://en.wikipedia.org/wiki/Cyclomatic_complexity Current limitations: * An automatic refactoring tool: SourceGraph gives *you* information on how you might want to possibly refactor your code. It's not smart: it can't tell that you've clumped functions foo and bar in the same module because they do similar things or because it's a utility module, even though they're not related. For automatic refactoring, see something like HaRe [5]. * SourceGraph ignore's "data-based" functions, i.e. record-functions and class/instance declarations, as it's too confusing (IMHO) which actual function you mean (if you see "show" being called, is it for Int, Double, or something else?). * Despite using Haskell-Src-Exts, some extensions (e.g. TH) are ignored, mainly because I have no idea how they work and nothing to test it on. GHC extensions should be supported (read the parser won't choke on them) though. * Reporting output is currently rather limited: - The report will be generated in a subdirectory called "SourceGraph" of the codebase directory; this is currently hardwired in. - It will produce an all-in-one html file report, with no fancy CSS magic to make it look pretty. Ideally, it would produce a split-file, and allow you to choose output format. - Large graphs are shrunk down to being a maximum of 15"x10". Ideally, I'd like to extend this later so that large graphs will have a shrunk version in the graph, which link to a larger version (note though that these graphs get very large very fast). - The output of individual function names, etc. could be improved. [5] http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html SourceGraph can be installed with cabal-install. Once you've done so, you can analyse a cabalized library/application Foo as follows: $ SourceGraph /path/to/codebase/Foo.cabal Report generated at: /path/to/codebase/SourceGraph/Foo.html This has been written as part of my mathematics Honours Thesis, "Graph-Theoretic Analysis of the Relationships in Discrete Data". Since I've actually got to write the thesis up now, I won't be making any more releases for a while. After uni is over for the semester though, I hope to tidy it up and extend it. If you want to check the code out yourselves, there's also darcs repositories for Graphalyze [6] and SourceGraph [7]. [6] http://code.haskell.org/Graphalyze [7] http://code.haskell.org/SourceGraph/ Note that whilst Graphalyze is fully documented, etc., the internals of SourceGraph are a bit fugly (mainly due to time constraints). Enjoy! - -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkjyAacACgkQfEfFJ9JhvyiHEACfVVuRk2FR3ZQiJ6H18FFK/de/ sukAn0tuCLwqxmzlQvWicQKQ3qEJKC1K =HRUK -----END PGP SIGNATURE----- From dave at zednenem.com Sun Oct 12 11:29:48 2008 From: dave at zednenem.com (David Menendez) Date: Sun Oct 12 11:25:54 2008 Subject: [Haskell-cafe] Pandoc questions In-Reply-To: <48F1CFB9.2020901@btinternet.com> References: <48F1CFB9.2020901@btinternet.com> Message-ID: <49a77b7a0810120829m6a80f9e6v3bed065de071c4f1@mail.gmail.com> On Sun, Oct 12, 2008 at 6:21 AM, Andrew Coppin wrote: > Also, while Markdown *almost* does what I want, there are a few small > constructs it doesn't have. For example, I'd like to have some way to denote > a "term" the first time I use it. I could just use italics, but I'd prefer > some way to visually indicate that this isn't just an emphasised word, it's > a new technical term. In HTML, I'd use a style class, Markdown allows arbitrary HTML tags, so you can just put the terms in a element. I don't know if that will work with the LaTeX conversion. Markdown is specifically designed to produce HTML, so it's not clear to me how Pandoc does any of the non-HTML output formats. -- Dave Menendez From frantisek.kocun at gmail.com Sun Oct 12 11:32:49 2008 From: frantisek.kocun at gmail.com (frantisek kocun) Date: Sun Oct 12 11:28:56 2008 Subject: [Haskell-cafe] Haskell on the JVM In-Reply-To: References: <3e1162e60810110907n60e5b3eau4cbe15f68f2c7be4@mail.gmail.com> <200810121119.55602.jon@ffconsultancy.com> Message-ID: There is CAL language (purely functional, very Haskell like, the most I have seen). CAL Eclipse plugin (IDE for CAL for non java-ers) is incredible, with support for code comletition, documentation, refactor, code navigation.. They have graphical editor GemCutter for it as well. You can use java libraries within it with unsafe imports or call cal function from java or there is even embedded CAL in Java:) Check out: http://openquark.org Embeded CAL: http://groups.google.com/group/cal_language/web/embedded-cal This is from CAL for Haskell Programmers: CAL implements essentially all the non-syntactic sugar features of Haskell 98 (with its standard addendums) including: ? algebraic functions with parametric polymorphism and inferred types o type declarations can specialize or assert types ? data declarations for algebraic types o strictness flags for data constructor arguments ? a module system supporting separate compilation ? expression syntax supporting if-then-else, case, let (for both local variable and function definitions) and lambda expressions o support for most of Haskell's expression operators ? special syntax for tuples, strings, characters, numbers and lists ? an extensive collection of standard libraries ? single parameter type classes o superclasses o derived instances, such as the instance declaration for Eq List o deriving clauses for common classes o default class method definitions o higher-kinded type variables, such as with the Functor type class ? dynamics support via the Typeable type class and Dynamic type ? user documentation generated from source code (similar to Haddock) ? foreign function support ? hierarchical module names Another interesting project is COHATOE (contributing Haskell to Eclipse) by which one can write Haskell plugins to Eclipse, but I have no clue how it works. http://eclipsefp.sourceforge.net/cohatoe/ Fero -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081012/21c896df/attachment.htm From marco-oweber at gmx.de Sun Oct 12 11:38:30 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Sun Oct 12 11:34:41 2008 Subject: [Haskell-cafe] Could not deduce .. why ? Message-ID: <20081012153830.GA18606@gmx.de> Surely I've overseen a small point. But I can't see it: Why doesn't ghc recognize taht elc_ (class decl), elc (instance decl) and elc_1 are the same type To help you find the connecting pieces faster I've marked them with ## ## Marc data PT a b = PT b -- phantom type containing state a and the result b class AddEl el_ el2_ elc_ where addEl :: el_ -> elc -> el2_ -- el, child -- ========== adding sub elements (tags) ============================= class AddElT est el_ estc ##elc_## est2 el2_ | estc est -> est2 , est est2 estc el2_ -> el_ , est est2 estc el2_ -> elc_ where addElT :: PT est el_ -> PT estc ##elc_## -> PT est2 el2_ -- first child ? attrs ok? instance ( AddEl el el2 ##elc## <-- this is not recognized because elc != elc_1 , Consume st (Elem celType) st' , DetermineElAddEl (NYV (Element elType AttrsOk st HFalse)) el (Valid celType) elc (NYV (Element elType AttrsOk st' HTrue)) el2 ) => AddElT (NYV (Element elType AttrsOk st HFalse)) el (Valid celType) ##elc## <-- elc_ from class declaration (NYV (Element elType AttrsOk st' HTrue)) el2 where addElT (PT t) (PT ##c##) = PT $ addEl t c -- <<<<<<<<< line 435, c should have type elc, not elc_1 src/Text/XML/Validated/Types.hs|435 col 32 error| || Could not deduce (AddEl el el2 elc_1) || from the context (AddElT || (NYV (Element elType AttrsOk st HFalse)) || el || (Valid celType) || elc || (NYV (Element elType AttrsOk st' HTrue)) || el2, || AddEl el el2 elc, || Consume st (Elem celType) st', || DetermineElAddEl || (NYV (Element elType AttrsOk st HFalse)) || el || (Valid celType) || elc || (NYV (Element elType AttrsOk st' HTrue)) || el2) || arising from a use of `addEl' || at src/Text/XML/Validated/Types.hs:435:32-40 || Possible fix: || add (AddEl el el2 elc_1) to the context of the instance declaration || In the second argument of `($)', namely `addEl t c' || In the expression: PT $ addEl t c || In the definition of `addElT': || addElT (PT t) (PT c) = PT $ addEl t c From andrewcoppin at btinternet.com Sun Oct 12 11:45:01 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 12 11:41:01 2008 Subject: [Haskell-cafe] Pandoc questions In-Reply-To: <49a77b7a0810120829m6a80f9e6v3bed065de071c4f1@mail.gmail.com> References: <48F1CFB9.2020901@btinternet.com> <49a77b7a0810120829m6a80f9e6v3bed065de071c4f1@mail.gmail.com> Message-ID: <48F21B7D.1060003@btinternet.com> David Menendez wrote: > Markdown allows arbitrary HTML tags, so you can just put the terms in > a element. > > I don't know if that will work with the LaTeX conversion. Markdown is > specifically designed to produce HTML, so it's not clear to me how > Pandoc does any of the non-HTML output formats. > Well, no... Markdown is a way of marking up text in a way which is still moderately readable to human beings. You can turn it into any markup format in principle. The trouble as, as soon as Pandoc doesn't understand the markup, you can't really expect it to handle the translation any more... From daniel.is.fischer at web.de Sun Oct 12 12:16:12 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Oct 12 12:10:09 2008 Subject: [Haskell-cafe] Could not deduce .. why ? In-Reply-To: <20081012153830.GA18606@gmx.de> References: <20081012153830.GA18606@gmx.de> Message-ID: <200810121816.13035.daniel.is.fischer@web.de> Am Sonntag, 12. Oktober 2008 17:38 schrieb Marc Weber: > Surely I've overseen a small point. But I can't see it: > Why doesn't ghc recognize taht elc_ (class decl), elc (instance decl) and > elc_1 are the same type To help you find the connecting pieces faster I've > marked them with ## ## > > Marc > > > data PT a b = PT b -- phantom type containing state a and the result b > > class AddEl el_ el2_ elc_ where > addEl :: el_ -> elc -> el2_ -- el, child ^^^^^^ I suspect that might be responsible, didn't you mean to write elc_ there? From andrewcoppin at btinternet.com Sun Oct 12 13:08:22 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 12 13:04:22 2008 Subject: [Haskell-cafe] Still stacking monad transformers Message-ID: <48F22F06.1080607@btinternet.com> I am becoming extremely frustrated now. The task I want to perform is simple, yet I simply cannot make Haskell do what I want. I've given up hope of ever getting my program to handle infinite result sets. That means I can make do with just ListT. So I have the following monad: type MyMonad x = StateT MyState (ListT Identity) x Now I'm trying to run two computations, starting from _the same state_, and combine the two resulting lists. The trouble is, I am literally losing the will to live trying to comprehend the whinings of the type checker. The operation I'm trying to perform is perfectly simple; I don't understand why this has to be so damned *difficult*! >_< Any suggestions? I found that by using the brief and easily memorable construction "runIdentity $ runListT $ runStateT foo state" I can get at the result set for each action, and combine them. But nothing in hell seems to transform this from [((), MyState)] back into MyMonad (). From duncan.coutts at worc.ox.ac.uk Sun Oct 12 13:18:19 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Oct 12 13:14:26 2008 Subject: [Haskell-cafe] Still stacking monad transformers In-Reply-To: <48F22F06.1080607@btinternet.com> References: <48F22F06.1080607@btinternet.com> Message-ID: <1223831899.14942.14.camel@dell.linuxdev.us.dell.com> On Sun, 2008-10-12 at 18:08 +0100, Andrew Coppin wrote: > I am becoming extremely frustrated now. The task I want to perform is > simple, yet I simply cannot make Haskell do what I want. > > I've given up hope of ever getting my program to handle infinite result > sets. That means I can make do with just ListT. So I have the following > monad: > > type MyMonad x = StateT MyState (ListT Identity) x > > Now I'm trying to run two computations, starting from _the same state_, > and combine the two resulting lists. The trouble is, I am literally > losing the will to live trying to comprehend the whinings of the type > checker. The operation I'm trying to perform is perfectly simple; I > don't understand why this has to be so damned *difficult*! >_< > > Any suggestions? Have you tried pure lazy functional programming without stacked monads? I've never been convinced that stacked monads is a good way to write ordinary code. Monad transformers are great for building your own custom monads but they should be wrapped in a newtype and made abstract. One shouldn't have to see the multiple layers. If ordinary code is full of 'lift' then it would seem to me that one is doing something wrong. Duncan From miguelimo38 at yandex.ru Sun Oct 12 13:25:10 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun Oct 12 13:21:23 2008 Subject: [Haskell-cafe] Still stacking monad transformers In-Reply-To: <48F22F06.1080607@btinternet.com> References: <48F22F06.1080607@btinternet.com> Message-ID: <293211EB-8FBD-4A60-B0E6-C53C27F4858F@yandex.ru> On 12 Oct 2008, at 21:08, Andrew Coppin wrote: > I found that by using the brief and easily memorable construction > "runIdentity $ runListT $ runStateT foo state" I can get at the > result set for each action, and combine them. But nothing in hell > seems to transform this from [((), MyState)] back into MyMonad (). Well, State monad (and StateT transformer) doesn't work with STATE, they work with STATE CHANGES. So, instead of [((), MyState], you should have something like (MyState -> [((), MyState)]). And that can be transformed to MyMonad () quite easily: Prelude Control.Monad.State Control.Monad.List Control.Monad.Identity> :t \f -> StateT $ ListT . Identity . f \f -> StateT $ ListT . Identity . f :: (s -> [(a, s)]) -> StateT s (ListT Identity) a From gwern0 at gmail.com Sun Oct 12 13:24:40 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Oct 12 13:21:50 2008 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: Graphalyze-0.4 and SourceGraph-0.2 In-Reply-To: <20081012235444.18600479@gmail.com> References: <20081012235444.18600479@gmail.com> Message-ID: <20081012172440.GA4207@craft> On 2008.10.12 23:54:44 +1000, Ivan Lazar Miljenovic scribbled 6.4K characters: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I'd like to announce version 0.4 of my Graphalyze library [1] and 0.2 of my > SourceGraph programme [2]. > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze > [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SourceGraph > > This should fix the bugs reported by Gwern Branwen, Magnus Therning (thanks to > Niklas Broberg for stating the correct version for Haskell-Src-Exts) and > Christopher Hinson. No really new features are included in this release. I > was planning on fixing this and releasing it sooner but - to utilise what seems > to be a current meme [3] - "I accidentally my Gentoo" on Tuesday night and only > fixed it yesterday. > > [3] http://encyclopediadramatica.com/I_accidentally_X > > Since I'm more awake now than I was when I made the initial release, here's a > run-down of what SourceGraph is: > > SourceGraph is a programme designed to help you analyse the static complexity > of your Haskell code when represented as a graph. At the moment, it does the > following (M == for each module, I = for imports, C = the whole codebase): > > * Visualise it {M,I,C} > * See a "collapsed" visualisation {M} > * Proposed module/directory layout using two different algorithms {I,C} > * See the "core" visualisation (recursively strip off roots/leaves) {M} > * Calculate the Cyclomatic complexity [4] {M,I,C} > * Root analysis (compare what's exported to what actually is a root) {M,I,C} > * Determine how many components you have, to see if you should split {M,I,C} > * Clique Analysis (find co-recursive functions) {M,C} > * Cycle analysis (non-cliques) {M,I,C} > * Chain detection (e.g. "straight-line" functions/imports) {M,I,C} > > [4] http://en.wikipedia.org/wiki/Cyclomatic_complexity > > Current limitations: > > * An automatic refactoring tool: SourceGraph gives *you* information on how you > might want to possibly refactor your code. It's not smart: it can't tell > that you've clumped functions foo and bar in the same module because they do > similar things or because it's a utility module, even though they're not > related. For automatic refactoring, see something like HaRe [5]. > * SourceGraph ignore's "data-based" functions, i.e. record-functions and > class/instance declarations, as it's too confusing (IMHO) which actual > function you mean (if you see "show" being called, is it for Int, Double, or > something else?). > * Despite using Haskell-Src-Exts, some extensions (e.g. TH) are ignored, mainly > because I have no idea how they work and nothing to test it on. GHC > extensions should be supported (read the parser won't choke on them) though. > * Reporting output is currently rather limited: > - The report will be generated in a subdirectory called "SourceGraph" of the > codebase directory; this is currently hardwired in. > - It will produce an all-in-one html file report, with no fancy CSS magic to > make it look pretty. Ideally, it would produce a split-file, and allow you > to choose output format. > - Large graphs are shrunk down to being a maximum of 15"x10". Ideally, I'd > like to extend this later so that large graphs will have a shrunk version > in the graph, which link to a larger version (note though that these graphs > get very large very fast). > - The output of individual function names, etc. could be improved. > > [5] http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html > > SourceGraph can be installed with cabal-install. Once you've done so, you can > analyse a cabalized library/application Foo as follows: > > $ SourceGraph /path/to/codebase/Foo.cabal > Report generated at: /path/to/codebase/SourceGraph/Foo.html > > This has been written as part of my mathematics Honours Thesis, > "Graph-Theoretic Analysis of the Relationships in Discrete Data". Since I've > actually got to write the thesis up now, I won't be making any more releases > for a while. After uni is over for the semester though, I hope to tidy it up > and extend it. > > If you want to check the code out yourselves, there's also darcs repositories > for Graphalyze [6] and SourceGraph [7]. > > [6] http://code.haskell.org/Graphalyze > [7] http://code.haskell.org/SourceGraph/ > > Note that whilst Graphalyze is fully documented, etc., the internals of > SourceGraph are a bit fugly (mainly due to time constraints). > > Enjoy! > > - -- > Ivan Lazar Miljenovic OK, I've installed and yes - it now produces output for XMC instead of looping. However, I happened to want to look at the output for one of my modules, XMonad.Util.XSelection - and it simply isn't there. Most of the XMC modules seem to be there, but that one isn't. It's in the cabal file, SourceGraph did not output any errors or warnings, but XSelection is not mentioned in the HTML output nor are any PNGs generated with regard to it. See: gwern@craft:24375~/bin/XMonadContrib/SourceGraph>grep XSelection ../xmonad-contrib.cabal [ 1:20PM] XMonad.Util.XSelection gwern@craft:24372~/bin/XMonadContrib>SourceGraph xmonad-contrib.cabal [ 1:16PM] Report generated at: SourceGraph/xmonad-contrib.html SourceGraph xmonad-contrib.cabal 59.05s user 4.14s system 98% cpu 1:03.83 total gwern@craft:24373~/bin/XMonadContrib>c SourceGraph [ 1:17PM] codeCluster.png XMonad.Layout.DragPane_collapsed.png codeCollapsed.png XMonad.Layout.DragPane.png codeCore.png XMonad.Layout.DwmStyle_collapsed.png codeCW.png XMonad.Layout.DwmStyle.png code.png XMonad.Layout.Gaps_collapsed.png codeRNG.png XMonad.Layout.Gaps.png importCluster.png XMonad.Layout.Grid_collapsed.png importCW.png XMonad.Layout.Grid.png importRNG.png XMonad.Layout.HintedGrid_collapsed.png imports.png XMonad.Layout.HintedGrid.png Main_collapsed.png XMonad.Layout.HintedTile_collapsed.png Main.png XMonad.Layout.HintedTile_core.png XMonad.Actions.Commands_collapsed.png XMonad.Layout.HintedTile.png XMonad.Actions.Commands.png XMonad.Layout.IM_collapsed.png XMonad.Actions.ConstrainedResize_collapsed.png XMonad.Layout.IM.png XMonad.Actions.ConstrainedResize.png XMonad.Layout.LayoutCombinators_collapsed.png XMonad.Actions.CopyWindow_collapsed.png XMonad.Layout.LayoutCombinators.png XMonad.Actions.CopyWindow.png XMonad.Layout.LayoutHints_collapsed.png XMonad.Actions.CycleRecentWS_collapsed.png XMonad.Layout.LayoutHints.png XMonad.Actions.CycleRecentWS.png XMonad.Layout.LayoutModifier_collapsed.png XMonad.Actions.CycleSelectedLayouts_collapsed.png XMonad.Layout.LayoutModifier.png XMonad.Actions.CycleSelectedLayouts.png XMonad.Layout.LayoutScreens_collapsed.png XMonad.Actions.CycleWS_collapsed.png XMonad.Layout.LayoutScreens.png XMonad.Actions.CycleWS_core.png XMonad.Layout.MagicFocus_collapsed.png XMonad.Actions.CycleWS.png XMonad.Layout.MagicFocus.png XMonad.Actions.DeManage_collapsed.png XMonad.Layout.Magnifier_collapsed.png XMonad.Actions.DeManage.png XMonad.Layout.Magnifier.png XMonad.Actions.DwmPromote_collapsed.png XMonad.Layout.Master_collapsed.png XMonad.Actions.DwmPromote.png XMonad.Layout.Master.png XMonad.Actions.DynamicWorkspaces_collapsed.png XMonad.Layout.Maximize_collapsed.png XMonad.Actions.DynamicWorkspaces.png XMonad.Layout.Maximize.png XMonad.Actions.FindEmptyWorkspace_collapsed.png XMonad.Layout.MosaicAlt_collapsed.png XMonad.Actions.FindEmptyWorkspace.png XMonad.Layout.MosaicAlt_core.png XMonad.Actions.FlexibleManipulate_collapsed.png XMonad.Layout.MosaicAlt.png XMonad.Actions.FlexibleManipulate.png XMonad.Layout.MultiToggle_collapsed.png XMonad.Actions.FlexibleResize_collapsed.png XMonad.Layout.MultiToggle.Instances_collapsed.png XMonad.Actions.FlexibleResize.png XMonad.Layout.MultiToggle.Instances.png XMonad.Actions.FloatKeys_collapsed.png XMonad.Layout.MultiToggle.png XMonad.Actions.FloatKeys.png XMonad.Layout.Named_collapsed.png XMonad.Actions.FocusNth_collapsed.png XMonad.Layout.Named.png XMonad.Actions.FocusNth.png XMonad.Layout.NoBorders_collapsed.png XMonad.Actions.MouseGestures_collapsed.png XMonad.Layout.NoBorders.png XMonad.Actions.MouseGestures.png XMonad.Layout.PerWorkspace_collapsed.png XMonad.Actions.MouseResize_collapsed.png XMonad.Layout.PerWorkspace.png XMonad.Actions.MouseResize.png XMonad.Layout.Reflect_collapsed.png XMonad.Actions.NoBorders_collapsed.png XMonad.Layout.Reflect.png XMonad.Actions.NoBorders.png XMonad.Layout.ResizeScreen_collapsed.png XMonad.Actions.PerWorkspaceKeys_collapsed.png XMonad.Layout.ResizeScreen.png XMonad.Actions.PerWorkspaceKeys.png XMonad.Layout.Roledex_collapsed.png XMonad.Actions.Plane_collapsed.png XMonad.Layout.Roledex.png XMonad.Actions.Plane.png XMonad.Layout.ShowWName_collapsed.png XMonad.Actions.Promote_collapsed.png XMonad.Layout.ShowWName.png XMonad.Actions.Promote.png XMonad.Layout.SimpleDecoration_collapsed.png XMonad.Actions.RotSlaves_collapsed.png XMonad.Layout.SimpleDecoration.png XMonad.Actions.RotSlaves.png XMonad.Layout.SimpleFloat_collapsed.png XMonad.Actions.Search_collapsed.png XMonad.Layout.SimpleFloat.png XMonad.Actions.Search.png XMonad.Layout.Simplest_collapsed.png XMonad.Actions.SimpleDate_collapsed.png XMonad.Layout.SimplestFloat_collapsed.png XMonad.Actions.SimpleDate.png XMonad.Layout.SimplestFloat.png XMonad.Actions.SinkAll_collapsed.png XMonad.Layout.Simplest.png XMonad.Actions.SinkAll.png XMonad.Layout.Spiral_collapsed.png XMonad.Actions.Submap_collapsed.png XMonad.Layout.Spiral_core.png XMonad.Actions.Submap.png XMonad.Layout.Spiral.png XMonad.Actions.SwapWorkspaces_collapsed.png XMonad.Layout.Square_collapsed.png XMonad.Actions.SwapWorkspaces.png XMonad.Layout.Square.png XMonad.Actions.TagWindows_collapsed.png XMonad.Layout.TabBarDecoration_collapsed.png XMonad.Actions.TagWindows.png XMonad.Layout.TabBarDecoration.png XMonad.Actions.UpdatePointer_collapsed.png XMonad.Layout.Tabbed_collapsed.png XMonad.Actions.UpdatePointer.png XMonad.Layout.Tabbed.png XMonad.Actions.Warp_collapsed.png XMonad.Layout.ToggleLayouts_collapsed.png XMonad.Actions.Warp.png XMonad.Layout.ToggleLayouts.png XMonad.Actions.WindowBringer_collapsed.png XMonad.Layout.TwoPane_collapsed.png XMonad.Actions.WindowBringer.png XMonad.Layout.TwoPane.png XMonad.Actions.WindowGo_collapsed.png XMonad.Layout.WindowArranger_collapsed.png XMonad.Actions.WindowGo.png XMonad.Layout.WindowArranger.png XMonad.Actions.WindowNavigation_collapsed.png XMonad.Layout.WindowNavigation_collapsed.png XMonad.Actions.WindowNavigation_core.png XMonad.Layout.WindowNavigation_core.png XMonad.Actions.WindowNavigation.png XMonad.Layout.WindowNavigation.png XMonad.Config.Arossato_collapsed.png XMonad.Layout.WorkspaceDir_collapsed.png XMonad.Config.Arossato.png XMonad.Layout.WorkspaceDir.png XMonad.Config.Azerty_collapsed.png XMonad.Prompt.AppendFile_collapsed.png XMonad.Config.Azerty.png XMonad.Prompt.AppendFile.png XMonad.Config.Desktop_collapsed.png XMonad.Prompt.AppLauncher_collapsed.png XMonad.Config.Desktop.png XMonad.Prompt.AppLauncher.png XMonad.Config.Droundy_collapsed.png XMonad.Prompt_collapsed.png XMonad.Config.Droundy.png XMonad.Prompt_core.png XMonad.Config.Gnome_collapsed.png XMonad.Prompt.Directory_collapsed.png XMonad.Config.Gnome.png XMonad.Prompt.Directory.png XMonad.Config.Kde_collapsed.png XMonad.Prompt.DirExec_collapsed.png XMonad.Config.Kde.png XMonad.Prompt.DirExec.png XMonad.Config.PlainConfig_collapsed.png XMonad.Prompt.Email_collapsed.png XMonad.Config.PlainConfig_core.png XMonad.Prompt.Email.png XMonad.Config.PlainConfig.png XMonad.Prompt.Input_collapsed.png XMonad.Config.Sjanssen_collapsed.png XMonad.Prompt.Input.png XMonad.Config.Sjanssen.png XMonad.Prompt.Layout_collapsed.png XMonad.Config.Xfce_collapsed.png XMonad.Prompt.Layout.png XMonad.Config.Xfce.png XMonad.Prompt.Man_collapsed.png xmonad-contrib.html XMonad.Prompt.Man.png XMonad.Doc_collapsed.png XMonad.Prompt.png XMonad.Doc.Configuring_collapsed.png XMonad.Prompt.RunOrRaise_collapsed.png XMonad.Doc.Configuring.png XMonad.Prompt.RunOrRaise.png XMonad.Doc.Developing_collapsed.png XMonad.Prompt.Shell_collapsed.png XMonad.Doc.Developing.png XMonad.Prompt.Shell_core.png XMonad.Doc.Extending_collapsed.png XMonad.Prompt.Shell.png XMonad.Doc.Extending.png XMonad.Prompt.Ssh_collapsed.png XMonad.Doc.png XMonad.Prompt.Ssh.png XMonad.Hooks.DynamicHooks_collapsed.png XMonad.Prompt.Theme_collapsed.png XMonad.Hooks.DynamicHooks.png XMonad.Prompt.Theme.png XMonad.Hooks.DynamicLog_collapsed.png XMonad.Prompt.Window_collapsed.png XMonad.Hooks.DynamicLog.png XMonad.Prompt.Window.png XMonad.Hooks.EventHook_collapsed.png XMonad.Prompt.Workspace_collapsed.png XMonad.Hooks.EventHook.png XMonad.Prompt.Workspace.png XMonad.Hooks.EwmhDesktops_collapsed.png XMonad.Prompt.XMonad_collapsed.png XMonad.Hooks.EwmhDesktops.png XMonad.Prompt.XMonad.png XMonad.Hooks.FadeInactive_collapsed.png XMonad.Util.CustomKeys_collapsed.png XMonad.Hooks.FadeInactive.png XMonad.Util.CustomKeys.png XMonad.Hooks.ManageDocks_collapsed.png XMonad.Util.Dmenu_collapsed.png XMonad.Hooks.ManageDocks.png XMonad.Util.Dmenu.png XMonad.Hooks.ManageHelpers_collapsed.png XMonad.Util.Dzen_collapsed.png XMonad.Hooks.ManageHelpers.png XMonad.Util.Dzen.png XMonad.Hooks.Script_collapsed.png XMonad.Util.EZConfig_collapsed.png XMonad.Hooks.Script.png XMonad.Util.EZConfig.png XMonad.Hooks.ServerMode_collapsed.png XMonad.Util.Invisible_collapsed.png XMonad.Hooks.ServerMode.png XMonad.Util.Invisible.png XMonad.Hooks.SetWMName_collapsed.png XMonad.Util.Loggers_collapsed.png XMonad.Hooks.SetWMName.png XMonad.Util.Loggers.png XMonad.Hooks.UrgencyHook_collapsed.png XMonad.Util.NamedWindows_collapsed.png XMonad.Hooks.UrgencyHook.png XMonad.Util.NamedWindows.png XMonad.Hooks.XPropManage_collapsed.png XMonad.Util.Paste_collapsed.png XMonad.Hooks.XPropManage.png XMonad.Util.Paste.png XMonad.Layout.Accordion_collapsed.png XMonad.Util.Run_collapsed.png XMonad.Layout.Accordion.png XMonad.Util.Run.png XMonad.Layout.BoringWindows_collapsed.png XMonad.Util.Scratchpad_collapsed.png XMonad.Layout.BoringWindows.png XMonad.Util.Scratchpad.png XMonad.Layout.Circle_collapsed.png XMonad.Util.Themes_collapsed.png XMonad.Layout.Circle.png XMonad.Util.Themes.png XMonad.Layout.Combo_collapsed.png XMonad.Util.Timer_collapsed.png XMonad.Layout.Combo.png XMonad.Util.Timer.png XMonad.Layout.Decoration_collapsed.png XMonad.Util.WindowProperties_collapsed.png XMonad.Layout.Decoration_core.png XMonad.Util.WindowProperties_core.png XMonad.Layout.DecorationMadness_collapsed.png XMonad.Util.WindowProperties.png XMonad.Layout.DecorationMadness.png XMonad.Util.WorkspaceCompare_collapsed.png XMonad.Layout.Decoration.png XMonad.Util.WorkspaceCompare.png XMonad.Layout.Dishes_collapsed.png XMonad.Util.XUtils_collapsed.png XMonad.Layout.Dishes.png XMonad.Util.XUtils.png gwern@craft:24374~/bin/XMonadContrib/SourceGraph>grep XSelection * [ 1:19PM] gwern@craft:24375~/bin/XMonadContrib/SourceGraph> (I'd attach the output, but even a gzipped tarball of SourceGraph/ is 8.2M, and someone complained about the last one which was only a few megabytes, so...) -- gwern SLBM TRW NSS 32 Poseidon blackjack global Aum enforcers Unit -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081012/51a7a931/attachment.bin From andrewcoppin at btinternet.com Sun Oct 12 13:43:46 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Oct 12 13:39:47 2008 Subject: [Haskell-cafe] Still stacking monad transformers In-Reply-To: <1223831899.14942.14.camel@dell.linuxdev.us.dell.com> References: <48F22F06.1080607@btinternet.com> <1223831899.14942.14.camel@dell.linuxdev.us.dell.com> Message-ID: <48F23752.9010406@btinternet.com> Duncan Coutts wrote: > Have you tried pure lazy functional programming without stacked monads? > I want to process multiple results. The list monad seems a natural way to do this. (All of which goes horribly wrong when you try to add error processing...) > I've never been convinced that stacked monads is a good way to write > ordinary code. Monad transformers are great for building your own custom > monads but they should be wrapped in a newtype and made abstract. One > shouldn't have to see the multiple layers. If ordinary code is full of > 'lift' then it would seem to me that one is doing something wrong. > Given that what I'm attempting to do is extremely simple, yet I am having extreme difficulty doing it, yeah, I think we can safely conclude I'm doing something wrong. From gianfranco.alongi at gmail.com Sun Oct 12 14:05:44 2008 From: gianfranco.alongi at gmail.com (Gianfranco Alongi) Date: Sun Oct 12 14:01:50 2008 Subject: [Haskell-cafe] Congrats. to wxHaskell In-Reply-To: <20081012014517.GM11641@scytale.galois.com> References: <20081012014517.GM11641@scytale.galois.com> Message-ID: Is it crash / bug -free? I know this has been a big issue with WxHaskell, something that made me use HGL. On Sun, Oct 12, 2008 at 3:45 AM, Don Stewart wrote: > I just want to congratulate the wxHaskell team on their new release. > With GHC 6.10 RC, cabal 1.6, and cabal-install 0.6, I was able to > simply, > > cabal install wxcore wx > > And it all worked. > > Well done! > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Patience is the last resort for those unable to take action From apfelmus at quantentunnel.de Sun Oct 12 14:24:55 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Sun Oct 12 14:21:19 2008 Subject: [Haskell-cafe] Re: Interesting new user perspective In-Reply-To: <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> References: <20081005012510.GB2331@scytale.galois.com> <81F80850-EDDF-4EA9-ADF2-5E55B7787CEA@gmail.com> <1223661943.1394.13.camel@jcchost> <6bhve4lbdut9kk0825vj7458k91748nd3a@4ax.com> <1223674294.1394.43.camel@jcchost> <48EFCFCA.50008@btinternet.com> <19F6E971-A248-4E9D-B863-EE352FBB8524@gmail.com> Message-ID: Iain Barnett wrote: > apfelmus wrote: >>> Martin DeMello wrote: >>>> >>>> http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem >>>> >>>> is a brilliant example of a common workaday problem found in other >>>> languages, and solved elegantly in Haskell >> >> ... and a solution to a problem that you souldn't have in the first >> place. I mean, if you want to construct XML or SQL statements, you ought >> to use an abstract data type that ensures proper nesting etc. and not a >> simple string. > > Do you have an example of what you mean? Ah, yes, let me explain. Tom Moertel's post introduces two use cases, namely generating SQL statements and HTML documents from a template and some parameters (the latter are given as String ). Representing all of them as String is prone to bugs concerning escaping, so he uses a custom string type instead, namely one that indicates whether it was an SQL statement or HTML document. So far so good. Now note that I kept saying "HTML document" or "SQL statement" instead of "HTML string" or "SQL string" because, and that's my point, why on earth would you want to think of them as strings in the first place? I mean, a HTML document is a DOM-tree and an SQL statement is a logical formula. Just like a Haskell module is a set of function, type and class definitions and more. Sure, it's nice that all of them can be represented as a list of Unicode characters, but that's not the primary way of working with them. In other words, the typed way of thinking of these things is as abstract data types "Html" and "Sql" with operations for constructing and deconstructing them, like for instance ulist :: Html -> Html -- enclose with a