summaryrefslogtreecommitdiff
path: root/testsuite/tests/unsatisfiable/T14141_Unsat.hs
blob: 8be3b419607736065ce8ba8c3f52d7a8d2414b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{-# LANGUAGE Haskell2010 #-}

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

module T14141_Unsat where

import GHC.TypeError
import Data.Kind
  ( Constraint, Type )

-- Example 1: from #14141

data D where
  MkD :: C => D

type C :: Constraint
type family C where
    C = Unsatisfiable ('Text "error")

f :: D -> ()
f MkD = ()

-- Example 2: from #16377

type F :: Type -> Constraint
type family F a :: Constraint
type instance F Int  = ()
type instance F Char = Unsatisfiable  ('Text "Nope")

data T where
  A :: F Int  => T
  B :: F Char => T

exhaustive :: T -> ()
exhaustive A = ()
exhaustive B = ()