Friday 13 May 2016

Haskell: putChar: Write a character to the standard output

Haskell provides putChar function, which writes a character to standard output.

Prelude> :t putChar
putChar :: Char -> IO ()


Sample.hs
main = do
        putStrLn "Enter (M) If you are male, else (F) "
        gender <- getChar
        putChar gender

$ ghc Sample.hs
Linking Sample ...
$ ./Sample
Enter (M) If you are male, else (F) 
M
M



Previous                                                 Next                                                 Home

No comments:

Post a Comment