Re: [Haskell-cafe] Design Patterns by Gamma or equivalent

2009-03-15 Thread ajb
G'day all. Quoting wren ng thornton : Most of the (particular) problems OO design patterns solve are non-issues in Haskell because the language is more expressive. ...and vice versa. Some of the "design patterns" that we use in Haskell, for example, are to overcome the fact that Haskell does

[Haskell-cafe] A new haskell tools project

2009-03-15 Thread L.Guo
Hi all: I have just created an haskell work toolset project in google code. Currently there are only a few tools to process YUV image files I wrote before. Welcome you attend in to improve my code or to add in your tools. And also pleasure to get your advices. http://code.googl

[Haskell-cafe] Re: is there a version of hsffig that builds on a recent versin of haskell?

2009-03-15 Thread Anatoly Yakovenko
i can try to fix it if i can get some help. i've never used cabal. any idea why i am getting this: anato...@anatolyy-linux /shared/anatolyy/hsffig-1.0 $ cabal install Warning: HSFFIG.cabal: The field "hs-source-dir" is deprecated, please use "hs-source-dirs" Warning: HSFFIG.cabal: The field "hs-s

Re: [Haskell-cafe] Data.Binary, Data.Text and errors

2009-03-15 Thread Bryan O'Sullivan
On Sun, Mar 15, 2009 at 8:40 PM, Alexander Dunlap < alexander.dun...@gmail.com> wrote: > > I have noticed that in both Data.Binary and Data.Text (which is still > experimental, but still), the "decode" functions can be undefined > (i.e. bottom) if they encounter malformed input. > For decoding Un

