Re: [Haskell-cafe] Writing functions in Haskell.
Am Freitag, 29. April 2005 18:01 schrieb Ross Paterson:
On Thu, Apr 28, 2005 at 09:22:15PM -0400, Cale Gibbard wrote:
The second problem arises from hugs not doing the same thing as ghci with respect to looking up qualified variable names (that is, those with the module name specified, in this case, the standard module Char). You can tell hugs to also load the Char module on top of whatever code you have loaded by using the command ":also Char", after which the prompt should look like Char> and you can try toUpper 'a'
Might as well use :load -- in both case Char becomes the new current module, making the old current module inaccessible.
There is a difference, though. Compare Test> :l Char Char> :n my_map ERROR - No names selected and Test> :a Char Char> :n my_map Test.my_map (1 names listed) So with :a(lso) the old module remains in sight for :n(ames) - and for :i in qualified form. Unfortunately I haven't found a way to use them, Hugs (Nov. 2003) in general refuses qualified names, though with some rather weird behaviour: Prelude> :l Test Test> :a Char Char> Prelude.map toUpper "buh" "BUH" Char> Data.Char.toUpper 'u' 'U' Char> :i Test.my_map my_map :: (a -> b) -> [a] -> [b] Char> Data.Char.toUpper 'u' ERROR - Undefined qualified variable "Data.Char.toUpper" Char> Prelude.map toUpper "buh" ERROR - Undefined qualified variable "Prelude.map" How can it be that Hugs knows these qualified names before I ask about Test.my_map but not afterwards? Puzzled, Daniel
On Fri, Apr 29, 2005 at 06:56:28PM +0200, Daniel Fischer wrote:
So with :a(lso) the old module remains in sight for :n(ames) - and for :i in qualified form. Unfortunately I haven't found a way to use them, Hugs (Nov. 2003) in general refuses qualified names, though with some rather weird behaviour:
Prelude> :l Test Test> :a Char Char> Prelude.map toUpper "buh" "BUH" Char> Data.Char.toUpper 'u' 'U' Char> :i Test.my_map my_map :: (a -> b) -> [a] -> [b]
Char> Data.Char.toUpper 'u' ERROR - Undefined qualified variable "Data.Char.toUpper" Char> Prelude.map toUpper "buh" ERROR - Undefined qualified variable "Prelude.map"
How can it be that Hugs knows these qualified names before I ask about Test.my_map but not afterwards?
Hugs discards the import table of a module when switching modules, e.g. with :m. It used to hold on to it, but this cost a lot of space. So the qualified names in scope at the prompt immediately after :load are what the user's guide says, but they disappear when you switch modules. Unfortunately :i is also implemented using module switching.
Am Dienstag, 3. Mai 2005 17:56 schrieben Sie:
On Fri, Apr 29, 2005 at 06:56:28PM +0200, Daniel Fischer wrote:
So with :a(lso) the old module remains in sight for :n(ames) - and for :i in qualified form. Unfortunately I haven't found a way to use them, Hugs (Nov. 2003) in general refuses qualified names, though with some rather weird behaviour:
Prelude> :l Test Test> :a Char Char> Prelude.map toUpper "buh" "BUH" Char> Data.Char.toUpper 'u' 'U' Char> :i Test.my_map my_map :: (a -> b) -> [a] -> [b]
Char> Data.Char.toUpper 'u' ERROR - Undefined qualified variable "Data.Char.toUpper" Char> Prelude.map toUpper "buh" ERROR - Undefined qualified variable "Prelude.map"
How can it be that Hugs knows these qualified names before I ask about Test.my_map but not afterwards?
Hugs discards the import table of a module when switching modules, e.g. with :m. It used to hold on to it, but this cost a lot of space. So the qualified names in scope at the prompt immediately after :load are what the user's guide says, but they disappear when you switch modules. Unfortunately :i is also implemented using module switching.
Hm, I don't quite get it. Apparently whenever I ask :info Qualified.name with a qualification different from the top module, I lose all qualified names, even from explicitly imported modules -- right? Okay, that's not a problem, only a little odd. Now I encountered another odd thing: Char> :l Prelude> :a Char Char> :a Test Char> :l -- notice the top module is still Char! Prelude> :a Test Test> :a Char Char> in that session, this behaviour was reproducible, in later sessions it wasn't: Prelude> :a Char Char> :a Test Test> :l Prelude> :a Test Test> :a Char Char> :l Prelude> :a Char Char> :a Test Test> Any idea how that may come? Cheers, Daniel
On Tue, May 03, 2005 at 07:59:51PM +0200, Daniel Fischer wrote:
Hm, I don't quite get it. Apparently whenever I ask :info Qualified.name with a qualification different from the top module, I lose all qualified names, even from explicitly imported modules -- right?
Yes, :info M.f is implemented as :m M, :i f, :m OriginalModule, and the module switch does the damage.
Okay, that's not a problem, only a little odd.
I'm not claiming it's a feature.
Now I encountered another odd thing: Char> :l Prelude> :a Char Char> :a Test Char> :l -- notice the top module is still Char! Prelude> :a Test Test> :a Char Char>
in that session, this behaviour was reproducible, in later sessions it wasn't:
I can't reproduce it either. What was the first part of the first session?
On Tue, May 03, 2005 at 07:59:51PM +0200, Daniel Fischer wrote:
Now I encountered another odd thing: Char> :l Prelude> :a Char Char> :a Test Char> :l -- notice the top module is still Char!
OK, the bug was triggered by :m before :a. Now fixed in CVS. Thanks for the report.
Hi, Please, what is the exactly meaning of [n,m..m]? or where can I find a precise explanation obout this arithmetical series? I mean, it seems quite strange that, for example: Prelude> [1.2,3.3..8] [1.2,3.3,5.4,7.5] Prelude> [1.2,3.3..9] [1.2,3.3,5.4,7.5,9.6] Prelude> [1,-3..(-14)] [1,-3,-7,-11] Prelude> [1,-3..(-15)] [1,-3,-7,-11,-15] Thanks in advance, Paqui --------------------------------- Paqui Lucio Dpto de LSI Facultad de Informática Paseo Manuel de Lardizabal, 1 20080-San Sebastián SPAIN --------------------------------- Tfn: (+34) (9)43 015049 Fax: (+34) (9)43 015590 ---------------------------------
On 2005 May 05 Thursday 10:27, Paqui Lucio wrote:
Please, what is the exactly meaning of [n,m..m]? or where can I find a precise explanation obout this arithmetical series?
[n,m..m] is defined as equivalent to the function enumFromThenTo, which is specified in section 6.3.4 of the Haskell 98 report. http://www.haskell.org/onlinereport/basic.html#sect6.3.4
participants (4)
-
Daniel Fischer -
Paqui Lucio -
Ross Paterson -
Scott Turner