F#
Guess a project by logo
Where should the source code of Visual F# Tools be?
Recently Steffen Forkmann raised a very important question about CodePlex usability and how it affects future of F# OSS contribution. Please read his arguments in “Microsoft, Open Source development and Codeplex” and share your opinion. Thanks.
Lexing and Parsing with F# – Part I
Good startup guide for FsLexYacc http://fsprojects.github.io/FsLexYacc/
Syntax tutorials:
– http://plus.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamllex-tutorial/index.html
– http://plus.kaist.ac.kr/~shoh/ocaml/ocamllex-ocamlyacc/ocamlyacc-tutorial/index.html
September 10th 2010 | David Cooksey
Lexing and Parsing with F# â Part 1
FsLex and FsYacc are F# implementations of Ocamlâs Lex and Yacc. They are part of the F# Powerpack released for Visual Studio 2010. Used together, they take an input string and create a parse tree of typed objects. Once you have the parse tree, you can do anything with itâgenerate code for another language, interpret it directly, etc. If youâd like to jump right into the code, scroll to the bottom of the post. Note that the code includes a small test project using FsUnit.
FsLex is the lexer part of the lexer-parser pair. It converts an input string or stream into a series of tokens. A token is simply a string labeled so that the parser knows how to handle it. For example, â92â might be within a token labeled DIGIT. Simply put, theâŚ
View original post 606 more words
Why I wish C# never got async/await
Absolutely the same feelings
Where to practice your F# with fun?
Recently Scott Wlaschin blogged an excellent post “Twenty six low-risk ways to use F# at work” with guides and samples of how to improve your productivity at work with some of F# tips. But how to train your F# skills? Yes, the best answer is to read excellent F# books and contribute to open sourced F# projects. But it could be not so entertaining if you want to improve your language understanding and practice it in combat. (Nevertheless, contribution to open source is the most useful way)
I have tried to collect all (known to me) online competitions and problem archives that accept source code in F# or do not obligate you to sent source code to the server. This post is inspired by blog post from Alex Ivanovs “14 Coding Challenges to Help You Train Your Brain“.
Resources that support F# compilation.
HackerRank
Competitive programming challenges and contests across computer science.
SPOJ(Sphere Online Judge)
Sphere Online Judge â is a problemset archive, online judge and contest hosting service accepting solutions in many languages.
CODECHEF
CodeChef is a global programming community. They host contests, trainings and events for programmers around the world.
 Hello World Open
