- 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...
-
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 point)...
-
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...
- this is a
comment on more
lines -} -- and this is a
comment on one line
putStrLn "Wikipedia" -- this is
another comment Haskell also
provides a literate...
- (), the unit type,
which contains no information. main :: IO () main =
putStrLn "****o, World!"
Command line
arguments are not
given to main; they must...
- is a one-liner: it
sorts its
input lines ASCIIbetically. main = (mapM_
putStrLn . Data.List.sort . lines) =<<
getContents -- In ghci a
qualified name like...