clash-lang / clash-prelude

CLaSH prelude library containing datatypes and functions for circuit design
http://www.clash-lang.org/
Other
31 stars 27 forks source link

GHC HEAD compile error #27

Closed ggreif closed 9 years ago

ggreif commented 9 years ago

(I tried --ghc-options="-fplugin GHC.TypeLits.Normalise" but it did not help)

Maybe below error messages ring a bell what could have gone wrong...

[21 of 42] Compiling CLaSH.Sized.Fixed ( src/CLaSH/Sized/Fixed.hs, dist/dist-sandbox-fa345477/build/CLaSH/Sized/Fixed.o )

src/CLaSH/Sized/Fixed.hs:116:1: error:
    Couldn't match representation of type ?a2?
                             with that of ?rep (int + frac)?
      arising from a use of ?coerce?
    Relevant bindings include
      minBound :: Fixed rep int frac
        (bound at src/CLaSH/Sized/Fixed.hs:116:1)
    In the expression:
        coerce (minBound :: rep ((+) int frac)) :: Fixed rep int frac
    In an equation for ?minBound?:
        minBound
          = coerce (minBound :: rep ((+) int frac)) :: Fixed rep int frac
    When typechecking the code for ?minBound?
      in a derived instance for ?Bounded (Fixed rep int frac)?:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ?Bounded (Fixed rep int frac)?

src/CLaSH/Sized/Fixed.hs:116:1: error:
    Couldn't match representation of type ?a3?
                             with that of ?rep (int + frac)?
      arising from a use of ?coerce?
    Relevant bindings include
      maxBound :: Fixed rep int frac
        (bound at src/CLaSH/Sized/Fixed.hs:116:1)
    In the expression:
        coerce (maxBound :: rep ((+) int frac)) :: Fixed rep int frac
    In an equation for ?maxBound?:
        maxBound
          = coerce (maxBound :: rep ((+) int frac)) :: Fixed rep int frac
    When typechecking the code for ?maxBound?
      in a derived instance for ?Bounded (Fixed rep int frac)?:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ?Bounded (Fixed rep int frac)?

src/CLaSH/Sized/Fixed.hs:117:1: error:
    Couldn't match representation of type ?a1?
                             with that of ?rep (int + frac)?
      arising from a use of ?coerce?
    Relevant bindings include
      def :: Fixed rep int frac (bound at src/CLaSH/Sized/Fixed.hs:117:1)
    In the expression:
        coerce (def :: rep ((+) int frac)) :: Fixed rep int frac
    In an equation for ?def?:
        def = coerce (def :: rep ((+) int frac)) :: Fixed rep int frac
    When typechecking the code for ?def?
      in a derived instance for ?Default (Fixed rep int frac)?:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ?Default (Fixed rep int frac)?

src/CLaSH/Sized/Fixed.hs:123:1: error:
    Couldn't match representation of type ?a0?
                             with that of ?rep (int + frac)?
      arising from a use of ?coerce?
    Relevant bindings include
      zeroBits :: Fixed rep int frac
        (bound at src/CLaSH/Sized/Fixed.hs:123:1)
    In the expression:
        coerce (zeroBits :: rep ((+) int frac)) :: Fixed rep int frac
    In an equation for ?zeroBits?:
        zeroBits
          = coerce (zeroBits :: rep ((+) int frac)) :: Fixed rep int frac
    When typechecking the code for ?zeroBits?
      in a derived instance for ?Bits (Fixed rep int frac)?:
      To see the code I am typechecking, use -ddump-deriv
    In the instance declaration for ?Bits (Fixed rep int frac)?
Failed to install clash-prelude-0.10
cabal.lnk: Error: some packages failed to install:
clash-prelude-0.10 failed during the building phase. The exception was:
ExitFailure 1
christiaanb commented 9 years ago

Meh, this is just a GHC bug..., is there any difference between the -ddump-deriv of 7.10.* and HEAD?

christiaanb commented 9 years ago

It seems that coerce is failing those type-classes where the members do not have a function type, such as Bounded:

class Bounded a where
  minBound :: a
  maxBound :: a
ggreif commented 9 years ago

I do not have 7.10.2 around, but I am adding the HEAD (7.11.20150621) output.

