Hacker News new | ask | show | jobs
by Durgasoft 2240 days ago
I also dislike unnecessary use of programming jargon. A type constructor is all the possible ways to make a value of that type.

For example:

  type answer = | Yes | No | Maybe 
The type is 'answer'. The constructors are Yes, No, and Maybe (these are actually called type variants but now we're getting into jargon). I presume an 'abstraction over type constructors' means you want to generalize that type, so you can use the constructors to produce an abstract type that works with any type but I've never heard that specific term.
1 comments

This is wrong, those variants are value constructors. The type constructor there is “answer,” there’s only one of them.
So type constructors take types as their parameters and return new types you're saying, whereas the variant type in my example, the values are the constructors that make up the value of Type Answer
That's right. Type constructors are related to generics. For example if you have a generic type `List<A>` you could think of `List` as a type constructor.

In most languages, however, that's not a construct you can do much of anything with.