Opened 6 years ago

Closed 15 months ago

#1930 closed feature request (fixed)

Make operators into type constructors, rather than type variables

Reported by: igloo Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: ghci/scripts/ghci033 Blocked By:
Blocking: Related Tickets:

Description

The + a b here should be either (+) a b or a + b:

$ ghci -XTypeOperators
GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> :t undefined :: a + b
undefined :: a + b :: + a b
Prelude> 

Change History (7)

comment:1 Changed 6 years ago by nfrisby

Moreover, infix constructors - even those that are not operators - are also incorrectly printed.

data Report = AsExpected Outcome | Outcome `InsteadOf` Outcome

Note how GHC 6.8.2 prints the InsteadOf operator without the backticks:

*Correctness> :i Report
data Report = AsExpected Outcome | Outcome InsteadOf Outcome
        -- Defined at Correctness.hs:23:5-10

comment:2 Changed 6 years ago by simonpj

  • Test Case set to ghci/scripts/ghci033

I have fixed the bug in the commend from Frisby:

Mon Aug  4 17:10:39 BST 2008  simonpj@microsoft.com
  * Fix the bug part of Trac #1930

However, the original report is a different point. In Haskell (+) is a type variable not a type constructor. So saying

  undefined :: a+b

means

  undefined :: forall (+), a, b.  (+) a b

Now, you could argue that the type variable (+) should be printed infix. But I'm planning to make (+) into a type constructor, as described here http://hackage.haskell.org/trac/haskell-prime/wiki/InfixTypeConstructors. So I am disinclined to fix the original report in #1930.

Still I'll leave it open to remind me to do the infix-type-constructor thing. Yell if you think that the infix type constructor proposal is a Bad Idea.

Simon

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:5 Changed 3 years ago by simonpj

  • Summary changed from infix type constructors are printed incorrectly by GHC to Make operators into type constructors, rather than type variables
  • Type changed from bug to feature request
  • Type of failure set to None/Unknown

I'm changing the title of this ticket, and making it a feature request, namely to make operators into type constructors rather than type variables. See the Haskell Prime ticket

comment:7 Changed 15 months ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

From the 7.6.1 release notes: "The behavior of the TypeOperator? extension has changed: previously, only type operators starting with ":" were considered type constructors, and other operators were treated as type variables. Now type operators are always constructors. "

Note: See TracTickets for help on using tickets.