Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

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


Today's Topics:

   1.  formatting? (Alexander Chen)
   2. Re:  formatting? (Magnus Therning)


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

Message: 1
Date: Thu, 7 May 2020 19:01:43 +0200 (CEST)
From: Alexander Chen <alexan...@chenjia.nl>
To: beginners@haskell.org
Subject: [Haskell-beginners] formatting?
Message-ID: <1914130608.288460.1588870903...@ichabod.co-bxl>
Content-Type: text/plain; charset="utf-8"

Hi,

tensDigit.hs

tensDigit :: Integral a => a ->a
tensDigit x = d
  where xLast = x `div` 10
            d         = xLast `mod` 10

prelude> load tensDigit.hs
parse error on input ‘=’
Perhaps you need a 'let' in a 'do' block?
e.g. 'let x = 5' instead of 'x = 5'
4 |             d         = xLast `mod` 10   |                       ^
[1 of 1] Compiling Main             ( chapter7_8.hs, interpreted )
Failed, no modules loaded.

I suspect this has something to do with the spacing (since this is example 
code) if so could someone explain to me what the rules on spacing are so I can 
get past this. I am using a simple text editor so if someone has a 
recommendation for an IDE that simply takes care of this, much obliged!!

best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200507/f70d5195/attachment-0001.html>

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

Message: 2
Date: Thu, 07 May 2020 19:23:55 +0200
From: Magnus Therning <mag...@therning.org>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] formatting?
Message-ID: <87368bodzo....@therning.org>
Content-Type: text/plain; charset="utf-8"


Alexander Chen <alexan...@chenjia.nl> writes:

> Hi,
>
> tensDigit.hs
>
> tensDigit :: Integral a => a ->a
> tensDigit x = d
>   where xLast = x `div` 10
>             d         = xLast `mod` 10
>
> prelude> load tensDigit.hs
> parse error on input ‘=’
> Perhaps you need a 'let' in a 'do' block?
> e.g. 'let x = 5' instead of 'x = 5'
> 4 |             d         = xLast `mod` 10   |                       ^
> [1 of 1] Compiling Main             ( chapter7_8.hs, interpreted )
> Failed, no modules loaded.
>
> I suspect this has something to do with the spacing (since this is
> example code) if so could someone explain to me what the rules on
> spacing are so I can get past this. I am using a simple text editor so
> if someone has a recommendation for an IDE that simply takes care of
> this, much obliged!!
>

Try lining up the definitions in the where-clause. That'll do it.

tensDigit :: Integral a => a ->a
tensDigit x = d
  where xLast = x `div` 10
        d     = xLast `mod` 10

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: mag...@therning.org
twitter: magthe              http://magnus.therning.org/

If you can tell the truth, you don't have to remember anything.
     — Mark Twain
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200507/e72cf536/attachment-0001.sig>

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 143, Issue 1
*****************************************

Reply via email to