[Haskell-beginners] having trouble with helloworld style program
Ertugrul Soeylemez
es at ertes.de
Mon Aug 8 15:57:41 CEST 2011
Sukumaran A <sukumaaar at gmail.com> wrote:
> 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
This is exactly equivalent to the other methods, but has the additional
'return', which is a no-op. Please do not suggest such a style. To be
honest, I think the best coding style for this particular example is not
to use do-notation at all:
module Main where
main :: IO ()
main =
let stringToInt :: String -> Int
stringToInt = read
in fmap stringToInt getLine >>=
print
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Beginners
mailing list