[Haskell-cafe] So far, so good! Until... (Haskell 98 Report questions)

2007-08-17 Thread Ian Duncan
... I hit Chapter 3 and started reading about expressions. *If you are able to answer any of these questions, please send me an email. I am very lost and confused in this section, so even one answered question may help greatly.* I actually decided to sit down and figure out the Haskell 98

Re: [Haskell-cafe] So far, so good! Until... (Haskell 98 Report questions)

2007-08-17 Thread Christopher L Conway
Ian, This is all programming language parsing jargon. If the Wikipedia doesn't help (try http://en.wikipedia.org/wiki/Formal_grammar), I recommend the first few chapters of Aho, Sethi, Ullman's Compilers: Principles, Techniques, and Tools aka the dragon book, or any good book on compilers, e.g.,

Re: [Haskell-cafe] So far, so good! Until... (Haskell 98 Report questions)

2007-08-17 Thread Andy Gimblett
On Fri, Aug 17, 2007 at 04:50:02AM -0700, Ian Duncan wrote: So here's my list of questions so far: 1. What are nonterminals? 2. What are productions and substitutions? [snip] Sounds to me like you want a book on language design, grammars, parsing, etc. :-) There are many good ones out

[Haskell-cafe] Basic question....

2007-08-17 Thread rodrigo.bonifacio
Hi all. I want to create the following polymorphic type (EnvItem) that we can apply two functions (envKey and envValue). I tried the following: type Key = String data EnvItem a = EnvItem (Key, a) envKey :: EnvItem (Key, a) - String envKey EnvItem (key, value) = key envValue ::

Re: [Haskell-cafe] Basic question....

