[Haskell-cafe] Expanding do notation

Bulat Ziganshin bulatz at HotPOP.com
Sat Jan 7 17:56:35 EST 2006

Hello David,

Saturday, January 07, 2006, 8:37:01 PM, you wrote:

>> the mind-bending-thing I had to learn with Haskell is that the "let p ="
>> creates source code *shorthand*.
DFP> Yes, this is just what I need to understand.  Could you point me to a
DFP> description of this?  I couldn't find any discussion of it in the  
DFP> reference document.  Thanks.

i attached here two letters from july's dicussion on topic "Confused
about Cyclic struture". hope this will help

Daniel, i also included you in crossposting because these letters can
also help you understand how "run-time compilation" works. basically
it's a very simple thing: when we can compute at compile time value of
some computation, many compilers will do it and substitute expression
with its final value. the same can be done at the run-time - as soon
as we can compute value of some expression used in program or at least
simplify it using our knowing of part of arguments, this can be used
to reduce number of computations which program need to perform. say,

n <- readIO
print (factorial n)
print (factorial n)

here, "factorial n" can be computed just one time. it's obvious. in
this case

n <- readIO
flip mapM [1..100] $ \x ->
  print (x^n)

it's not so obvious that when program read value of `n`, it can
substitute instead of `x^n` the concrete, faster algorithm, say 'x*x'
for n=2. Haskell's ideology of "graph reductions" makes such "run-time
optimizations" automatically. it it the thing that called "run-time
compilation" on those wiki page. in KMP algorithm we compile string
searched to algorithm that will do the search of this concrete string.
another examples from my own practice is compilation of strings
representing regular expressions to functions which tests compliance
with these regexprs, and compiling list of sorting criterions to
compare function (you can find last example at the end of
RunTimeCompilation hawiki page)

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: letter1
Type: application/octet-stream
Size: 4347 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060108/725ee398/letter1.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: letter2
Type: application/octet-stream
Size: 6450 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060108/725ee398/letter2.obj

More information about the Haskell-Cafe mailing list