OverloadedLists

Simon Peyton-Jones simonpj at microsoft.com
Fri Feb 15 09:52:02 CET 2013


| 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 at haskell.org [mailto:ghc-devs-bounces at haskell.org]
| On Behalf Of Isaac Dupree
| Sent: 14 February 2013 21:35
| To: ghc-devs at 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 at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-devs



More information about the ghc-devs mailing list