---
title: "Creation Functions"
canonical: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Coproducts/creation.html"
source: "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Coproducts/creation.md"
part: "Sets, Sequences, and Mappings"
chapter: "Coproducts"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Sets, Sequences, and Mappings", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/index-sets-sequences-mappings.md"}
  - {"title": "Coproducts", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Coproducts/index-coproducts.md"}
prev: {"title": "Introduction", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Coproducts/introduction.md"}
next: {"title": "Accessing Functions", "source": "https://docs.magma-maths.org/v2.30-1/SetsSequencesMappings/Coproducts/access.md"}
intrinsics:
  - {"name": "cop", "signature": "cop< S₁, S₂, ..., Sₖ >: Str, Str, ... -> Cop, [ Map ]"}
  - {"name": "cop", "signature": "cop< [ S₁, S₂, ..., Sₖ ] >: [ Str, Str, ... ] -> Cop, [ Map ]"}
  - {"name": "m(e)", "signature": "m(e): Map, Elt -> CopElt"}
  - {"name": "!", "signature": "C ! e: Cop, Elt -> CopElt"}
---

# Creation Functions

There are two versions of the coproduct constructor. Ordinarily, coproducts will be constructed from a list of structures. These structures are called the *constituents* of the coproduct. A single sequence argument is allowed as well to be able to create coproducts of parameterized families of structures conveniently.

## Creation of Coproducts

<a id="constructor-constructor-cop-str-str-cop-map"></a>
### `cop< S₁, S₂, ..., Sₖ >: Str, Str, ... -> Cop, [ Map ]`

<a id="constructor-constructor-cop-str-str-cop-map-2"></a>
### `cop< [ S₁, S₂, ..., Sₖ ] >: [ Str, Str, ... ] -> Cop, [ Map ]`

Given a list or a sequence of two or more structures $S_1$, $S_2$, $\ldots$, $S_k$, this function creates and returns their coproduct $C$ as well as a sequence of maps [$m_1$, $m_2$, $\ldots$, $m_k$] that provide the injections $m_i\colon S_i\rightarrow C$.

## Creation of Coproduct Elements

Coproduct elements are usually created by the injections returned as the second return value from the `cop<>` constructor. The bang (!) operator may also be used but only if the type of the relevant constituent is unique for the particular coproduct.

<a id="literal-m-map-elt"></a>
### `m(e): Map, Elt -> CopElt`

Given a coproduct injection map $m$ and an element of one of the constituents of the coproduct $C$, create the coproduct element version of $e$.

<a id="operation-op-cop-elt"></a>
### `C ! e: Cop, Elt -> CopElt`

Given a coproduct $C$ and an element $e$ of one of the constituents of $C$ such that the type of that constituent is unique within that coproduct, create the coproduct element version of $e$.
