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

Manlio Perillo manlio_perillo at libero.it
Thu Jan 15 05:53:07 EST 2009

Artyom Shalkhakov ha scritto:
> Hi Manlio,

Hi Artyom.
Note that it seems you have sent this message only to me;
I'm sending the reply to both you and the mailing list.

> 2009/1/14 Manlio Perillo <manlio_perillo at libero.it>:
>> 2) In Python it is possible to import modules inside a function.
>>   In Haskell something like:
>>   joinPath' root name =
>>       joinPath [root, name]
>>       importing System.FilePath (joinPath)
> I guess you're talking about first-class modules, the ones that
> might be passed to functions as arguments, returned from functions
> as a result, loaded at run-time, etc.

No, I was not going that far :).

I simply was proposing a method to keep imported definitions local to a 

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"

     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

 > [...]

Manlio Perillo

More information about the Haskell-Cafe mailing list