Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 461
    • Merge requests 461
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2701
Closed
Open
Created Oct 16, 2008 by batterseapower@trac-batterseapower

Cannot derive Data for structures containing unboxed values

Trying to compile this:

{-# LANGUAGE MagicHash, DeriveDataTypeable #-}
module Test where

import GHC.Prim

import Data.Data
import Data.Typeable

data Foo = MkFoo Int#
         deriving (Typeable, Data)

Results in an error:

$ ghc/stage1-inplace/ghc --make ~/DerivingUnboxed.hs 
[1 of 1] Compiling Test             ( /Users/mbolingbroke/DerivingUnboxed.hs, /Users/mbolingbroke/DerivingUnboxed.o )

/Users/mbolingbroke/DerivingUnboxed.hs:10:29:
    Couldn't match kind `#' against `*'
    When matching the kinds of `Int# :: #' and `d :: *'
      Expected type: d
      Inferred type: Int#
    In the first argument of `z', namely `MkFoo'

/Users/mbolingbroke/DerivingUnboxed.hs:10:29:
    Couldn't match kind `#' against `*'
    When matching the kinds of `Int# :: #' and `b :: *'
      Expected type: b
      Inferred type: Int#
    In the first argument of `z', namely `MkFoo'

I'm not sure if this is really a bug or not. It might be nice if deriving Data handled this case by reboxing Int#, or alternatively if it gave a clear error messages about not being able to handle unboxed values.

Trac metadata
Trac field Value
Version 6.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking