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

2009-01-20 Thread Bas van Dijk
On Wed, Jan 14, 2009 at 3:59 PM, Manlio Perillo manlio_peri...@libero.it 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) I just like to point

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

2009-01-20 Thread Lennart Augustsson
Yes, the Agda modules remind me of Cayenne. :) On Tue, Jan 20, 2009 at 12:54 PM, Bas van Dijk v.dijk@gmail.com wrote: On Wed, Jan 14, 2009 at 3:59 PM, Manlio Perillo manlio_peri...@libero.it wrote: 2) In Python it is possible to import modules inside a function. In Haskell something

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

2009-01-20 Thread George Pollard
On Wed, 2009-01-14 at 15:59 +0100, Manlio Perillo wrote: 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 = uabc\N{VULGAR FRACTION ONE HALF} This is possible via QuasiQuotation, you can

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

2009-01-17 Thread Artyom Shalkhakov
Hello, 2009/1/16 Immanuel Litzroth immanuel...@gmail.com: I don't understand your comment. 1) If XMonad already uses it the problem is solved, without giving Haskell import new semantics? Right, but there are some restrictions. 2) These guys refer to a method to do plugin work in Haskell

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

2009-01-16 Thread Manlio Perillo
Artyom Shalkhakov ha scritto: [...] 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

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

2009-01-15 Thread Manlio Perillo
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_peri...@libero.it: 2) In Python it is possible to import modules inside a function. In

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

2009-01-15 Thread Manlio Perillo
Brandon S. Allbery KF8NH ha scritto: [... about Python import local to functions ...] Sometime they are necessary, to avoid circular import problems (but this not a problem with Haskell). ...in theory. In practice GHC needs help with circular imports, and some cycles might be impossible

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

2009-01-15 Thread Marc Weber
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 = uabc\N{VULGAR FRACTION ONE HALF} I think you can use quasi quotation of ghc to achieve this ? Your code would look like this then: let

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

2009-01-15 Thread Immanuel Litzroth
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) In Python importing a module has totally different semantics from importing in Haskell. I runs the

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

2009-01-15 Thread Brandon S. Allbery KF8NH
On 2009 Jan 15, at 5:55, Manlio Perillo wrote: Brandon S. Allbery KF8NH ha scritto: [... about Python import local to functions ...] Sometime they are necessary, to avoid circular import problems (but this not a problem with Haskell). ...in theory. In practice GHC needs help with circular

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

2009-01-15 Thread Artyom Shalkhakov
Hi Immanuel, 2009/1/15 Immanuel Litzroth immanuel...@gmail.com: In Python importing a module has totally different semantics from importing in Haskell. I runs the initialization code for the module makes the names in that module available to you code. In Haskell modules are just namespace

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

2009-01-15 Thread Artyom Shalkhakov
Hi Manlio 2009/1/15 Manlio Perillo manlio_peri...@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,

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

2009-01-14 Thread Manlio Perillo
Hi. There are two features found in Python language, that I would like to see in Haskell. 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 = uabc\N{VULGAR FRACTION ONE HALF} 2) In Python it is

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

