The same views for the int list compared to the int list & # 8594; Int?

Why do they both have the same look?

ghci> :k [Int]
[Int] :: *
ghci> :k [Int -> Int]
[Int -> Int] :: *

EDIT for @ Gabriel Gonzalez a helpful comment.

I don’t understand kindswell, so I don’t have a good basis for expecting the above types to change in kind.

+4
source share
3 answers

Ok, let it check.

Int :: *
[] :: * -> *

Therefore, when you apply a type Intto a type constructor []:

[] Int :: *

This is another (legal) way of writing

[Int] :: *

Well, that should be pretty easy.

Int :: *
(->) :: * -> * -> *
[] :: * -> *

(->) Int :: * -> *
(->) Int Int :: *

Same as

Int -> Int :: *

and therefore, for the same reasons as above,

[Int -> Int] :: *

But here's the secret .. Get to know the type [].

[] :: * -> *

, , , *. - *, *.

- , . , . , kind * , " ". ( , , .) , , *.

+9

* . , . :

Int
Int -> Int

[] * -> * - . (.. *):

[ Int ]
[ Int -> Int ]
+3

, * . , ( - ) Int, [Int], Int -> [Int] *.

Maybe , . Maybe Int - , Maybe Float ..... wheresas. , Maybe , (, Int) Maybe Int. , * -> * : . , Maybe , , Maybe a, .

In the same manner, 2-uple (,)takes 2 type a, and bcreates a new: (a, b). This is good * -> * -> *, etc.

+1
source

All Articles