Beginning F# – Console app and a Form

Just learning some F# basics – the following the tale of my journeys.

( This is literally going to be like a set of -superawesome- notes )


*Equips Visual Studio*

*Equips PluralSight*


Starting off with a F# Console Application


in a console application this will print text to the console.




creates  an -immutable- binding to a value. Since let binding are immutable by default, what is normally referred to as a variable is now referred to as a value (I’m going to assume its ok to keep calling it a variable as long as you know that it’s supposed to be immutable in F#). Immutable means that once an object has been created, it cannot be modified. Its like a Paladin bubble, except instead of repelling attacks for a small duration it repels definition changes for-ev-er. But… You can make a value mutable by simply sticking the keyword mutable after let.



to print a value in a printfn string, you must use a special character %s (%d for an int)




allows you to ‘open’ a namespace to use; functional equivalent of a using statement in C#


opening System.Windows.Forms requires adding a reference to the project.



allows you to create a data type.


which can be used to store data based upon the provided constructor (what’s in the curly braces)


F# already knows that you’re creating a new value of type Person based upon the parameters provided.

Intelligence + 2

Array [| |]

an array can be created by using a ‘[|’ to open the array and ‘|]’ to close it


I created an array of Person types that referenced use previously created data like my phil Person and the data read from the user’s input.

Intelligence + 1


time to make use of the open statement from above. Forms allow you to create a graphical representation of your data.


F# uses .NET just as C# can, to create a new form, use the ‘new’ keyword and instantiate a new Form().

The form requires a control to present the data, else it’s just a empty form. Instantiate a new GridGridView() with the ‘new’ keyword. Once it’s been created, it needs to be added to the form.

Finally, Application.Run(form) will let the app know to open up the form.

Here’s the finished product of this learning experience:


When the array is presented in the form, it was nice enough to sort the data out instead of having it all willy-nilly the way I entered it.

Intelligence = Over 9000.

2012-02-14-hold all this slinky

I was in a really weird mood while writing this blog. Hopefully if you read it, you got some enjoyment out of it. I learned something, maybe you did too ;D


Leave a Reply

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

You are commenting using your 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