Ticket #5830 (closed bug: fixed)

Opened 4 months ago

Last modified 4 months ago

Arrow if/then/else sugar breaks type inference

Reported by: jamey Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.4
Keywords: Cc: josh
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Attachments

ArrowChoiceInference.hs Download (0.6 KB) - added by jamey 4 months ago.
minimal test case

Change History

Changed 4 months ago by jamey

minimal test case

Changed 4 months ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed

Thanks for the report. A few arrow bugs have been fixed recently, and this module is accepted in the 7.4 branch and the HEAD, so I think this is fixed now.

Note: See TracTickets for help on using tickets.