Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / typecheck / should_fail / T13929.hs
1 {-# LANGUAGE MagicHash #-}
2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE PolyKinds #-}
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 instance (GUnbox f rf, GUnbox g rg) => GUnbox (f :+: g) ('SumRep '[rf, rg]) where
32 type GUnboxed (f :+: g) ('SumRep '[rf, rg]) = (# GUnboxed f rf | GUnboxed g rg #)
33 gunbox (L1 l) = (# gunbox l | #)
34 gunbox (R1 r) = (# | gunbox r #)
35
36 main :: IO ()
37 main = pure ()