F# interface inheritance failure due to unit

This looks like a nasty corner-case in the F# language, but I’m not sure if it qualifies as a by-design limitation or a bug in the compiler. If it is by design limitation, then the error message should say that (because currently, it doesn’t make much sense). Anyway, the problem is that the F# compiler … Read more

F# changes to OCaml [closed]

This question has been answered for some time now, but I was quite surprised that most of the answers say what OCaml features are missing in F# – this is definitely good to know if you want to port existing OCaml programs to F# (which is probably the motivation of most of the referenced articles). … Read more

Help me to explain the F# Matrix transpose function

The function is not particularly readably written, which may be the reason for your confusion. The construct (_::_)::_ is a pattern matching on value of type list of lists of ints that says that the first case should be run when you get a non-empty list of non-empty lists. The same thing can be written … Read more

While or Tail Recursion in F#, what to use when?

The best answer is ‘neither’. 🙂 There’s some ugliness associated with both while loops and tail recursion. While loops require mutability and effects, and though I have nothing against using these in moderation, especially when encapsulated in the context of a local function, you do sometimes feel like you’re cluttering/uglifying your program when you start … Read more

How do I write this member constraint in F#?

It’s not explicitly writing the constraints that is the issue, it’s that the syntax is not so nice that you can place a member constraint on a parameter and then invoke the member in the usual way. The body of walk_the_creature and walk_the_creature2 would be the same here: let inline walk_the_creature_2 (creature:^a when ^a:(member Walk … Read more