Re: [Haskell-cafe] Haskell vs Ruby as a scripting language

2007-02-10 Thread Donald Bruce Stewart
joelr1: > Is anyone using Haskell as a scripting language in their app? > > I'm thinking of viable it would be to embed ghc in a Mac (Cocoa) app. > > TextMate [1] uses Ruby as the extension language and quite > successfully at that. Everybody loves Ruby since it's simple. I need > a trading s

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Matthew Brecknell
Rafael Almeida said: > I've always found the following definition of the sieve of eratosthenes > the clearest definition one could write: > > sieve [] = [] > sieve (x:xs) = x : sieve [y | y <- xs, y `mod` x /= 0] > > It doesn't perform better than Augustsson's solution. It does fairly > worse, ac

Re: [Haskell-cafe] Beginner Question

2007-02-10 Thread Rafael Almeida
On 2/9/07, vishy anand <[EMAIL PROTECTED]> wrote: I have just started on my journey in learning Haskell.I have started off reading wikibook,then will read yet another tutorial on haskell.Please guide me if I am on right track The book I used on my learning was "Haskell: the craft of functional

[Haskell-cafe] Parsec and Java

2007-02-10 Thread Joel Reymont
Folks, Is there a Java parser implemented using Parsec? Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Rafael Almeida
I've always found the following definition of the sieve of eratosthenes the clearest definition one could write: sieve [] = [] sieve (x:xs) = x : sieve [y | y <- xs, y `mod` x /= 0] It doesn't perform better than Augustsson's solution. It does fairly worse, actually, but it performs way better t

[Haskell-cafe] Lambada and connecting Haskell to a Weblogic server

2007-02-10 Thread Joel Reymont
Folks, Where can I find Lambada these days and would it be of any use to me in trying to connect to a Weblogic server? To make the long story short, my broker's Java software connects to a remote Weblogic server and I would like to do the same. I suppose this would require me to implement

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Nicolas Frisby
A wee bit off topic, but I'm sure it's an acceptable detour. I just wanted to say that I appreciate both this sort of post and the consistent responses it solicits. I have yet to need my Haskell to perform well, but I'm sure that day will come. I like to follow these questions and hopefully be be

Re: [Haskell-cafe] FFI basics

2007-02-10 Thread Yitzchak Gale
Thanks to everyone for all the help! Everything is working for me now. It turns out that the main detail I was missing was exactly what commands to type to compile it, and how to use it in GHCI. Pretty important detail, actually. Alistair - yes, there are a few simpler pages about FFI on the old

Re: [Haskell-cafe] What's wrong with "cgi-undecidable"?

2007-02-10 Thread Robin Green
On Sat, 10 Feb 2007 23:37:04 +0100 Bjorn Bringert <[EMAIL PROTECTED]> wrote: > I've also recently changed the version number scheme on most of the > packages I maintain (which includes most of the packages required by > Hope) from a date-based one to a major.minor scheme. This has the > unfor

Re: [Haskell-cafe] What's wrong with "cgi-undecidable"?

2007-02-10 Thread Bjorn Bringert
On Feb 10, 2007, at 9:15 , Donald Bruce Stewart wrote: haskell: <[EMAIL PROTECTED]> said: Then another problem,after I unregistered cgi-2006.9.6,the fastcgi-2006.10.9could't work well with cgi-1.0 . You might need fastcgi-1.0: http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi Ac

[Haskell-cafe] Re: Optimization fun

