<html><body bgcolor="#FFFFFF"><div>Yeah, seems to work too.<br><br>Отправлено с iPhone</div><div><br>Jun 20, 2011, в 10:55, "Corey O'Connor" <<a href="mailto:coreyoconnor@gmail.com">coreyoconnor@gmail.com</a>> написал(а):<br><br></div><div></div><blockquote type="cite"><div><div class="gmail_quote"><div>Not just a proposal any more. :-) GHC 7.0 does not generalize local let bindings in some situations. See here for information: <a href="http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7"><a href="http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7">http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7</a></a></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">There is a proposal (from Big Simon) to remove let-generalization: <a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/let-gen.pdf" target="_blank"><a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/let-gen.pdf">http://research.microsoft.com/en-us/um/people/simonpj/papers/constraints/let-gen.pdf</a></a><br>
<div><div></div><div class="h5"><br>
On 19 Jun 2011, at 18:26, Serguey Zefirov wrote:<br>
<br>
> Right now I write a quite heavy transformation of Haskell source code<br>
> and found some strange behaviour of typechecker.<br>
><br>
> Some prerequisites:<br>
> -- dummy class. My own class is much bigger, but I<br>
> -- could reproduce that behaviour with that class.<br>
> class ToWires a<br>
><br>
> -- a type with phantom type arguments.<br>
> data E ins outs = E<br>
><br>
> -- a function that relates E and its inputs.<br>
> projectInsType :: E ins outs -> ins<br>
> projectInsType = error "projectInsType gets evaluated."<br>
><br>
> -- "register" function.<br>
> register :: a -> a -> a<br>
> register def a = def<br>
><br>
> -- a simple addition.<br>
> add2 :: (ToWires a, Num a) => (a,a) -> a<br>
> add2 (a,b) = a+b<br>
><br>
><br>
> First I have a function:<br>
> func :: (ToWires a, Num a) => Maybe a -> a<br>
> func mbA = currentSum<br>
> where<br>
> x = case mbA of<br>
> Just a -> a<br>
> Nothing -> 0<br>
> nextSum = add2 (x,currentSum)<br>
> currentSum = register 0 nextSum<br>
><br>
> It typechecks and works just fine after some transformation.<br>
><br>
> The transformation I work on transform code into something like that:<br>
> func_E :: (ToWires a, Num a) => E (Maybe a) a<br>
> func_E = r<br>
> where<br>
> r = E<br>
> -- here we relate mbA and r.<br>
> mbA = projectInsType r<br>
> x = case mbA of<br>
> Just a -> a<br>
> Nothing -> 0<br>
> nextSum = add2 (x,currentSum)<br>
> currentSum = register 0 nextSum<br>
><br>
> Note the absence of input of func in transformed func_E. I relate mbA<br>
> with it's proper type using binding "mbA = projectInsType r".<br>
><br>
> Then suddently ghc loses all of the context associated with mbA. And<br>
> find type error at the calling of add2.<br>
><br>
> If I drop ToWires from contexts of func_E and add2 types, all works<br>
> fine. If I change add2 to simple addition (x + currentSum), all works<br>
> fine.<br>
><br>
> Full source code is in attachment.<br>
><br>
> I found it using ghc 6.12.1. I asked colleagues, they told me that the<br>
> same error manifests itself in ghc 7.0.3.<br>
><br>
> Should I fill a bug report or maybe I misunderstood something?<br>
</div></div>> <a.hs>_______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org"><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a></a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank"><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a></a><br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org"><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a></a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank"><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a></a><br>
</blockquote></div><br>
</div></blockquote></body></html>