Xamarin / Android: F # scoping - how can I see the namespace in another file?
I know this sounds very thorough, but I can't get it to work. I will illustrate an example:
I am launching a new solution, I select a new Android application F # and call it FSScopeTest1, giving me MainActivity.fs
namespace FSScopeTest1 open System open Android.Content open Android.OS open Android.Runtime open Android.Views open Adroid.Widget [<Activity (Label = "FSScopeTest1", MainLauncher = true)>] type MainActivity () = inherit Activity () let mutable count:int = 1 override this.OnCreate (bundle) = base.OnCreate (bundle) // Set our view from the "main" layout resource this.SetContentView (Resource_Layout.Main) // Get our button from the layout resource, and attach an event to it let button = this.FindViewById<Button>(Resource_Id.myButton) button.Click.Add (fun args -> button.Text <- sprintf "%d clicks" count count <- count + 1 )
Then I add the new F # source file, ScopeTestNS.fs
namespace ScopeTestNS module ScopeTestMod = let astr = "some text"
Then I add to MainActivity.fs, in the second line:
open ScopeTestNS
and change the lamba expression for button.Click.Add to read
button.Click.Add (fun args -> // button.Text <- sprintf "%d clicks!" count // count <- count + 1 button.Text <- ScopeTestMod.astr )
now when i create the solution i get the error:
The namespace or module "ScopeTestMod" is not defined.
How to make my ScopeTestNS namespace visible in MainActivity.fs so that I can see any modules I define there?
Thanks a lot, Ross
source share