Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't GHCi resolve the kind of [[]]?

Why can't Haskell resolve the kind of [[]] (A list of lists)?
Why isn't it simply * -> *, as I can give it a type like Int, and get [[Int]], which is of kind *.

like image 278
Squidly Avatar asked Jun 08 '10 04:06

Squidly


People also ask

What is the difference between GHC and ghci?

Introduction. GHCi is GHC's interactive environment, in which Haskell expressions can be interactively evaluated and programs can be interpreted.

Is ghci an interpreter?

This library offers interfaces which mediate interactions between the ghci interactive shell and iserv , GHC's out-of-process interpreter backend.

How do I run a Haskell file with ghci?

If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.


1 Answers

I think it's the same as with Maybe Maybe, although in the latter case the reason is perhaps clearer: the "outer" type constructor expects to be passed a type of kind *, but sees a type constructor of type * -> * (the "inner" Maybe / []) and complains. If I'm correct, this is not really a problem with the :kind functionality of GHCi, but rather with finding the correct syntax to express the composition of higher-kinded type constructors.

As a workaround, something like

:kind forall a. [[a]]
:kind forall a. Maybe (Maybe a)

can be used (with the appropriate language extension turned on -- ExistentialQuantification, I think -- to enable the forall syntax).

like image 192
Michał Marczyk Avatar answered Oct 14 '22 22:10

Michał Marczyk