20-CS-4003-001 Organization of Programming Languages Fall 2018

Lambda calculus, Type theory, Formal semantics, Program analysis

Prev     Next     All lectures           Code     Motivation


main = do
  putStrLn "What is your name?"
  name <- getLine
  putStrLn ("My name is " ++ name)
  -   A Haskell version of the following c++ code
using namespace std;

int main () {
   string name = "";
   cout << "What is your name?\n";
   cin >> name;
   cout << "My name is " << name << "\n";
   return 1;
Operations are pipelined to ensure extraction of text from the input stream and insertion of text into the output stream are handled correctly - that is, this sequence should be considered to be one operation that changes state multiple times and, when finished, presents as output a uniformly constructed state. Recall this is what happened in list comprehensions