[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

Re: [Haskell-cafe] Re: Bi-directional Maps

2007-08-20 Thread Rich Neswold
On 8/20/07, apfelmus [EMAIL PROTECTED] wrote: Andrew Wagner wrote: It occurred to me that it would be useful to explicitly have a Bi-directional Map, which does the maintenance of keeping the Maps synchronized behind the scenes. Thus, Bimap was born! ... most of the map functions

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

2007-08-20 Thread Stefan O'Rear
On Mon, Aug 20, 2007 at 05:27:04AM -0700, 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

Re: [Haskell-cafe] Parsing binary data.

2007-08-20 Thread Adam Langley
On 8/19/07, Matthew Sackman [EMAIL PROTECTED] wrote: But it's vastly harder to do that for floats / non-integers. Now I know that the number classes in the Prelude are basically broken anyway and all really need rewriting, but it does seem completely arbitrary that Words somehow are only

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 Hartman
Take a look at the Cabal.cabal file, how this is solved, atm. where is this, how can I take a look at it? The next release of Cabal (and the current HEAD) supports conditionals I couldn't install head, but since I'm running 6.7, do I already have it? [EMAIL

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 Neil Mitchell
Hi Distribution/Simple/InstallDirs.hs:267:36: Not in scope: `dropDrive' [EMAIL PROTECTED]:~/installs/cabal-head/caballs -l `which ghc` lrwxrwxrwx 1 root root 31 2007-08-20 11:08 /usr/local/bin/ghc - /usr/local/bin/ghc-6.7.20070816 You'll need to upgrade the filepath library as well,

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

2007-08-20 Thread Stefan O'Rear
On Mon, Aug 20, 2007 at 11:21:01AM -0500, 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

Re: [Haskell-cafe] GHC optimisations

2007-08-20 Thread Stefan O'Rear
On Mon, Aug 20, 2007 at 06:30:27PM +0100, Andrew Coppin wrote: 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

RE: [Haskell-cafe] GHC optimisations

2007-08-20 Thread Simon Peyton-Jones
GHC does some constant folding, but little by way of strength reduction, or using shifts instead of multiplication. It's pretty easy to add more: it's all done in a single module. Look at primOpRules in the module PrelRules. Patches welcome! But please also supply test-suite tests that check

[Haskell-cafe] Re: Parsing binary data.

2007-08-20 Thread Aaron Denney
On 2007-08-19, Matthew Sackman [EMAIL PROTECTED] wrote: Recently, Adam Langley responded so: 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

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

2007-08-20 Thread Dan Piponi
On 8/20/07, David Ritchie MacIver [EMAIL PROTECTED] wrote: I was playing with some code for compiling regular expressions to finite state machines and I ran into the following problem. I've met exactly the same problem myself and you got me interested in it again. I think the tricky part isn't

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

2007-08-20 Thread Stefan O'Rear
On Mon, Aug 20, 2007 at 03:39:28PM -0700, Dan Piponi wrote: On 8/20/07, David Ritchie MacIver [EMAIL PROTECTED] wrote: I was playing with some code for compiling regular expressions to finite state machines and I ran into the following problem. I've met exactly the same problem myself and

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

2007-08-20 Thread Levi Stephen
Al Falloon wrote: Maybe I am misunderstanding your requirements, but it seems to me that the simplest solution would be best in this case: data Widget = BlogWidget [Article] | TextWidget String | MenuWiget Menu | Rows Spacing [Widget] | Columns Spacing [Widget] You can also

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 20.58, Thomas Hartman wrote: Take a look at the Cabal.cabal file, how this is solved, atm. where is this, how can I take a look at it? http://darcs.haskell.org/cabal/Cabal.cabal See below for a little more explaination. The next release of Cabal (and the current

[Haskell-cafe] #haskell irc channel reaches 400 users

2007-08-20 Thread Donald Bruce Stewart
A small announcement :) 5 1/2 years after its inception, under the guiding hand of Shae Erisson (aka shapr), the #haskell IRC channel[1] on freenode has finally reached 400 users! To chart the growth, we can note that the channel was founded in late 2001, and had slow growth till 2006,

[Haskell-cafe] STM, IO and b-trees

2007-08-20 Thread Ben
for sake of argument, suppose an enterprising haskell newbie wanted to code up concurrent b-trees (really b-link trees) in haskell. if i am understanding STM correctly, it will NOT help in any way with the implementation, because of the IO-intensive nature of the algorithms? so i will have to

Re: [Haskell-cafe] STM, IO and b-trees

2007-08-20 Thread Thomas Conway
On 8/21/07, Ben [EMAIL PROTECTED] wrote: for sake of argument, suppose an enterprising haskell newbie wanted to code up concurrent b-trees (really b-link trees) in haskell. if i am understanding STM correctly, it will NOT help in any way with the implementation, because of the IO-intensive

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

2007-08-20 Thread Bertram Felgenhauer
David Ritchie MacIver wrote: Essentially I have data FSM = State { transitions :: (Map Char FSM) } and transitions' :: Regexp - Map Char Regexp I want to lift this so that the Regexps become states of the finite state machine (while making sure I set up a loop in the data structure).