Created
November 28, 2018 04:54
-
-
Save nahiyan/4ea3181b6b4da9cb23556907301c7bd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright BDH Lab 2018 | |
#include <iostream> | |
#include <string> | |
using std::cout; | |
using std::string; | |
// IO class | |
class IO { | |
string output; | |
public: | |
void setOutput(string output) { | |
this->output = output; | |
} | |
string getOutput() { | |
return this->output; | |
} | |
IO bind(IO io) { | |
IO binded; | |
binded.setOutput(this->output + io.getOutput()); | |
return binded; | |
} | |
void execute() { | |
cout << output; | |
} | |
}; | |
// IO text | |
IO text(string text) { | |
IO io; | |
io.setOutput(text); | |
return io; | |
} | |
// Functional core's main | |
IO main_() { | |
return text("Hello World!\n") | |
.bind( | |
text("Hi hi!\n")); | |
} | |
// Imperative shell's main | |
int main() { | |
main_().execute(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment