Ticket #1930 (closed feature request: fixed)

Opened 5 years ago

Last modified 4 months ago

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

Changed 5 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

Changed 5 years ago by simonpj

  • testcase 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

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 2 years ago by simonpj

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

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

Changed 4 months ago by morabbin

Changed 4 months ago by simonmar

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

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.