RE: OverloadedLists

| Finally I managed to build again (don't know what's wrong with my
| system, I built on a virtual machine instead now), and the tests pass. I
| attached the four patches, they were created with git diff --no-prefix,
| and their name specifies the submodule they are to be applied to. I hope
| it isn't to late to include them in 7.8. Should I publish them somewhere
| else also, or is this fine?
Great. It's done! Thanks for all your work on this.
Would you like to update the wiki page? http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
You probably don't want to mention your repo any more; and please just check the rest to make sure it's accurate.
I did quite a bit of refactoring, especially to the type checking of arithmetic sequences, which had lots of duplication; fixed the documentation which was out of date; fixed various error message changes in the main testsuite; and committed.
Simon
commit 3234a4ade7204c4206831b4c1dc4a8b23624cc6b
Author: Simon Peyton Jones

Somebody claiming to be Simon Peyton-Jones wrote:
The design is described here: http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
Eg. you can use it for maps, so that [(1,"foo"), (4,"bar")] :: Map Int String
So, this has probably been asked before, but out of curiosity, given: instance IsList Text where type Item Text = Char fromList = Text.pack toList = Text.unpack What is the relationship to OverloadedStrings? Since "blah" is sugar for ['b','l','a','h'], could OverloadedLists also work for string literals / string patterns? -- Stephen Paul Weber, @singpolyma See http://singpolyma.net for how I prefer to be contacted edition right joseph

On Thu, Feb 14, 2013 at 7:58 AM, Stephen Paul Weber < singpolyma@singpolyma.net> wrote:
So, this has probably been asked before, but out of curiosity, given:
instance IsList Text where type Item Text = Char fromList = Text.pack toList = Text.unpack
What is the relationship to OverloadedStrings? Since "blah" is sugar for ['b','l','a','h'], could OverloadedLists also work for string literals / string patterns?
It's described in the wiki. OverloadedLists could subsume OverloadedStrings if the former had an statically allocated compact representation for certain lists, which we have for Strings today (see unpackCString#).

On 02/14/2013 10:10 AM, Simon Peyton-Jones wrote:
| Finally I managed to build again (don't know what's wrong with my | system, I built on a virtual machine instead now), and the tests pass. I | attached the four patches, they were created with git diff --no-prefix, | and their name specifies the submodule they are to be applied to. I hope | it isn't to late to include them in 7.8. Should I publish them somewhere | else also, or is this fine?
Great. It's done! Thanks for all your work on this.
Would you like to update the wiki page? http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
Wiki says: "GHC, during the typechecking and desugaring phases, uses whatever is in scope with the names of fromList, toList and fromListN" Does this mean that if OverloadedLists is on and more than one fromList or toList is in scope (even if one of them is GHC.Exts.fromList/toList), then list literals and patterns (resp.) will not compile? I just selfishly don't want to hide those in every import list (and to give up polymorphic list literals altogether in modules that define/export a monomorphic fromList). Anyhow, good work on this! (Admission: I've been importing Data.Map etc. unqualified because I want the ambiguities with Prelude: I want to force my code to say List.filter just like it says Map.filter. Is there a better way to do this? :) -Isaac

| Does this mean that if OverloadedLists is on and more than one fromList | or toList is in scope (even if one of them is GHC.Exts.fromList/toList), | then list literals and patterns (resp.) will not compile? No... the documentation is poor on that point: * Normally, it'll use GHC.Exts.fromList (etc) regardless of whether GHC.Exts is imported, or what other fromList's are in scope. * If you also use -XRebindableSyntax, it'll use whatever fromList is in scope. Then if you imported Data.Map and GHC.Exts it'd be ambiguous. This is precisely the behaviour of, say integer literals. Normally they desugar to a call of the Prelude's fromInteger, but with RebindableSyntax it becomes whatever fromInteger is in scope. I'll fix the documentation. Simon | -----Original Message----- | From: ghc-devs-bounces@haskell.org [mailto:ghc-devs-bounces@haskell.org] | On Behalf Of Isaac Dupree | Sent: 14 February 2013 21:35 | To: ghc-devs@haskell.org | Subject: Re: OverloadedLists | | On 02/14/2013 10:10 AM, Simon Peyton-Jones wrote: | > | Finally I managed to build again (don't know what's wrong with my | > | system, I built on a virtual machine instead now), and the tests | > | pass. I attached the four patches, they were created with git diff | > | --no-prefix, and their name specifies the submodule they are to be | > | applied to. I hope it isn't to late to include them in 7.8. Should I | > | publish them somewhere else also, or is this fine? | > | > Great. It's done! Thanks for all your work on this. | > | > Would you like to update the wiki page? | > http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists | | Wiki says: "GHC, during the typechecking and desugaring phases, uses | whatever is in scope with the names of fromList, toList and fromListN" | | Does this mean that if OverloadedLists is on and more than one fromList | or toList is in scope (even if one of them is GHC.Exts.fromList/toList), | then list literals and patterns (resp.) will not compile? I just | selfishly don't want to hide those in every import list (and to give up | polymorphic list literals altogether in modules that define/export a | monomorphic fromList). Anyhow, good work on this! | | (Admission: I've been importing Data.Map etc. unqualified because I want | the ambiguities with Prelude: I want to force my code to say List.filter | just like it says Map.filter. Is there a better way to do this? :) | | -Isaac | | | _______________________________________________ | ghc-devs mailing list | ghc-devs@haskell.org | http://www.haskell.org/mailman/listinfo/ghc-devs

On 02/15/2013 03:52 AM, Simon Peyton-Jones wrote:
| Does this mean that if OverloadedLists is on and more than one fromList | or toList is in scope (even if one of them is GHC.Exts.fromList/toList), | then list literals and patterns (resp.) will not compile?
No... the documentation is poor on that point:
* Normally, it'll use GHC.Exts.fromList (etc) regardless of whether GHC.Exts is imported, or what other fromList's are in scope.
* If you also use -XRebindableSyntax, it'll use whatever fromList is in scope. Then if you imported Data.Map and GHC.Exts it'd be ambiguous.
This is precisely the behaviour of, say integer literals. Normally they desugar to a call of the Prelude's fromInteger, but with RebindableSyntax it becomes whatever fromInteger is in scope.
I'll fix the documentation.
Simon
Ah, that's what I'd expect. Thanks! -Isaac
participants (4)
-
Isaac Dupree
-
Johan Tibell
-
Simon Peyton-Jones
-
Stephen Paul Weber