[Haskell-cafe] some ideas for Haskell', from Python

Artyom Shalkhakov artyom.shalkhakov at gmail.com
Thu Jan 15 23:26:03 EST 2009


Hi Manlio

2009/1/15 Manlio Perillo <manlio_perillo at libero.it>:
> Note that it seems you have sent this message only to me;
> I'm sending the reply to both you and the mailing list.

Yes, sorry, I always forget forwading to the mailing list. :(

> By the way, here is a strange (for me) problem I hit, and made me think
> about this extension.
>
> Suppose a file foo.hs defines:
>
> import Control.Monad
> import System.Posix.Files as PF
>
>
> isDirectory :: FilePath -> IO Bool
> isDirectory path =
>    PF.isDirectory `liftM` PF.getFileStatus path
>
>
> If I try to load the file from ghci I get:
>
> Prelude> :l foo.hs
> [1 of 1] Compiling Main             ( foo.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> isDirectory "/var"
>
> <interactive>:1:0:
>    Ambiguous occurrence `isDirectory'
>    It could refer to either `Main.isDirectory', defined at foo.hs:6:0
>                          or `PF.isDirectory', imported from
> System.Posix.Files at foo.hs:2:0-30
>

That's exactly the problem of "function call hi-jacking". [1] In Haskell
it's solved using qualified imports.

Cheers,
Artyom Shalkhakov.

[1] http://digitalmars.com/d/2.0/hijack.html


More information about the Haskell-Cafe mailing list