Re: [Haskell-cafe] Re: Library design question

2008-09-20 Thread David Menendez
On Fri, Sep 19, 2008 at 7:02 PM, Andre Nathan [EMAIL PROTECTED] wrote: On Fri, 2008-09-19 at 23:16 +0200, Daniel Fischer wrote: Yes. What's IO gotta do with it? I did it because of randomIO :( (or what about StateT (Graph a b) (State StdGen) ?). Now there's something I wouldn't have

Re: [Haskell-cafe] Re: Library design question

2008-09-20 Thread Daniel Fischer
Am Samstag, 20. September 2008 08:53 schrieb David Menendez: On Fri, Sep 19, 2008 at 7:02 PM, Andre Nathan [EMAIL PROTECTED] wrote: On Fri, 2008-09-19 at 23:16 +0200, Daniel Fischer wrote: Yes. What's IO gotta do with it? I did it because of randomIO :( (or what about StateT (Graph a

Re: [Haskell-cafe] Re: Library design question

2008-09-20 Thread Andre Nathan
On Sat, 2008-09-20 at 14:56 +0200, Daniel Fischer wrote: modify' f = do s - get put $! f s Or try Control.Monad.State.Strict. Control.Monad.State.Strict did it for me, but the strict modify didn't. I tried using modify' and also randomDouble = do g - get let (r, g') =

Re: [Haskell-cafe] Re: Library design question

2008-09-20 Thread Daniel Fischer
Am Samstag, 20. September 2008 17:46 schrieb Andre Nathan: On Sat, 2008-09-20 at 14:56 +0200, Daniel Fischer wrote: modify' f = do s - get put $! f s Or try Control.Monad.State.Strict. Control.Monad.State.Strict did it for me, but the strict modify didn't. I tried using

[Haskell-cafe] Re: Library design question

2008-09-19 Thread apfelmus
Andre Nathan wrote: I'm trying to write a simple graph library for a project of mine There's also Martin Erwig's functional graph library in Data.Graph.Inductive ( fgl on hackage). Regards, apfelmus ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: Library design question

2008-09-19 Thread Christian Maeder
Duncan Coutts wrote: On Thu, 2008-09-18 at 15:43 -0300, Andre Nathan wrote: My Graph type is the following. data Graph a b = Graph { adjacencies :: Map Int (a, (Map Int b)) , numVertices :: Int , numEdges:: Int } addVertex :: Int - a - State (Graph a b) ()

[Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 10:35 +0200, Christian Maeder wrote: I agree. Duncan's version also looks more atomic to me, [...] OK, so what I have now is addVertex :: Int - a - Graph a b - Graph a b addVertex v l g = Graph adj (numVertices g + 1) (numEdges g) where adj = Map.insert v (l,

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 09:51 +0200, apfelmus wrote: There's also Martin Erwig's functional graph library in Data.Graph.Inductive ( fgl on hackage). I tried it some time ago, but for large graphs it has a very high memory usage. Best, Andre ___

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Daniel Fischer
Am Freitag, 19. September 2008 22:55 schrieb Andre Nathan: On Fri, 2008-09-19 at 10:35 +0200, Christian Maeder wrote: I agree. Duncan's version also looks more atomic to me, [...] OK, so what I have now is addVertex :: Int - a - Graph a b - Graph a b addVertex v l g = Graph adj

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 23:16 +0200, Daniel Fischer wrote: Yes. What's IO gotta do with it? I did it because of randomIO :( (or what about StateT (Graph a b) (State StdGen) ?). Now there's something I wouldn't have thought of... I changed the RandomGraph type to type RandomGraph a b = StateT