Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / indexed-types / should_fail / T13784.hs
1 {-# LANGUAGE DataKinds, FlexibleContexts, FlexibleInstances, GADTs #-}
2 {-# LANGUAGE KindSignatures, MultiParamTypeClasses, TypeFamilies,
3 TypeOperators #-}
4
5 module T13784 where
6
7 import Data.Kind (Type)
8 import Data.Monoid ((<>))
9
10 data Product :: [Type] -> Type where
11 (:*) :: a -> Product as -> Product (a : as)
12 Unit :: Product '[]
13 infixr 5 :*
14
15 instance Show (Product '[]) where
16 show Unit = "Unit"
17
18 instance (Show a, Show (Product as)) => Show (Product (a : as)) where
19 show (a :* as) = show a <> " :* " <> show as
20
21 class Divideable a as where
22 type Divide a as :: [Type]
23 divide :: Product as -> (a, Product (Divide a as))
24
25 instance Divideable a (a : as) where
26 -- type Divide a (a : as) = as
27 -- Conflicting type family instances, seems like OVERLAPS isn't a thing for
28 -- type families.
29 divide (a :* as) = (a, as)
30
31 instance Divideable b as => Divideable b (a : as) where
32 type Divide b (a : as) = a : Divide b as
33 divide (a :* as) = a :* divide as