Only pass mod_location with HscRecomp instead of the entire ModSummary
[ghc.git] / testsuite / tests / typecheck / should_run / T1735.hs
1 {-# LANGUAGE TemplateHaskell, FlexibleInstances, ScopedTypeVariables,
2 ScopedTypeVariables, GADTs, RankNTypes, FlexibleContexts,
3 MultiParamTypeClasses, GeneralizedNewtypeDeriving,
4 DeriveDataTypeable,
5 OverlappingInstances, UndecidableInstances, CPP #-}
6
7 module Main (main) where
8
9 import T1735_Help.Basics
10 import T1735_Help.Xml
11
12 data YesNo = Yes | No
13 deriving (Eq, Show, Typeable)
14 instance Sat (ctx YesNo) => Data ctx YesNo where
15 toConstr _ Yes = yesConstr
16 toConstr _ No = noConstr
17 gunfold _ _ z c = case constrIndex c of
18 1 -> z Yes
19 2 -> z No
20 _ -> error "Foo"
21 dataTypeOf _ _ = yesNoDataType
22 yesConstr :: Constr
23 yesConstr = mkConstr yesNoDataType "Yes" [] Prefix
24 noConstr :: Constr
25 noConstr = mkConstr yesNoDataType "No" [] Prefix
26 yesNoDataType :: DataType
27 yesNoDataType = mkDataType "YesNo" [yesConstr, noConstr]
28
29 newtype MyList a = MkMyList { unMyList :: [a] }
30 deriving (Show, Eq, Typeable)
31 instance (Sat (ctx (MyList a)), Sat (ctx [a]), Data ctx a)
32 => Data ctx (MyList a) where
33 gfoldl _ f z x = z MkMyList `f` unMyList x
34 toConstr _ (MkMyList _) = mkMyListConstr
35 gunfold _ k z c = case constrIndex c of
36 1 -> k (z MkMyList)
37 _ -> error "Foo"
38 dataTypeOf _ _ = myListDataType
39 mkMyListConstr :: Constr
40 mkMyListConstr = mkConstr myListDataType "MkMyList" [] Prefix
41 myListDataType :: DataType
42 myListDataType = mkDataType "MyList" [mkMyListConstr]
43
44 #if defined(FOO)
45 rigidTests :: Maybe (Maybe [YesNo])
46 rigidTests =
47 mkTest [Elem "No" []] (Just [No])
48 #endif
49
50 rigidManualTests :: Maybe (Maybe (MyList YesNo))
51 rigidManualTests =
52 mkTest [Elem "MkMyList" [Elem "Yes" []]] (Just (MkMyList [Yes]))
53
54 mkTest :: (Eq a, Xml a) => [Element] -> Maybe a -> Maybe (Maybe a)
55 mkTest es v = case fromXml es of
56 v' | v == v' -> Nothing
57 | otherwise -> Just v'
58
59 main :: IO ()
60 main = print rigidManualTests
61