{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS -Wall #-} module M where import Data.Kind import GHC.TypeLits data L = L1 | L2 data Foo (xs :: [L]) where T1 :: (In L1 xs) => Foo xs T2 :: (In L2 xs) => Foo xs type family In x xs :: Constraint where In x (x:xs) = () In x (y:xs) = In x xs In x '[] = TypeError (ShowType x :<>: Text "not found in list") bar :: Foo '[L1] -> () bar T1 = () bar T2 = ()