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

Job Vranish jvranish at gmail.com
Wed Jan 14 12:37:58 EST 2009

What I would really like to see is locally scoped imports but with
parameterized modules. (so modules could take types and values as
The places where I most want a feature like this is when I have a group of
helper functions that need a value that is outside the modules scope, but
that in general doesn't change. Usually we just curry the functions, but
that generates a lot of wasted code.
A good example might be the token
parsec. Rather than have something like this:

whiteSpace= P.whiteSpace
lexeme    = P.lexeme lexer
symbol    = P.symbol
<http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#symbol> lexer
natural   = P.natural

We could do something like:

import ParsecToken lexer

Having an import/module feature like this would replace almost all cases
where someone might wish for a macro system for Haskell.

>> Hmm, looks nice, and sensible. But as soon as you've got \N{....} syntax
I want:
>> "foo\E{show i}bar"
> "foo"++show i++"bar"
>Change the language - save two characters.

For simple cases, doing "foo" ++ show i ++ "bar" isn't bad at all, but when
you have five or six or ten (show i)s that you want to mix in, it can get
pretty hard to read.

On Wed, Jan 14, 2009 at 11:43 AM, Ketil Malde <ketil at malde.org> wrote:

> "Neil Mitchell" <ndmitchell at gmail.com> writes:
> >> 1) In a Python string it is available the \U{name} escape, where name is
> >>   a character name in the Unicode database.
> >>   As an example:
> >>       foo = u"abc\N{VULGAR FRACTION ONE HALF}"
> Why not:
>    import Unicode.Entities as U
>    foo = "abc"++U.vulgar_fraction_one_half
> > Hmm, looks nice, and sensible. But as soon as you've got \N{....} syntax
> I want:
> >
> > "foo\E{show i}bar"
>   "foo"++show i++"bar"
> Change the language - save two characters.
> >> 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)
> > It does mean you need to read an entire file to see
> Well, then you might as well allow multiple modules per file as per
> the recent discussion.  And multi-module files will possibly let you
> achieve the desired encapsulation without actually changing the
> language.
> -k
> --
> If I haven't seen further, it is by standing in the footprints of giants
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090114/dae43710/attachment.htm

More information about the Haskell-Cafe mailing list