Wired-in data-constructors with UNPACKed fields

Simon Peyton Jones simonpj at microsoft.com
Sun Aug 17 21:56:32 UTC 2014


Herbert

You'll see that 'pcDataCon' in TysWiredIn ultimately calls pcDataConWithFixity'.  And that builds a data constructor with a NoDataConRep field, comment "Wired-in types are too simple to need wrappers".

But your wired-in type is NOT too simply to need a wrapper!  You'll need to build a suitable DCR record (see DataCon.lhs), which will be something of a nuisance for you, although you can doubtless re-use utility functions that are currently used to build a DCR record.

Alternatively, just put a ByteArray# as the argument of JP# and JN#.  After all, you have Int# as the argument of SI#!

Simon

| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Herbert
| Valerio Riedel
| Sent: 17 August 2014 14:16
| To: ghc-devs
| Subject: Wired-in data-constructors with UNPACKed fields
| 
| Hello *,
| 
| I'm a bit stuck with the wired-in type aspect of integer-gmp2 and was
| hoping someone with more experience in this area could provide direction
| on how to properly register the data definition
| 
|   data Integer  = SI#                Int#
|                 | Jp# {-# UNPACK #-} !BigNat
|                 | Jn# {-# UNPACK #-} !BigNat
| 
|   data BigNat = BN# ByteArray#
| 
| with compiler/prelude/TysWiredIn.lhs
| 
| Right now I'm getting the Lint-failure
| 
|     Unfolding of sqrInteger
|       <no location info>: Warning:
|           In the expression: $wsqrBigNat dt
|           Argument value doesn't match argument type:
|           Fun type: ByteArray# -> BigNat
|           Arg type: BigNat
|           Arg: dt
| 
| where
| 
|   sqrBigNat :: BigNat -> BigNat
| 
| which seems to be caused by the UNPACK property not being handled
| correctly.
| 
| 
| 
| The full error message can be found at
| 
| 
| http://git.haskell.org/ghc.git/commitdiff/13cb42bc8b6b26d3893d4ddcc22eeab
| 36d39a0c7
| 
| and the other half of the integer-gmp2 patch can be found at
| 
| 
| http://git.haskell.org/ghc.git/commitdiff/b5ed2f277e551dcaade5837568e4cbb
| 7dd811c04
| 
| or alternatively
| 
|   https://phabricator.haskell.org/D82
| 
| 
| Thanks in advance,
|   hvr
| _______________________________________________
| ghc-devs mailing list
| ghc-devs at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-devs


More information about the ghc-devs mailing list