3 F# Syntax Basics

 

This chapter covers

  • Understanding core F# syntax
  • Working with type inference in F#

Now that you’ve gained a basic understanding of F# tooling and have spent a little time writing some (admittedly simple) F#, it’s time to learn about the core elements of the F# language. Many of the concepts and elements that you learn in this chapter are what I would call “cross-cutting”—they don’t have specific effects in any one type of application or use case but form the underpinnings of almost everything else in the language. So, it’s important to make sure you learn these concepts thoroughly. The first two, syntax and type inference, will give you an insight into the structure and look and feel of the language, while the second half of this chapter will help you understand how you’ll be structuring and composing applications together and building basic routines at a fundamental level.

3.1 F# syntax basics

The core syntax rules of a language say a lot about the “feeling” of the language. For example, some languages may focus on being highly explicit and verbose (I would, for example, put Java into this category); others may be terse and powerful but require more investment up front to understand what’s going on (Haskell, perhaps). Others might be lightweight with the intention of getting out of your way but don’t allow you to easily define the rules of what you’re trying to achieve (Go and, perhaps, Python).

3.1.1 Characteristics of F# syntax

3.1.2 The let keyword

3.1.3 Scoping

3.2 Type inference

3.2.1 Benefits of type inference

3.2.2 Type inference basics

3.2.3 Inferring generics

3.2.4 Diagnosing unexpected type inference behavior

3.2.5 Limitations of type inference

3.2.6 Criticisms of type inference

3.3 Exercise answers

Summary

sitemap