The question
What is the type constructor which generates a concrete type like [(Int,String)]
?
The origin of the question
I think this really sounds either like a stupid question or a meaningless riddle. I hope the following convinces you that I'm actually trying to find gaps in my understanding of the basics.
I know that []
- is a value (an empty list of any type),
- and it is a (unary) type constructor;
to "visualize" the second aspect, I can just type
> x = [1,2,3] :: [] Int
> :t x
x :: [Int]
which clearly shows that []
applied to the concrete type Int
gives another concrete type [Int]
.
So far so good.
On the other hand, (,)
also has two meanings:
- it is a (binary) type constructor too, which I verify with this
> x = (1,1) :: (,) Int Int
> :t
x :: (Int, Int)
- but it is also a value constructor:
> (,) 1 "hello"
(1,"hello")
So, if both []
and (,)
are type constructors that can originate, among other types, concrete types [Int]
and (Int,Char)
, I wonder what is the type constructor that generates a type like [(Int,Char)]
.
[]
applied to the concrete typeInt
gives another concrete type[Int]
" yes: tryGHCi> :k []
in GHCi to see this type's kind attesting to that. useGHCi> :t []
to see that value's type (same with(,)
, both as a value and as a type -- functions are values too). – Will Ness