Hacker News
points by markasoftware 2 days ago | 0 comments
Those are not types at all. Ok and Err are type constructors for the Result<A, B> type that take arguments of type A and B respectively.
[–] SkiFire13 2 days ago
> type constructors

Nit: the type constructor is `Result`: given two types `A` and `B` (not instances of those types, but actual types) it gives you a new type `Result<A, B>`.

`Ok` and `Err` are called "variants" and can be used to construct a new _instance_ of `Result<A, B>`.

[–] markasoftware 1 day ago
Ah, thanks! I'd remembered the term "data constructor" from Haskell and called it a type constructor instead.
[–] kazinator 1 day ago
Ok and Err are "thingies" which are in the type system, which give rise to distinctions that allow for compile-time diagnostics. They are part of the type.

Ok and Err are not just type constructors because they appear on the left hand side in pattern matching: they "do" matching and destructuring also.