Re: [Haskell-cafe] Towards an IO-Comonad that preserves referential transparency (was: "comonads, io" Jan 02, 2003)

2006-11-02 Thread Sven Biedermann
Hello Nick, Am 02.11.2006 um 20:51 schrieb Nicolas Frisby: OI has been lingering in the back of my mind during my own comonadic adventures. Did you enjoy them? One thing that's bothered me is the signature of comain. comain :: OI () -> () If the OI comonad is to represent values "in t

Re: [Haskell-cafe] Finding Memory Leaks

2006-11-02 Thread Donald Bruce Stewart
mattcbro: > > > > Jason Dagit-2 wrote: > > > > > > > > Do any memory leaks show up if you compile with -caf-all when you profile? > > > > Jason > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/li

Re: [Haskell-cafe] Finding Memory Leaks

2006-11-02 Thread SevenThunders
Jason Dagit-2 wrote: > > > > Do any memory leaks show up if you compile with -caf-all when you profile? > > Jason > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > It doesn't

Re: [Haskell-cafe] Finding Memory Leaks

2006-11-02 Thread Jason Dagit
On 11/2/06, SevenThunders <[EMAIL PROTECTED]> wrote: SevenThunders wrote: > > All my code is compiled using the -prof -auto > flag and then run using +RTS -hc -RTS. The resulting plots do not show > a linear increase in heap usage, although the Windows XP operating > system does report such

Re: [Haskell-cafe] Finding Memory Leaks

2006-11-02 Thread SevenThunders
SevenThunders wrote: > > All my code is compiled using the -prof -auto > flag and then run using +RTS -hc -RTS. The resulting plots do not show > a linear increase in heap usage, although the Windows XP operating > system does report such an increase. > > This is either a bug in GHC or

[Haskell-cafe] Very Small Program

2006-11-02 Thread Bernie Pope
On 02/11/2006, at 9:56 PM, [EMAIL PROTECTED] wrote: G'day all. Quoting Bernie Pope <[EMAIL PROTECTED]>: This is a weird example of a pattern binding, and it is surprising (to me) that the syntax is valid. Maybe. But you wouldn't balk at this: numzeroes xs = sum [ 1 | 0 <- xs ] ...e

Re: [Haskell-cafe] Non-integer part of a Double

2006-11-02 Thread Sebastian Sylvan
On 11/2/06, Maurí­cio <[EMAIL PROTECTED]> wrote: Hi, Is there a function to get that? I'm using \x -> x - fromIntegral(floor x) since I was not able to find something better, but I guess I have missed something in the standard library since there are functions with similar funcionality.

[Haskell-cafe] Non-integer part of a Double

2006-11-02 Thread Maurí­cio
Hi, Is there a function to get that? I'm using \x -> x - fromIntegral(floor x) since I was not able to find something better, but I guess I have missed something in the standard library since there are functions with similar funcionality. Thanks, Maurício __

Re: [Haskell-cafe] Decorating a list of strings

2006-11-02 Thread Steve Schafer
On Thu, 02 Nov 2006 12:20:55 -0800, you wrote: >It seems you only need a table of counts of the number of times >the string has occurred previously, which you can have available >on the first pass. > >e.g, >import Data.List >import Data.Map as Map >mark strings = snd $ mapAccumL >(\counts str -> >

Re: [Haskell-cafe] Decorating a list of strings

2006-11-02 Thread Brandon Moore
Steve Schafer wrote: I have a list of text strings: ["Alice", "Bob", "Cindy", "Bob", "Bob", "Dave", "Cindy"] As you can see, some of the strings occur only once; others appear two or more times. I would like to end up with a new list, according to the following rules: 1) If a string occurs o

[Haskell-cafe] Finding Memory Leaks

2006-11-02 Thread Matthew Bromberg
I have a rather complex Haskell program that performs an engineering simulation using a lot of large complex valued matrices. The imperative components of the simulation are written in C and interfaced into Haskell which handles the higher level logic. This has served me fairly well, and I've b

Re: Re: [Haskell-cafe] Towards an IO-Comonad that preserves referential transparency (was: "comonads, io" Jan 02, 2003)

2006-11-02 Thread Nicolas Frisby
OI has been lingering in the back of my mind during my own comonadic adventures. One thing that's bothered me is the signature of comain. comain :: OI () -> () If the OI comonad is to represent values "in the context of the RealWorld", and yet we can have multiple and differing copies of the R

[Haskell-cafe] Decorating a list of strings

2006-11-02 Thread Steve Schafer
I have a list of text strings: ["Alice", "Bob", "Cindy", "Bob", "Bob", "Dave", "Cindy"] As you can see, some of the strings occur only once; others appear two or more times. I would like to end up with a new list, according to the following rules: 1) If a string occurs only once in the origina

Re: [Haskell-cafe] Class

