blob: c7310529c6b93bed76cc05cb7d16148166c99baa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{-# LANGUAGE Rank2Types #-}
-- A classic test for type inference
-- Taken from "Haskell and principal types", Section 3
-- by Faxen, in the Haskell Workshop 2003, pp88-97
module ShouldCompile where
class HasEmpty a where
isEmpty :: a -> Bool
instance HasEmpty [a] where
isEmpty x = null x
instance HasEmpty (Maybe a) where
isEmpty Nothing = True
isEmpty (Just x) = False
test1 y
= (null y)
|| (let f :: forall d. d -> Bool
f x = isEmpty (y >> return x)
in f y)
test2 y
= (let f :: forall d. d -> Bool
f x = isEmpty (y >> return x)
in f y)
|| (null y)
|