[Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)?

Saurabh Nanda saurabhnanda at gmail.com
Wed Sep 20 16:12:51 UTC 2017


Intresting. Wont using "void" or "_ <- forM blah" have the same effect? Why
not?

On 20-Sep-2017 9:37 PM, "Nick Smallbone" <nick at smallbone.se> wrote:


Hi Stanislav,

Станислав Черничкин <schernichkin at gmail.com> writes:
> I've wrote simple Haskell benchmark program, which populated primitive
vector
> from vector package:
>
> ...
> void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int)

'for' is a variant of 'map' - it returns a list of results (in this case
a list of a million () values). Instead you should use 'forM_' (note the
underscore) from Control.Monad, which discards the result - that cuts
the runtime by a huge amount when I try it. (And make sure to compile
with -O too.)

Nick

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170920/5b9029df/attachment.html>


More information about the Haskell-Cafe mailing list