2006-11-02 Thread Sebastian Sylvan
On 11/2/06, Slavomir Kaslev <[EMAIL PROTECTED]> wrote: On 11/2/06, Sebastian Sylvan <[EMAIL PROTECTED]> wrote: > On 11/2/06, Slavomir Kaslev <[EMAIL PROTECTED]> wrote: > > Little by little, I think I am getting closer. > > > > class Show a => Visible a where > > toString :: a -> String > >

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread isto
Hi & no problems (I didn't tell it clearly right away), I modified the code along the comments given by Lemmih and things improved a lot. mod-operator can be removed by two loops as in C version, which still further improved the speed. I tried this with the old version and the speed-up was next

Re: [Haskell-cafe] Towards an IO-Comonad that preserves referential transparency (was: "comonads, io" Jan 02, 2003)

2006-11-02 Thread Sven Biedermann
I just realized that I mixed up data bases and functional programming and apologize for this. Of course, I meant "referential transparency"! Sven Biedermann Am 02.11.2006 um 16:43 schrieb Sven Biedermann: Dear Haskellers, The OI Comonad in Richard Kieburtz' paper does break referential inte

Re: [Haskell-cafe] Class

2006-11-02 Thread Slavomir Kaslev
On 11/2/06, Sebastian Sylvan <[EMAIL PROTECTED]> wrote: On 11/2/06, Slavomir Kaslev <[EMAIL PROTECTED]> wrote: > Little by little, I think I am getting closer. > > class Show a => Visible a where > toString :: a -> String > toString = show > size :: a -> Int > size = length . show

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-02 Thread Jason Dagit
On 11/2/06, Spencer Janssen <[EMAIL PROTECTED]> wrote: On Nov 2, 2006, at 8:48 AM, alaiyeshi wrote: > Also, I guess my code still waste too much time "parsing" input (I > compiled my code with -prof flag on)... > Maybe ByteString may save me (or a smarter brain), What is your > opinion about doin

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-02 Thread alaiyeshi
Thank you so much! I've met replicateM_ for the first time;-) This could be a "template" for doing online-judge exercises I guess. And it's very useful for newbies like me. Again many Thanks:-)___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-02 Thread Spencer Janssen
On Nov 2, 2006, at 8:48 AM, alaiyeshi wrote: Also, I guess my code still waste too much time "parsing" input (I compiled my code with -prof flag on)... Maybe ByteString may save me (or a smarter brain), What is your opinion about doing faster IO, would you please tell me? ByteString will lik

[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 39, Issue 6

2006-11-02 Thread Chad Scherrer
Lemmih wrote: Using 'seq' is generally a bad idea. It can worsen the performance if not used carefully and GHCs strictness analyser is usually good enough. Is GHC.Conc.pseq any better? Usually the whole point of making things more strict is to optimize performance for pieces you know will be ev

Re: [Haskell-cafe] Very Small Program

2006-11-02 Thread Jason Dagit
On 11/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: G'day all. Quoting Bernie Pope <[EMAIL PROTECTED]>: > This is a weird example of a pattern binding, and it is surprising > (to me) that the syntax is valid. Maybe. But you wouldn't balk at this: numzeroes xs = sum [ 1 | 0 <- xs ]

[Haskell-cafe] Towards an IO-Comonad that preserves referential integry (was: "comonads, io" Jan 02, 2003)

2006-11-02 Thread Sven Biedermann
Dear Haskellers, The OI Comonad in Richard Kieburtz' paper does break referential integrity, but he worte, that the implementation is just something "...to experiment with". In this papers he states, that a real OI needs special properties. For instance enableOI needs "...to have the effect of co

Re: Re[2]: [Haskell-cafe] Class

2006-11-02 Thread Slavomir Kaslev
On 11/2/06, Bulat Ziganshin <[EMAIL PROTECTED]> wrote: Hello Slavomir, Thursday, November 2, 2006, 4:42:21 PM, you wrote: > instance Show a => Visible a where > toString = show > size = length . show > instance Visible a => Visible [a] where >toString = concat . map toString >s

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-02 Thread alaiyeshi
Thank you for replying. Smart method! I've learned much;-) I'll have a try using UArray. Also, I guess my code still waste too much time "parsing" input (I compiled my code with -prof flag on)... Maybe ByteString may save me (or a smarter brain), What is your opinion about doing faster IO, wou

Fwd: [Haskell-cafe] Class

2006-11-02 Thread Slavomir Kaslev
Little by little, I think I am getting closer. class Show a => Visible a where toString :: a -> String toString = show size :: a -> Int size = length . show Is just declaration, not definition. It doesn't define anything, even though it has default implementations for toString and si

Re[2]: [Haskell-cafe] Class

2006-11-02 Thread Bulat Ziganshin
Hello Slavomir, Thursday, November 2, 2006, 4:42:21 PM, you wrote: > instance Show a => Visible a where > toString = show > size = length . show > instance Visible a => Visible [a] where >toString = concat . map toString >size = foldl (+) 0 . map size > Illegal instance dec

Re: [Haskell-cafe] Class

2006-11-02 Thread Slavomir Kaslev
On 11/2/06, Sebastian Sylvan <[EMAIL PROTECTED]> wrote: On 11/2/06, Slavomir Kaslev <[EMAIL PROTECTED]> wrote: > > Visible 'subclasses' Show. Doesn't this mean that Visible should be > defined for all types with Show instances? No, it just means that any type that you want to instantiate in Vis

Re: Fwd: [Haskell-cafe] Class

2006-11-02 Thread Daniel Fischer
Am Donnerstag, 2. November 2006 10:57 schrieb Slavomir Kaslev: > -- Forwarded message -- > From: Slavomir Kaslev <[EMAIL PROTECTED]> > Date: Nov 2, 2006 10:47 AM > Subject: Re: [Haskell-cafe] Class > To: Daniel Fischer <[EMAIL PROTECTED]> > > On 11/2/06, Daniel Fischer <[EMAIL PROTE

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Lennart Augustsson
Oh, sorry, I thought your version was a rewritten version of mine. :) The names are so similar, after all. On Nov 2, 2006, at 02:26 , isto wrote: Hi, When writing IO version, I wasn't aware of other twister versions, and the only reason is/was that it was easiest to me and that I knew (believe

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Donald Bruce Stewart
bulat.ziganshin: > Hello isto, > > Thursday, November 2, 2006, 1:16:55 AM, you wrote: > > > I have tried to do different things but now I'm stuck. unsafeRead > > and unsafeWrite improved a bit the lazy (STUArray-version) and > > why you think it's a lazy? :) ST monad is just the same as IO mon

