- program: main :: IO () main = do
putStrLn "****o, world!"
putStrLn "What is your name, user?" name <-
getLine putStrLn ("Nice to meet you, " ++ name ++...
-
command line and
outputs a
greeting message: main = do
putStrLn "What's your name?" name <-
getLine putStr ("****o, " ++ name ++ "!\n") The do-notation eases...
- main = do let full = Just 42 let
empty =
Nothing putStrLn $ "showValue full -> " ++
showValue full
putStrLn $ "showValue
empty -> " ++
showValue empty showValue...
-
firstWord putStrLn
bigWord braceful = do { text <-
getContents ; let {
firstWord = head $
words text ;
bigWord = map
toUpper firstWord } ;
putStrLn bigWord...
- " more
bottles of beer on the wall!") [3..] main :: IO () main =
mapM_ putStrLn (reverse $ take 99 verses) for i in range(99,0,-1): print(i,"bottles of...
- :: (Show t, r\x, r\y) => Rec (x::t, y::t | r) -> IO ()
printXY point =
putStrLn xy -- with SML
style field accessors ('#' prefix)
where xy = show (#x...
-
program in
Idris might look like this:
module Main main : IO () main =
putStrLn "****o, World!" The only
differences between this
program and its Haskell...
- file main :: IO () -- the
compiler can
infer this type
definition main =
putStrLn "****o, World!" The
factorial function in Haskell,
defined in a few different...
- is a one-liner: it
sorts its
input lines ASCIIbetically. main = (mapM_
putStrLn . Data.List.sort . lines) =<<
getContents -- In ghci a
qualified name...
- (), the unit type,
which contains no information. main :: IO () main =
putStrLn "****o, World!"
Command line
arguments are not
given to main; they must...