Zero constructors are allocated only once. Then all their applications are separated (in GHC, this behavior is not dictated by the Haskell standard).
() is the null constructor of a unit of type () . Therefore, using () universally worth some kind of memory. If you create a parameter of type () , you will still pay for the presence of this parameter. That is why, for example, there is a specialized Set a instead of Map a () .
For a data structure with a key, you need a type with the correct value. Therefore () is the right choice, but empty data types are not. A polymorphic type such as forall a. a forall a. a , must additionally be wrapped in a different data type, or require an offense if it is used as an argument, which is usually not supported properly.
source share