Re: [Haskell-cafe] Newbie Q: GHCi: Where “List” module is imported from?

Jules Bean jules at jellybean.co.uk
Fri Feb 16 18:01:02 EST 2007


Dmitri O.Kondratiev wrote:
>
> Where exactly "the Ord instance for lists is defined in the Prelude"?

Depends slightly on  your compiler, but you will find that some of the 
prelude has source, and some of the prelude is inevitably not written in 
haskell (the type system has to be bootstrapped somehow). There is 
special language support for lists although it is essentially just 
syntax: you could define a list by hand, but you wouldn't get the cute 
[1,2,3,4] style syntax for them (you'd have to write 1:2:3:4:Empty or 
similar).

> It seems that Prelude treats "list" as a built-in type same as a 
> "tuple" type. Also Prelude does not know anything about Data.List 
> type, right?

Data.List isn't a type. It's a module. (I.e. a bunch of functions and 
types). Data.List just happens to define some useful functions to use on 
lists.

http://cvs.haskell.org/Hugs/pages/libraries/base/Data-List.html

> As I understand in Haskell to be an instance of a class type must be 
> declared as:
>
> instance ClassName  TypeName
>
> where  then declaration:
>
> instance Ord []
>
> can be found?

In the source for the prelude.

Jules



More information about the Haskell-Cafe mailing list