How does F#’s async really work?

A few things. First, the difference between let resp = req.GetResponse() and let! resp = req.AsyncGetReponse() is that for the probably hundreds of milliseconds (an eternity to the CPU) where the web request is ‘at sea’, the former is using one thread (blocked on I/O), whereas the latter is using zero threads. This is the … Read more

Why isn’t there a protected access modifier in F#?

The protected modifier can be quite problematic in F#, because you often need to call members from a lambda expression. However, when you do that, you no longer access the method from within the class. This also causes confusion when using protected members declared in C# (see for example this SO question). If you could … Read more

F# keyword ‘Some’

Some is not a keyword. There is an option type however, which is a discriminated union containing two things: Some which holds a value of some type. None which represents lack of value. It’s defined as: type ‘a option = | None | Some of ‘a It acts kind of like a nullable type, where … Read more

F# Tail Recursive Function Example

Start with a simple task, like mapping items from ‘a to ‘b in a list. We want to write a function which has the signature val map: (‘a -> ‘b) -> ‘a list -> ‘b list Where map (fun x -> x * 2) [1;2;3;4;5] == [2;4;6;8;10] Start with non-tail recursive version: let rec map … Read more

F# collection initializer syntax

To elaborate a bit on collection initialization in F#, here are a few examples: read-only dictionary dict [ (1, “a”); (2, “b”); (3, “c”) ] seq (IEnumerable<T>) seq { 0 .. 99 } list [1; 2; 3; 4; 5] set set [1; 2; 3; 4; 5] array [| 1; 2; 3; 4; 5 |]

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)