Ticket #1769 (closed task: fixed)

Opened 6 years ago

Last modified 2 years ago

Deriving Typeable for data families

Reported by: chak Owned by: chak
Priority: low Milestone: 7.0.1
Component: Compiler (Type checker) Version: 6.9
Keywords: Cc: mmitar@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: indexed-types/should_compile/T1769 Blocked By:
Blocking: Related Tickets:

Description

See Simon's proposal in the attachment.

Attachments

DataFamilyDerivingTypable.txt Download (3.4 KB) - added by chak 6 years ago.
Spec

Change History

Changed 6 years ago by chak

Spec

  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 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

  Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

  Changed 3 years ago by igloo

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

  Changed 3 years ago by mitar

  • cc mmitar@… added
  • failure set to None/Unknown

Ping.

This would be really great to have. Currently (7.0 from repository) it fails with:

    Can't make a derived instance of
      `Typeable (...)':
      `...' is a type family

But without Typeable I cannot make instance of Data for data types I have associated with my type class.

  Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to indexed-types/should_compile/T1769
  • resolution set to fixed

OK, I've done this

Mon Nov 15 23:11:46 GMT Standard Time 2010  simonpj@microsoft.com
  * Deriving Typeable changes
  
  * Fix a bug that led to a crash with
      data family T a
      deriving Functor T
  
  * Allow deriving Typeable for data families
      data family T a
      deriving Typeable1 T
  
  * Some refactoring and tidying

    M ./compiler/typecheck/TcDeriv.lhs -47 +58

Simon

  Changed 2 years ago by mitar

Will this be included in 7.0.2?

  Changed 2 years ago by simonpj

We don't add features in patch releases, just fix bugs. There is always pressure to put more features in as the deadline approaches, and we have to stop somewhere.

Still I suppose you could argue that this patch just fixes a bug. Adding it would break no programs. So I don't have a strong opinion. Ian, Simon, I defer to you.

follow-up: ↓ 11   Changed 2 years ago by mitar

Without it my  library cannot compile. This is why I am pushing for this.

in reply to: ↑ 10   Changed 2 years ago by heatsink

Replying to mitar:

As a workaround, you can derive from Typeable without this feature by writing your own instance.

data family T a

instance Typeable a => Typeable (T a) where
  typeOf x = mkTyConApp (mkTyCon "T") [typeOf (unT x)]
    where
      unT :: T a -> a
      unT = undefined

  Changed 2 years ago by mitar

This is really equal to what would deriving do?

  Changed 2 years ago by mitar

Wouldn't it be enough to define?

instance Typeable1 T where
  typeOf1 _ = mkTyConApp (mkTyCon "T") []
Note: See TracTickets for help on using tickets.