2009-01-14 Thread Neil Mitchell
Hi 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 = uabc\N{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 i.e.

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

2009-01-14 Thread minh thu
2009/1/14 Neil Mitchell ndmitch...@gmail.com: Hi 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 = uabc\N{VULGAR FRACTION ONE HALF} Hmm, looks nice, and sensible. But as soon as you've got

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

2009-01-14 Thread Neil Mitchell
As an example: foo = uabc\N{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 i.e. embed expressions in strings. I think this would be fantastic. why not simpy foo\E{i}bar ? What if i is a string? You'd

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

2009-01-14 Thread Dougal Stanton
On Wed, Jan 14, 2009 at 3:12 PM, Neil Mitchell ndmitch...@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

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

2009-01-14 Thread Manlio Perillo
Neil Mitchell ha scritto: Hi 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 = uabc\N{VULGAR FRACTION ONE HALF} Hmm, looks nice, and sensible. But as soon as you've got \N{} syntax I want:

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

2009-01-14 Thread Lennart Augustsson
When Haskell was designed there was a bried discussion (if my memory serves me) to have import be a decl, so it could occur anywhere a normal declaration can occur. I kinda like the idea, but some people didn't and it never happened. -- Lennart On Wed, Jan 14, 2009 at 3:12 PM, Neil Mitchell

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

2009-01-14 Thread Ketil Malde
Neil Mitchell ndmitch...@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 = uabc\N{VULGAR FRACTION ONE HALF} Why not: import Unicode.Entities as U foo =

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

2009-01-14 Thread Job Vranish
What I would really like to see is locally scoped imports but with parameterized modules. (so modules could take types and values as parameters) 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

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

2009-01-14 Thread Tim Wawrzynczak
Having an import/module feature like this would replace almost all cases where someone might wish for a macro system for Haskell. Don't say that until you've tried Lisp macros... read some of Paul Graham's essays or try some Common Lisp for yourself... macros can be an incredibly powerful tool,

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

2009-01-14 Thread David Leimbach
joinPath' root name = import.System.FilePath.joinPath [root,name] How is this different from joinPath' root name = System.FilePath.joinPath [root,name] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

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

2009-01-14 Thread David Leimbach
On Wed, Jan 14, 2009 at 10:13 AM, David Leimbach leim...@gmail.com wrote: joinPath' root name = import.System.FilePath.joinPath [root,name] How is this different from joinPath' root name = System.FilePath.joinPath [root,name] I'm sorry I didn't mean different, I meant better than? I

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

2009-01-14 Thread Job Vranish
On Wed, Jan 14, 2009 at 12:48 PM, Tim Wawrzynczak inforichl...@gmail.com wrote: Having an import/module feature like this would replace almost all cases where someone might wish for a macro system for Haskell. Don't say that until you've tried Lisp macros... read some of Paul Graham's

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

2009-01-14 Thread Tim Wawrzynczak
You're probably right. I've played around with LISP macros a little, but it seems that most of the cases where you would use a macro in LISP you don't need one in haskell due to lazy evaluation. Although I haven't played around with them enough to say much one way or another. Do you know

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

2009-01-14 Thread Miguel Mitrofanov
Well, like many good programming tools, Lisp macros are another abstraction, but instead of dealing with data, they deal with code. I didn't know Lisp puts such an emphasis on the difference between code and data. ___ Haskell-Cafe mailing list

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

2009-01-14 Thread Martijn van Steenbergen
Jonathan Cast wrote: Haskell already has a couple of abstraction tools for dealing with code. One is called `first-class functions'; another is called `lazy evaluation'. And for all the rest there is TH? M. ___ Haskell-Cafe mailing list

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

2009-01-14 Thread Tim Wawrzynczak
On Wed, Jan 14, 2009 at 12:56 PM, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: Jonathan Cast wrote: Haskell already has a couple of abstraction tools for dealing with code. One is called `first-class functions'; another is called `lazy evaluation'. And for all the rest there

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

2009-01-14 Thread Martijn van Steenbergen
Tim Wawrzynczak wrote: Woah fellas, I wasn't trying to start a flame war, I was merely commenting that those who have not used Lisp don't really understand the power that macros can have in a language (such as Lisp) that supports them, and where code and data can be used interchangeably. And

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

2009-01-14 Thread Max Rabkin
On Wed, Jan 14, 2009 at 10:48 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: Do you have an example of a macro that can't be replaced by higher-order functions and laziness? I believe I do: one macro I found useful when writing a web app in Lisp was something I called hash-bind, which binds

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

2009-01-14 Thread Alex Queiroz
Hallo, On Wed, Jan 14, 2009 at 5:06 PM, Max Rabkin max.rab...@gmail.com wrote: On Wed, Jan 14, 2009 at 10:48 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: Do you have an example of a macro that can't be replaced by higher-order functions and laziness? I believe I do: one macro I found

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

2009-01-14 Thread Jonathan Cast
On Wed, 2009-01-14 at 11:06 -0800, Max Rabkin wrote: On Wed, Jan 14, 2009 at 10:48 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: Do you have an example of a macro that can't be replaced by higher-order functions and laziness? I believe I do: one macro I found useful when writing a

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

2009-01-14 Thread Max Rabkin
On Wed, Jan 14, 2009 at 11:11 AM, Alex Queiroz asand...@gmail.com wrote: I have one for binding GET/POST variables to regular variables transparently and with error checking, just inside the body of the macro. N! You reinvented PHP. What happens if a request variable shadows the name

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

2009-01-14 Thread Alex Queiroz
Hallo, On Wed, Jan 14, 2009 at 5:16 PM, Max Rabkin max.rab...@gmail.com wrote: On Wed, Jan 14, 2009 at 11:11 AM, Alex Queiroz asand...@gmail.com wrote: I have one for binding GET/POST variables to regular variables transparently and with error checking, just inside the body of the macro.

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

2009-01-14 Thread Tim Wawrzynczak
On Wed, Jan 14, 2009 at 1:14 PM, Jonathan Cast jonathancc...@fastmail.fmwrote: On Wed, 2009-01-14 at 11:06 -0800, Max Rabkin wrote: On Wed, Jan 14, 2009 at 10:48 AM, Jonathan Cast jonathancc...@fastmail.fm wrote: Do you have an example of a macro that can't be replaced by higher-order

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

2009-01-14 Thread Max Rabkin
2009/1/14 Tim Wawrzynczak inforichl...@gmail.com: The reason the macro is better is that the length of the list is known at compile time, so you don't need to traverse the list to calculate the length of the list. Or you could use a real compiler (perhaps even a glorious one) that does

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

2009-01-14 Thread Dougal Stanton
(defun avg (rest args) (/ (apply #'+ args) (length args))) Or as a macro like this: (defmacro avg (rest args) `(/ (+ ,@args) ,(length args))) The reason the macro is better is that the length of the list is known at compile time, so you don't need to traverse the list to calculate

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

2009-01-14 Thread Alex Queiroz
Hallo, On Wed, Jan 14, 2009 at 8:47 PM, Dougal Stanton ith...@gmail.com wrote: (defun avg (rest args) (/ (apply #'+ args) (length args))) Or as a macro like this: (defmacro avg (rest args) `(/ (+ ,@args) ,(length args))) The reason the macro is better is that the length of the list

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

2009-01-14 Thread Lennart Augustsson
With macros you can define new variable binding constructs. That's something I occasionally miss in Haskell. -- Lennart On Wed, Jan 14, 2009 at 6:48 PM, Jonathan Cast jonathancc...@fastmail.fm wrote: On Wed, 2009-01-14 at 12:39 -0600, Tim Wawrzynczak wrote: You're probably right.

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

2009-01-14 Thread Brandon S. Allbery KF8NH
On 2009 Jan 14, at 10:26, Neil Mitchell wrote: As an example: foo = uabc\N{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 i.e. embed expressions in strings. I think this would be fantastic. why not simpy

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

2009-01-14 Thread Brandon S. Allbery KF8NH
On 2009 Jan 14, at 10:39, Manlio Perillo wrote: Neil Mitchell ha scritto: Hi 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 = uabc\N{VULGAR FRACTION ONE HALF} Hmm, looks nice, and sensible. But as

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

2009-01-14 Thread Jonathan Cast
On Wed, 2009-01-14 at 18:59 -0500, Brandon S. Allbery KF8NH wrote: On 2009 Jan 14, at 10:26, Neil Mitchell wrote: As an example: foo = uabc\N{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 i.e.