Re: [Haskell-cafe] Very Small Program

2006-11-02 Thread ajb
G'day all. Quoting Bernie Pope <[EMAIL PROTECTED]>: > This is a weird example of a pattern binding, and it is surprising > (to me) that the syntax is valid. Maybe. But you wouldn't balk at this: numzeroes xs = sum [ 1 | 0 <- xs ] ...even if you wouldn't naturally express it that way. Pat

Re[2]: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Bulat Ziganshin
Hello Lennart, Thursday, November 2, 2006, 6:04:39 AM, you wrote: > The whole point of writing the Mersenne Twister was that I wanted to > show how a stateful computation could be encapsulated in the ST monad > and none of it showing up outside. This aspect of the code is > totally gone now

Re[2]: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Bulat Ziganshin
Hello Lennart, Thursday, November 2, 2006, 4:34:04 AM, you wrote: > A big problem with the Mersenne Twister is the shifts. As has been > noted elsewhere, ghc doesn't do such a great job on those. #ifdef __GLASGOW_HASKELL__ (I# a) <<# (I# b) = (I# (a `iShiftL#` b)) (I# a) >># (I# b) = (I# (a

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Bulat Ziganshin
Hello isto, Thursday, November 2, 2006, 1:16:55 AM, you wrote: > I have tried to do different things but now I'm stuck. unsafeRead > and unsafeWrite improved a bit the lazy (STUArray-version) and why you think it's a lazy? :) ST monad is just the same as IO monad internally, only types are dif

Re: [Haskell-cafe] Very Small Program

2006-11-02 Thread Bulat Ziganshin
Hello Jason, Thursday, November 2, 2006, 8:45:14 AM, you wrote: > let 0 = 1 in 0 > let { 1 + 1 = 3; 3 + 1 = 7 } in 1 + 1 + 1 > Where you get 7. these sippets looks cool :) they may be placed in somewhat like Haskell puzzles -- Best regards, Bulatmailto:[EMAIL PRO

Re: [Haskell-cafe] Class

2006-11-02 Thread Bulat Ziganshin
Hello Slavomir, Thursday, November 2, 2006, 2:06:05 AM, you wrote: > Can someone please enlighten my (still) C++ thinking head? you is not alone :))) look into http://haskell.org/haskellwiki/OOP_vs_type_classes -- Best regards, Bulatmailto:[EMAIL PROTECTED]

Fwd: [Haskell-cafe] Class

2006-11-02 Thread Slavomir Kaslev
-- Forwarded message -- From: Slavomir Kaslev <[EMAIL PROTECTED]> Date: Nov 2, 2006 10:47 AM Subject: Re: [Haskell-cafe] Class To: Daniel Fischer <[EMAIL PROTECTED]> On 11/2/06, Daniel Fischer <[EMAIL PROTECTED]> wrote: Am Donnerstag, 2. November 2006 00:06 schrieb Slavomir Kasl

Re: [Haskell-cafe] A type class puzzle

2006-11-02 Thread Yitzchak Gale
On Tue, Oct 31, 2006 I wrote: Consider the following sequence of functions that replace a single element in an n-dimensional list: replace0 :: a -> a -> a replace1 :: Int -> a -> [a] -> [a] replace2 :: Int -> Int -> a -> [[a]] -> [[a]] Generalize this using type classes. Thanks to everyone fo