Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Salvatore Insalaco
2008/5/22 Marc Weber [EMAIL PROTECTED]: I'd like to illustrate two different ideas using a small example: (A) data CD = CD { title :: String, tracks :: [ Track ] } data Track = Track { track :: String, cd :: CD } data PDB = PDB { cds :: Set CD, tracks :: Set Track }

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
On Thu, May 22, 2008 at 08:16:54AM +0200, Salvatore Insalaco wrote: 2008/5/22 Marc Weber [EMAIL PROTECTED]: I'd like to illustrate two different ideas using a small example: (A) data CD = CD { title :: String, tracks :: [ Track ] } data Track = Track { track :: String, cd ::

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
On Wed, May 21, 2008 at 06:07:15PM -0700, Dan Weston wrote: Consider SQLite [1], which is a software library that implements a [..] It has a C API which you can wrap as needed with the FFI, and you wouldn't need more than a dozen or so functions to start with (it understands SQL too).

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Ketil Malde
Salvatore Insalaco [EMAIL PROTECTED] writes: This doesn't look like a relational structure at all in Haskell. I believe you are abusing terminology here. 'Relation' refers to a table (since it represents a subset of AxBxC.., i.e. a relation), not to references between tables. Mutability and

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
On Thu, May 22, 2008 at 10:56:03AM +0200, Ketil Malde wrote: Salvatore Insalaco [EMAIL PROTECTED] writes: This doesn't look like a relational structure at all in Haskell. I believe you are abusing terminology here. 'Relation' refers to a Yes. Sorry. I thought the relational in relational

Re: [Haskell-cafe] Ubuntu and ghc

2008-05-22 Thread Duncan Coutts
On Wed, 2008-05-21 at 17:32 -0500, Galchin, Vasili wrote: Hello, https://bugs.launchpad.net/ubuntu/+source/gtk2hs/+bug/229489 this is almost identical to my problem. I am just trying to help others on this list who are using Ubuntu Linux to avoid my predicament! I had that problem

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Salvatore Insalaco
Consider let x = Cd ... forkIO $ ( do something with x } -- (1) print x -- (2) How can ghc know when running line (2) that (1) hasen't changed the record? I see two solutions: a) give the forked process a copy (Then my design will collapse) but this is expensive to copy data without

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
Hi Salvatore On Thu, May 22, 2008 at 11:01:01AM +0200, Salvatore Insalaco wrote: Consider let x = Cd ... forkIO $ ( do something with x } -- (1) print x -- (2) How can ghc know when running line (2) that (1) hasen't changed the record? I see two solutions: a) give the forked

Re: [Haskell-cafe] Ubuntu and ghc

