Fix #13929 by adding another levity polymorphism check
[ghc.git] / testsuite / tests / typecheck / should_fail / T13929.hs
1 {-# LANGUAGE MagicHash #-}
2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE TypeInType #-}
4 {-# LANGUAGE TypeFamilies #-}
5 {-# LANGUAGE MultiParamTypeClasses #-}
6 {-# LANGUAGE DeriveGeneric #-}
7 {-# LANGUAGE DefaultSignatures #-}
8 {-# LANGUAGE UnboxedTuples #-}
9 {-# LANGUAGE TypeOperators #-}
10 {-# LANGUAGE FlexibleInstances #-}
11 {-# LANGUAGE FlexibleContexts #-}
12 {-# LANGUAGE UndecidableInstances #-}
13 {-# LANGUAGE RankNTypes #-}
14 {-# LANGUAGE AllowAmbiguousTypes #-}
15
16 module Main where
17
18 import GHC.Exts
19 import Data.Kind
20 import GHC.Generics
21
22 class GUnbox (f :: Type -> Type) (r :: RuntimeRep) where
23 type GUnboxed f r :: TYPE r
24 gunbox :: f p -> GUnboxed f r
25
26 instance (GUnbox f rf, GUnbox g rg) => GUnbox (f :*: g) ('TupleRep '[rf, rg]) where
27 type GUnboxed (f :*: g) ('TupleRep '[rf, rg]) = (# GUnboxed f rf, GUnboxed g rg #)
28 -- if I remove implementation of `gunbox` it compiles successfully
29 gunbox (x :*: y) = (# gunbox x, gunbox y #)
30
31 main :: IO ()
32 main = pure ()