Input/Output Flashcards
What is an Action
An action is a value of type IO a that, when performed, may do some input/output, before delivering a value of type a.
Example putStrLn :: String -> IO()
What does the bind operator»_space;= do?
Passes the result of performing a first action to a parameterised second action i.e
snooper = readFile “/etc/passwd”»_space;=
putStrLn
Do notation
Do notation provides a convenient notation for the»_space;= and»_space; operators
test fn s
= do writeFile fn s
readFile fn
Why is traditional parallel programming hard?
One must conceive of a parallel algorithm express the algorithm using tasks map the tasks onto processors ensure that scheduling avoids deadlock.
Why is function parallel programming easier?
One must
conceive of a parallel algorithm
Why would a sequential algorithm not work well on multiprocessor machine
Only one processor can get involved.
Before creating a task to evaluate an expression one must consider:
is the result going to be useful
is the computation large enough
is there spare processing capacity