On 28/07/2010 17:46, Simon Peyton Jones wrote:
Wed Jul 28 09:35:39 PDT 2010  simo...@microsoft/com
   * Add two local type signatures

   I'm adding these type signatures to satisfy the "do not generalise
   local let/where" rule that GHC is taking on.

   The signatures are clearly correct, but I was surprised at the
   polymorphism needed.  For example

   parseOptVersion :: ReadP r Version
   parseOptVersion = parseQuoted ver<++ ver
     where ver :: ReadP r Version
           ver = parse<++ return noVersion
           noVersion = Version{ versionBranch=[], versionTags=[] }

   Note that 'ver' really is called at two different types!  That
   in turn is because of the type of (<++)

     (<++) :: ReadP a a ->  ReadP r a ->  ReadP r a
     (+++) :: ReadP r a ->  ReadP r a ->  ReadP r a

   Note the "a a" in the first arg, which is very unusual.
   For example, compare the type of (+++).

   Changing it to match the type of (+++) makes ReadP fail to compile,
   though, so I assume it's right as it stands. But surely this deserves
   a comment?!

Perhaps whoever wrote it didn't understand it well enough to write a comment. That wouldn't surprise me, having grappled with a similar situation using MonadCont recently. ReadP is a continuation monad, and the first type argument is the "result" of the whole computation. In the GHC implementation of ReadP this type argument is universally quantified, but this module is using the "portable" version of ReadP which exposes the type argument to avoid requiring RankNTypes.

Cheers,
        Simon
_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to