Skip to content

Arrow if/then/else sugar breaks type inference

Starting in GHC 7.0, using the Arrows if/then/else syntactic sugar for ArrowChoice doesn't propagate type constraints the way I expect. This bug still exists in 7.2.

The expected type of the result of the conditional should constrain the type of each branch of the conditional. Instead, the branches remain unconstrained. If the arrow in the branches is polymorphic and its argument type doesn't completely constrain its result (I used "read" in this test case) then GHC reports that the types are ambiguous:

     Ambiguous type variable `c0' in the constraint:
       (Read c0) arising from a use of `read'

Using the case-expression sugar instead works fine.

Trac metadata
Trac field Value
Version 7.0.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC josh
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information