Language independent resources.
Sites that ask to solve problems and provide the answer but do not obligate you to send source code.
Project Euler
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.
Rosalind
Rosalind is a platform for learning bioinformatics through problem solving.
Google Code Jam
Google Code Jam is onŃe a year competition. It is back in action challenging professional and student programmers around the globe to solve difficult algorithmic puzzles.
Kaggle
Kaggle is a platform for predictive modelling and analytics competitions on which companies and researchers post their data and statisticians and data miners from all over the world compete to produce the best models.
P.S. If you know other competitions or training sites that support F# please leave links in comments.
Notes from .NET Meetup #4 & F# ad
Today I first visited an event from .NET User Group Minsk: .NET Meetup #4 in Imaguru startup hub. I was quite surprised by F# questions from audience!
The first speaker Dmitriy Gurskiy told us a history of creation EPAM‘s Microsoft Technology Radar (that is unfortunately not public yet). A first F# question was asked here “Where is F#(and all this functional stuff) on this radar?”.  Alas, but F# was not there.
The second speaker Alius Petraťka (a guest from Lithuania) showed up how to start developing with Windows Azure. Some technical issues with Wi-Fi were there, but it was funny.
The last and third speaker Maxim Paulousky shared news from BUILD 2014 and his impressions from this event. At the end of his talk, he also got some questions about F#: “What was announced about F#?”, “What plans Microsoft has for F#?” and “Why we do not have F# projects in Minsk?”.
It was really unexpected to hear so much interest to F#. Nice to know that F# is interesting for people.
For those who interested in F#, I want to tell that we have Minsk F# User Group: you can join us on meetup.com, join our Facebook group, join our Skype group or follow #fsharp on Twitter.
P.S. Thank for the event to all organizers. It was cute.
Building an “actor” in F# with higher throughput than Akka and Erlang actors
Amazing post!!!
Building an âactorâ in F# with higher throughput than Akka and Erlang actors
The âBig Dataâ problem
Our free lunch is over!
The number of transistors in our CPUs is still increasing like Mooreâs law predicted. However, the frequency of our chips is flat-lining. We can no longer expect to see a 2x or even 1.5x performance improvement every 18 months from code that doesnât exploit parallelism.
âBig Dataâ has arrived
According to Cisco we are now in The Zetabyte Era.
Global IP traffic has increased eightfold over the past 5 years.
Globally, mobile data traffic will increase 18-fold between 2011 and 2016.
The Economist ran an article in 2010 on what some are calling âthe industrial revolution of dataâ.
Oracle, IBM, Microsoft and SAP between them have spent more than $15 billion on buying software firms specialising in data management and analytics.
This industry is estimated toâŚ
View original post 2,148 more words
F# Kung Fu #3: Exceptions recap.
Define
Usually, you do not need to define custom exceptions during programming in F#. If you do scripting in F#, in the most cases you will be happy with standard .NET exception types and F# built-in helper functions. But when you create a custom library or design complex enterprise software, you will need to use power of .NET exceptions. How you can do it from F#:
// C# style exception (possible, but not recommended) type MyCsharpException(msg, id:int) = inherit System.Exception(msg) member this.Id = id // F# style exceptions exception MyFsharpSimpleException exception MyFsharpException of string * int
Note that F# has a special keyword exception for defining “handy” exceptions.
Raise(Throw)
F# provides set of functions (failwith, failwithf, invalidArg, invalidOp, nullArg) that help to raise most common exceptions. They are very convenient especially for F# scripts.
let rnd = System.Random()
let rnd = System.Random()
let raiseException() =
match rnd.Next(8) with
| 0 -> failwith "throws a generic System.Exception"
| 1 -> failwithf "throws a generic Exception with formatted message (%d)" 1
| 2 -> invalidArg "_" "throws an ArgumentException"
| 3 -> invalidOp "throws an InvalidOperationException"
| 4 -> nullArg "throws a NullArgumentException"
| 5 -> raise <| MyFsharpException("throws a MyFsharpException", 5)
| 6 -> raise <| MyCsharpException("throws a MyCsharpException", 6)
| 7 -> assert (2>1)
| _ -> raise <| System.Exception("Impossible case")
The assert expression is syntactic sugar for System.Diagnostics.Debug.Assert. The assertion is triggered only if the DEBUG compilation symbol is defined.
Try-With/Finally (Catch)
The last step is to catch exceptions and handle them in a proper way.
let catchException() =
try
raiseException()
with
| Failure(msg) // 'Failure' active pattern catches only Exception objects
-> printfn "%s" msg
| MyFsharpException(msg, id)
-> printfn "Catch F# exceptions using pattern matching"
| : ? System.ArgumentException as ex
-> printfn "Invalid argument '%s'" ex.ParamName
| : ? MyCsharpException | : ? System.InvalidOperationException
-> printfn "You can handle multiple exceptions at a time"
| _ as ex
-> printfn "Log: exception '%s'" (ex.GetType().Name)
reraise() // re-raise exception
let finaly() =
try
catchException()
finally
printfn "Now, I am ready for exceptions!"
‘: ?‘ is a two-symbol operator without space inside.
Note:
- Failure active pattern catches only System.Exception objects. It is useful to handle exceptions raised by failwith & failwithf functions.
- Exceptions defined using exception keyword could be handled automatically using pattern matching.
- F# provides reraise function that helps to raise a current exception one more time. This function can be used only from pattern matching rules of try-with expressions.
If you want to learn more about exceptions, read an amazing The “Expressions and syntax” series from Scott Wlaschin.

























































