#1080: Arrows desguaring does not take account of bindings in patterns
-------------------------+--------------------------------------------------
Reporter: simonpj | Owner: Ross Paterson
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------+--------------------------------------------------
The test arrows/should_compile/arrowcase1 is failing Lint. The bug is in
the desugarer.
Here’s a smaller test case:
{{{
h :: ArrowChoice a => Int -> a (Int,Int) Int
h x = proc (y,z) -> case compare x y of
GT -> returnA -< z+x
}}}
The type checker turns the case into
{{{
case compare x y of
GT { p77 = plusInt } -> returnA -< p77 z x
}}}
Here p77 is a local binding for the (+) operation. In general, patterns
can contain bindings (used to discharge constraints that are bound by the
pattern). In this case the binding isn’t strictly necessary, but in
general it is – consider existentials. It’s equivalent to adding a
‘let’ around the RHS, but since the patters are perhaps nested, and
one pattern might use a constraint that is bound by another, the pattern
is the right place to attach the binding.
This has come up because GHC is binding things a little earlier than
before, but an existential would have exposed it before.
The trouble is that the suspicious-looking replaceLeaves code in DsArrows
(line 528 or so) doesn’t know about these bindings.
I don’t understand DsArrows at all. Indeed the whole Arrows code feels
smelly to me. Maybe we tried to share too much code?
I'm hoping Ross will look at this.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1080>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs