title: F# functional Callback
body: <p>I'm trying to migrate a C# program in F#. 
  The program is a FtpClient that wrap the FluentFtp library and expose the ftp methods through an interface as follow:</p>
  
  <pre><code>  public interface IFtpSession
  {
      IEnumerable&lt;string&gt; ListFiles(string remoteFolder);
  }
  
  sealed class FtpSession : IFtpSession
  {
      private FluentFTP.FtpClient FluentFtpClient { get; set; }
  
      internal FtpSession(FluentFTP.FtpClient fluentFtpClient)
      {
          this.FluentFtpClient = fluentFtpClient;
      }
  
      public IEnumerable&lt;string&gt; ListFiles(string remoteFolder)
      {
          return FluentFtpClient.GetListing(remoteFolder).Where(fileItem =&gt; fileItem.Type == FtpFileSystemObjectType.File).Select(fileItem =&gt; fileItem.FullName);
      }
  
  }}
  
  private static void CreateFtpSession(FtpConnectionSettings settings, Action&lt;IFtpSession&gt; onSessionOpen) {
          FluentFTP.FtpClient ftpClient = new FluentFTP.FtpClient(settings.Host, settings.Port, settings.UserName, settings.UserPassword);
          ftpClient.Connect();
          FtpSession ftpSession = new FtpSession(ftpClient);
          onSessionOpen(ftpSession);
          ftpClient.Disconnect();
      }
  </code></pre>
  
  <p>I would like to do the same thing in F# but in a functional way. That means that I don't want to use objects with members to replicate the above code in a OO F# style, but using only functions and value types.</p>
  
  <p>What is the correct way to do this kind of job?</p>
  
  <p>In the example above there is only one function (ListFiles), but my question assume that the interface IFtpSession could have other functions and doesn't respect the single responsability principle.</p>
  
  <p>Thanks a lot for your help</p>