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.  Functions in "where" block. (Venu Chakravorty)
   2. Re:  Functions in "where" block. (Kim-Ee Yeoh)
   3. Re:  tutorials on space complexity? (Dimitri DeFigueiredo)


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

Message: 1
Date: Wed, 11 Jun 2014 21:54:42 -0400 (EDT)
From: Venu Chakravorty <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Functions in "where" block.
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hello everyone,
        I can't figure out why the following function does not work:




myFun :: Integer -> Integer
myFun x = op x + ep x
          where op x = 99
                    ep x = 1      -- squawks here



        Yeah it's a stupid function, but I was just trying to declare two 
functions in the "where" block. I expected
this to work and always return 100.


This is the error I get while compiling:

==================
Prelude> :l fun.hs
[1 of 1] Compiling Main             ( fun.hs, interpreted )


fun.hs:4:15: parse error on input `='
Failed, modules loaded: none.

==================


Could someone please tell me where I am going wrong?
Thanks in advance.



Regards,
Venu Chakravorty.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140611/77384d2c/attachment-0001.html>

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

Message: 2
Date: Thu, 12 Jun 2014 09:21:56 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Functions in "where" block.
Message-ID:
        <CAPY+ZdQV-dKPEz=hnybwwuzazsogqbmheweii+vad9mjtre...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Thu, Jun 12, 2014 at 8:54 AM, Venu Chakravorty <[email protected]> wrote:

> fun.hs:4:15: parse error on input `='
>

The problem wasn't obvious until I copy-pasted it into an editor:

You have tabs instead of spaces for the line defining ep.

The rule of thumb is that your editor must expand all tabs into matching
spaces for whitespace-sensitive languages like haskell. Or else you'll
waste time with this kind of parsing errors.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140612/6bc1ba6b/attachment-0001.html>

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

Message: 3
Date: Thu, 12 Jun 2014 01:32:39 -0300
From: Dimitri DeFigueiredo <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] tutorials on space complexity?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Thanks for the links. The guidance on your blog post is exactly the kind 
of analysis I was looking for.

Dimitri


Em 10/06/14 06:20, Heinrich Apfelmus escreveu:
> Dimitri DeFigueiredo wrote:
>> Are there any good tutorials on understanding space complexity for 
>> haskell programs?
>>
>> My current approach of "waiting for it to crash" by being out of 
>> memory, doesn't really seem like good engineering practice. However, 
>> I have not found a source that gives me any proactive insight into 
>> what should be avoided. Most of what I have read only helps to solve 
>> the problem "after the fact". How do we design programs that avoid 
>> those problems from the beginning? Any pointers?
>
> Lazy evaluation makes it difficult to reason about space usage -- it's 
> not compositional anymore. However, I have found the following 
> technique, dubbed "space invariants", to be very helpful:
>
> http://apfelmus.nfshost.com/blog/2013/08/21-space-invariants.html
>
> The main idea is that because it is impossible to trace lazy 
> evaluation in detail, we have to use invariants. In particular, we can 
> attach bounds on space usage to semantic meaning. Example:
>
>   "If this container with 5 elements is in WHNF, then it will use only 
> as much space as the 5 elements."
>
> (This invariant seems banal, but the point is that lazy evaluation 
> does not preserve it.)
>
> (WHNF means "weak head normal form", i.e. the expression has been 
> evaluated to the outermost constructor.)
>
>
> Best regards,
> Heinrich Apfelmus
>
> -- 
> http://apfelmus.nfshost.com
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



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

Subject: Digest Footer

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


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

End of Beginners Digest, Vol 72, Issue 12
*****************************************

Reply via email to