summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_fail/T4485.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/indexed-types/should_fail/T4485.hs
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/indexed-types/should_fail/T4485.hs')
-rw-r--r--testsuite/tests/indexed-types/should_fail/T4485.hs66
1 files changed, 66 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_fail/T4485.hs b/testsuite/tests/indexed-types/should_fail/T4485.hs
new file mode 100644
index 0000000000..b48e8206f2
--- /dev/null
+++ b/testsuite/tests/indexed-types/should_fail/T4485.hs
@@ -0,0 +1,66 @@
+-- The behavior of type-inference and OverlappingInstances has changed
+-- between GHC 6.12 and GHC 7.0 such that the following code
+-- type-checks under 6.12, but not 7.0rc2. I assume this change has
+-- something to do with the new type checker in GHC 7, but it is not
+-- clear to me if this change in behavior is intended. Nor am I clear
+-- how to achieve something similar to the old behavior. This is
+-- preventing HSP (and by extension, happstack) from migrating to GHC
+-- 7. I reported this earlier on the mailing lists, but I have further
+-- simplied the test case here.
+
+{-# LANGUAGE TypeFamilies, MultiParamTypeClasses
+ , FlexibleContexts, FlexibleInstances, UndecidableInstances
+ , TypeSynonymInstances, GeneralizedNewtypeDeriving
+ , OverlappingInstances
+ #-}
+module XMLGenerator where
+
+newtype XMLGenT m a = XMLGenT (m a)
+ deriving (Functor, Monad)
+
+class Monad m => XMLGen m where
+ type XML m
+ data Child m
+ genElement :: String -> XMLGenT m (XML m)
+
+class XMLGen m => EmbedAsChild m c where
+ asChild :: c -> XMLGenT m [Child m]
+
+instance (EmbedAsChild m c, m1 ~ m) => EmbedAsChild m (XMLGenT m1 c)
+
+instance (XMLGen m, XML m ~ x) => EmbedAsChild m x
+
+data Xml = Xml
+data IdentityT m a = IdentityT (m a)
+instance Monad (IdentityT m)
+instance XMLGen (IdentityT m) where
+ type XML (IdentityT m) = Xml
+
+data Identity a = Identity a
+instance Monad Identity
+
+instance EmbedAsChild (IdentityT IO) (XMLGenT Identity ())
+
+data FooBar = FooBar
+
+instance EmbedAsChild (IdentityT IO) FooBar where
+ asChild b = asChild $ (genElement "foo")
+ -- asChild :: FooBar -> XMLGenT (XMLGenT (IdentityT IO) [Child (IdentitiyT IO)])
+
+{- ---------- Deriving the constraints ----------
+ asChild :: EmbedAsChild m c => c -> XMLGenT m [Child m]
+ genElement :: XMLGen m => String -> XMLGenT m (XML m)
+
+ Wanted: EmbedAsChild m c, with m = IdentityT IO
+ c = XMLGenT meta (XML meta)
+ XMLGen meta
+
+ ie EmbedAsChild (IdentityT IO) (XMLGen meta (XML meta)
+ XMLGen meta
+
+We have instances
+ EmbedAsChild (IdentityT IO) FooBar
+ EmbedAsChild (IdentityT IO) (XMLGenT Identity ())
+ EmbedAsChild m (XMLGenT m1 c)
+ EmbedAsChild m x
+-}