diff options
Diffstat (limited to 'testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs b/testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs new file mode 100644 index 0000000000..dc0ae5392a --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/NonLinearLHS.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE TypeFamilies, EmptyDataDecls, FlexibleContexts #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances, OverlappingInstances, 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
\ No newline at end of file |