summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/CustomTypeErrors02.hs
blob: 06eb234071cfaeceb7efd598b4baa29c09b2d521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# LANGUAGE DataKinds, UndecidableInstances #-}
{-# LANGUAGE TypeFamilies, TypeOperators, FlexibleContexts #-}
module T2 where

import GHC.TypeLits

type family IntRep a where
  IntRep Int      = Integer
  IntRep Integer  = Integer
  IntRep Bool     = Integer
  IntRep a        = TypeError (Text "The type '" :<>: ShowType a :<>:
                               Text "' cannot be represented as an integer.")

convert :: Num (IntRep a) => a -> IntRep a
convert _ = 5

err = convert id