F Sharp for beginners: Modules in F #

List of articles of F Sharp beginner series

All the codes you write in F Sharp are by default in a MODULE, regardless of the fact that whether you explicitly define a module or not.

Anonymous Module

clip_image001

Anonymous module has the same name as of file name with first letter in upper case.

Let us say,

  1. you are writing codes inside a file called myfile.fs
  2. You have explicitly not given a module name.
  3. Inside the file myfile.fs, you have code as below

 

clip_image002

4. By default module for above code would be Myfile (same as the file name of the code with first letter in upper case)

image

Creating Module

Explicitly Module name can be given by using the keyword “Module” .

clip_image004

Now if you want to access variable myNumber in some other module then you will access as below,

clip_image005

Creating Nested Modules

You can create nested modules by using equal to (=) sign with the module name.

clip_image006

In above code we have defined nested modules. You can access myNumber1 variable as below,

clip_image008

In other module you will find inellisense also working,

clip_image009

This was all about Modules in F sharp.

I hope this post was useful. Thanks for reading Smile

List of articles of F Sharp beginner series

 

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

3 thoughts on “F Sharp for beginners: Modules in F #

  1. Pingback: Dew Drop – September 29, 2011 | Alvin Ashcraft's Morning Dew

  2. Pingback: Monthly Report September 2011: Total Posts 28 « debug mode……

  3. Pingback: Interesting .NET Links - September 30 , 2011 | TechBlog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s