Hacker News new | comments | show | ask | jobs | submit login
What I Learned Reading the F# Source (andredublin.github.io)
60 points by andredublin on Oct 2, 2015 | hide | past | web | favorite | 5 comments

> We can also combine expressions to build multidimensional arrays, and that Array.concat will concatenate (flatten) an array of arrays even though the documentation states and provides and example that it only concatenates a sequence of arrays.

Uhm what is he trying to say here? Arrays are sequences (they implement IEnumerable<T>), it is implied that you can use an array of arrays when it says you can use a sequence of arrays. You can also use a list of arrays. Or any other sort of sequence of arrays.

> We see that it indeed does take a sequence of arrays, may be an array of arrays is coerced via Array.toSeq before the concat operation happens.

That's exactly the opposite of what happens in the code. The concatArrays function takes an array of arrays. If the concat function is given a sequence that isn't an array then it converts that sequence to an array of arrays using Array.toSeq. Also "coerced" is the wrong term, it's just converted.

Another thing:

> Then we call the C# class method Array.Copy.

The author seems to be conflating C# with .NET.

Thanks for the feedback, I'll update my post and make sure to credit you. One question, Array.Copy is considered is considered a clr construct not exclusively to c#?

There is not really anything in .net that is exclusive to C#, though Microsoft.CSharp.dll has the purpose of supporting the C# compiler.

Array.Copy is part of mscorlib which is the most basic parts of .NET, and is defined in the ECMA-335 standard.

Nice write-up. I've generally found the F# source[1] very approachable and easy to peruse. Once you've learned the basics of F# it's a very good place to dig deeper into the language.

Although having said that, the source for FSharp.Control[2] (MailboxProcessor and its support types and functions) still leaves my head spinning somewhat!

[1] https://github.com/fsharp/fsharp

[2] https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSha...

Thanks! It'll be tough but fun to learn about.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact