Uses of the type Unit
-
03-11-2019 - |
Frage
The Unit
type is a singleton type containing the constant unit
. In functional languages with side effects, unit
is used in functions that perform side effects. For example print
is a function from string
to Unit
.
Unit
also corresponds to truth. If you view the type of the expression as a proposition and the program as a proof, Unit
corresponds to truth since you can always prove Unit
by using the constant unit
.
My question is aside from these two uses, is there any other uses of Unit
?
Keine korrekte Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit cs.stackexchange