Ticket #1702 (new bug)

Opened 4 years ago

Last modified 4 months ago

type operator precedences don't work in contexts

Reported by: b.hilken@… Owned by:
Priority: low Milestone: 7.4.1
Component: Compiler Version: 6.8
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

Type contexts don't parse correctly when a type class is used infix. The following example:

>    infixr 4 :=:
>    infixl 3 :+:
>    infix 2 `Disjoint`
>
>    labelZip :: (n :=: a `Disjoint` m :=: b) 
>             => n -> m -> [a] -> [b] -> [n :=: a :+: m :=: b]

gives the error:

    Type constructor `:=:' used as a class
    In the type `(:=: n (a Disjoint (m :=: b))) =>
                 n -> m -> [a] -> [b] -> [(n :=: a) :+: (m :=: b)]'
    In the type signature for `labelZip':
      labelZip :: (:=: n (a Disjoint (m :=: b))) =>
                  n -> m -> [a] -> [b] -> [(n :=: a) :+: (m :=: b)]

where the parenthesised version works.

Change History

Changed 4 years ago by simonpj

  • description modified (diff)

Absolutely right, good report.

It's really a structural flaw with historical origins. Infix expressions (including types) are sorted out by the renamer not the parser. This is a Good Thing. However, before the advent of infixity in types, the parser decides what the class is in the context of a type signature. But with infix stuff, the parser can't do that.

Solution: defer the unravelling of contexts until the renamer, removing it from the parser. I'll get to this but not until after ICFP.

Simon

Changed 4 years ago by simonpj

  • description modified (diff)

Changed 4 years ago by igloo

  • milestone set to 6.1

Changed 4 years ago by simonpj

See also #1727

Changed 4 years ago by simonmar

  • os changed from MacOS X to Multiple
  • architecture changed from powerpc to Multiple

Changed 3 years ago by simonmar

  • architecture changed from Multiple to Unknown/Multiple

Changed 3 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple

Changed 3 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 22 months ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 20 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 14 months ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 11 months ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 4 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1
Note: See TracTickets for help on using tickets.