2007-02-10 Thread apfelmus
You're right, 'fix' is *not* a fix for non-termination, this is better fixed in the type system (with the right fixed points or you're in a fix) ;) Fixed regards, apfelmus Lennart Augustsson wrote: > This is actually a pretty good algorithm. And also a rather subtle one > when it comes to termin

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Creighton Hogg
On 2/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Creighton Hogg wrote: > Hello Haskell-ers, > So a friend and I were thinking about making code faster in Haskell, and I > was wondering if there was a way to improve the following method of > generating the list of all prime numbers. It t

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Bulat Ziganshin
Hello Creighton, Sunday, February 11, 2007, 12:02:09 AM, you wrote: > import Data.List > primes = 2:(foldr (\x y -> if isPrime x then x:y else y) [] [3..]) >     where isPrime x = foldl' (\z y -> z && (if x `mod` y == 0 then > False else True)) True (take (floor $ sqrt $ fromIntegral x) primes)

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Lennart Augustsson
This is actually a pretty good algorithm. And also a rather subtle one when it comes to termination. :) -- Lennart On Feb 10, 2007, at 22:00 , [EMAIL PROTECTED] wrote: Creighton Hogg wrote: Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, an

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Lennart Augustsson
Yeah, the 1 first primes takes about 0.1 seconds in Haskell too using the code I posted. On Feb 10, 2007, at 21:49 , Creighton Hogg wrote: On 2/10/07, Peter Berry <[EMAIL PROTECTED]> wrote: Gah! Gmail has really broken defaults for posting to lists. On 10/02/07, Creighton Hogg <[EMA

[Haskell-cafe] Re: Optimization fun

2007-02-10 Thread apfelmus
Creighton Hogg wrote: > Hello Haskell-ers, > So a friend and I were thinking about making code faster in Haskell, and I > was wondering if there was a way to improve the following method of > generating the list of all prime numbers. It takes about 13 seconds to > run, meanwhile my friend's C vers

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Creighton Hogg
On 2/10/07, Peter Berry <[EMAIL PROTECTED]> wrote: Gah! Gmail has really broken defaults for posting to lists. On 10/02/07, Creighton Hogg <[EMAIL PROTECTED]> wrote: > Hello Haskell-ers, > So a friend and I were thinking about making code faster in Haskell, and I > was wondering if there was a

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Creighton Hogg
On 2/10/07, Creighton Hogg <[EMAIL PROTECTED]> wrote: On 2/10/07, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > > There are many things that makes your code slow. > * The default for Haskell is to compute with Integer, not Int. So > that makes from Integral and floor very slow. > * foldl' i

Fwd: [Haskell-cafe] Optimization fun

2007-02-10 Thread Peter Berry
Gah! Gmail has really broken defaults for posting to lists. On 10/02/07, Creighton Hogg <[EMAIL PROTECTED]> wrote: Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, and I was wondering if there was a way to improve the following method of generating the list

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Creighton Hogg
On 2/10/07, Lennart Augustsson <[EMAIL PROTECTED]> wrote: There are many things that makes your code slow. * The default for Haskell is to compute with Integer, not Int. So that makes from Integral and floor very slow. * foldl' is a bad choice, because it is too strict, you want to abort the lo

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Lennart Augustsson
Hbc implements the IO type by request/response IO. I.e., the original Haskell I/O system. People who assume IO involves some RealWorld being passed around are just making unwarranted assumptions. The Haskell definition leaves the IO type abstract. -- Lennart On Feb 10, 2007, at 19:16

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Lennart Augustsson
There are many things that makes your code slow. * The default for Haskell is to compute with Integer, not Int. So that makes from Integral and floor very slow. * foldl' is a bad choice, because it is too strict, you want to abort the loop as soon as possible. * your take is really wrong. Th

[Haskell-cafe] Optimization fun

2007-02-10 Thread Creighton Hogg
Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, and I was wondering if there was a way to improve the following method of generating the list of all prime numbers. It takes about 13 seconds to run, meanwhile my friend's C version took 0.1. I'd love to lear

Fwd: [Haskell-cafe] Newbie: generating a truth table

2007-02-10 Thread Peter Berry
Sigh, I seem to have done a reply to sender. Reposting to the list. On 06/02/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, I would like to create a Haskell function that generates a truth table, for all Boolean values, say, using the following "and" function : and :: Bool -> Bool ->

Re[2]: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Bulat Ziganshin
Hello Rafael, Saturday, February 10, 2007, 8:26:38 PM, you wrote: > I'm using debian etch (linux), my processor is a pentium 4 3.0ghz, which > has sse and sse2 > Showing that this kind of benchmarking is usually not very accurate or, > at least, that my processor is not well suited for functiona

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Kirsten Chevalier
On 2/10/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote: To everyone's surprise, GHC 6.6 beats GCC (3.3.5) here, at least the two test machines: $ ghc -O -fexcess-precision -fbang-patterns -optc-O3 -optc-ffast-math -optc-mfpmath=sse -optc-msse2 A.hs -o a $ time ./a 3.33

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Stefan O'Rear
hmm, my inexperienced forwarding attempt mangled the message... > data Process = Getc (Char -Process) > | Putc Char (() -Process) > | forall a. NewIORef a (IORef a -Process) > | forall a. ReadIORef (IORef a) (a -Process) > | forall a. WriteIORef (

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Stefan O'Rear
Gah. For the first time ever, I seem to have accidentally done a reply to sender. (IE Bulat please ignore this message) On Sat, Feb 10, 2007 at 07:25:19PM +0300, Bulat Ziganshin wrote: > Hello haskell-cafe, > > just another interesting discussion in russian forum raised such idea: > > we all sa

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Lennart Augustsson
Yes! That's the code I like. On Feb 10, 2007, at 17:46 , Felipe Almeida Lessa wrote: On 2/10/07, Rafael Almeida <[EMAIL PROTECTED]> wrote: While the haskell program took so long, the C program went really faster than the haskell version: $ gcc -O3 -ffast-math -mfpmath=sse -msse2 -std=c99

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Nicolas Frisby
Very rarely is a nontrivial solution the "only way." Monads are a construct that nicely represents the sequencing side-effecting computations in a pure and strongly-typed environment. They are a nice way to do it, but certainly not the only one. Now I'm not confident enough to boldly make this cl

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Rafael Almeida
On 2/10/07, Felipe Almeida Lessa <[EMAIL PROTECTED]> wrote: Under gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5), the following asm code is generated for part of the main function: mov dword ptr [esp+4], 0aaabh mov dword ptr [esp+8], 400ah mov dwor

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Felipe Almeida Lessa
On 2/10/07, Rafael Almeida <[EMAIL PROTECTED]> wrote: While the haskell program took so long, the C program went really faster than the haskell version: $ gcc -O3 -ffast-math -mfpmath=sse -msse2 -std=c99 loop.c -o c_loop $ time ./c_loop 3.33 real0m0.001s user0m0.000s sys

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Rafael Almeida
On 2/10/07, Donald Bruce Stewart <[EMAIL PROTECTED]> wrote: The following C program was described on #haskell #include int main() { double x = 1.0/3.0; double y = 3.0; int i= 1; for (; i<=10; i++) { x = x*y/3.0; y

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Lennart Augustsson
GCC 4.x gets a pass on this test. :) You can do (much) better than that, of course. But it's what I'd expect without going over board. -- Lennart On Feb 10, 2007, at 16:45 , Donald Bruce Stewart wrote: dons: The following C program was described on #haskell #include int mai

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Donald Bruce Stewart
dons: > The following C program was described on #haskell > > #include > > int main() > { > double x = 1.0/3.0; > double y = 3.0; > int i= 1; > for (; i<=10; i++) { > x = x*y/3.0; > y = x*9.0; > } > p

[Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Donald Bruce Stewart
The following C program was described on #haskell #include int main() { double x = 1.0/3.0; double y = 3.0; int i= 1; for (; i<=10; i++) { x = x*y/3.0; y = x*9.0; } printf("%f\n", x+y); } Which

[Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Bulat Ziganshin
Hello haskell-cafe, just another interesting discussion in russian forum raised such idea: we all say that monads are the haskell way to do i/o. is it true? may be, uniqueness types, just like in Clean and Mercury, are real way, and monads are only the way to write programs that use uniqueness ty

Re: [Haskell-cafe] Haskell vs Ruby as a scripting language

2007-02-10 Thread Neil Mitchell
Hi > Also, I recommend looking into embedding YHC. I have not had a > chance to use > it yet, but it looks like it is a better fit to an "interpreter-only" > embedding situation than GHC--with GHC, you are getting a lot more > than you > seem to be asking for. I would want to compile code as we

Re: [Haskell-cafe] Haskell vs Ruby as a scripting language

2007-02-10 Thread Joel Reymont
On Feb 10, 2007, at 2:25 PM, Brian Smith wrote: Is your application primarily written in Haskell? If not, you would have to create an interface between that language and Haskell in order for your Haskell programs to manipulate your domain objects and user interface. It would be Objective-

[Haskell-cafe] Embedding ghc

2007-02-10 Thread Brian Smith
"If you have to ask, you can't afford it." :) The GHC API is not modular--if you use it, then the entirety of GHC is included into your program. That means that your executable will increase by the size of ghc.exe. Furthermore, you will also need to ship several of the supporting executables, al

Re: [Haskell-cafe] Haskell vs Ruby as a scripting language

2007-02-10 Thread Brian Smith
On 2/10/07, Joel Reymont <[EMAIL PROTECTED]> wrote: Is anyone using Haskell as a scripting language in their app? I'm thinking of viable it would be to embed ghc in a Mac (Cocoa) app. Is your application primarily written in Haskell? If not, you would have to create an interface between that

[Haskell-cafe] Haskell vs Ruby as a scripting language

2007-02-10 Thread Joel Reymont
Is anyone using Haskell as a scripting language in their app? I'm thinking of viable it would be to embed ghc in a Mac (Cocoa) app. TextMate [1] uses Ruby as the extension language and quite successfully at that. Everybody loves Ruby since it's simple. I need a trading systems language and I

[Haskell-cafe] Embedding ghc

2007-02-10 Thread Joel Reymont
Has anyone tried embedding ghc into their app? How big are the resulting binaries? Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] GHC throws IOError on Win32 when there is no console