Re: [Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5

2009-03-15 Thread Alan Mock
By default GMP builds for x86_64. Do ./configure ABI=32 to build 32- bit libraries for GHC. On Mar 15, 2009, at 10:54 PM, Dean Herington wrote: I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in / usr/local/lib.

[Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5

2009-03-15 Thread Dean Herington
I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in /usr/local/lib. When I do "./configure" in GHC's dist directory, however, I get: bash-3.2$ ./configure checking build system type... powerpc-apple-darwin9.6.0 check

[Haskell-cafe] Data.Binary, Data.Text and errors

2009-03-15 Thread Alexander Dunlap
Hi all, I have noticed that in both Data.Binary and Data.Text (which is still experimental, but still), the "decode" functions can be undefined (i.e. bottom) if they encounter malformed input. What is the preferred way to use these functions in a safe way? For example, if one writes data to a dis

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Sun, 2009-03-15 at 18:11 -0700, Ryan Ingram wrote: > On Sun, Mar 15, 2009 at 1:56 PM, Jonathan Cast > wrote: > >> But not if you switch the (x <- ...) and (y <- ...) parts: > >> > >> main = do > >> r <- newIORef 0 > >> v <- unsafeInterleaveIO $ do > >> writeIORef r 1 > >>

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Ryan Ingram
On Sun, Mar 15, 2009 at 1:56 PM, Jonathan Cast wrote: >> But not if you switch the (x <- ...) and (y <- ...) parts: >> >> main = do >>     r <- newIORef 0 >>     v <- unsafeInterleaveIO $ do >>         writeIORef r 1 >>         return 1 >>     y <- readIORef r >>     x <- case f v of >>          

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread wren ng thornton
Yusaku Hashimoto wrote: Hello, I was studying about what unsafeInterleaveIO is.I understood unsafeInterleaveIO takes an IO action, and delays it. But I couldn't find any reason why unsafeInterleaveIO is unsafe. I have already read an example in http://www.haskell.org/pipermail/haskell-cafe/2009

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Mon, 2009-03-16 at 01:04 +0100, Daniel Fischer wrote: > Am Montag, 16. März 2009 00:47 schrieb Jonathan Cast: > > On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > > > > > > > However, I understand > > > > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > > > >

Re: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr

2009-03-15 Thread wren ng thornton
R J wrote: I need to write an implementation using foldl, and a separate implementation using foldr, of a function, "remdups xs", that removes adjacent duplicate items from the list xs. For example, remdups [1,2,2,3,3,3,1,1]= [1,2,3,1]. My approach is first to write a direct recursion, as fol

[Haskell-cafe] Re: Help with Bird problem 4.5.6: sequence of successive maxima

2009-03-15 Thread Benedikt Huber
R J schrieb: This Bird problem vexes me, in the first instance because it doesn't seem to specify a unique solution: Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] such that j_1 = 1 and j_m < j_n => x_j

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Daniel Fischer
Am Montag, 16. März 2009 00:47 schrieb Jonathan Cast: > On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > > > > > However, I understand > > > > "unsafeInterleaveIO allows IO computation to be deferred lazily. When > > > > passed a value of type IO a, the IO will only be performed when the

Re: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-15 Thread Thomas Hartman
Except that there is nothing like =~ s in haskell, as far as I can tell. I was mulling over this and thinking, the nicest solution for this -- from the lens of perl evangelism anyway -- would be to have some way of accessing the perl6 language =~ s mechanism in pugs, which would get us everything

Re: [Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 21:09 schrieb R J: > This Bird problem vexes me, in the first instance because it doesn't seem > to specify a unique solution: > > Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive > maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] su

Re: [Haskell-cafe] State monad is missing Applicative instance

2009-03-15 Thread Henning Thielemann
Peter Verswyvelen schrieb: > ouch, I was confusing the mtl and transformers package... > > so basically transformers is a better replacement for mtl? > > or does mtl offer things transformers does not? transformers and monad-fd are cleanly separated, transformers is Haskell 98 and monad-fd uses

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Mon, 2009-03-16 at 00:14 +0100, Daniel Fischer wrote: > Am Sonntag, 15. März 2009 23:30 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > > > Am Sonntag, 15. März 2009 22:20 schrieb Jonathan Cast: > > > > There is *no* guarantee that main0 prints 0, while main

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Claus Reinke
main = do r <- newIORef 0 v <- unsafeInterleaveIO $ do writeIORef r 1 return 1 x <- case f v of 0 -> return 0 n -> return (n - 1) y <- readIORef r print y -- a couple of examples: f x = 0 -- program prints "0" -- f x = x -- program prints "1"

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 23:30 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > > Am Sonntag, 15. März 2009 22:20 schrieb Jonathan Cast: > > > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > > > claimed. The compiler is in fact free to pr

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Sun, 2009-03-15 at 23:18 +0100, Daniel Fischer wrote: > Am Sonntag, 15. März 2009 22:20 schrieb Jonathan Cast: > > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > > claimed. The compiler is in fact free to produce either output given > > either program, at its option. S

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 22:20 schrieb Jonathan Cast: > There is *no* guarantee that main0 prints 0, while main1 prints 1, as > claimed. The compiler is in fact free to produce either output given > either program, at its option. Since the two programs do in fact have > exactly the same set of p

Re: [Haskell-cafe] big discussion about Haskell on Reddit

2009-03-15 Thread Don Stewart
fft1976: > I noticed that on Programming Reddit, where I lurk, there is a big > discussion about the disconnect between how much Haskell is advocated > there and the number of applications written in it. > > http://www.reddit.com/r/programming/comments/84sqt/dear_reddit_i_am_seeing_12_articles_in/

[Haskell-cafe] big discussion about Haskell on Reddit

2009-03-15 Thread FFT
I noticed that on Programming Reddit, where I lurk, there is a big discussion about the disconnect between how much Haskell is advocated there and the number of applications written in it. http://www.reddit.com/r/programming/comments/84sqt/dear_reddit_i_am_seeing_12_articles_in/ The difficulty of

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Sun, 2009-03-15 at 22:09 +0100, Daniel Fischer wrote: > Am Sonntag, 15. März 2009 21:56 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > > > Am Sonntag, 15. März 2009 21:25 schrieb Jonathan Cast: > > > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: >

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 21:56 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > > Am Sonntag, 15. März 2009 21:25 schrieb Jonathan Cast: > > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > > Furthermore, due to the monad laws, if f is total, then re

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Sun, 2009-03-15 at 21:43 +0100, Daniel Fischer wrote: > Am Sonntag, 15. März 2009 21:25 schrieb Jonathan Cast: > > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > > > Furthermore, due to the monad laws, if f is total, then reordering the > > > (x <- ...) and (y <- ...) parts of the p

Re: [Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 21:09 schrieb R J: > This Bird problem vexes me, in the first instance because it doesn't seem > to specify a unique solution: > > Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive > maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] su

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Daniel Fischer
Am Sonntag, 15. März 2009 21:25 schrieb Jonathan Cast: > On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > > > Furthermore, due to the monad laws, if f is total, then reordering the > > (x <- ...) and (y <- ...) parts of the program should have no effect. > > But if you switch them, the progr

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Jonathan Cast
On Sun, 2009-03-15 at 13:02 -0700, Ryan Ingram wrote: > unsafeInterleaveIO allows embedding side effects into a pure > computation. This means you can potentially observe if some pure > value has been evaluated or not; the result of your code could change > depending how lazy/strict it is, which

Re: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h

2009-03-15 Thread Don Stewart
Fixed on hackage. $ cabal update $ cabal install plugins-1.4.1 Or via the web: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/plugins-1.4.1 -- Don yuri.kashnikoff: > Thanks. Problem solved now! > > On Sun, Mar 15, 2009 at 7:20 PM, Duncan Coutts > wrote: > > On Sun, 2

[Haskell-cafe] Help with Bird problem 4.5.6: sequence of successive maxima

2009-03-15 Thread R J
This Bird problem vexes me, in the first instance because it doesn't seem to specify a unique solution: Given a list xs = [x_1, x_2, . . . , x_n], the sequence of successive maxima "ssm xs" is the longest subsequence [x_j1, x_j2, x_j3..x_jk] such that j_1 = 1 and j_m < j_n => x_jm < x_jn. For

Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Ryan Ingram
unsafeInterleaveIO allows embedding side effects into a pure computation. This means you can potentially observe if some pure value has been evaluated or not; the result of your code could change depending how lazy/strict it is, which is very hard to predict! For example: > -- given > f :: Inte

[Haskell-cafe] What unsafeInterleaveIO is unsafe

2009-03-15 Thread Yusaku Hashimoto
Hello, I was studying about what unsafeInterleaveIO is.I understood unsafeInterleaveIO takes an IO action, and delays it. But I couldn't find any reason why unsafeInterleaveIO is unsafe. I have already read an example in http://www.haskell.org/pipermail/haskell-cafe/2009-March/057101.html says la

[Haskell-cafe] Re: is there a version of hsffig that builds on a recent versin of haskell?

2009-03-15 Thread Dmitry Golubovsky
On Mar 15, 4:03 am, Anatoly Yakovenko wrote: > is there a version of hsffig that builds on a recent versin of haskell? > ___ > Haskell-Cafe mailing list > haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe Unfortunately no. The

Re: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h

2009-03-15 Thread Yuri Kashnikoff
Thanks. Problem solved now! On Sun, Mar 15, 2009 at 7:20 PM, Duncan Coutts wrote: > On Sun, 2009-03-15 at 11:38 +0600, Yuri Kashnikoff wrote: >> Hi! >> >> I was trying to install hs-plugins both from sources "$./Setup.lhs >> ..." and with "$cabal fetch&&cabal install" and both failed. >> It alway

Re: [Haskell-cafe] Link errors

2009-03-15 Thread Jochem Berndsen
Lingappan, Loganathan wrote: > If I include > > import Text.Regex.Posix ((=~)) > > into a Haskell code, I get the following link error: > > FindBBUsage.o:fake:(.text+0x44d): undefined reference to > `__stginit_regexzmposixzm0zi72zi0zi3_TextziRegexziPosix_' > collect2: ld returned 1 exit status

[Haskell-cafe] Link errors

2009-03-15 Thread Lingappan, Loganathan
Hi, If I include import Text.Regex.Posix ((=~)) into a Haskell code, I get the following link error: FindBBUsage.o:fake:(.text+0x44d): undefined reference to `__stginit_regexzmposixzm0zi72zi0zi3_TextziRegexziPosix_' collect2: ld returned 1 exit status Any ideas on how to fix this? I am using G

[Haskell-cafe] ANNOUNCE: dzen-utils 0.1

2009-03-15 Thread Felipe Lessa
Hello! I'm please to announce dzen-utils 0.1. I don't feel like it is ready to be released, but let's see how everything goes. :) == WHAT == dzen-utils contains various utilities for creating dzen input strings in a type-safe way using some combinators, including the ability to apply colors loca

Re: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr

2009-03-15 Thread Peter Verswyvelen
Why don't you just swap the pattern match order? remdups :: (Eq a) => [a] -> [a] remdups (x : xx : xs) = if x == xx then remdups (x : xs) else x : remdups (xx : xs) remdups xs= xs This should cover all cases no? Also I prefer guards, but I guess that is persona

Re: [Haskell-cafe] State monad is missing Applicative instance

2009-03-15 Thread Peter Verswyvelen
ouch, I was confusing the mtl and transformers package... so basically transformers is a better replacement for mtl? or does mtl offer things transformers does not? On Sun, Mar 15, 2009 at 12:04 AM, Henning Thielemann < lemm...@henning-thielemann.de> wrote: > > On Sat, 14 Mar 2009, Peter Verswyv

Re: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr

2009-03-15 Thread Roel van Dijk
2009/3/15 R J : > What, if any, is the implementation using only two cases? This version considers 2 cases 2 times :-) But only the 'go' function is recursive, so it could probably be written using some kind of fold. The value being build by the fold should probably be some kind of tuple so you ca

Re: [Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr

2009-03-15 Thread Sebastian Sylvan
2009/3/15 R J > I need to write an implementation using foldl, and a separate > implementation using foldr, of a function, "remdups xs", that removes > adjacent duplicate items from the list xs. For example, remdups > [1,2,2,3,3,3,1,1]= [1,2,3,1]. > > My approach is first to write a direct recu

Re: [Haskell-cafe] I can't install hs-plugins beceause of Linker.h

2009-03-15 Thread Duncan Coutts
On Sun, 2009-03-15 at 11:38 +0600, Yuri Kashnikoff wrote: > Hi! > > I was trying to install hs-plugins both from sources "$./Setup.lhs > ..." and with "$cabal fetch&&cabal install" and both failed. > It always reports that Linker.h is missing. > Setup.lhs: Missing dependency on a foreign library:

[Haskell-cafe] Most elegant funciton for removing adjacent duplicates from a list using foldl and foldr

2009-03-15 Thread R J
I need to write an implementation using foldl, and a separate implementation using foldr, of a function, "remdups xs", that removes adjacent duplicate items from the list xs. For example, remdups [1,2,2,3,3,3,1,1]= [1,2,3,1]. My approach is first to write a direct recursion, as follows: re

[Haskell-cafe] A non-inductive Haskell proof?

2009-03-15 Thread R J
The following theorem is obviously true, but how is it proved (most cleanly and simply) in Haskell? Theorem: (nondecreasing xs) => nondecreasing (insert x xs), where: nondecreasing :: (Ord a) => [a] -> Bool nondecreasing []= True nondecreasing xxs@(x : xs)

Re: [Haskell-cafe] Re: How to catch error in array index when debugging

2009-03-15 Thread Colin Paul Adams
> "Peter" == Peter Hercek writes: Peter> Colin Paul Adams wrote: >>> "Adrian" == Adrian Neumann >>> writes: >> Adrian> You can use the ghci debugger >> >> >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci- Adrian> debugger.html >>

Re: [Haskell-cafe] Default Tuple Orderings

2009-03-15 Thread Martijn van Steenbergen
Mark Spezzano wrote: In other words my best guess is that the ordering of tuples is by comparing the first tuple elements and then the seconds, thirds etc, until there’s an element less than another. ...until there's an element not equal to the other, yes. It finds the first position at which

[Haskell-cafe] is there a version of hsffig that builds on a recent versin of haskell?

2009-03-15 Thread Anatoly Yakovenko
is there a version of hsffig that builds on a recent versin of haskell? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Default Tuple Orderings

2009-03-15 Thread Mark Spezzano
Hi, Does anyone know how Haskell’s tuple ordering works? Presumably for some tuple T1 (x1,x2,...xn) and another tuple T2 (y1,y2,...yn) Haskell would compare T1 and T2 as follows: T1 < T2 if: x1 < y1 OR otherwise if x1 == y1 then if x2 < y2 OR otherwise if x2 == y2 then if x3 < y3 OR othe

Re: [Haskell-cafe] How to catch error in array index when debugging

2009-03-15 Thread Colin Paul Adams
> "Claus" == Claus Reinke writes: Claus> None of which is satisfactory. You might also want to add Claus> yourself to this ticket: >> Claus> "index out of range" error message regression Claus> http://hackage.haskell.org/trac/ghc/ticket/2669 >> >> How do I do tha