[Haskell-beginners] annoying precedence of unary negate
John M. Dlugosz
ngnr63q02 at sneakemail.com
Mon Apr 28 09:30:49 UTC 2014
On 4/27/2014 11:24 PM, Magnus Therning wrote:
> On Sun, Apr 27, 2014 at 10:59:27PM -0500, John M. Dlugosz wrote:
>>
>
> It most likely sees it as the binary minus rather than the unary minus.
>
That's what I thought.
Couldn't match expected type `Picture'
with actual type `Float -> Picture -> Picture'
In the expression: translate - 50 0 $ color green (Circle 50)
In the first argument of `Pictures', namely
`[Circle 100, translate - 50 0 $ color green (Circle 50),
scale 200 200 $ color red $ (Pictures $ take 20 chain1), testcirc]'
In the expression:
Pictures
[Circle 100, translate - 50 0 $ color green (Circle 50),
scale 200 200 $ color red $ (Pictures $ take 20 chain1), testcirc]
But what is the error message telling me?
Given that infix is done after adjacency application, it should parse as:
((translate - (50 0) ) $ (color (green (Circle 50))))
Left of the $, that is the parse tree
subtract+
|
+ translate
|
+ apply+
|
+ 50
|
+ 0
I think it would complain that 50 isn't a function, or the first argument of subtract is
not a Num but a function
translate :: Float -> Float -> Picture -> Picture,
or that the argument of translate isn't a Float but something it can't make sense of.
Why is it looking for a Picture? Where is it getting Float->Picture->Picture (seems to be
a curried translate? But the next token is not something it would like so how can it find
a first argument?)
Understanding the compiler's errors is a skill I want to learn, as well as shake out my
understanding of what's really going on.
Thanks,
—John
More information about the Beginners
mailing list