2007-02-10 Thread John Ky
Hi Duncan, Thanks for your comments. In the context of a haskell process running as a Windows service, a message box is useless, because Haskell services do not have a GUI and cannot interact with the desktop. -John ___ Haskell-Cafe mailing list Haske

Re: [Haskell-cafe] FFI basics

2007-02-10 Thread Sven Panne
Am Samstag, 10. Februar 2007 09:21 schrieb Donald Bruce Stewart: > bulat.ziganshin: > > Hello Yitzchak, > > > > Friday, February 9, 2007, 3:23:53 PM, you wrote: > > > I would like to use FFI for the first time. Can someone > > > give me a really, really simple complete example? > > > > nothing can

Re: [Haskell-cafe] GHC throws IOError on Win32 when there is no console

2007-02-10 Thread Duncan Coutts
On Sat, 2007-02-10 at 09:32 +1100, John Ky wrote: > Hi, > > I noticed on Windows that when I use IO functions that write to stdout > when the process is lacking a console, those functions throw an > IOError. I'm not sure if this also occurs for stderr because I > haven't tried it. > > Some clas

Re: [Haskell-cafe] IO is not a monad

2007-02-10 Thread Lennart Augustsson
I'm not sure what you're asking. The (untyped) lambda calculus is Turing complete. How could seq improve that? On Feb 8, 2007, at 11:18 , Yitzchak Gale wrote: Lennart Augustsson wrote: I think seq is funny because it is not lambda definable. Does the set of computable functions on the nat

Re: [Haskell-cafe] Query

2007-02-10 Thread Matthew Brecknell
vishy anand <[EMAIL PROTECTED]> said: > hi i am going through yaht tutorial and exercise 4.6 and 4.7..i > understood > 4.6,but not 4.7 in which fromTuple (One a ) = Left (Left a ) and > fromTuple > (Two a b ) = Left (Right (a,b) ) function r written..why use Either > type..cant i just say fromTuple

Re[2]: [Haskell-cafe] FFI basics

2007-02-10 Thread Bulat Ziganshin
Hello Donald, Saturday, February 10, 2007, 11:21:58 AM, you wrote: >> foreign import ccall "mysin.h mysin" >> c_mysin :: Double -> Double > Shouldn't that be CDouble? At least for Int/CInt you can hit troubles on > 64 bit machines... conceptually - yes. practically, it should be the same for

[Haskell-cafe] learning Haskell

2007-02-10 Thread Bulat Ziganshin
Hello, i'd a discussion in russian programmer's forum (rsdn.ru) about haskell and learning it. one interesting point was that imperative programmers imagine that multi-threading programming should require special knowledges. they was really amazed when i showed the following program that creates t

Re: [Haskell-cafe] FFI basics

2007-02-10 Thread Donald Bruce Stewart
bulat.ziganshin: > Hello Yitzchak, > > Friday, February 9, 2007, 3:23:53 PM, you wrote: > > > I would like to use FFI for the first time. Can someone > > give me a really, really simple complete example? > > nothing can be easier > > main = print (c_mysin 1.0) > > foreign import ccall "mysin.h

Re: [Haskell-cafe] What's wrong with "cgi-undecidable"?

2007-02-10 Thread Donald Bruce Stewart
haskell: > <[EMAIL PROTECTED]> said: > > > Then another problem,after I unregistered cgi-2006.9.6,the > > fastcgi-2006.10.9could't work well with > > cgi-1.0 . > > You might need fastcgi-1.0: > > http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi > > > Actually,I was trying my best to in

Re: [Haskell-cafe] What's wrong with "cgi-undecidable"?

2007-02-10 Thread Matthew Brecknell
<[EMAIL PROTECTED]> said: > Then another problem,after I unregistered cgi-2006.9.6,the > fastcgi-2006.10.9could't work well with > cgi-1.0 . You might need fastcgi-1.0: http://www.cs.chalmers.se/~bringert/darcs/haskell-fastcgi > Actually,I was trying my best to install hope: > http://www.cs.cha