2008-05-22 Thread Claus Reinke
https://bugs.launchpad.net/ubuntu/+source/gtk2hs/+bug/229489 this is almost identical to my problem. I am just trying to help others on this list who are using Ubuntu Linux to avoid my predicament! I had that problem upgrading too. I posted a workaround:

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Salvatore Insalaco
2008/5/22 Marc Weber [EMAIL PROTECTED]: So in haskell it would look like this: let updatedCd = 0x22 CD (0x6 My song) (0x20 ( 0x23 : ...) updatedTrack = 0x23 Track ( 0x21 updated track title ) 0x22 in (0x27) DB (0x24 (updatedCd:otherCds)) (0x25

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
On Thu, May 22, 2008 at 12:48:42PM +0200, Salvatore Insalaco wrote: 2008/5/22 Marc Weber [EMAIL PROTECTED]: So in haskell it would look like this: let updatedCd = 0x22 CD (0x6 My song) (0x20 ( 0x23 : ...) updatedTrack = 0x23 Track ( 0x21 updated track title ) 0x22

[Haskell-cafe] Network.CGI and error handling

2008-05-22 Thread Ketil Malde
Hi, I'm trying to implement a CGI, but I have encountered some problems with handling program errors properly. I think it boils down to this: The first program from the documentation at http://hackage.haskell.org/packages/archive/cgi/3001.1.5.2/doc/html/Network-CGI.html import Network.CGI

[Haskell-cafe] A chance to share your experience

2008-05-22 Thread Simon Peyton-Jones
Friends I know for a fact that many of you are using Haskell successfully for real applications. Yet none of you have sent me an offer of a presentation at the Commercial Users of Functional Programming workshop, which happens in late Sept. I'm the program co-chair, and I confidently

Re: [Haskell-cafe] Newbie: State monad example questions

2008-05-22 Thread Olivier Boudry
On Wed, May 21, 2008 at 6:19 PM, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote: -- Then we can use this State object (returned by getAny) in a function generating random values such as: makeRnd :: StdGen - (Int, StdGen) makeRnd = runState (do y - getAny

Re: [Haskell-cafe] Newbie: State monad example questions

2008-05-22 Thread Eric Stansifer
So, are there any other simple motivating examples that show what state is really good for? Here's an example from some code that I'm (trying to) write; I am writing a DSL for the Povray Scene Description Language. This part of my program creates a `String' which holds a piece of Povray SDL

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Marc Weber
On Thu, May 22, 2008 at 03:34:36PM +0200, Marc Weber wrote: On Thu, May 22, 2008 at 09:11:28AM -0400, Isaac Dupree wrote: to whoever in this thread hasn't realized it: Map String (Map Int Foo) == Map (String,Int) Foo (at least to an approximation) There is another difference if you want

Re: [Haskell-cafe] relational data representation in memory using haskell?

2008-05-22 Thread Isaac Dupree
Marc Weber wrote: On Thu, May 22, 2008 at 03:34:36PM +0200, Marc Weber wrote: On Thu, May 22, 2008 at 09:11:28AM -0400, Isaac Dupree wrote: to whoever in this thread hasn't realized it: Map String (Map Int Foo) == Map (String,Int) Foo (at least to an approximation) There is another

[Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-22 Thread Krasimir Angelov
Hello Guys, We have Data.Tree in the standard libraries for a long time but for some reason we still don't have standard implementation for Zipper. I wrote recently one implementation for Yi but there are many other versions hanging around. At least I know for some. I propose to add one in the

[Haskell-cafe] Re: Network.CGI and error handling

2008-05-22 Thread Ketil Malde
Since Björn Bringert suggested (on IRC) the problem could be due to laziness, and that I should force the result string before giving it to output, I've been playing around a bit. (The program is somewhat more involved than the short test I provided earlier, but available on request). Without

Re: [Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-22 Thread Conal Elliott
Hi Krasimir, I had a long exchange with chessguy about this interface, suggesting a significant change in style, simplifying the type. (Incidentally, the change removed the State and hence mtl dependence.) The conversation is on http://tunes.org/~nef/logs/haskell/08.05.17, starting with

RE: [Haskell-cafe] Re: MD5 performance optimizations, and GHC -via-C producing segfaulting binary

2008-05-22 Thread Simon Peyton-Jones
| I'm confused. GHC of course unboxes strict fields of primitive data types. | | {-# OPTIONS -O2 -fvia-C -optc-O2 -funbox-strict-fields #-} | | ... but only when you give -funbox-strict-fields, as there, or UNPACK. | The point is that it never loses sharing to unbox a strict Int field |

[Haskell-cafe] What to do when GHC works, RUNGHC fails

2008-05-22 Thread Peter Verswyvelen
I'm experimenting creating a Cabal script on Windows that installs a module that refers to some DLLs (freetype, png, ...) via C wrappers When configuring, building, and installing using cabal, a test program that uses this installed module runs fine when compiled with GHC --make, but fails

Re: [Haskell-cafe] Newbie: State monad example questions

2008-05-22 Thread David Menendez
2008/5/22 Olivier Boudry [EMAIL PROTECTED]: On Wed, May 21, 2008 at 6:19 PM, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote: -- Then we can use this State object (returned by getAny) in a function generating random values such as: makeRnd :: StdGen - (Int, StdGen) makeRnd = runState (do

[Haskell-cafe] Re: Network.CGI and error handling

2008-05-22 Thread Ketil Malde
Ketil Malde [EMAIL PROTECTED] writes: Since Björn Bringert suggested (on IRC) the problem could be due to laziness [..] Does anybody else have it working? I found that other person, and he is us. I played around some more, and thought -- just to not leave any stone unturned -- that I should

Re: [Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-22 Thread Conal Elliott
* Every definition of tp I meant of type, forgetting that my emacs abbrevs don't expand in gmail. On Thu, May 22, 2008 at 2:13 PM, Conal Elliott [EMAIL PROTECTED] wrote: Hi Krasimir, I had a long exchange with chessguy about this interface, suggesting a significant change in style,

Re: [Haskell-cafe] Re: MD5 performance optimizations, and GHC -via-C producing segfaulting binary

2008-05-22 Thread Isaac Dupree
Simon Peyton-Jones wrote: | [1] I'm not sure if this is true... if it has to rebox the Int, you get | another copy floating around, not the original, right? Correct. If you have data T = MkT {-# UNPACK #-} !Int then given case x of { MkT y - h y } then GHC must re-box the 'y'

Re: [Haskell-cafe] whhaskell on osx 10.5

2008-05-22 Thread Benjamin L. Russell
wxHaskell - Building - MacOS X (http://wxhaskell.sourceforge.net/building-macosx.html): Due to complicated MacOS X restrictions, graphical wxHaskell applications do not work directly when used from GHCi. Fortunately, Wolfgang Thaller has kindly provided an ingenious Haskell module that