Opened 15 months ago

Last modified 6 months ago

#7647 new feature request

UNPACK polymorphic fields

Reported by: liyang Owned by: simonpj
Priority: normal Milestone: 7.10.1
Component: Compiler Version: 7.6.1
Keywords: Cc: hackage.haskell.org@…, mnislaih@…, bgamari@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets: 3990

Description

comment:9:ticket:3990 mentions the possibility of unpacking polymorphic fields. To quote:

[…]

What I mean by "polymorphic unpack" is this:

  data Poly a = MkP Bool {-# UNPACK #-} a 
  data Mango = MkMango {-# UNPACK #-} (Poly Int)

Now a value of type Poly t would be represented using two pointer fields, as usual (ie the UNPACK would have no direct effect on Poly). But a Mango value would be represented thus:

  data Mango = MkMangoRep Bool Int#

  MkMango :: Poly Int -> MangoRep
  MkMango (MkP b (I# i)) = MkMangoRep b i

  -- Pattern match      (MkMango p -> rhs)
  -- is transformed to  (MkMangoRep b i -> let p = MkP b (I# i) in rhs

Something like that would be rather nice. This ticket is just a reminder.

Thanks,
/Liyang

Change History (4)

comment:1 Changed 15 months ago by liyang

  • Cc hackage.haskell.org@… added

comment:2 Changed 12 months ago by igloo

  • Difficulty set to Unknown
  • Milestone set to 7.8.1

comment:3 Changed 10 months ago by mnislaih

  • Cc mnislaih@… added

comment:4 Changed 6 months ago by bgamari

  • Cc bgamari@… added
  • Milestone changed from 7.8.1 to 7.10.1

Indeed this wouldn't be nice but clearly won't happen for 7.8.1. Punting to 7.10.

Note: See TracTickets for help on using tickets.