Re: patch applied (packages/base): IsString is GHC-only (so why is it in the Prelude?)

On Tue, 2007-01-23 at 10:38 -0800, Ross Paterson wrote:
Tue Jan 23 10:30:07 PST 2007 Ross Paterson
* IsString is GHC-only (so why is it in the Prelude?)
Yes, can we please have a discussion about what's going on here. Changes to the base library are supposed to go via the libraries review process. I'm not complaining that we slipped up, I just want to make sure people can have a chance to comment. I'm cc'ing the libraries list. Duncan

Duncan Coutts
Tue Jan 23 10:30:07 PST 2007 Ross Paterson
* IsString is GHC-only (so why is it in the Prelude?) Yes, can we please have a discussion about what's going on here. Changes to the base library are supposed to go via the libraries review process. I'm not complaining that we slipped up, I just want to make sure people can have a chance to comment.
I agree that this development is strange. The Prelude module in base is supposed to export exactly and only the Haskell'98-specified Prelude. There should be no proposed extensions in there, especially if they are compiler-specific. There are lots of other places an extension can live, e.g. GHC.Base [ Actually, to be honest I'm not quite sure why the Prelude module lives in the base package, rather than the haskell98 package? The same question applies to the Numeric module. ] Regards, Malcolm

Malcolm Wallace wrote:
[ Actually, to be honest I'm not quite sure why the Prelude module lives in the base package, rather than the haskell98 package? The same question applies to the Numeric module. ]
Packages don't support re-exposing modules from other packages right now; it has been suggested as an extension from time to time. If we did have support for re-exposing then the haskell98 package could re-expose Prelude and Numeric, and it would be possible for a pure Haskell 98 program/library to depend only on the haskell98 package. Right now we have the situation that a program/library can be independent of the haskell98 package, which wouldn't be true if Prelude were in haskell98. Also it would make building base a bit harder, because nothing would be able to import Prelude. Cheers, Simon

On Tue, Jan 23, 2007 at 06:43:22PM +0000, Duncan Coutts wrote:
On Tue, 2007-01-23 at 10:38 -0800, Ross Paterson wrote:
Tue Jan 23 10:30:07 PST 2007 Ross Paterson
* IsString is GHC-only (so why is it in the Prelude?) Yes, can we please have a discussion about what's going on here. Changes to the base library are supposed to go via the libraries review process. I'm not complaining that we slipped up, I just want to make sure people can have a chance to comment. I'm cc'ing the libraries list.
For those who haven't been following, this comes from a new GHC extension that means string literals like "foo" have type (IsString a => a) rather than String. This is analogous to (5 :: Num a => a) in Haskell 98. This uses a new class class IsString a where fromString :: String -> a which is defined in GHC.Base and re-exported by the Prelude. Letting this Prelude change through was my fault - for some reason I didn't notice it, or it didn't register, or something. That said, I'm not sure where else I'd put it. GHC.Exts is the only place I can think of that it vaguely belongs, but the class itself is entirely portable, so this doesn't feel right to me. Also, in GHC(-fglasgow-exts) the class will appear in types with no other modules loaded. If the extension was in the language then I would certainly expect the class to be in the Prelude. When I last asked Isaac about it, it hadn't beeen decided how much Haskell' will say about libraries. I can't remember if I've said this in public before, but my opinion is that it should say as little as possible; we have recently been able to make a number of improvements to the base libraries as the move to hierarchical libraries has meant that the Haskell 98 standard hasn't tied our hands, and I think it would be a mistake to tie them again with Haskell'. Thus I think the addition of such a class, even to the Prelude, should be OK for Haskell'. Of course, concensus may not agree with me, and it's also possible there will be releases of implementations using the HEAD branch of the base packages before Haskell' is done. So to summarise, it was a mistake to let it in without discussion; sorry. But my opinion is that it should be there (for all implementations) anyway once we are making Haskell' implementations, and I don't know where to put it in the meantime. Thanks Ian

I'm sorry for putting IsString into Base like that. Like Ian I don't know where else it should go, and since the module is named GHC.Base the name seems to indicate that what is in it is for GHC, so I didn't think it needed to have any #ifdef around it. Would some #ifdef somewhere be appropriate? -- Lennart On Jan 24, 2007, at 08:15 , Ian Lynagh wrote:
On Tue, Jan 23, 2007 at 06:43:22PM +0000, Duncan Coutts wrote:
On Tue, 2007-01-23 at 10:38 -0800, Ross Paterson wrote:
Tue Jan 23 10:30:07 PST 2007 Ross Paterson
* IsString is GHC-only (so why is it in the Prelude?) Yes, can we please have a discussion about what's going on here. Changes to the base library are supposed to go via the libraries review process. I'm not complaining that we slipped up, I just want to make sure people can have a chance to comment. I'm cc'ing the libraries list.
For those who haven't been following, this comes from a new GHC extension that means string literals like "foo" have type (IsString a => a) rather than String. This is analogous to (5 :: Num a => a) in Haskell 98.
This uses a new class
class IsString a where fromString :: String -> a
which is defined in GHC.Base and re-exported by the Prelude.
Letting this Prelude change through was my fault - for some reason I didn't notice it, or it didn't register, or something.
That said, I'm not sure where else I'd put it. GHC.Exts is the only place I can think of that it vaguely belongs, but the class itself is entirely portable, so this doesn't feel right to me.
Also, in GHC(-fglasgow-exts) the class will appear in types with no other modules loaded. If the extension was in the language then I would certainly expect the class to be in the Prelude.
When I last asked Isaac about it, it hadn't beeen decided how much Haskell' will say about libraries. I can't remember if I've said this in public before, but my opinion is that it should say as little as possible; we have recently been able to make a number of improvements to the base libraries as the move to hierarchical libraries has meant that the Haskell 98 standard hasn't tied our hands, and I think it would be a mistake to tie them again with Haskell'. Thus I think the addition of such a class, even to the Prelude, should be OK for Haskell'. Of course, concensus may not agree with me, and it's also possible there will be releases of implementations using the HEAD branch of the base packages before Haskell' is done.
So to summarise, it was a mistake to let it in without discussion; sorry. But my opinion is that it should be there (for all implementations) anyway once we are making Haskell' implementations, and I don't know where to put it in the meantime.
Thanks Ian

On Wed, Jan 24, 2007 at 08:35:16AM -0500, Lennart Augustsson wrote:
Like Ian I don't know where else it should go, and since the module is named GHC.Base the name seems to indicate that what is in it is for GHC, so I didn't think it needed to have any #ifdef around it.
Sorry, I wasn't clear; the definition in GHC.Base is fine, it's the re-export in Prelude that we're worried about. (although it would probably be nicer to have the definition in a portable module). Thanks Ian

Ian Lynagh wrote:
On Tue, Jan 23, 2007 at 06:43:22PM +0000, Duncan Coutts wrote:
Tue Jan 23 10:30:07 PST 2007 Ross Paterson
* IsString is GHC-only (so why is it in the Prelude?) Yes, can we please have a discussion about what's going on here. Changes to the base library are supposed to go via the libraries review On Tue, 2007-01-23 at 10:38 -0800, Ross Paterson wrote: process. I'm not complaining that we slipped up, I just want to make sure people can have a chance to comment. I'm cc'ing the libraries list.
For those who haven't been following, this comes from a new GHC extension that means string literals like "foo" have type (IsString a => a) rather than String. This is analogous to (5 :: Num a => a) in Haskell 98.
This uses a new class
class IsString a where fromString :: String -> a
which is defined in GHC.Base and re-exported by the Prelude.
Unfortunately additions to the Prelude module affect compatibility with Haskell 98, so we can't admit any such additions while we claim to support Haskell 98. I suggest this be backed out. I don't think there's any issue with the compiler having built-in knowledge of a class that isn't part of the Prelude. In order to mention the class explicitly you'd have to import the relevant module, that's all. So how about proposing it for Data.String, perhaps? Cheers, Simon
participants (5)
-
Duncan Coutts
-
Ian Lynagh
-
Lennart Augustsson
-
Malcolm Wallace
-
Simon Marlow