1 --!!! Testing Haskell 1.3 syntax
3 -- Haskell 1.3 syntax differs from Haskell 1.2 syntax in several ways:
5 -- * Qualified names in export lists
6 module TestSyntax where
8 -- * Qualified import/export
12 import qualified Prelude as P
15 import qualified Prelude
18 import Prelude (fst,snd)
19 import qualified Prelude(fst,snd)
21 -- bizarre syntax allowed in draft of Haskell 1.3
23 import Prelude(fst,snd,)
24 import Prelude(Ord(..),Eq((==),(/=)),)
25 import Prelude hiding (fst,snd,)
27 import Prelude hiding (fst,snd)
28 import qualified Prelude hiding (fst,snd)
31 import qualified Prelude as P
33 import Prelude as P(fst,snd)
34 import Prelude as P(,)
35 import qualified Prelude as P(fst,snd)
37 import Prelude as P hiding (fst,snd)
38 import qualified Prelude as P hiding (fst,snd)
40 -- 2) Use of qualified type names
41 -- 3) Use of qualified constructors
42 -- 4) Use of qualified variables
44 -- * No n+k patterns (yippee!)
47 -- Some things are unchanged.
49 -- * Unqualified imports and use of hiding/selective import.
51 -- Note: it's not clear how these various imports are supposed to
52 -- interact with one another.
54 -- 1) "hiding" lists etc are just abbreviations for very long
56 -- 2) Multiple imports are additive.
57 -- (This makes the meaning order-independent!)
58 -- Note: Hugs allows imports anywhere a topdecl is allowed.
59 -- This isn't legal Haskell - but it does no harm.
61 -- import Prelude(lex)
63 -- import Prelude hiding (lex)
64 -- lex = 1 :: Int -- error unless we've hidden lex.
70 -- Function/operator names
71 myfilter x = Prelude.filter x -- argument added to avoid monomorphism restn
72 mycompose = (Prelude..)
74 -- Use of module synonyms
75 myfilter2 p = P.filter p
78 myplus :: Num a => a -> a -> a
82 myminus = (Prelude.-) :: Prelude.Int -> Prelude.Int -> Prelude.Int
88 -- Class names in instances
89 instance P.Num P.Bool where
94 instance (P.Num a, P.Num b) => P.Num (a,b) where
95 x + y = (fst x + fst y, snd x + snd y)
97 -- Constructor names in expressions
99 -- this used to break tidyInfix in parser.y
100 -- Note that P.[] is _not_ legal!
101 testInfixQualifiedCon = 'a' P.: [] :: String
103 -- Constructor names in patterns
105 f (P.Nothing) = False
111 -- * Support for octal and hexadecimal numbers
112 -- Note: 0xff and 0xFF are legal but 0Xff and 0XFF are not.
113 -- ToDo: negative tests to make sure invalid numbers are excluded.
115 d = ( -1, -0, 0, 1) :: (Int,Int,Int,Int)
116 o = (-0o1,-0o0,0o0,0o1) :: (Int,Int,Int,Int)
117 x = (-0x1,-0x0,0x0,0x1) :: (Int,Int,Int,Int)
118 x' = (0xff,0xFf,0xfF,0xFF) :: (Int,Int,Int,Int)
120 -- * No renaming or interface files
121 -- We test that "interface", "renaming" and "to" are not reserved.