liveBook · Manning

Type constructor

A type constructor is a construct that takes type parameters, and sometimes values, to form or instantiate a type.

How 3 Manning books explain it

Functional Programming in Scala, Second Edition

A type constructor is a type-level function that takes one or more types as parameters and produces a new parameterized type.

How it is used
Abstracts over parameterized computational and data contexts to define shared interfaces such as Foldable, Functor, Monad, and Free.
How deep it goes
Defines unary constructors, then works through partial application and type lambdas for two-argument State before applying constructors in abstractions.
Examples
Uses List, Option, Gen, Parser, State, Par, Function0, Async, TailRec, and Free as concrete constructor examples.
What you can do after
Apply it via Scala type aliases and type lambdas to supply one-argument constructors required by Monad instances.

Read how Functional Programming in Scala, Second Edition explains type constructor →

Functional Programming in JavaScript

An operation or definition that creates values of a parameterized type.

How it is used
Creates the container form used before chaining, flattening, or handling missing values in monadic code.
How deep it goes
Defines the constructor role and names its place in the monad interface, but stops short of formal type-system detail.
Examples
Uses Wrapper.of, Maybe.of, and Maybe.fromNullable as concrete constructors for wrapped, present, or absent values.
What you can do after
Build it from scratch as the entry point for values that will be mapped, joined, or safely handled later.

Read how Functional Programming in JavaScript explains type constructor →

Type-Driven Development with Idris

A type constructor is a construct that takes types or values as arguments and forms a type.

How it is used
Defines data types and their parameters, including families indexed by values.
How deep it goes
Works through generic and dependent definitions, type errors, and length-aware vector functions.
Examples
Uses List, power-indexed Vehicle, and length-indexed Vect, including vector append.
What you can do after
Build it from scratch by defining types such as Vect and implementing functions whose types express length relationships.

Read how Type-Driven Development with Idris explains type constructor →

What to know first

Related concepts

Questions about type constructor

What is type constructor?

A type constructor is a construct that takes type parameters, and sometimes values, to form or instantiate a type.

Which Manning books explain type constructor?

Functional Programming in Scala, Second Edition, Functional Programming in JavaScript and Type-Driven Development with Idris.

What should I know before learning type constructor?

Manning books that teach type constructor usually introduce data transformation, list and referential transparency first.

What kinds of type constructor are there?

Kinds of type constructor include vect and anonymous type constructor.

What is type constructor part of?

Type constructor is part of data type. A data type classifies values by their permitted forms or representations and the operations or interpretations applicable to them.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.