Chapter 5. Mastering 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. This chapter covers .NET and F# types in general and generics and subtyping in particular. ...

Get Expert F# 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.