Opened 3 years ago

Last modified 13 months ago

#12980 new bug

Unlifted class method rejected

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone:
Component: Compiler Version: 8.1
Keywords: LevityPolymorphism Cc: oerjan, osa1
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

If I say

class C a where
  meth :: Array# a

I get

    • Expecting a lifted type, but ‘Array# a’ is unlifted
    • In the type signature: meth :: Array# a
      In the class declaration for ‘C’

This definition looks OK to me. I don't see why we can't have an unlifted member of a class.

(As @oerjan points out in comment:25:ticket:12708, we can't have a levity-polymorphic class member, but this is solidly levity-monomorphic.)

I'm happy to lift this restriction in ongoing work in this area, but I wanted to double-check before doing so.

For the record, the same error occurs even when the class has more than one member, so it's not the no-unlifted-newtypes restriction.

Change History (4)

comment:1 Changed 3 years ago by simonpj

Certainly should be ok for multi-method classes. I'm not quite sure about the single-method case, because of the interaction with newtypes -- but I think there's a case for using data types in the single-method case too.

comment:2 Changed 3 years ago by simonpj

Keywords: LevityPolymorphism added

comment:3 in reply to:  1 Changed 3 years ago by oerjan

Cc: oerjan added

Replying to simonpj:

Certainly should be ok for multi-method classes. I'm not quite sure about the single-method case, because of the interaction with newtypes -- but I think there's a case for using data types in the single-method case too.

Alternatively, since fields cannot be levity-polymorphic (at least without extra indirection), you could restrict the newtype optimization to methods of kind Type.

comment:4 Changed 13 months ago by osa1

Cc: osa1 added
Note: See TracTickets for help on using tickets.