2007-08-17 Thread Brandon S. Allbery KF8NH
On Aug 17, 2007, at 9:11 , rodrigo.bonifacio wrote: envKey :: EnvItem (Key, a) - String envKey EnvItem (key, value) = key envValue :: EnvValue(Key, a) - a envValue EnvItem (key, value) = value But this is resulting in the error: [Constructor EnvItem must have exactly 1 argument in

Re: [Haskell-cafe] Basic question....

2007-08-17 Thread Janis Voigtlaender
- Ursprüngliche Nachricht - Von: rodrigo.bonifacio [EMAIL PROTECTED] Datum: Freitag, August 17, 2007 3:11 pm Betreff: [Haskell-cafe] Basic question Hi all. I want to create the following polymorphic type (EnvItem) that we can apply two functions (envKey and envValue). I tried

Re: [Haskell-cafe] Basic question....

2007-08-17 Thread Chaddaï Fouché
Not only does you lack some parens around your patterns, your function types are wrong : type Key = String data EnvItem a = EnvItem (Key, a) envKey :: EnvItem a - String envKey (EnvItem (key, value)) = key envValue :: EnvItem a - a envValue (EnvItem (key, value)) = value -- Jedaï

[Haskell-cafe] Re: I'm stuck in my thought experiment

2007-08-17 Thread Al Falloon
Levi Stephen wrote: Hi, Apologies for a long post that may not be totally clear. I was thinking through a problem and how the data might be represented in Haskell. I'm now stuck and frustrated. Now, I'm not even sure whether I'm on the right track (I might still be thinking too OO).

Re: [Haskell-cafe] Re: Basic question....

2007-08-17 Thread Chaddaï Fouché
17 Aug 2007 14:44:28 +0100, Jon Fairbairn [EMAIL PROTECTED]: Why not data EnvItem a = EnvItem {key:: Key, value:: a} It's the real solution, but I feel it was worthwhile to underscore the other mistakes (often encountered by the newbies) in types and parameters. -- Jedaï

Re: [Haskell-cafe] defining last using foldr

2007-08-17 Thread Kurt Hutchinson
On 8/16/07, ok [EMAIL PROTECTED] wrote: We're going to have to keep track of whether we have a last element or not. The obvious candidate for this is Maybe x. Initially there is no element, Nothing. f x Empty = Just x f x (Just y) = Just y This picks up a new value (x) when there

Re: [Haskell-cafe] Looking at program execution

2007-08-17 Thread Thomas Hartman
[EMAIL PROTECTED]:~cat test.hs import Debug.Trace foo = foldl (\first second - (trace ( first: ++ ( show first) ) first) + (trace ( second: ++ (show second) ) second) ) 0 [1,2,3] bar = foldl (+) traceIt x = trace (\nTraceIt:\n++show x++\n) x [EMAIL PROTECTED]:~ghc -e foo test.hs first:

[Haskell-cafe] Very fast searching of byte strings

2007-08-17 Thread ChrisK
Post the the library mailing list at [1] is the Boyer-Moore algorithm implemented for strict and lazy bytestrings (and combinations thereof). It finds all the overlapping instances of the pattern inside the target. I have performance tuned it. But the performance for searching a strict

Re: [Haskell-cafe] Diagnosing stack overflow

2007-08-17 Thread Justin Bailey
On 8/16/07, Matthew Brecknell [EMAIL PROTECTED] wrote: However, it's possible that your use of this function is forcing evaluation of a deeply-nested thunk you've created somewhere else (as print does in the foldl example). Thank you for the detailed and helpful reply. I was led to this

Re: [Haskell-cafe] Re: Diagnosing stack overflow

2007-08-17 Thread Justin Bailey
On 8/17/07, apfelmus [EMAIL PROTECTED] wrote: Extracting the head and tail of ss with a let statement could lead to a huge unevaluated expression like rest = tail (tail (tail (...))) Even though they are probably forced, would breaking the head and tail apart via pattern-matching or a

Re: [Haskell-cafe] Looking at program execution

2007-08-17 Thread Thomas Hartman
or actually just... [EMAIL PROTECTED]:~cat test.hs import Debug.Trace foo = foldl (\first second - trace ( ( show first) ++ (+) ++ (show second ) ) ( first + second) ) 0 [1,2,3] [EMAIL PROTECTED]:~ghc -e foo test.hs 0+1 1+2 3+3 6 [EMAIL PROTECTED]:~ is probably better Thomas Hartman

Re: [Haskell-cafe] Basic question....

2007-08-17 Thread Brent Yorgey
On 8/17/07, rodrigo.bonifacio [EMAIL PROTECTED] wrote: Hi all. I want to create the following polymorphic type (EnvItem) that we can apply two functions (envKey and envValue). I tried the following: type Key = String data EnvItem a = EnvItem (Key, a) envKey :: EnvItem (Key, a) -

[Haskell-cafe] Re: Diagnosing stack overflow

2007-08-17 Thread apfelmus
Justin Bailey wrote: apfelmus wrote: Extracting the head and tail of ss with a let statement could lead to a huge unevaluated expression like rest = tail (tail (tail (...))) Even though they are probably forced, would breaking the head and tail apart via pattern-matching or a case

Re: [Haskell-cafe] Basic question....

2007-08-17 Thread Bryan Burgers
On 8/17/07, rodrigo.bonifacio [EMAIL PROTECTED] wrote: Hi all. I want to create the following polymorphic type (EnvItem) that we can apply two functions (envKey and envValue). I tried the following: type Key = String data EnvItem a = EnvItem (Key, a) envKey :: EnvItem (Key, a) -

[Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7

2007-08-17 Thread Thomas Hartman
I'm trying to build the latest regex base, which is required for the other regex packages under ghc 6.7 It complains that it can't find Data.Sequence, because it's in a hidden module containers. I added containers to the cabal depends as can be seen in the grep below. And containers isn't

Re: [Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7

2007-08-17 Thread Stefan O'Rear
On Fri, Aug 17, 2007 at 02:40:33PM -0400, Thomas Hartman wrote: I'm trying to build the latest regex base, which is required for the other regex packages under ghc 6.7 It complains that it can't find Data.Sequence, because it's in a hidden module containers. I added containers to the cabal

[Haskell-cafe] Remember the future

2007-08-17 Thread Andrew Coppin
I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] trouble building regex-base 0.91 on ghc 6.7

2007-08-17 Thread Thomas Hartman
thanks stefan, I did remember that discussion (actually also an answer to a question I asked.) I got from that that previous help that I had to edit the cabal file. The problem here, as you say, is that I had not re-run runghc Setup.hs configure. thanks, thomas. Stefan O'Rear [EMAIL

[Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Thomas Hartman
trying to compile regex-tdfa, I ran into another issue. (earlier I had a cabal problem but that's resolved.) there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 import GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#) so the fresh darcs regex tdfa

Re: [Haskell-cafe] GHC linking problems

2007-08-17 Thread SevenThunders
Did I find a bug cabal? I have attempted to fix the problem Main.c:(.text+0x22): undefined reference to `__stginit_ZCMain' by compiling my Haskell library using the flag -no-hs-main. One would think that this would make sense if the library is to be used by an external C program. However I

Re: [Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Stefan O'Rear
On Fri, Aug 17, 2007 at 04:27:29PM -0400, Thomas Hartman wrote: trying to compile regex-tdfa, I ran into another issue. (earlier I had a cabal problem but that's resolved.) there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 import

[Haskell-cafe] Re: Diagnosing stack overflow

2007-08-17 Thread Joe Buehler
Matthew Brecknell wrote: The key point of the example is that foldl itself doesn't need any of the intermediate values of the accumulator, so these just build up into a deeply-nested unevaluated thunk. When print finally demands an integer, the run-time pushes a stack frame for each level of

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Andrew Coppin
Gwern Branwen wrote: On 0, Andrew Coppin [EMAIL PROTECTED] scribbled: I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? Take a look at issue 6 of The Monad Reader; search for time

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Dan Piponi
On 8/17/07, Andrew Coppin [EMAIL PROTECTED] wrote: I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? Suppose you buy into the notion that monads sequence actions. Then consider the following

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Dan Piponi
On 8/17/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/17/07, Andrew Coppin [EMAIL PROTECTED] wrote: That sounds completely absurd to me... can anybody explain? Except...you can switch on ghc's special time travel features... On reflection I decided my example isn't very convincing. For one

Re: [Haskell-cafe] Re: Diagnosing stack overflow

2007-08-17 Thread Bryan O'Sullivan
Joe Buehler wrote: What is the point in building this huge thunk if it can't be evaluated without a stack overflow? It's not that there's a point to it, it's just the behaviour of foldl. Hence you shouldn't be using foldl. GHC's strictness analyser can sometimes save you from yourself if

[Haskell-cafe] What to do about an absent package maintainer?

2007-08-17 Thread Adam Langley
The HsOpenSSL package[1] is good work, but the author doesn't respond to email(*). I've a bunch of darcs patches to add tests, DSA support and fast Integer - BIGNUM functions. Can I use my Hackage account to upload version 0.2 if someone else uploaded 0.1? It is reasonable? I'm guessing that this

Re: [Haskell-cafe] defining last using foldr

2007-08-17 Thread Chaddaï Fouché
For a really good article to see how foldr is in fact very powerful and how you can make it do some funny tricks, see the Monad.Reader 6th issue : http://www.haskell.org/sitewiki/images/1/14/TMR-Issue6.pdf I'll point out that you can write a lazy dropWhile with foldr in the style of the first

Re: [Haskell-cafe] defining last using foldr

2007-08-17 Thread Chaddaï Fouché
2007/8/18, Chaddaï Fouché [EMAIL PROTECTED]: For a really good article to see how foldr is in fact very powerful and how you can make it do some funny tricks, see the Monad.Reader 6th issue : http://www.haskell.org/sitewiki/images/1/14/TMR-Issue6.pdf I just saw this was already linked in

Re: [Haskell-cafe] monte carlo trouble

2007-08-17 Thread Paul Johnson
I finally decided to actually solve the problem, and I'm sorry to say I was on the wrong track. ListT won't do it on its own: you actually need a custom monad that does the random pick in the bind operation. Attached are a module to solve the problem and a Main module that tests it. I hope

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread jerzy . karczmarczuk
Andrew Coppin writes: I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? Actually, borrowing from the future - in an interpretation which is close to my own interests - doesn't need

Re: [Haskell-cafe] Remember the future

2007-08-17 Thread Paul Johnson
[EMAIL PROTECTED] wrote: Andrew Coppin writes: I've seen comments in various places that monads allow you to borrow things from the future. That sounds completely absurd to me... can anybody explain? Actually, borrowing from the future - in an interpretation which is close to my own

Re: [Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Thomas Hartman
Thanks Stefan. I got regex tdfa to compile on 6.7. FWIW, here's a patch, generated with darcs whatsnew against a fresh unzip of regex tdfa 0.92 I didn't patch against the darcs head because this uses a language progma in {-# options #-} in some file*, which ghc 6.7 didn't know what to do with,

Re: [Haskell-cafe] trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-17 Thread Stefan O'Rear
On Fri, Aug 17, 2007 at 08:13:55PM -0400, Thomas Hartman wrote: Thanks Stefan. I got regex tdfa to compile on 6.7. FWIW, here's a patch, generated with darcs whatsnew against a fresh unzip of regex tdfa 0.92 I didn't patch against the darcs head because this uses a language progma in {-#

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Lennart Augustsson
On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Lennart Augustsson wrote: And as a previous poster showed, ghc does concatenate strings. And Haskell (as in the current language definition) does not. I was talking about Haskell. Haskell says nothing about compile time or run time in

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-17 Thread Tim Chevalier
On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Incidentally, GHC's type checker is Turing complete. You already have as much static evaluation as is practically possible. You already knew that. I don't see how the first statement implies the second. Cheers, Tim -- Tim Chevalier *

Re: [Haskell-cafe] Re: Bathroom reading

2007-08-17 Thread Albert Y. C. Lai
Dan Weston wrote: I hate to be a party pooper, but isn't this just: f = foldr (\a z - (a:snd z,fst z)) ([],[]) This takes less time to grok and takes no longer to run. For each type with exported constructors, one can always write deconstructors for it, if not already found in libraries.

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-18 Thread Lennart Augustsson
I agree. Computation on the type level does not imply computation on the value level. On 8/18/07, Tim Chevalier [EMAIL PROTECTED] wrote: On 8/17/07, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Incidentally, GHC's type checker is Turing complete. You already have as much static evaluation as is

Re: [Haskell-cafe] Remember the future

2007-08-18 Thread Andrew Coppin
Dan Piponi wrote: On 8/17/07, Dan Piponi [EMAIL PROTECTED] wrote: On 8/17/07, Andrew Coppin [EMAIL PROTECTED] wrote: That sounds completely absurd to me... can anybody explain? Except...you can switch on ghc's special time travel features... On reflection I decided my

Re: [Haskell-cafe] Diagnosing stack overflow

2007-08-18 Thread Matthew Brecknell
Justin Bailey: Would retainer profiling help me see what was building up this large thunk/closure? I'm not really familiar enough with GHC's profiling to answer that, but I'll take a guess. My guess is that profiling will only sometimes be useful in diagnosing stack overflows, because I

[Haskell-cafe] Re: Remember the future

2007-08-18 Thread Benjamin Franksen
Andrew Coppin wrote: Surely all this means is that the magical mdo keyword makes the compiler arbitrarily reorder the expression...? It is not magical but simple syntactic sugar. And no, the compiler does not 'arbitrarily reorder' anything, you do the same in any imperative language with

Re: [Haskell-cafe] Remember the future

2007-08-18 Thread Dan Piponi
On 8/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Surely all this means is that the magical mdo keyword makes the compiler arbitrarily reorder the expression...? What mdo actually does is described here: http://www.cse.ogi.edu/PacSoft/projects/rmb/mdo.pdf My last example desugars to: test =

[Haskell-cafe] Parsing binary data.

2007-08-18 Thread Peter Cai
Hi all, Recently I am considering doing part of my job using Haskell. My duty is writing a network server which talks to another server through a binary based private protocol. As the old version of this component is written in C, it's very natural that this protocol is base on C structure

Re: [Haskell-cafe] Sudoku Solver

2007-08-18 Thread Wouter Swierstra
I'm a little surprised no one's tried a parallel solution yet, actually. We've got an SMP runtime for a reason, people! I hacked up a parallel version of Richard Bird's function pearl solver: http://www.haskell.org/sitewiki/images/1/12/SudokuWss.hs It not really optimized, but there are a

Re: [Haskell-cafe] Parsing binary data.

2007-08-18 Thread Marc Weber
As I am a newbie to Haskell, I am not sure how to handle this problem with less work. Do you have any ideas about this problem? Thanks in advance! Have a look at http://haskell.org/haskellwiki/Applications_and_libraries/Data_structures section 3 (IO) -

[Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-18 Thread Peter Verswyvelen
When reading an article about tail recursion (http://themechanicalbride.blogspot.com/2007/04/haskell-for-c-3-programmers. html) I came across the follow statements: If you can write a non-recursive function that uses the colon syntax it is probably better than a tail recursive one that doesn't.

Re: [Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-18 Thread Derek Elkins
On Sat, 2007-08-18 at 20:35 +0200, Peter Verswyvelen wrote: When reading an article about tail recursion (http://themechanicalbride.blogspot.com/2007/04/haskell-for-c-3-programmers. html) I came across the follow statements: If you can write a non-recursive function that uses the colon

[Haskell-cafe] Chessboard-building in Haskell

2007-08-18 Thread Andrew Wagner
I've started a blog series on writing a chess engine in Haskell. I just posted the second blog entry today: http://sequence.complete.org/node/361 I suspect there's more work to be done on that function, though. It seems like there should be a nice way to remove that flip in apply. Any thoughts?

[Haskell-cafe] Old editions of The Monad.Reader lost

2007-08-18 Thread Henk-Jan van Tuyl
L.S., Now that all hawiki pages have been removed, we have lost some valuable information. For example The Monad.Reader; on http://www.haskell.org/haskellwiki/The_Monad.Reader it says: Older editions can be found on the old Haskell wiki – they haven't been included here for licensing

Re: [Haskell-cafe] Chessboard-building in Haskell

2007-08-18 Thread Twan van Laarhoven
Andrew Wagner wrote: I've started a blog series on writing a chess engine in Haskell. I just posted the second blog entry today: http://sequence.complete.org/node/361 I suspect there's more work to be done on that function, though. It seems like there should be a nice way to remove that flip in

[Haskell-cafe] How do I simulate dependent types using phantom types?

2007-08-18 Thread DavidA
Hi, I am trying to implement quadratic fields Q(sqrt d). These are numbers of the form a + b sqrt d, where a and b are rationals, and d is an integer. In an earlier attempt, I tried data QF = QF Integer Rational Rational (see http://www.polyomino.f2s.com/david/haskell/hs/QuadraticField.hs.txt)

Re: [Haskell-cafe] How do I simulate dependent types using phantom types?

2007-08-18 Thread Lennart Augustsson
Use value :: a - Integer On 8/18/07, DavidA [EMAIL PROTECTED] wrote: Hi, I am trying to implement quadratic fields Q(sqrt d). These are numbers of the form a + b sqrt d, where a and b are rationals, and d is an integer. In an earlier attempt, I tried data QF = QF Integer Rational

Re: [Haskell-cafe] How do I simulate dependent types using phantom types?

2007-08-18 Thread Twan van Laarhoven
DavidA wrote: Hi, I am trying to implement quadratic fields Q(sqrt d). These are numbers of the form a + b sqrt d, where a and b are rationals, and d is an integer. ... class IntegerType a where value :: Integer The problem is, this doesn't work. GHC complains: The class method

Re: [Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-18 Thread Chaddaï Fouché
foo n = if n0 then [] else n : foo (n-1) bar n = aux 0 [] where aux i xs = if in then xs else aux (i+1) (i:xs) that foo is more efficient than bar because lazy evaluation of foo just puts the delayed computation in the cdr of the list, while lazy evaluation of bar has to keep track of

[Haskell-cafe] Re: How do I simulate dependent types using phantom types?

2007-08-18 Thread DavidA
Twan van Laarhoven twanvl at gmail.com writes: The solution is to use a dummy parameter: class IntegerType a where value :: a - Integer And call it like: f = value (undefined :: Two) So for instance: instance IntegerType d = Show (QF d) where show (QF a b) = show a ++

Re: [Haskell-cafe] Sudoku Solver

2007-08-18 Thread Jon Harrop
On Saturday 18 August 2007 19:05:04 Wouter Swierstra wrote: I hacked up a parallel version of Richard Bird's function pearl solver: http://www.haskell.org/sitewiki/images/1/12/SudokuWss.hs It not really optimized, but there are a few neat tricks there. Rather than prune the search space by

[Haskell-cafe] Using Apple Spotlight to search for .hs and .lhs files

2007-08-18 Thread Dan Piponi
This isn't really a Haskell question but I'm guessing some Haskell hackers have a solution. MacOS X's Spotlight doesn't seem to be able to search for text in .lhs and .hs files. But it can find text in .txt files. Is there a way of getting Spotlight to treat .lhs and .hs files like .txt files so I

Re: [Haskell-cafe] building a regular polygon

2007-08-19 Thread Radosław Grzanka
2007/8/19, Daniel C. Bastos [EMAIL PROTECTED]: Any help is appreciated. I also had problem with this exercise. However this was more Haskell newbie problem :) If you're feeling lost you can always try google and come up with this blog with solutions to exercises from this book. You should find

RE: [Haskell-cafe] building a regular polygon

2007-08-19 Thread Frank Buss
(*) Exercise 2.2 Define a function regularPolygon :: Int - Side - Shape such that regularPolygon n s is a regular polygon with n sides, each of length s. (Hint: consider using some of Haskell's trigonometric functions, such as sin :: Float - Float, cos :: Float - Float, and tan :: Float

[Haskell-cafe] List comprehension desugaring

2007-08-19 Thread Neil Mitchell
Hi, The Haskell desugaring for list comprehensions is given in: http://haskell.org/onlinereport/exps.html#list-comprehensions All the rules seem to be left to right rewrites, apart from the second one, which seems to be right to left. Is there some deep reason for this, or is this accidental.

[Haskell-cafe] Re: List comprehension desugaring

2007-08-19 Thread Neil Mitchell
Hi Sorry for the noise, I've now realised they are a left to right rewrite system, the second rule is required to set up the base case. Thanks Neil On 8/19/07, Neil Mitchell [EMAIL PROTECTED] wrote: Hi, The Haskell desugaring for list comprehensions is given in:

Re: [Haskell-cafe] Re: Error building takusen with Cabal-1.1.6.2

2007-08-19 Thread Alistair Bayley
Setup.hs:13:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package Cabal-1.1.6.2) This is what I did to make takusen build with ghc-6.6.1: [EMAIL PROTECTED]: .../haskell/takusen_0 darcs whatsnew { hunk ./Setup.hs 13 -import

[Haskell-cafe] GHC optimisations

2007-08-19 Thread Andrew Coppin
Does GHC do stuff like converting (2*) into (shift 1) or converting x + x into 2*x? If I do x * sin 12, is GHC likely to compute sin 12 at compile-time? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Using Apple Spotlight to search for .hs and .lhs files

2007-08-19 Thread alpheccar
Since it is not really Haskell related, I have answered by email. If anyone is interested, don't hesitate to email me. alpheccar. This isn't really a Haskell question but I'm guessing some Haskell hackers have a solution. MacOS X's Spotlight doesn't seem to be able to search for text in .lhs

[Haskell-cafe] Re: List comprehension desugaring

2007-08-19 Thread apfelmus
Neil Mitchell wrote: The Haskell desugaring for list comprehensions is given in: http://haskell.org/onlinereport/exps.html#list-comprehensions All the rules seem to be left to right rewrites, apart from the second one, which seems to be right to left. Is there some deep reason for this, or is

Re: [Haskell-cafe] Re: How do I simulate dependent types using phantom types?

2007-08-19 Thread Bertram Felgenhauer
DavidA wrote: Twan van Laarhoven twanvl at gmail.com writes: The solution is to use a dummy parameter: class IntegerType a where value :: a - Integer Thanks to all respondents for this suggestion. That works great. I prefer a slightly elaborate way, newtype Mark n t = Mark t

[Haskell-cafe] Using Collections: ElemsView and KeysView

2007-08-19 Thread Benjamin Franksen
Hi I am using collections-0.3 and need to perform some operations on keys resp. values of a map. In the concrete implementations there are functions like 'elems' and 'keys' but there is no such thing in Data.Collections. Instead there are the types 'ElemsView' and 'KeysView' and functions

Re: [Haskell-cafe] Parsing binary data.

2007-08-19 Thread Adam Langley
On 8/18/07, Matthew Sackman [EMAIL PROTECTED] wrote: Also, one thing to watch out for is the fact the existing Get and Put instances may not do anything like what you expect. For example, for some reason I expected that the instances of Get and Put for Float and Double would send across the

Re: [Haskell-cafe] GHC optimisations

2007-08-19 Thread Tim Chevalier
On 8/19/07, Andrew Coppin [EMAIL PROTECTED] wrote: Does GHC do stuff like converting (2*) into (shift 1) or converting x + x into 2*x? Hmm, that's an interesting architecture where multiplication is cheaper than addition :-) If I do x * sin 12, is GHC likely to compute sin 12 at

Re: [Haskell-cafe] GHC optimisations

2007-08-19 Thread Stefan O'Rear
On Sun, Aug 19, 2007 at 12:53:07PM +0100, Andrew Coppin wrote: Does GHC do stuff like converting (2*) into (shift 1) or converting x + x into 2*x? For a good time, compile some code which uses even or odd :: Int - Bool using -O2 -fasm -ddump-asm... The compiler *really* shouldn't be using

RE: [Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-19 Thread Peter Verswyvelen
Thanks. I got confused because the StackOverflow link on http://www.haskell.org/haskellwiki/HaWiki_migration is dead. -Original Message- From: Derek Elkins [mailto:[EMAIL PROTECTED] Sent: Saturday, August 18, 2007 8:54 PM To: Peter Verswyvelen Cc: haskell-cafe@haskell.org Subject: Re:

[Haskell-cafe] Re: Interval Arithmetics

2007-08-19 Thread Henning Thielemann
The page http://www.haskell.org/haskellwiki/Applications_and_libraries/Mathematics#Number_representations lists several implementations of several flavours of computable reals, which may be useful for you. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] building a regular polygon

2007-08-19 Thread Rafael Almeida
On 8/19/07, Frank Buss [EMAIL PROTECTED] wrote: (*) Exercise 2.2 Define a function regularPolygon :: Int - Side - Shape such that regularPolygon n s is a regular polygon with n sides, each of length s. (Hint: consider using some of Haskell's trigonometric functions, such as sin ::

[Haskell-cafe] IO in HApps handler ?

2007-08-19 Thread Luc TAESCH
Subject: IO in HApps handler ? I am trying to add a handler that would run an external command in HApps 0.8.8, and I got a type issue I do not know how to get around.. can we have IO in a handler ? testcmdpost.hs:52:8: Couldn't match expected type `Ev st Request' against inferred

[Haskell-cafe] ghc 6.7 /6.8

2007-08-19 Thread Luc TAESCH
Date: Sun, 19 Aug 2007 12:39:50 +0200 Subject: Fwd: ghc 6.7 /6.8 hello. will 6.7 be released, or will only 6.8 be ? ( i.e do you use an even/uneven relesing number convention) -in that case, does the 6.8 branch means the freeze is on, and what would be the target for 6.8 ? Q3/2007 ? Q4 ? (

Re: [Haskell-cafe] ghc 6.7 /6.8

2007-08-19 Thread Neil Mitchell
Hi will 6.7 be released, or will only 6.8 be ? 6.7 is the HEAD branch, 6.8 will be released. -in that case, does the 6.8 branch means the freeze is on, and what would be the target for 6.8 ? Q3/2007 ? Q4 ? Soon, in the next month - according to latest targets/estimates. ( context: I am

[Haskell-cafe] Re: trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-19 Thread ChrisK
Stefan O'Rear wrote: On Fri, Aug 17, 2007 at 04:27:29PM -0400, Thomas Hartman wrote: trying to compile regex-tdfa, I ran into another issue. (earlier I had a cabal problem but that's resolved.) there's a line that won't compile, neither for ghc 6.6.1 nor 6.7 import

Re: [Haskell-cafe] Re: trouble compiling import GHC.Prim(MutableByteArray#, ..... (building regex-tdfa from darcs) -- what's that # sign doing?

2007-08-19 Thread Stefan O'Rear
On Sun, Aug 19, 2007 at 11:25:49PM +0100, ChrisK wrote: #ifdef __GLASGOW_HASKELL__ foreign import ccall unsafe memcpy memcpy :: MutableByteArray# RealWorld - MutableByteArray# RealWorld - Int# - IO () {-# INLINE copySTU #-} copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s))

[Haskell-cafe] Bi-directional Maps

2007-08-19 Thread Andrew Wagner
Hi folks! So, in writing my chess engine, I've been trying to maintain 2 Map objects. One maps squares on the board to Ints, the other maps Ints to actual Pieces. It occurred to me that it would be useful to explicitly have a Bi-directional Map, which does the maintenance of keeping the Maps

RE: [Haskell-cafe] building a regular polygon

2007-08-19 Thread Frank Buss
From: Rafael Almeida [mailto:[EMAIL PROTECTED] I used the cosine law in order to calculate r. After all, s is actually the size of the side of the polygon and not the distance of its vertices from the origin. You are right, my solution was wrong. If you don't mind rounding errors, this is

Re: [Haskell-cafe] IO in HApps handler ?

2007-08-19 Thread Marc Weber
Hi TAESCH, THat's what haskell is good for. It prevents you from doing unsafe things by accident. You must get the source and have a look at the definition of the Ev type: (module HAppS.MACID.Types where:) (Not sure wether this code is most recent or not (Version: 0.8.8)) =

Re: [Haskell-cafe] IO in HApps handler ?

2007-08-19 Thread Tim Newsham
Subject: IO in HApps handler ? I am trying to add a handler that would run an external command in HApps 0.8.8, and I got a type issue I do not know how to get around.. can we have IO in a handler ? http://www.haskell.org/haskellwiki/HAppS_tutorial#Application The MACID monad lets you update

[Haskell-cafe] Re: Bi-directional Maps

2007-08-20 Thread apfelmus
Andrew Wagner wrote: So, in writing my chess engine, I've been trying to maintain 2 Map objects. One maps squares on the board to Ints, the other maps Ints to actual Pieces. It occurred to me that it would be useful to explicitly have a Bi-directional Map, which does the maintenance of keeping

[Haskell-cafe] Tying the knot with unknown keys

2007-08-20 Thread David Ritchie MacIver
I was playing with some code for compiling regular expressions to finite state machines and I ran into the following problem. I've solved it, but I'm not terribly happy with my solution and was wondering if someone could come up with a better one. :-) Essentially I have data FSM = State {

[Haskell-cafe] Re: Using Collections: ElemsView and KeysView

2007-08-20 Thread Jean-Philippe Bernardy
foldr on ElemsView is defined as such: foldr f i (ElemsView c) = foldr (f . snd) i c so, for example: getElementList = toList . ElemViews When I designed this code (some years ago), I didn't like the fold of Map to have the type: fold :: (a - b - b) - b - Map k a - b This just doesn't

[Haskell-cafe] How can I pass IOUArrays to FFI functions?

2007-08-20 Thread Ryan Ingram
I have a C function of type void f ( HsWord32* p0, HsWord32* p1, HsWord32 size ); along with the FFI declaration: foreign import ccall unsafe f :: Ptr Word32 - Ptr Word32 - Word32 - IO () In my Haskell code I have an unboxed IO array of Word32; IOUArray Int Word32. I want to pass the

Re: [Haskell-cafe] How can I pass IOUArrays to FFI functions?

2007-08-20 Thread Spencer Janssen
On Monday 20 August 2007 07:27:04 Ryan Ingram wrote: I have a C function of type void f ( HsWord32* p0, HsWord32* p1, HsWord32 size ); along with the FFI declaration: foreign import ccall unsafe f :: Ptr Word32 - Ptr Word32 - Word32 - IO () In my Haskell code I have an unboxed IO

Re: [Haskell-cafe] Diagnosing stack overflow

2007-08-20 Thread Justin Bailey
On 8/18/07, Matthew Brecknell [EMAIL PROTECTED] wrote: Justin Bailey: Would retainer profiling help me see what was building up this large thunk/closure? I'm not really familiar enough with GHC's profiling to answer that, but I'll take a guess. You're experimental programs have given me

Re: [Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-20 Thread Lanny Ripple
Not really more efficient but plays to the language implementation's strengths. Imagine take 10 $ foo (10^9) and take 10 $ bar (10^9) bar wouldn't evaluate until the 10^9 was done. (And I just ground my laptop to a halt checking that. :) foo on the other hand would run out to 10^6

Re: [Haskell-cafe] Newbie question: Where is StackOverflow on the Wiki?

2007-08-20 Thread Lanny Ripple
Lanny Ripple wrote: Not really more efficient but plays to the language implementation's strengths. Imagine take 10 $ foo (10^9) and take 10 $ bar (10^9) bar wouldn't evaluate until the 10^9 was done. (And I just ground my laptop to a halt checking that. :) foo on the other hand

Re: [Haskell-cafe] Tying the knot with unknown keys

2007-08-20 Thread Bertram Felgenhauer
David Ritchie MacIver wrote: I was playing with some code for compiling regular expressions to finite state machines and I ran into the following problem. I've solved it, but I'm not terribly happy with my solution and was wondering if someone could come up with a better one. :-)

[Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Hartman
cafe, is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility? I just patched HDBC head to compile under ghc 6.7. Unfortunately it now won't compile in 6.6.1. is there a way for build-depends to detect which version of ghc you're on? also I

[Haskell-cafe] cabal install of HDBC-odbc fails on ghc 6.7, -I flag causes problems

2007-08-20 Thread Thomas Hartman
problemw with the -I flag to ghc are causing cabal install to fail for hdbc-odbc (darcs head). man ghc still reports that -I is a valid flag after installing ghc 6.7 from darcs head a couple days ago. I think the problem might be the space after the -I flag (which is bad for both 6.6.1 and

Re: [Haskell-cafe] GHC optimisations

2007-08-20 Thread Andrew Coppin
Stefan O'Rear wrote: On Sun, Aug 19, 2007 at 12:53:07PM +0100, Andrew Coppin wrote: Does GHC do stuff like converting (2*) into (shift 1) or converting x + x into 2*x? For a good time, compile some code which uses even or odd :: Int - Bool using -O2 -fasm -ddump-asm... The compiler

Re: [Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

2007-08-20 Thread Thomas Schilling
On 20 aug 2007, at 18.37, Thomas Hartman wrote: cafe, is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility? I just patched HDBC head to compile under ghc 6.7. Unfortunately it now won't compile in 6.6.1. is there a way for

Re: [Haskell-cafe] can't build haxml under ghc 6.7, says HughesPJ is hidden... but ghc-pkg doesn't say it's hidden...

2007-08-20 Thread Thomas Hartman
so you get $ runghc Setup.hs configure Setup.hs: Multiple description files found. Please use only one of : [HaXml.cabal,HaXml-darcs.cabal] is there a way to specify which cabal file should be used, or do you just have to move a file out out the way with eg mv HaXml.cabal HaXml.cabal.tmp

<    1   2   3   4   5   6   7   8   9   10   >