==================== Derived instances ====================
Derived instances:
  instance Data.Bits.Bits
             (rep_azap (int_azaq GHC.TypeLits.+ frac_azar)) =>
           Data.Bits.Bits
             (CLaSH.Sized.Fixed.Fixed rep_azap int_azaq frac_azar) where
    (Data.Bits..&.)
      = GHC.Prim.coerce
          ((Data.Bits..&.) ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    (Data.Bits..|.)
      = GHC.Prim.coerce
          ((Data.Bits..|.) ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.xor
      = GHC.Prim.coerce
          (Data.Bits.xor ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.complement
      = GHC.Prim.coerce
          (Data.Bits.complement ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.shift
      = GHC.Prim.coerce
          (Data.Bits.shift ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.rotate
      = GHC.Prim.coerce
          (Data.Bits.rotate ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.zeroBits
      = GHC.Prim.coerce
          (Data.Bits.zeroBits ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.bit
      = GHC.Prim.coerce
          (Data.Bits.bit ::
             GHC.Types.Int -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          GHC.Types.Int
          -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.setBit
      = GHC.Prim.coerce
          (Data.Bits.setBit ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.clearBit
      = GHC.Prim.coerce
          (Data.Bits.clearBit ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.complementBit
      = GHC.Prim.coerce
          (Data.Bits.complementBit ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.testBit
      = GHC.Prim.coerce
          (Data.Bits.testBit ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int -> GHC.Types.Bool
    Data.Bits.bitSizeMaybe
      = GHC.Prim.coerce
          (Data.Bits.bitSizeMaybe ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Base.Maybe GHC.Types.Int) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Base.Maybe GHC.Types.Int
    Data.Bits.bitSize
      = GHC.Prim.coerce
          (Data.Bits.bitSize ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq) -> GHC.Types.Int) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
    Data.Bits.isSigned
      = GHC.Prim.coerce
          (Data.Bits.isSigned ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Bool
    Data.Bits.shiftL
      = GHC.Prim.coerce
          (Data.Bits.shiftL ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.unsafeShiftL
      = GHC.Prim.coerce
          (Data.Bits.unsafeShiftL ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.shiftR
      = GHC.Prim.coerce
          (Data.Bits.shiftR ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.unsafeShiftR
      = GHC.Prim.coerce
          (Data.Bits.unsafeShiftR ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.rotateL
      = GHC.Prim.coerce
          (Data.Bits.rotateL ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.rotateR
      = GHC.Prim.coerce
          (Data.Bits.rotateR ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)
             -> GHC.Types.Int
                -> rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int
             -> CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
    Data.Bits.popCount
      = GHC.Prim.coerce
          (Data.Bits.popCount ::
             rep_ayOo ((GHC.TypeLits.+) int_ayOp frac_ayOq) -> GHC.Types.Int) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOo int_ayOp frac_ayOq
          -> GHC.Types.Int

  instance Test.QuickCheck.Arbitrary.CoArbitrary
             (rep_azas (int_azat GHC.TypeLits.+ frac_azau)) =>
           Test.QuickCheck.Arbitrary.CoArbitrary
             (CLaSH.Sized.Fixed.Fixed rep_azas int_azat frac_azau) where
    Test.QuickCheck.Arbitrary.coarbitrary
      = GHC.Prim.coerce
          (Test.QuickCheck.Arbitrary.coarbitrary ::
             rep_ayOr ((GHC.TypeLits.+) int_ayOs frac_ayOt)
             -> Test.QuickCheck.Gen.Gen b_ircd
                -> Test.QuickCheck.Gen.Gen b_ircd) ::
          forall (b_ircd :: *).
          CLaSH.Sized.Fixed.Fixed rep_ayOr int_ayOs frac_ayOt
          -> Test.QuickCheck.Gen.Gen b_ircd -> Test.QuickCheck.Gen.Gen b_ircd

  instance Test.QuickCheck.Arbitrary.Arbitrary
             (rep_azav (int_azaw GHC.TypeLits.+ frac_azax)) =>
           Test.QuickCheck.Arbitrary.Arbitrary
             (CLaSH.Sized.Fixed.Fixed rep_azav int_azaw frac_azax) where
    Test.QuickCheck.Arbitrary.arbitrary
      = GHC.Prim.coerce
          (Test.QuickCheck.Arbitrary.arbitrary ::
             Test.QuickCheck.Gen.Gen (rep_ayOu ((GHC.TypeLits.+) int_ayOv frac_ayOw))) ::
          Test.QuickCheck.Gen.Gen (CLaSH.Sized.Fixed.Fixed rep_ayOu int_ayOv frac_ayOw)
    Test.QuickCheck.Arbitrary.shrink
      = GHC.Prim.coerce
          (Test.QuickCheck.Arbitrary.shrink ::
             rep_ayOu ((GHC.TypeLits.+) int_ayOv frac_ayOw)
             -> [] (rep_ayOu ((GHC.TypeLits.+) int_ayOv frac_ayOw))) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOu int_ayOv frac_ayOw
          -> [] (CLaSH.Sized.Fixed.Fixed rep_ayOu int_ayOv frac_ayOw)

  instance Data.Default.Class.Default
             (rep_azay (int_azaz GHC.TypeLits.+ frac_azaA)) =>
           Data.Default.Class.Default
             (CLaSH.Sized.Fixed.Fixed rep_azay int_azaz frac_azaA) where
    Data.Default.Class.def
      = GHC.Prim.coerce
          (Data.Default.Class.def ::
             rep_ayOx ((GHC.TypeLits.+) int_ayOy frac_ayOz)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOx int_ayOy frac_ayOz

  instance GHC.Enum.Bounded
             (rep_azaB (int_azaC GHC.TypeLits.+ frac_azaD)) =>
           GHC.Enum.Bounded
             (CLaSH.Sized.Fixed.Fixed rep_azaB int_azaC frac_azaD) where
    GHC.Enum.minBound
      = GHC.Prim.coerce
          (GHC.Enum.minBound ::
             rep_ayOA ((GHC.TypeLits.+) int_ayOB frac_ayOC)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOA int_ayOB frac_ayOC
    GHC.Enum.maxBound
      = GHC.Prim.coerce
          (GHC.Enum.maxBound ::
             rep_ayOA ((GHC.TypeLits.+) int_ayOB frac_ayOC)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOA int_ayOB frac_ayOC

  instance GHC.Enum.Enum
             (rep_azaE (int_azaF GHC.TypeLits.+ frac_azaG)) =>
           GHC.Enum.Enum
             (CLaSH.Sized.Fixed.Fixed rep_azaE int_azaF frac_azaG) where
    GHC.Enum.succ
      = GHC.Prim.coerce
          (GHC.Enum.succ ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
    GHC.Enum.pred
      = GHC.Prim.coerce
          (GHC.Enum.pred ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
    GHC.Enum.toEnum
      = GHC.Prim.coerce
          (GHC.Enum.toEnum ::
             GHC.Types.Int -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)) ::
          GHC.Types.Int
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
    GHC.Enum.fromEnum
      = GHC.Prim.coerce
          (GHC.Enum.fromEnum ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF) -> GHC.Types.Int) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> GHC.Types.Int
    GHC.Enum.enumFrom
      = GHC.Prim.coerce
          (GHC.Enum.enumFrom ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> [] (rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF))) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> [] (CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF)
    GHC.Enum.enumFromThen
      = GHC.Prim.coerce
          (GHC.Enum.enumFromThen ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
                -> [] (rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF))) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
             -> [] (CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF)
    GHC.Enum.enumFromTo
      = GHC.Prim.coerce
          (GHC.Enum.enumFromTo ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
                -> [] (rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF))) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
             -> [] (CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF)
    GHC.Enum.enumFromThenTo
      = GHC.Prim.coerce
          (GHC.Enum.enumFromThenTo ::
             rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
             -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
                -> rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF)
                   -> [] (rep_ayOD ((GHC.TypeLits.+) int_ayOE frac_ayOF))) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
          -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
             -> CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF
                -> [] (CLaSH.Sized.Fixed.Fixed rep_ayOD int_ayOE frac_ayOF)

  instance GHC.Classes.Ord
             (rep_azaH (int_azaI GHC.TypeLits.+ frac_azaJ)) =>
           GHC.Classes.Ord
             (CLaSH.Sized.Fixed.Fixed rep_azaH int_azaI frac_azaJ) where
    GHC.Classes.compare
      = GHC.Prim.coerce
          (GHC.Classes.compare ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> GHC.Types.Ordering) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> GHC.Types.Ordering
    (GHC.Classes.<)
      = GHC.Prim.coerce
          ((GHC.Classes.<) ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> GHC.Types.Bool
    (GHC.Classes.<=)
      = GHC.Prim.coerce
          ((GHC.Classes.<=) ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> GHC.Types.Bool
    (GHC.Classes.>)
      = GHC.Prim.coerce
          ((GHC.Classes.>) ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> GHC.Types.Bool
    (GHC.Classes.>=)
      = GHC.Prim.coerce
          ((GHC.Classes.>=) ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> GHC.Types.Bool
    GHC.Classes.max
      = GHC.Prim.coerce
          (GHC.Classes.max ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
    GHC.Classes.min
      = GHC.Prim.coerce
          (GHC.Classes.min ::
             rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
             -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)
                -> rep_ayOG ((GHC.TypeLits.+) int_ayOH frac_ayOI)) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
          -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI
             -> CLaSH.Sized.Fixed.Fixed rep_ayOG int_ayOH frac_ayOI

  instance GHC.Classes.Eq
             (rep_azaK (int_azaL GHC.TypeLits.+ frac_azaM)) =>
           GHC.Classes.Eq
             (CLaSH.Sized.Fixed.Fixed rep_azaK int_azaL frac_azaM) where
    (GHC.Classes.==)
      = GHC.Prim.coerce
          ((GHC.Classes.==) ::
             rep_ayOJ ((GHC.TypeLits.+) int_ayOK frac_ayOL)
             -> rep_ayOJ ((GHC.TypeLits.+) int_ayOK frac_ayOL)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOJ int_ayOK frac_ayOL
          -> CLaSH.Sized.Fixed.Fixed rep_ayOJ int_ayOK frac_ayOL
             -> GHC.Types.Bool
    (GHC.Classes./=)
      = GHC.Prim.coerce
          ((GHC.Classes./=) ::
             rep_ayOJ ((GHC.TypeLits.+) int_ayOK frac_ayOL)
             -> rep_ayOJ ((GHC.TypeLits.+) int_ayOK frac_ayOL)
                -> GHC.Types.Bool) ::
          CLaSH.Sized.Fixed.Fixed rep_ayOJ int_ayOK frac_ayOL
          -> CLaSH.Sized.Fixed.Fixed rep_ayOJ int_ayOK frac_ayOL
             -> GHC.Types.Bool

Generic representation:

  Generated datatypes for meta-information:

  Representation types:
christiaanb commented 9 years ago

Can you test if this works:

{-# LANGUAGE ScopedTypeVariables, TypeOperators, KindSignatures, DataKinds #-}
module CoerceBug where

import Data.Coerce
import GHC.TypeLits

newtype  Fixed (rep :: Nat -> *) (int :: Nat) (frac :: Nat) = Fixed { unFixed :: rep (int + frac) }

minBoundTest :: forall rep int frac . Bounded (rep (int + frac))
             => Fixed rep int frac
minBoundTest = coerce (minBound :: rep (int + frac))
ggreif commented 9 years ago

Yep, I get an error:

CoerceBug.hs:11:16: error:
    Couldn't match representation of type ?a0?
                             with that of ?rep (int + frac)?
      arising from a use of ?coerce?
    Relevant bindings include
      minBoundTest :: Fixed rep int frac (bound at CoerceBug.hs:11:1)
    In the expression: coerce (minBound :: rep (int + frac))
    In an equation for ?minBoundTest?:
        minBoundTest = coerce (minBound :: rep (int + frac))
christiaanb commented 9 years ago

The CoerceBug module compiles just fine on GHC 7.10.2. Could you post a regression/bug report on the GHC trac?

ggreif commented 9 years ago

Just tried version 7.11.20150923, it works there! Sorry for the noise, looks like I'll need an upgrade... :-(

christiaanb commented 9 years ago

So this issue can be closed then?

ggreif commented 9 years ago

Probably, but let me check. Tomorrow I'll have a freshly baked GHC. Then I'll try building CLaSH, and if all goes right I close this myself.

ggreif commented 9 years ago

I am hanging in the prerequisite packages th-desugar & co., (which do not compile due to TH changes) but the original bug seems to be fixed in yesterday's GHC. So, closing.