[Haskell-cafe] Language.Haskell.Parser question
Neil Mitchell
ndmitchell at gmail.com
Thu Mar 26 17:05:11 EDT 2009
> Excellent!
> The black magic had me scratching my head until I realized it was broken
> magic. :)
I should probably rerelease Uniplate so the documentation gets fixed,
but its not actually "broken" - although there is no way it does what
I intended!
vals x = [Val i | i <- universe x]
Given the type rules:
Val :: Int -> Expr
universe :: a -> [a]
And the knowledge that:
universe (i :: Int) = [i]
We can conclude that i :: Int and x :: Int. Therefore the function is
equivalent to:
vals :: Int -> [Expr]
vals i = [Val i]
Certainly not what I was going for, but it does work! You could even
argue it would be sensible to name such a function vals...
Thanks
Neil
>
> On Thu, Mar 26, 2009 at 4:23 PM, Neil Mitchell <ndmitchell at gmail.com> wrote:
>>
>> Hi John,
>>
>> > Actually, looking at the docs for UniplateStr[1], isn't there an error
>> > in
>> > the following example statement in the Queries section?
>> >
>> > vals x = [Val i | i <- universe x]
>> >
>> > Shouldn't that be:
>> > vals x = [i | Val i <- universe x]
>>
>> Yep, you are indeed right. I've fixed the examples in the darcs
>> version, and next time there is a release these changes will be
>> incorporated.
>>
>> Many thanks
>>
>> Neil
>
>
More information about the Haskell-Cafe
mailing list