Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Generating Code To Embed in an Event Loop (Stephen Tetley)
   2.  Need some advices about university (Zhi-Qiang Lei)
   3. Re:  When to use ST (Ertugrul Soeylemez)


----------------------------------------------------------------------

Message: 1
Date: Tue, 25 Oct 2011 23:08:14 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Generating Code To Embed in an Event
        Loop
Cc: [email protected]
Message-ID:
        <cab2tprbqwbdapusi5kxtexkmbgfdpjjfadgwyvkhyozbtoi...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Darrin

The more typical scenario is to embed a "higher level" scripting
language within a game (Lua has been particularly popular) rather use
a higher level language to generate low level code.

Pragmatically, code generation works well in domains where you have a
succint input format and many candidates to generate - parser
generators like YACC or Haskell's Happy are prime examples. If you
don't have many candidates for generating, writing good libraries in
the low-level language seems a more profficient use of one's time.



------------------------------

Message: 2
Date: Wed, 26 Oct 2011 13:56:05 +0800
From: Zhi-Qiang Lei <[email protected]>
Subject: [Haskell-beginners] Need some advices about university
To: Haskell Beginer <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi,

I'm making a plan to gain more computer knowledge (functional programming and 
Haskell especially) and a Master's degree in a university. Does anybody know 
which university in USA has good resources in this domain? Thanks.

Best regards,
Zhi-Qiang Lei
[email protected]




------------------------------

Message: 3
Date: Wed, 26 Oct 2011 10:38:33 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] When to use ST
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII

Alex Rozenshteyn <[email protected]> wrote:

> Does anyone have any guidelines on when to use ST in an algorithm vs
> looking for a non-monadic, pure solution?

First of all, monadic doesn't mean impure.  Impure means IO or ST, and
only to a certain degree (you use destructive update, but regarding the
type system you don't break referential transparency, as long as you
don't unsafePerformIO).

Now to answer your question:  In general, never use ST.  Always
implement your algorithm purely using appropriate data structures
(vectors, maps, etc.).  With the right data structures your algorithms
should perform very well.

In some cases you really need to pull the last bit per second out of
your code.  In these cases find the bottleneck in your code and only
write that part in ST.  For example when working with vectors, use the
immutable ones, but in certain spots you can use 'create' or 'modify'
and sidestep into ST only for particular operations.

In less fixed data structures you generally don't need destructive
update at all, because e.g. maps only consume extra memory for the
changed paths.  Done properly the old paths get garbage-collected
immediately, thus immutable maps are very fast in Haskell.


> The reason I ask is that I have just implemented an Earley parser for
> class (in Python) and would like to re-implement it in Haskell. The
> algorithm makes heavy use of mutable state, some of which can clearly
> be refactored out, but some of which can't be done so clearly.

If it's just a parser, I suggest, well, writing a parser.  Use your
favorite parser monad.  If you need high efficiency in terms of
throughput, try attoparsec, which is a very fast ByteString parser.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/





------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 40, Issue 40
*****************************************

Reply via email to