What is () in Haskell, exactly?

前端 未结 6 1628
星月不相逢
星月不相逢 2020-12-12 15:55

I\'m reading Learn You a Haskell, and in the monad chapters, it seems to me that () is being treated as a sort of \"null\" for every type. When I check

6条回答
  •  执念已碎
    2020-12-12 16:21

    Yet another angle:

    () is the name of a set which contains a single element called ().

    Its indeed slightly confusing that the name of the set and the element in it happens to be the same in this case.

    Remember: in Haskell a type is a set that has its possible values as elements in it.

提交回复
热议问题