On Thu, Nov 20, 2008 at 12:57 PM, David Roundy <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 20, 2008 at 02:44:33AM +0300, Dmitry Kurochkin wrote:
>> hunk ./src/Darcs/Patch/Real.hs 175
>> >                                                a:>p':>b ->
>> >                                                    do (b',xs') <- mac b xs 
>> > goneby
>> >                                                       --traceDoc 
>> > (greenText "foo1" $$
>> > -                                                     --          
>> > showPatch (sort_coalesceFL $
>> > -                                                     --                   
>> >   effect $ p':<:a)) $ Just ()
>> > -                                                     NilFL <- return $ 
>> > sort_coalesceFL $ effect $ p':<:a
>> > +                                                     --          
>> > showPatch (sort_coalesce_effects $ p':<:a)) $ Just ()
>> > +                                                     NilFL <- return $ 
>> > sort_coalesce_effects $ p':<:a
>> >                                                       return (reverseRL 
>> > (p':<:a)+>+b', xs')
>> >                                                     `mplus` do NilFL <- 
>> > return goneby
>>
>> Use sort_coalesce_effects instead of sort_coalesceFL.
>>
>> It would be easier to read if "sort_coalesce_effects $ p':<:a" is
>> bound to a name with let. Not sure if it worth changing though.
>
> But alas, that would cause ghc's brain to explode.  NilFL is a GADT,
> and you can't use let bindings with GADT patterns.  This relates to
> the fact that matching NilFL puts a constraint on the type witnesses,
> and because let bindings are lazy, they don't work well with that.

Actually, I bet Dmitry read it the same way I did when I first read
it.  Which is to say, I thought there was a repeated subexpression:
"sort_coalesceFL $ effect $ p':<:a"

But it doesn't appear twice because one of the uses in a comment.

The suggestion would have worked though as near as I can tell.  My
spacing may be off because I only have a proportional width font to
work with.  But, just image the "let" has the correct indentation
level to be in the do-block
                                                   do (b',xs') <- mac
b xs goneby
                                                       --traceDoc
(greenText "foo1" $$
+                                                     let foo =
sort_coalesce_effects $ p':<:a
+                                                     --
showPatch foo $ Just ()
+                                                     NilFL <- return foo
                                                       return
(reverseRL (p':<:a)+>+b', xs')

I except this to be fine because we're not actually asserting that foo
is NilFL until we do it in the monadic pattern binding (the line
"NilFL <- return foo").  But, I'm not saying anything needs to be
amended; I'm just trying to clarify what I think was the suggestion
and how it could be made to work.

Or maybe Dmitry was objecting to us gratuitously using "<- return"
with a pure value.

Well, if nothing I hope my example clarifies that we can use let here,
just not a let that requires a pattern match.

By the way, if you want to understand better why a lazy pattern match
fails to work you need to look at how Haskell is translated to System
F and the interaction between type inference and the way that System F
requires type variables to be passed explicitly.  Those two things
(inference + explicit type passing) do not play well with existentials
if the pattern match is lazy.  I had questions about this on
Haskell-Cafe:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg47034.html

A related problem is using lazy patterns with existentials:
http://www.haskell.org/pipermail/glasgow-haskell-users/2008-November/016032.html

I hope that helps!
Jason
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to