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

Dougal Stanton ithika at gmail.com
Wed Jan 14 10:30:24 EST 2009

On Wed, Jan 14, 2009 at 3:12 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:

>> 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)
> Looks a bit ugly, but kind of useful. I'd make the syntax:
> joinPath' root name = joinPath [root,name]
>  where import System.FilePath(joinPath)
> It does mean you need to read an entire file to see what functions it
> imports, but perhaps that is the way it should be. I could also
> imagine a syntax:
> joinPath' root name = import.System.FilePath.joinPath [root,name]
> i.e. doing an import and use at the same time.

This can be done with a fully-qualified name (or two). Not quite as
succinct, but I assume the scope of these imports is only local

> joinPath root path = jp [root,filename path]
>  where jp = System.FilePath.joinPath
>        filename = System.FilePath.takeFileName


> joinPath root path = System.FilePath.joinPath [root,System.FilePath.takeFileName path]



More information about the Haskell-Cafe mailing list