[Haskell-beginners] Re: the role of assignments

prad prad at towardsfreedom.com
Fri Jul 2 03:26:09 EDT 2010


On Fri, 2 Jul 2010 03:27:00 +0200
Ertugrul Soeylemez <es at ertes.de> wrote:

> I think, you're building up the wrong intuition here.  Let me try to
> correct it.
thank you, ertugrul!
your detailed, example-laden explanation was wonderful!


> This is not an assignment.  You just give the result of the
> computation a name.
>
this is very meaningful to me.
thinking about it as you say really makes a difference in clarity for
me.


> getLine is a computation of type IO String, so 'line' is of type
> String. There is no conversion involved, because actually there is no
> "running" involved at all.
>
ya this too is something to understand - my reasoning has been
pythonish and that is likely a big part of the problem.


> As you can see from its type, it's
> also an IO computation:
> 
>   main :: IO ()
> 
this came as big surprise - but of course, now i think "what else could
it possibly be?"


> Whenever an equals sign is involved, this is
> just name giving, not an 'assignment' in the usual sense.
>
again this requires a conceptual shift for me.


> You can view GHCi's
> command line as one 'do' block, which gets executed as you type it.
> That's why you need 'let'.  You can't write top level definitions in
> GHCi.
> 
that clears up a big mystery. one of the tutorials i read pointed out
that things are just done 'differently' in ghci, but didn't explain the
rationale as you have done.


> I hope, this helps.
>
it most certainly has!!!
thanks to you and the other write-ups here, i'm starting to see haskell
differently which will no doubt result in constructing programs
successfully.

despite the difficulties i'm having, i've been convinced this is all
worth learning. 

and without doubt, the tone and activity of this board and its people
have much to do with it!


-- 
In friendship,
prad

                                      ... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's




More information about the Beginners mailing list