Personal tools

Questions and answers

From HaskellWiki

Revision as of 13:23, 22 January 2007 by MathematicalOrchid (Talk | contribs)

Jump to: navigation, search

Feel free to ask your questions here. Please sign your question using four tildes (~~~~). Questions and answers will be organised as they are added, and linked from here. We don't have much here yet, but the Haskell Newbie page on the old wiki has quite a few questions and answers you can look through.

  • Is this a good place to ask questions? MathematicalOrchid 15:30, 18 January 2007 (UTC)
    • not yet at least. try the #haskell irc channel on freenode which is usually manned by at least a few very helpfull people. alternatively try the haskell-cafe mailing list --Johannes Ahlmann 12:29, 22 January 2007 (UTC)
      • I tried the IRC channel. 300+ people and nobody speaking. Not very helpful. MathematicalOrchid 13:23, 22 January 2007 (UTC)

Hmm, that sounded like a 'no'... OK, I'm going to add a few 'real' questions, and see if that gets any more of a response... MathematicalOrchid 11:47, 22 January 2007 (UTC)

  • Which is faster?
    putStr (xs ++ ys ++ xs)
    or
    putStr xs; putStr ys; putStr zs
    ? How much of a difference does it make? MathematicalOrchid 11:47, 22 January 2007 (UTC)
    • hmm,
      (++)
      is a very slow operation which is O(n) in the length of the first string. for short strings the difference should be small, for very long string you'll see a big difference. concrete timing depends on putStr... --Johannes Ahlmann 12:29, 22 January 2007 (UTC)
      • (++)
        is right-associative when there's several, resulting in the fastest possible performance. (I understand this is why the
        Show
        class is so damn weird...) Even so, I wonder if it's more efficient to join strings or use real I/O... MathematicalOrchid 13:23, 22 January 2007 (UTC)
  • Haskell apparently allows you to write functions with bizarre names like '++' or '***'. What are the rules for this? Which characters can or can't you use? Are you required to give a fixity declaration first, or can you just use them? MathematicalOrchid 11:47, 22 January 2007 (UTC)
    • please refer the Language_and_library_specification. you don't need to give a fixity, there's a default fixity. functions starting with a letter are prefix, functions starting with a special char are infix. --Johannes Ahlmann 12:29, 22 January 2007 (UTC)
      • Ouch. Reading the spec sounds like fun...
  • GHC can do all sorts of program optimisations. But, for a given program, how can you tell what it really did when it compiled? Did it inline that function? Was that operation optimised into an in-place update? Is there a way to tell? (Short of using a disassembler that is!) MathematicalOrchid 11:47, 22 January 2007 (UTC)
    • you can look at intermediate compiler outputs with ghc flags. --Johannes Ahlmann 12:29, 22 January 2007 (UTC)
      • OK. I'll see if I can't dig it out of the GHC manual somewhere...
  • Is there a way to make a Haskell program utilise multiple CPUs? (I rephrase: clearly this is very possible theoretically. What I mean is does any known compiler provide a way to do this?) MathematicalOrchid 11:47, 22 January 2007 (UTC)
    • yes, ghc supports multiple CPUs. see GHC/Concurrency --Johannes Ahlmann 12:29, 22 January 2007 (UTC)
      • Right... Do I really need the nightly build to get this functionality? Or is that information outdated? That aside, I just need to compile my program with "-threaded" and run it with "+RTS -N2" or whatever? MathematicalOrchid 13:23, 22 January 2007 (UTC)
  • I want to write a program that renders bitmap graphics. Is there any way to get this onto the video screen in Haskell? Is there any way to get the data saved to disk in some sane file format? MathematicalOrchid 11:47, 22 January 2007 (UTC)