2 To: Lennart Augustsson <augustss@cs.chalmers.se>
3 Cc: partain@dcs.gla.ac.uk, John Peterson (Yale) <peterson-john@cs.yale.edu>,
5 Subject: Type checking matter
6 Date: Fri, 23 Oct 92 15:28:38 +0100
7 From: Simon L Peyton Jones <simonpj@dcs.gla.ac.uk>
10 I've looked at the enclosed again. It seems to me that
11 since "s" includes a recursive call to "sort", inside the body
12 of "sort", then "sort" is monomorphic, and hence so is "s";
13 hence the type signature (which claims full polymorphism) is
16 [Lennart says he can't see any free variables inside "s", but there
17 is one, namely "sort"!]
19 Will: one for the should-fail suite?
24 ------- Forwarded Message
27 From: Lennart Augustsson <augustss@cs.chalmers.se>
29 Subject: Re: just to show you I'm a nice guy...
30 Date: Tue, 26 May 92 17:30:12 +0200
32 > Here's a fairly simple module from our compiler, which includes what
33 > we claim is an illegal type signature (grep ILLEGAL ...).
34 > Last time I checked, hbc accepted this module.
36 Not that I don't believe you, but why is this illegal?
37 As far as I can see there are no free variables in the function s,
38 which makes me believe that it can typechecked like a top level
39 definition. And for a top level defn the signature should be
43 - ------- End of forwarded message -------
45 module ShouldFail where
47 sort :: Ord a => [a] -> [a]
48 sort xs = s xs (length xs)
50 s :: Ord b => [b] -> Int -> [b] -- This signature is WRONG
51 s xs k = if k <= 1 then xs
52 else merge (sort ys) (sort zs)
53 where (ys,zs) = init_last xs (k `div` (2::Int))
55 -- Defns of merge and init_last are just dummies with the correct types
56 merge :: Ord a => [a] -> [a] -> [a]
59 init_last :: [a] -> Int -> ([a],[a])