0

I am trying to connect to Interactive Brokers via their C# API. As an exercise, I am trying to develop my client in F#.

This is what I have done:

  1. I have imported the CSharpAPI project in Visual Studio. CSharpAPI defines the IBApi namespace
  2. I have created a new F# project in the solution. The project will host my implementation
  3. I created a new module in a .fs file as below:

    open IBApi
    
    module ibConnectivity =
    
       type IBclient =
           interface EWrapper with
           member this.connectionClosed() = printfn "connection has been closed"
           member this.currentTime time = printfn "server time: %i" time
    ....
    

I get the following error message:

Error 1 Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'

I have googled around for a solution. I am a complete noob. Some posts refer to F# file order, but in this case I am working with a C# library.

ildjarn
  • 62,044
  • 9
  • 127
  • 211
NoIdeaHowToFixThis
  • 4,484
  • 2
  • 34
  • 69

1 Answers1

0

This means that your file must start with a namespace or module declaration. Like this:

module ibConnectivity

open IBApi

type IBclient =
    interface EWrapper with
    member this.connectionClosed() = printfn "connection has been closed"
    member this.currentTime time = printfn "server time: %i" time

The syntax module Name = <indented declarations> is used to declare sub-modules within the module or namespace declared at the top of the file.

Tarmil
  • 11,177
  • 30
  • 35