Testsuite: delete Windows line endings [skip ci] (#11631)
[ghc.git] / testsuite / tests / typecheck / should_compile / faxen.hs
1 {-# LANGUAGE RankNTypes #-}
2
3 -- A classic test for type inference
4 -- Taken from "Haskell and principal types", Section 3
5 -- by Faxen, in the Haskell Workshop 2003, pp88-97
6
7 module ShouldCompile where
8
9 import GHC.List (null)
10 import Prelude hiding (null)
11
12 class HasEmpty a where
13 isEmpty :: a -> Bool
14
15 instance HasEmpty [a] where
16 isEmpty x = null x
17
18 instance HasEmpty (Maybe a) where
19 isEmpty Nothing = True
20 isEmpty (Just x) = False
21
22 test1 y
23 = (null y)
24 || (let f :: forall d. d -> Bool
25 f x = isEmpty (y >> return x)
26 in f y)
27
28 test2 y
29 = (let f :: forall d. d -> Bool
30 f x = isEmpty (y >> return x)
31 in f y)
32 || (null y)
33