diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/typecheck/should_run/tcrun028.hs | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun028.hs')
-rw-r--r-- | testsuite/tests/typecheck/should_run/tcrun028.hs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun028.hs b/testsuite/tests/typecheck/should_run/tcrun028.hs new file mode 100644 index 0000000000..f4f8fd9d61 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/tcrun028.hs @@ -0,0 +1,63 @@ +{-# OPTIONS_GHC -dcore-lint #-} +{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, + FlexibleInstances, UndecidableInstances #-} + +-- This is a rather exotic functional-dependency test. +-- It crashed GHC 5.04.3 with a core-lint error, because +-- of a bug in tcSimplifyRestricted (fixed Apr 03) + +module Main where + + +class ComposePS a b c | a b -> c where + (.>) :: PSOp a -> PSOp b -> PSOp c + (V a) .> (V b) = V (a ++ b) + +instance (ConcatPS a b c, CheckPS c Id Id d) => ComposePS a b d + +------------------------------------------------------------------------------ + +data PSOp a = V [String] deriving Show + +data Id +data Push t rest +data Pop t rest + + +class Reverse a b c | a b -> c +instance Reverse Id b b +instance Reverse a (Pop t b) c => Reverse (Pop t a) b c +instance Reverse a (Push t b) c => Reverse (Push t a) b c + +------------------------------------------------------------------------------ + +class ConcatPS a b c | a b -> c where + ccat :: a -> b -> c +instance ConcatPS Id a a +instance ConcatPS a b c => ConcatPS (Pop t a) b (Pop t c) +instance ConcatPS a b c => ConcatPS (Push t a) b (Push t c) + +------------------------------------------------------------------------------ + +class CheckPS a b c d | a b c -> d where + check :: a -> b -> c -> d + check _ _ _ = error "oki" + +instance Reverse a b c => CheckPS Id a b c + +instance CheckPS a b (Push t c) d => CheckPS (Push t a) b c d + +instance CheckPS a (Pop t b) Id d => CheckPS (Pop t a) b Id d + +instance CheckPS a b c d => CheckPS (Pop t a) b (Push t c) d + + +v1 :: PSOp (Pop a Id) +v1 = V [] + +v2 :: PSOp Id +v2 = V [] + +t = v1 .> v2 + +main = print t |