[Haskell-cafe] Functional version of this OO snippet

Andrew Wagner wagner.andrew at gmail.com
Fri Dec 5 07:40:38 EST 2008


Hi all,
public interface IEngine {
   void foo();
   void bar(string bah);
   ...
}
public class Program {
  public void Run(IEngine engine){
   while(true){
     string command = GetLine();
     if (command.startsWith("foo")){
       engine.foo();
     } else if (command.startsWith("bar")){
       engine.bar(command);
     ...
     else break;
}

In other words, I want to provide the same UI across multiple  
implementations of the engine that actually processes the commands.

Thanks in advance.


More information about the Haskell-Cafe mailing list