<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Here is an example illustrating a type problem I've having with GHC 6.10.1:<br><br><blockquote type="cite"><font class="Apple-style-span" color="#000000">module Main where<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">newtype Box a = B a<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">make :: a -> Box a<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">make x = B x<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">val :: Box a -> a<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">val (B x) = x<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">test1 :: Box a -> a -> [a]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">test1 box x = go box x<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;where<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;&nbsp;&nbsp;go :: Box a -> a -> [a]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;&nbsp;&nbsp;go b y = [(val b), y]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">test2 :: Box a -> a -> [a]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">test2 box x = go x<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;where<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">-- &nbsp;go :: a -> [a]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;&nbsp;&nbsp;go y = [(val box), y]<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">main :: IO ()<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">main = do<br></font></blockquote><blockquote type="cite"><font class="Apple-style-span" color="#000000">&nbsp;print $ test1 (make 1) 2<br></font></blockquote><br>If I uncomment the commented type declaration, I get the familiar error<br><br><blockquote type="cite"><font class="Apple-style-span" color="#000000">Couldn't match expected type `a1' against inferred type `a'<br></font></blockquote><br>On the other hand, the earlier code is identical except that it passes an extra argument, and GHC matches the types without complaint.<br><br>This is a toy example to isolate the issue; in the actual code one wants a machine-checkable type declaration to help understand the function, which is local to save passing an argument. To the best of my understanding, I've given the correct type, but GHC won't make the inference to unify the type variables.<br><br>I wonder if I found a GHC blind spot. However, it is far more likely that my understanding is faulty here. Any thoughts?<br><br>Thanks,<br>Dave<br></body></html>