Types and Sets - Cardinality of Custom type

The cardinality has to do with values!

Result True Red and the others r{n} you provided don’t have any meaning.

Result is a type constructor (which accepts two concrete types), and Bool and Color are both concrete types. It is defined as such:

Result e a
    = Err e
    | Ok a

Which means it can have Cardinality(e) values possible for the Err value constructor to accept and Cardinality(a) values possible in the case of the Ok value constructor.

Bool has two values : True and False. Same with Color who has three values: Red, White and Blue.

Therefore, Result Bool Color can only have 5 values:

v1 = Err True
v2 = Err False
v3 = Ok Red
v4 = Ok White
v5 = Ok Blue

Hope that makes sens :slight_smile:

4 Likes