Skip to content

Instantly share code, notes, and snippets.

Composable Types

This proposal describes a new composable type system for Go. It follows the design ideas of the already built-in composable types map and chan and should be understood as an alternative way to implement basic generic data structures.

The following is an example of a queue implemented as a composable type (boring code has been removed):

func main() {
	// compose a queue of integers
	q := comp[int]Queue{}