Welcome to fsharp-core-docs Discussions! #77
Replies: 2 comments 2 replies
-
Hello and thanks for the welcome. I am a long-time VB/C++/C# developer who avoids corporate work in the belief that the priority for software development at the moment is to bring new ideas to life not just computerise old ideas. I have worked with F# for about a year after finding C# got in the way of my designs. I honestly didn’t want to throw years of familiarity with C# out of the window and tried my best with C#, making use of all of its latest features (records, switch expressions etc.). Ultimately, I found them to be unnatural appendages to the already ungainly object orientated model. I appreciate how F#, by contrast, makes simple things simple. If I make a function call where the response might be choice between a person’s details, or a communication failure, or a general error with an explanatory text, then F# makes that easy to express. My purpose here in this forum is to help, where possible, to make F# better understood, especially by newcomers like me. I have done some experiments with regard to the above but thought before I foist them on to the community, it might be prudent to look at what directions are already being pursued. Accordingly, I read a lot of material including: dotnet/docs#26813 In general, the links above seem to be about improving the documentation in conventional ways. There are two problems I have with that:
To illustrate the second point, if you type “F# computation expressions” into Google or Bing, the first page that is displayed contains a long source code example that, for five and half years, did not compile. There is no shame in making mistakes, of course, but the fact that no-one complained in all that time strongly suggests people have little patience with documentation. So what to do instead of improving existing documentation? I suggest:
Since this forum is focused on documentation, I’ll just talk about an idea I've invented called F# Pearls. F# PearlsJust as a pearl is special, F# Pearls are pieces of documentation with special qualities. Pearls are:
The subject of each Pearl should:
A completed Pearl is added to the list of Pearls, which is ordered by importance. The list should appear as one long Html page with a table of contents at the top, allowing readers to skip to a topic of interest or to read through all the Pearls. The main purpose of F# Pearls is to turn people wanting to learn F# into working developers, but there are many other benefits:
Sample PearlsExample 1: F# decides the type of list/array by looking at the first elementSome programming languages scan entire array literals trying to guess what sort of array it is, or alternatively, insist that the type is stated explicitly. F# takes a simpler approach and uses just the first element to indicate the type of array. For example, the string at the start of the following list makes this a list of strings. You will get an error when the compiler encounters the number 1:
To make this list compile, you could make it an object list by casting the first element to a .Net System.Object as follows:
Example 2: Don’t despair over F# collection function namesThere are over 100 standard functions for processing lists, arrays and sequences etc. These functions have the format:
For reading and writing F# code, you are encouraged to learn all these functions. But how? The names themselves do not help much. For starters, the module names have limited meaning, usually just referring to the specific type of collection being targetted (List, Array and Seq etc). The function names often do not adequately communicate what they do. For example, it is unclear how List.pick and List.choose are different. There are better ways to learn the huge number of functions than to memorise them all. You can use modules [link to sample modules], or write your own, that map to the standard functions with functions that have more useful names. A more useful name might prompt you for what you’ve got and (roughly) what you want. So, a module might have entries like these:
So, in the case where you’ve got a List and you’d like to end up with something that represents one item in that list, you type List_one. and intellisense will prompt you with names such as pick, find, findBack, exactlyOne etc. Immediately, you are prompted with all the functions that take a list and return something that represents one item from that list. You’ve narrowed the scope from learning 100 functions to choosing from a few. |
Beta Was this translation helpful? Give feedback.
-
Hello @pbachmann It's a fundamentally great idea. For discussion this may not be the best place - this is really a technical repo for delivering doc content authored in dotnet/fsharp. It might be better to move to fslang-suggestions, and also to post links to the discussion on twitter. For execution, I'd just say "go for it" - just like Scott Wlaschin did (no permission was asked or needed to create "F# for fun and profit") . That is, create a blog, and start creating content, and perhaps find some like minded people on twitter or elsewhere to co-contribute. I and others will amplify. All your suggestions for topics to cover are good. |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions