summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs
blob: d500b324fe0a33b9eabb4cd3a6d808db16820e29 (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
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# LANGUAGE TypeFamilies, EmptyDataDecls, FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}

module NonLinearLHS where

type family E a b
type instance E a a = [a]

foo :: E [Int] (E Int Int) -> Int
foo = sum . concat

data family F a b
data instance F a a = MkF [a] 

goo :: F Int Int -> F Bool Bool
goo (MkF xs) = MkF $ map odd xs


-- HList-like type equality

data True; data False;

type family EqTy a b
type instance EqTy a a = True

class EqTyP a b result
instance (EqTy a b ~ isEq, Proxy isEq result) => EqTyP a b result

class Proxy inp out
instance (result ~ True) => Proxy True result
instance (result ~ False) => Proxy notTrue result

testTrue :: EqTyP Int Int r => r
testTrue = undefined

testFalse :: EqTyP Int Bool r => r
testFalse = undefined