[GHC] #15777: Ordering of code in file affects compilation
GHC
ghc-devs at haskell.org
Thu Oct 18 22:05:49 UTC 2018
#15777: Ordering of code in file affects compilation
-------------------------------------+-------------------------------------
Reporter: chessai | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone: 8.6.2
Component: Compiler | Version: 8.6.1
Resolution: duplicate | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #12088 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* status: new => closed
* resolution: => duplicate
* related: => #12088
Comment:
Thanks for the bug report. This is a duplicate of #12088 (as well as many
other tickets listed in its related tickets pane), so I'll close this
ticket in favor of #12088.
As a crude workaround, you can use Template Haskell to force GHC to see
the light. That is, this slight variant of the second program typechecks:
{{{#!hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
-- | Conversion between unlifted and lifted datatypes
module Packed.Levity
( -- * Types
Rep
, Levity(..)
) where
import Data.Kind (Type)
import GHC.Types (TYPE, RuntimeRep(..), Int(..), Word(..))
import GHC.Exts (Int#, Word#, ByteArray#)
class Levity (a :: Type) where
type Unlifted a :: TYPE (Rep a)
box :: Unlifted a -> a
unbox :: a -> Unlifted a
instance Levity Int where
type Unlifted Int = Int#
box = I#
unbox (I# i) = i
instance Levity Word where
type Unlifted Word = Word#
box = W#
unbox (W# w) = w
type family Rep (a :: Type) :: RuntimeRep
type instance Rep Int = IntRep
type instance Rep Word = WordRep
type Stuff# = (# Int#, Int# #)
data Stuff = Stuff Int# Int#
type instance Rep Stuff = TupleRep '[ 'IntRep, 'IntRep ]
$(pure [])
instance Levity Stuff where
type Unlifted Stuff = Stuff#
box = stuff#
unbox = unStuff#
stuff# :: (# Int#, Int# #) -> Stuff
stuff# (# x, y #) = Stuff x y
unStuff# :: Stuff -> (# Int#, Int# #)
unStuff# (Stuff x y) = (# x, y #)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15777#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list