[Haskell-cafe] Building ? using kleene closure {not haskell specific}

2011-08-12 Thread C K Kashyap
Hello gentle Haskell folks, I happened to read Beautiful code's chapter 1 today and found Brian Kerninghan's regex implementation. In it he only shows the * meta character. I can easily understand how + can be built but am having trouble with building ? (zero or one). I'd really appreciate it if

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread oleg
I guess you mean the function that converts an abstract syntax tree to a directed acyclic graph (DAG). Just for completeness I should mention that if the object language has effects including non-termination, one has to be careful eliminating seemingly common expressions. For example, in

Re: [Haskell-cafe] Building ? using kleene closure {not haskell specific}

2011-08-12 Thread Sai Hemanth K
Hi, Perhaps I did not understand the question properly, but it looks very straight forward : oneOrNone x = fmap Just x | pure Nothing it will have a type of oneOrNone :: (Alternative f) = f a - f (Maybe a) In fact, there is a function called optional in Control.Applicative[1] which does

Re: [Haskell-cafe] Building ? using kleene closure {not haskell specific}

2011-08-12 Thread Sebastian Fischer
I can easily understand how + can be built but am having trouble with building ? (zero or one). If there is a regular expression e for the empty word, one can define ? as a? = e | a If there is a regular expression o that never matches one can define e as e = o* If there are

Re: [Haskell-cafe] Building ? using kleene closure {not haskell specific}

2011-08-12 Thread C K Kashyap
On Fri, Aug 12, 2011 at 4:34 PM, Sebastian Fischer fisc...@nii.ac.jpwrote: I can easily understand how + can be built but am having trouble with building ? (zero or one). If there is a regular expression e for the empty word, one can define ? as a? = e | a If there is a regular

[Haskell-cafe] fyi GHC 7.2.1 release on the benchmarks game

2011-08-12 Thread Isaac Gouy
1) Some of the GHC programs contributed to the benchmarks game have problems with recent GHC releases - meteor-contest #5 - Ambiguous occurrence `permutations' http://shootout.alioth.debian.org/u64q/program.php?test=meteorlang=ghcid=5#log - regex-dna #2 - Precedence parsing error

Re: [Haskell-cafe] fyi GHC 7.2.1 release on the benchmarks game

2011-08-12 Thread austin seipp
Hello Isaac, On Fri, Aug 12, 2011 at 10:18 AM, Isaac Gouy igo...@yahoo.com wrote: 1) Some of the GHC programs contributed to the benchmarks game have problems with recent GHC releases - meteor-contest #5 - Ambiguous occurrence `permutations'

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Anton Kholomiov
Just to make it explicit, is it \a i - let t = a ! i in if i = 0 then t else if i 0 then t + a ! (i-1) else bad idea, because of last else-case? Can it be mended with one another pass for if-expressions? The upcoming

Re: [Haskell-cafe] Potential problem with AC-Vector-Fancy package

2011-08-12 Thread Andrew Coppin
I think I have found a problem with the union function: If you look here: http://hpaste.org/49889 You will see that line 4 gives a different result to lines 6, 8, 10; this shouldn't be the case because union is commutative. AC-Vector-Fancy is merely a fancy facard over AC-Vector. So the bug is

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Conal Elliott
Note that data-reify will only find *some* common/equal sub-expressions, namely the pointer-equal ones. In all of my code-generating (deep) DSLs, it's been very important for efficiency to also pull out equal-but-pointer-unequal expressions. - Conal On Thu, Aug 11, 2011 at 4:41 AM, Vo Minh

Re: [Haskell-cafe] Distributions link on Hackage

2011-08-12 Thread Joachim Breitner
Hi, Am Donnerstag, den 11.08.2011, 15:46 +0200 schrieb Peter Simons: the home page of a package on Hackage links to various distributions to show which versions are available, i.e. Fedora, Debian, FreeBSD, etc. In NixOS, we have fairly up-to-date package set, and I would like to see that

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Anton Kholomiov
Do you mean that x and y in x = a + 1 y = a + 1 are different from data-reify point of view? 2011/8/12 Conal Elliott co...@conal.net Note that data-reify will only find *some* common/equal sub-expressions, namely the pointer-equal ones. In all of my code-generating (deep) DSLs, it's been

