- program: main :: IO () main = do
putStrLn "****o, world!"
putStrLn "What is your name, user?" name <-
getLine putStrLn ("Nice to meet you, " ++ name ++...
- main = do let full = Just 42 let
empty =
Nothing putStrLn $ "showValue full -> " ++
showValue full
putStrLn $ "showValue
empty -> " ++
showValue empty showValue...
-
command line and
outputs a
greeting message: main = do
putStrLn "What's your name?" name <-
getLine putStr ("****o, " ++ name ++ "!\n") The do-notation eases...
-
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...
-
program in
Idris might look like this:
module Main main : IO () main =
putStrLn "****o, World!" The only
differences between this
program and its Haskell...
- :: (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...
- is a one-liner: it
sorts its
input lines ASCIIbetically. main = (mapM_
putStrLn . Data.List.sort . lines) =<<
getContents -- In ghci a
qualified name...
- file main :: IO () -- the
compiler can
infer this type
definition main =
putStrLn "****o, World!" The
factorial function in Haskell,
defined in a few different...
- jill
putStrLn ("Bob's balance: " ++ show
bobBalance ++ ", Jill's balance: " ++ show jillBalance) if
bobBalance == 8000 then
exitSuccess else
putStrLn "Trying...