Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Richard A. O'Keefe
The original poster wants to - read a file - get the contents as a String - break the string into lines - do something with the lines - and presumably print the result Easy. Put the following lines in a file called 'rf.hs': file_name = "rf.hs" main = readFile file_name >>= \string -> p

Re: [Haskell-cafe] Efficient matrix multiply using accelerate

2013-09-04 Thread Trevor L. McDonell
Hi Morten, On 04/09/2013, at 9:53 PM, Morten Olsen Lysgaard wrote: > I've been trying to get some speed out of the accelerate library today. > What I want to implement is something as simple as a matrix multiply. > I'd like it to be fast and memory efficient. Well, the trouble with something li

Re: [Haskell-cafe] Reasoning about performance

2013-09-04 Thread Scott Pakin
On 09/03/2013 05:43 PM, Bob Ippolito wrote: Haskell's non-strict evaluation can often lead to unexpected results when doing tail recursion if you're used to strict functional programming languages. In order to get the desired behavior you will need to force the accumulator (with something like

Re: [Haskell-cafe] type constructor section for (-> Bool), _not_ ((->) Bool)

2013-09-04 Thread AntC
> Brent Yorgey seas.upenn.edu> writes: > > > On Tue, Sep 03, 2013 at 11:33:46AM +, AntC wrote: > > > > I want an instance and type improvement constraint of the form > > > > instance (f ~ (-> Bool)) => C Foo (f b) where ... > > > > There is no operator section syntax for types. Moreo

Re: [Haskell-cafe] ANN: Cabal v1.18.0 released

2013-09-04 Thread Yuri de Wit
Thanks for all the hard work! If you see this in OSX (#1009) while installing cabal 1.18: *Warning: could not create a symlink in /Users/lemao/Library/Haskell/bin for * *cabal because the file exists there already but is not managed by cabal. You* *can create a symlink for this executable manuall

Re: [Haskell-cafe] ANN: Cabal v1.18.0 released

2013-09-04 Thread Darren Grant
Thank you all for the hard work. The new features are already of great help to me! Cheers, Darren On 2013-09-04 2:13 PM, "Johan Tibell" wrote: > Hi all, > > On behalf of the cabal maintainers and contributors I'm proud to > announce the Cabal (and cabal-install) 1.18.0 release. To install run >

[Haskell-cafe] ANN: Cabal v1.18.0 released

2013-09-04 Thread Johan Tibell
Hi all, On behalf of the cabal maintainers and contributors I'm proud to announce the Cabal (and cabal-install) 1.18.0 release. To install run cabal update && cabal install Cabal-1.18.0 cabal-install-1.18.0 With 854 commits since the last release there are two many improvements and bug fixes

Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Joe Q
Er, I seem to have misread and thought you were doing infinite replicateM, so that explanation doesn't completely address your question. That's what I get for reading on a phone! On Sep 4, 2013 4:11 PM, "Joe Q" wrote: > To give a very casual explanation, both mains are of the form "do this a > bu

Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Joe Q
To give a very casual explanation, both mains are of the form "do this a bunch of times and return the results". Your first is "do nothing and return the ()s", but importantly, it has to execute all those nothings. Your second is "print hello a bunch and return the ()s". The list it wants to event

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
Niklas: I missed your note about calling Haskell from JS, see this for Fay: https://github.com/faylang/fay/wiki/Fay-Status-Update-September-2013%3A-ZuriHac%2C-typeclasses%2C-haskell-suite%2C-and-strictness-wrappers#javascript-fay-communication On Wed, Sep 4, 2013 at 8:18 PM, Luite Stegeman wrot

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Chris Smith
I second the recommendation to look at Haste. It's what I would pick for a project like this today. In the big picture, Haste and GHCJS are fairly similar. But when it comes to the ugly details of the runtime system, GHCJS adopts the perspective that it's basically an emulator, where compatibili

[Haskell-cafe] ANNOUNCE: Haskell Refactorer (HaRe) version 0.7.0.0

2013-09-04 Thread AlanKim Zimmerman
I am please to announce an alpha release of the Haskell Refactorer making use of the GHC API. It is a work in progress, but currently supports the following refactorings iftocase Convert an if expression to a case expression dupdef Duplicate a definition

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Luite Stegeman
On Wed, Sep 4, 2013 at 6:32 PM, Daniil Frumin wrote: > > > I think it's nice that you've raised that question, I will think about > implementing a finer API for calling Haskell from JS. > > It sounds like something like h$runSyncWithResult (name open for bikeshedding) that takes an IO (JSRef a) a

Re: [Haskell-cafe] Reasoning about performance

2013-09-04 Thread Scott Pakin
On 09/03/2013 06:02 PM, Carter Schonwald wrote: It's also worth adding that ghci does a lot less optimization than ghc. Yes, I discovered that before I posted. Note from my initial message that I used ghc to compile, then loaded the compiled module into ghci: Prelude> :!ghc -c -O2 allpai

Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Tom Ellis
On Wed, Sep 04, 2013 at 10:21:37PM +0800, yi lu wrote: > I want to read a text file, and store it in a *String*. But readFile will > get *IO String*. I search with google and they tell me it is not > necessarily to do so. Can you explain to me why is this? Furthermore, How > to read a file and stor

[Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)

2013-09-04 Thread Tom Ellis
As an addendum to the recent discussion, can anyone explain why main crashes quickly with a stack overflow, whereas main' is happy to print "Hi" for ages (eventually crashing due to an out of memory condition)? bignum = 100 * 1000 * 1000 main = replicateM bignum (return ()) main' =

Re: [Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread Brandon Allbery
On Wed, Sep 4, 2013 at 10:21 AM, yi lu wrote: > I want to read a text file, and store it in a *String*. But readFile will > get *IO String*. I search with google and they tell me it is not > necessarily to do so. Can you explain to me why is this? Furthermore, How > to read a file and store it in

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Daniil Frumin
Hi! On Sep 4, 2013, at 13:02, Niklas Hambüchen wrote: > Hi, I'm also interested in that. > > Have you already evaluated haste? > > It does not seem to have any of your cons, but maybe others. > > What I particularly miss from all solutions is the ability to simply > call parts written in Haskell

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
Here are some points I'd like to emphasize in addition to the threads above, with the disclaimer that I'm the maintainer of Fay. Fay tries to be very simple, the code base is small (~4800 LoC). This really lowers the entry barrier for contributions which I think is very important for open source p

[Haskell-cafe] How to read a file and return a String?

2013-09-04 Thread yi lu
I want to read a text file, and store it in a *String*. But readFile will get *IO String*. I search with google and they tell me it is not necessarily to do so. Can you explain to me why is this? Furthermore, How to read a file and store it in a String? In fact, I want to read a file and split it

Re: [Haskell-cafe] Reasoning about performance

2013-09-04 Thread Carter Schonwald
Awesome/ thanks for sharing. It's worth noting that criterion is also pretty great for microbenchmarks too. On my machine I get pretty good timing accuracy on anything that takes more than 20 nanoseconds. On Wednesday, September 4, 2013, Scott Pakin wrote: > On 09/03/2013 06:02 PM, Carter Schonw

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Joachim Breitner
Hi, Am Mittwoch, den 04.09.2013, 14:46 +0200 schrieb Adam Bergmark: > You might be interested in these two comment threads (and maybe the > rest of the comments as well): > http://www.reddit.com/r/haskell/comments/1ldqav/thoughts_on_uhc_vs_haste_vs_fay/cbyrhwz > http://www.reddit.com/r/haskell/com

Re: [Haskell-cafe] Unexpected behaviour with send and send-buffer setting

2013-09-04 Thread Bryan O'Sullivan
On Tue, Sep 3, 2013 at 3:56 PM, Simon Yarde wrote: > I'm new to Haskell and have reached an impasse in understanding the > behaviour of sockets. > Your question is actually not related to Haskell at all, but is a general "I don't understand socket programming" question. You're being misled by th

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Adam Bergmark
You might be interested in these two comment threads (and maybe the rest of the comments as well): http://www.reddit.com/r/haskell/comments/1ldqav/thoughts_on_uhc_vs_haste_vs_fay/cbyrhwz http://www.reddit.com/r/haskell/comments/1htqi2/announce_haste_the_haskell_to_js_compiler_is_now/cay79g9?context

[Haskell-cafe] Efficient matrix multiply using accelerate

2013-09-04 Thread Morten Olsen Lysgaard
I've been trying to get some speed out of the accelerate library today. What I want to implement is something as simple as a matrix multiply. I'd like it to be fast and memory efficient. Given the equation C = AB where A is nxr B is rxm C is nxm it seem reasonable to allocate three arrays o

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Nathan Hüsken
In my opinion haste is somewhere between Fay and ghcjs. It supports more than Fay, but in difference to ghcjs some PrimOps are not supported (weak pointers for example). It is a little bit more "direct" than ghcjs, in the sense that it does not need such a big rts written in js. I like haste

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Alejandro Serrano Mena
I haven't looked at Haste too much, I'll give it a try. My main problem is that I would like to find a solution that will continue working in years (somehow, that will became "the" solution for generating JS from Haskell code). That's why I see GHCJS (which just includes some patches to mainstream

Re: [Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Niklas Hambüchen
Hi, I'm also interested in that. Have you already evaluated haste? It does not seem to have any of your cons, but maybe others. What I particularly miss from all solutions is the ability to simply call parts written in Haskell from Javascript, e.g. to write `fib` and then integrate it into an

[Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

2013-09-04 Thread Alejandro Serrano Mena
Hi, I'm currently writing a tutorial on web applications using Haskell. I know the pros and cons of each server-side library (Yesod, Snap, Scotty, Warp, Happstack), but I'm looking for the right choice for client-side programming that converts Haskell to JavaScript. I've finally come to Fay vs. GHC