[GHC] #8073: TransformListComp weird type error

#8073: TransformListComp weird type error -------------------------------------+------------------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type | Version: 7.6.3 checker) | Operating System: Unknown/Multiple Keywords: | Type of failure: GHC rejects Architecture: Unknown/Multiple | valid program Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Am I missing something, or is this broken? {{{ Prelude> :set -XTransformListComp Prelude> import Data.List Prelude Data.List> [ x | x <- ['a'..'z'], then sort] <interactive>:5:29: No instance for (Ord a) arising from a use of `sort' Possible fix: add (Ord a) to the context of a type expected by the context: [a] -> [a] In the expression: sort In a stmt of a list comprehension: then sort In the expression: [x | x <- ['a' .. 'z'], then sort] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8073 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8073: TransformListComp weird type error ----------------------------------------------+---------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type checker) | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by lelf): Broken or not, it's documented: **then f** — This statement requires that f have the type {{{ forall a. [a] -> [a] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8073#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8073: TransformListComp weird type error ----------------------------------------------+---------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Type checker) | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by simonmar): Ok, I guess that makes sense if we're typechecking the concrete syntax before desugaring. But I was using `MonadComprehensions`, and hence was looking at that section of the documentation which says {{{ [ x+y | x <- [1..10], y <- [1..x], then take 2 ] This translates to: do (x,y) <- take 2 (do x <- [1..10] y <- [1..x] return (x,y)) return (x+y) }}} So I found the behaviour quite surprising. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8073#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8073: TransformListComp weird type error ----------------------------------------------+---------------------------- Reporter: simonmar | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler (Type checker) | Version: 7.6.3 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: It's not a bug! There's a good reason for it, which you'll find discussed in [http://research.microsoft.com/~simonpj/papers/list-comp/index.htm the paper]. That said, I can see it's inconvenient here, and others may have ideas about what to do about it. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8073#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC