Explaining pattern matching vs switch

Having formerly been one of “those people”, I don’t know that there’s a succinct way to sum up why pattern-matching is such tasty goodness. It’s experiential. Back when I had just glanced at pattern-matching and thought it was a glorified switch statement, I think that I didn’t have experience programming with algebraic data types (tuples … Read more

Application architecture/composition in F#

This is easy once you realize that Object-Oriented Constructor Injection corresponds very closely to Functional Partial Function Application. First, I’d write Dings as a record type: type Dings = { Lol : string; Rofl : string } In F#, the IGetStuff interface can be reduced to a single function with the signature Guid -> seq<Dings> … Read more

Use of `inline` in F#

The inline keyword indicates that a function definition should be inserted inline into any code which uses it. Most of the time, this will not have any effect on the type of the function. However, in rare cases, it can lead to a function which has a more general type, since there are constraints which … Read more

Call F# code from C#

Below is a working example of calling F# from C#. As you encountered, I was not able to add a reference by selecting from the “Add Reference … Projects” tab. Instead I did have to do it manually, by browsing to the F# assembly in the “Add Reference … Browse” tab. —— F# MODULE —– … Read more

Is it possible to write a JIT compiler (to native code) entirely in a managed .NET language

And for the full proof of concept here is a fully capable translation of Rasmus’ approach to JIT into F# open System open System.Runtime.InteropServices type AllocationType = | COMMIT=0x1000u type MemoryProtection = | EXECUTE_READWRITE=0x40u type FreeType = | DECOMMIT = 0x4000u [<DllImport(“kernel32.dll”, SetLastError=true)>] extern IntPtr VirtualAlloc(IntPtr lpAddress, UIntPtr dwSize, AllocationType flAllocationType, MemoryProtection flProtect); [<DllImport(“kernel32.dll”, SetLastError=true)>] … Read more

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