CHAPTER 5Mastering Types and Generics

F# constructs such as lists, tuples, and function values are all generic, which means they can be instantiated at multiple different types. For example, int list, string list, and (int * int) list are all instantiations of the generic family of F# list types. Likewise, int -> int and string -> int are both instantiations of the generic family of F# function types. The F# library and the .NET Framework have many other generic types and operations in addition to these.

Closely related to generics is the notion of subtyping. Generics and subtyping combine to allow you to write code that is generic over families of types. In this chapter, we cover .NET and F# types in general and generics and subtyping in particular. ...

Get Expert F# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.