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

How would I translate a Haskell type class into F#?

My brief answer is: OO is not powerful enough to replace type classes. The most straightforward translation is to pass a dictionary of operations, as in one typical typeclass implementation. That is if typeclass Foo defines three methods, then define a class/record type named Foo, and then change functions of Foo a => yadda -> … 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

Generate tail call opcode

C# compiler does not give you any guarantees about tail-call optimizations because C# programs usually use loops and so they do not rely on the tail-call optimizations. So, in C#, this is simply a JIT optimization that may or may not happen (and you cannot rely on it). F# compiler is designed to handle functional … 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)