How do I check for reference equality in F#?

The answer, it turns out, is to use LanguagePrimitives.PhysicalEquality: let isSameObject = LanguagePrimitives.PhysicalEquality let a = [1; 2; 3] let b = [1; 2; 3] let a’ = a printfn “%A” (isSameObject a b) // Prints “false” printfn “%A” (isSameObject a a’) // Prints “true” There was precisely one question I could find on Stack … Read more

F# – Should I learn with or without #light?

I’d definitely prefer learning F# with the #light syntax. The non-light version is sometimes useful for understanding some tricks about the F# syntax, but the #light syntax gives you much pleasant experience. For example – using #light let add a b c = let ab = a + b printfn “%d” ab c – ab … Read more

In Functional Programming, is it considered a bad practice to have incomplete pattern matchings

If you complete your pattern-matchings with a constructor [] and not the catch-all _, the compiler will have a chance to tell you to look again at the function with a warning the day someone adds a third constructor to lists. My colleagues and I, working on a large OCaml project (200,000+ lines), force ourselves … Read more

F# Shortcut Syntax for Properties?

F# 3 has auto-implemented properties so you can declare properties without declaring the backing field. Example taken from Properties(F#) on MSDN: type MyClass() = member val MyProperty = “” with get, set

AutoOpen attribute in F#

I think the main use for the AutoOpen attribute is when you want to make some let-bound values available when the user of your library opens a namespace. This is where the attribute is very useful, because I think libraries should generally export all definitions in namespaces, but for some purposes you need to export … Read more

What F# sorcery is this (>=>)?

That’s the Kleisli composition operator for monads. It allows you to compose functions with signatures like ‘a -> M<‘b> and ‘b -> M<‘c’> where M is monadic: in your case the Result<‘t> from the linked article. >=> is really just a function composition, but >> wouldn’t work here since the return type of the first … Read more

When do you put double semicolons in F#?

In the non-interactive F# code that’s not supposed to be compatible with OCaml, you shouldn’t need to ever need double semicolon. In the OCaml compatible mode, you would use it at the end of a top-level function declaration (In the recent versions, you can switch to this mode by using files with .ml extension or … Read more

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