[Haskell-beginners] List syntax

Lyndon Maydwell maydwell at gmail.com
Fri Jul 27 17:01:20 CEST 2012


On Fri, Jul 27, 2012 at 10:52 PM, Stayvoid <stayvoid at gmail.com> wrote:
> Thanks.
>
> P.S. I think that you should send your answer to the list to show the
> others that this issue is solved.


Ah, I thought I replied to all. Well, here is my reply for the record :-)


Here's what I'm describing in a GHCi session:

>  λ [LT..GT]
>
> <interactive>:2:2:
>     Failed to load interface for `LT'
>     Use -v to see a list of the files searched for.
>
> <interactive>:2:2:
>     A section must be enclosed in parentheses thus: (LT.. GT)

I'm assuming that this was the error that you encountered when you
tried to use the syntax [LT..GT].

In my example I used a renamed module, but this also makes sense for a
module imported the usual way. I renamed the module so you could see
directly how an ambiguity could occur for 'LT'.

If you import a module you can rename it by using the 'as' keyword, in
this case, 'LT'. There is now an ambiguity between 'LT' = "less than"
and 'LT' = "Data.List".

>  λ import qualified Data.List as LT
>
>  λ :i LT.map
> map :: (a -> b) -> [a] -> [b]         -- Defined in `GHC.Base'

Here is a demonstration of the renamed module in action.

>  λ :i LT..
>
> Top level:
>     Failed to load interface for `LT'
>     Use -v to see a list of the files searched for.

And here is what I think is causing your error to be thrown - The
symbol '.' is being searched for in module LT in the same manner that
'map' was in the previous example, now given that there is no LT
module, it is failing.

This ambiguity might seem annoying, but it's not too bad since you can
just put some spaces in to resolve it.



More information about the Beginners mailing list