Re: [Haskell-cafe] fyi GHC 7.2.1 release on the benchmarks game

2011-08-12 Thread Chris Smith
On Fri, 2011-08-12 at 11:44 -0500, austin seipp wrote: 2) I noticed `-fvia-C` has now gone away [...] I can't forsee the potential performance ramifications, but frankly -fvia-C has been deprecated/not-advised-for-use for quite a while now, and I wonder how many of these programs just have

Re: [Haskell-cafe] fyi GHC 7.2.1 release on the benchmarks game

2011-08-12 Thread Henning Thielemann
On 12.08.2011 18:44, austin seipp wrote: Hello Isaac, On Fri, Aug 12, 2011 at 10:18 AM, Isaac Gouyigo...@yahoo.com wrote: 1) Some of the GHC programs contributed to the benchmarks game have problems with recent GHC releases - meteor-contest #5 - Ambiguous occurrence `permutations'

Re: [Haskell-cafe] fyi GHC 7.2.1 release on the benchmarks game

2011-08-12 Thread Isaac Gouy
--- On Fri, 8/12/11, austin seipp a...@hacks.yi.org wrote: Thanks, I do like easy fixes :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Conal Elliott
yes. On Fri, Aug 12, 2011 at 11:02 AM, Anton Kholomiov anton.kholom...@gmail.com wrote: Do you mean that x and y in x = a + 1 y = a + 1 are different from data-reify point of view? 2011/8/12 Conal Elliott co...@conal.net Note that data-reify will only find *some* common/equal

[Haskell-cafe] type-class inference

2011-08-12 Thread Patrick Browne
Hi, Why does the Haskell :type command only sometimes print the type-class? Should I expect type-class inference as well as type inference? Maybe the type-class is inferred where possible, but not always printed? Thanks, Pat -- Code k x = x + 3 data T = T class A a where g::a - a g a = a

Re: [Haskell-cafe] type-class inference

2011-08-12 Thread Chris Smith
On Fri, 2011-08-12 at 23:52 +0100, Patrick Browne wrote: -- Second in the case of a method of a type class. -- Inferred Num *Main :t g 3 g 3 :: forall t. (A t, Num t) = t -- Did not print class A. *Main :t g T g T :: T -- Did not print any class. This is because you already know that T

Re: [Haskell-cafe] type-class inference

2011-08-12 Thread Brandon Allbery
On Fri, Aug 12, 2011 at 18:52, Patrick Browne patrick.bro...@dit.ie wrote: Why does the Haskell :type command only sometimes print the type-class? Haskell infers the most specific type applicable. If the most specific it can get is a typeclass, that's what it produces; if it can infer an

Re: [Haskell-cafe] type-class inference

2011-08-12 Thread Brandon Allbery
On Fri, Aug 12, 2011 at 19:08, Brandon Allbery allber...@gmail.com wrote: On Fri, Aug 12, 2011 at 18:52, Patrick Browne patrick.bro...@dit.iewrote: Why does the Haskell :type command only sometimes print the type-class? Haskell infers the most specific type applicable. If the most specific

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread wren ng thornton
On 8/12/11 12:52 PM, Anton Kholomiov wrote: Just to make it explicit, is it \a i - let t = a ! i in if i= 0 then t else if i 0 then t + a ! (i-1) else bad idea, because of last else-case? Can it be mended with one

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Levent Erkok
On 8/12/2011 10:30 AM, Conal Elliott wrote: Note that data-reify will only find *some* common/equal sub-expressions, namely the pointer-equal ones. In all of my code-generating (deep) DSLs, it's been very important for efficiency to also pull out equal-but-pointer-unequal expressions. -

Re: [Haskell-cafe] library on common sub-expression elimination?

2011-08-12 Thread Vinod Grover
in let t= a!i a!i might be out of bounds ? On Fri, Aug 12, 2011 at 9:52 AM, Anton Kholomiov anton.kholom...@gmail.comwrote: Just to make it explicit, is it \a i - let t = a ! i in if i = 0 then t else if i 0 then t + a ! (i-1)