Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#9913 closed bug (invalid)

Discrepancy in type synonym definition and usage

Reported by: Iceland_jack Owned by:
Priority: lowest Milestone:
Component: Compiler (Parser) Version: 7.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: x86
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Minor consistency issue, the following compiles fine (note parentheses):

type Alg f a = f a -> a

initial :: Alg(f) a
initial = undefined

But changing the definition to mirror its use:

type Alg(f) a = f a -> a

initial :: Alg(f) a
initial = undefined

and it fails with:

    Unexpected type f
    In the type declaration for Alg
    A type declaration should have form
      type Alg a b c = ...
Failed, modules loaded: none.

Change History (2)

comment:1 Changed 4 years ago by nomeata

Resolution: invalid
Status: newclosed

Thanks for your report.

I don’t think this is a bug. There is a conceptual difference between the declaration, where the argument to the type synonyms are declared (and hence have to be variables), and the use of a type synonym, where parameters are type expressions.

Note that you can use Alg Maybe, but cannot define type Alg Maybe a = Maybe a -> a.

comment:2 Changed 4 years ago by rwbarton

Agreed with what Joachim said, but moreover this falls under the purview of the Haskell 2010 Report, so a bug report of this sort should ideally be accompanied by a reference to section(s) of the Report that GHC is deviating from (in this instance, though I haven't checked, I imagine the Report specifies the behavior that GHC exhibits).

Note: See TracTickets for help on using tickets.