[Haskell-beginners] having trouble with helloworld style program

Sukumaran A sukumaaar at gmail.com
Mon Aug 8 14:12:45 CEST 2011


Ohh, I missed to see reply from others. Anyway I am putting one more method
just from my side

module Main where
import Prelude

stringToInt::String->Int
stringToInt str = read str

main =do
   x<-getLine
   y<-return x
   print $ stringToInt y

Regards
Sukumaran

On Mon, Aug 8, 2011 at 5:33 PM, Sukumaran A <sukumaaar at gmail.com> wrote:

> Dear Sunil
> I am very new to haskell, started reading  http://learnyouahaskell.com and
> completed upto functionally-solving-problems. In your example, it is very
> clear where the issue is
>
> Please check below code and try to infer what is wrong with you. Please let
> me know if you want explanation from my side.
>
>
> module Main where
> import Prelude
>
> stringToInt::String->Int
> stringToInt str = read str
>
> main =do
>    x<-getLine
>    let y=stringToInt x
>    print y
>
> On Mon, Aug 8, 2011 at 5:09 PM, Sunil S Nandihalli <
> sunil.nandihalli at gmail.com> wrote:
>
>> Hello everybody,
>>  All I want to do in the following code is to read  an integer from stdin
>> and print it back to stdout. Can somebody help me fix my code snippet
>> below..
>>
>> Thanks,
>> Sunil
>>
>>
>> module Main where
>> import Prelude
>>
>> stringToInt::String->Int
>> stringToInt str = read str
>>
>> main =
>>     do x<-getLine
>>        y<-stringToInt x
>>        print y
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110808/b89cfccd/attachment.htm>


More information about the Beginners mailing list