[Haskell-cafe] Split and substitution using regex-pcre

2013-02-24 Thread Simon Marechal
I could not find the perl-equivalents of these functions on Hackage, so I quickly wrote mine. Code is there: https://github.com/bartavelle/pcre-utils It should behave like perl (not really tested actually), and do strange things like : splitCompile a b Right [b] splitCompile a

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Martin Drautzburg
On Wednesday, 20. February 2013 09:59:47 Tillmann Rendel wrote: So the grammar is: Exp ::= Int | Exp + Exp My naive parser enters an infinite recursion, when I try to parse 1+2. I do understand why: hmm, this expression could be a plus, but then it must start with

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Tillmann Rendel
Hi Martin, Martin Drautzburg wrote: Note that the left recursion is already visible in the grammar above, no need to convert to parser combinators. The problem is that the nonterminal Exp occurs at the left of a rule for itself. Just a silly quick question: why isn't right-recursion a similar

[Haskell-cafe] Munich Haskell Meeting

2013-02-24 Thread Heinrich Hördegen
Dear all, please note that our monthly Haskell get-together is scheduled on Wed, 27th Feb 2013 at 19h30 at Cafe Puck in Munich, Germany. If you plan to join, please go to http://www.haskell-munich.de/dates and click the button. Everyone interested in functional programming is welcome!

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Roman Cheplyaka
* Martin Drautzburg martin.drautzb...@web.de [2013-02-24 12:31:37+0100] Twan van Laarhoven told me that: Left-recursion is always a problem for recursive-descend parsers. Note that the left recursion is already visible in the grammar above, no need to convert to parser combinators.

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Kim-Ee Yeoh
On Sun, Feb 24, 2013 at 7:09 PM, Roman Cheplyaka r...@ro-che.info wrote: Thus, your recursion is well-founded — you enter the recursion with the input strictly smaller than you had in the beginning. Perhaps you meant /productive/ corecursion? Because the definition A ::= B A you gave is

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Roman Cheplyaka
* Kim-Ee Yeoh k...@atamo.com [2013-02-24 19:22:33+0700] On Sun, Feb 24, 2013 at 7:09 PM, Roman Cheplyaka r...@ro-che.info wrote: Thus, your recursion is well-founded — you enter the recursion with the input strictly smaller than you had in the beginning. Perhaps you meant

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Roman Cheplyaka
* Kim-Ee Yeoh k...@atamo.com [2013-02-24 19:22:33+0700] On Sun, Feb 24, 2013 at 7:09 PM, Roman Cheplyaka r...@ro-che.info wrote: Thus, your recursion is well-founded — you enter the recursion with the input strictly smaller than you had in the beginning. Perhaps you meant

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Kim-Ee Yeoh
On Sun, Feb 24, 2013 at 7:47 PM, Roman Cheplyaka r...@ro-che.info wrote: Or perhaps you meant that the production itself, when interpreted as a definition, is corecursive? I was merely thrown off by your mention of well-founded and the assertion that you're left with a strictly smaller input.

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Roman Cheplyaka
* Kim-Ee Yeoh k...@atamo.com [2013-02-24 19:56:13+0700] I was merely thrown off by your mention of well-founded and the assertion that you're left with a strictly smaller input. I don't see any of this. It may become more obvious if you try to write two recursive descent parsers (as recursive

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Kim-Ee Yeoh
On Sun, Feb 24, 2013 at 8:03 PM, Roman Cheplyaka r...@ro-che.info wrote: It may become more obvious if you try to write two recursive descent parsers (as recursive functions) which parse a left-recursive and a non-left-recursive grammars, and see in which case the recursion is well-founded

Re: [Haskell-cafe] cabal install ghc-mod installs 3 years old version

2013-02-24 Thread Niklas Hambüchen
You are right, my ghc-7.4.2 was broken in ghc-pkg list; I fixed the problem by killing my .cabal folder (as so often). Do you know if it is possible to make ghc-pkg list print some actual text when packages are broken instead of writing them in red (which goes away on output redirection)? Thanks

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Brandon Allbery
On Sun, Feb 24, 2013 at 6:31 AM, Martin Drautzburg martin.drautzb...@web.de wrote: Just a silly quick question: why isn't right-recursion a similar problem? Very roughly: Left recursion is: let foo n = n + foo n in ... Right recursion is: let foo 1 = 1; foo n = n + foo (n - 1) in ... In

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Tillmann Rendel
Hi, Kim-Ee Yeoh wrote: Perhaps you meant /productive/ corecursion? Because the definition A ::= B A you gave is codata. If you write a recursive descent parser, it takes the token stream as an input and consumes some of this input. For example, the parser could return an integer that says

[Haskell-cafe] Install qtHaskell 1.1.4 using Visual Studio 2010 and GHC 7.4.2

2013-02-24 Thread leonardo davinci
I am trying to install qtHaskell in Windows. I have Qt 4.8.4 (the Visual Studio 2010 version). I am following the section 2.3.2 Windows Manual Installation from the userGuide of qtHaskell. I set the path as described I added the line to qt.cabal, I changed dir to qws I gave qmake -recursive and

[Haskell-cafe] Thunks and GHC pessimisation

2013-02-24 Thread Tom Ellis
To avoid retaining a large lazy data structure in memory it is useful to hide it behind a function call. Below, many is used twice. It is hidden behind a function call so it can be garbage collected between uses. That's good. When compiling with -O it seems that GHC 7.4.1 decides to keep it in

Re: [Haskell-cafe] Thunks and GHC pessimisation

2013-02-24 Thread Joachim Breitner
Hi, I believe, without checking, that Am Sonntag, den 24.02.2013, 17:49 + schrieb Tom Ellis: many :: () - [Int] many () = [1..million] is indeed called many times. The problem is that [1..million] is not dependent on the parameter, so GHC will float it out to a top level declaration, and

Re: [Haskell-cafe] Thunks and GHC pessimisation

2013-02-24 Thread Don Stewart
In toy examples like this it will be generally hard to convince GHC not to just collapse your program down to a constant, when you're turning up the optimization level. In particular, you are implying -ffull-laziness with -O (or -O2), which can increase sharing. GHC doesn't implement complete

Re: [Haskell-cafe] Thunks and GHC pessimisation

2013-02-24 Thread Tom Ellis
On Sun, Feb 24, 2013 at 07:12:24PM +0100, Joachim Breitner wrote: You should try: million :: () - Int million _ = 10 ^ (6 :: Int) many :: () - [Int] many x = [1..million x] Thanks Joachim, but that doesn't work either. Tom % cat thunkfail.hs {-# OPTIONS_GHC -fno-warn-unused-binds

Re: [Haskell-cafe] Thunks and GHC pessimisation

2013-02-24 Thread Tom Ellis
On Sun, Feb 24, 2013 at 06:25:56PM +, Don Stewart wrote: If you explicitly rely on this not happening, turn it off: $ ghc -O2 -fno-full-laziness --make A.hs -rtsopts -fforce-recomp [1 of 1] Compiling Main ( A.hs, A.o ) Linking A ... $ time ./A +RTS -M750k

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread Kim-Ee Yeoh
On Sun, Feb 24, 2013 at 10:04 PM, Tillmann Rendel ren...@informatik.uni-marburg.de wrote: The recursion is well-founded if (drop n1 text) is smaller then text. So we have two cases, as Roman wrote: If the language defined by B contains the empty string, then n1 can be 0, so the recursion is

[Haskell-cafe] presentation on Diffusion of Innovation mentioning several times Haskell

2013-02-24 Thread Luc TAESCH
Just found an Interesting presentation mixing Diffusion of Innovation with Social Patterns, mentioning several times Haskell. Good introduction to a mix of techniques for whoever interested in Haskell proselytism, and go to market strategy,

Re: [Haskell-cafe] cabal install ghc-mod installs 3 years old version

2013-02-24 Thread Ivan Lazar Miljenovic
On 25 February 2013 01:33, Niklas Hambüchen m...@nh2.me wrote: You are right, my ghc-7.4.2 was broken in ghc-pkg list; I fixed the problem by killing my .cabal folder (as so often). Do you know if it is possible to make ghc-pkg list print some actual text when packages are broken instead of

Re: [Haskell-cafe] Parser left recursion

2013-02-24 Thread wren ng thornton
On 2/24/13 7:56 AM, Kim-Ee Yeoh wrote: On Sun, Feb 24, 2013 at 7:47 PM, Roman Cheplyaka r...@ro-che.info wrote: Or perhaps you meant that the production itself, when interpreted as a definition, is corecursive? I was merely thrown off by your mention of well-founded and the assertion that

[Haskell-cafe] Tournament knock out

2013-02-24 Thread Xinyu LIU
Hi, Tournament knock out is explained in [1] by Knuth. The limitation is that it can only handle the sequence of the length 2^m for some integer m. When the champion element is removed, it was replaced with negative infinity. Typically negative infinity is represented by a predefined big negative

Re: [Haskell-cafe] ifdef based on which OS you're on

2013-02-24 Thread Dan Cross
On Sun, Feb 24, 2013 at 5:28 PM, Andrew Cowie and...@operationaldynamics.com wrote: On Sat, 2013-02-16 at 08:18 +0100, Henk-Jan van Tuyl wrote: Anyone have any idea if the Cabal library exposes this somewhere? See... I blogged about my solution using Krzysztof and Henk's suggestions

Re: [Haskell-cafe] ANN: conduit-network-stream, A base layer for network protocols with Conduits

2013-02-24 Thread Alexander V Vershilov
Hello, Nils. Can you describe if there any difference with latest conduit API (yield, await) that can be used to write functions in a very similar style, but without using exeternal packages: runTCPServer settings app = appSource ap $$ go =$= CL.mapM_ encode =$ appSink app where

[Haskell-cafe] RFC: rewrite-with-location proposal

2013-02-24 Thread Michael Snoyman
Quite a while back, Simon Hengel and I put together a proposal[1] for a new feature in GHC. The basic idea is pretty simple: provide a new pragma that could be used like so: error :: String - a errorLoc :: IO Location - String - a {-# REWRITE_WITH_LOCATION error errorLoc #-} Then all usages of