Closed Temurson closed 4 years ago
I have tried adding infixl 6 +.
, infixl 6 -.
and infixl 7 *.
to Color.hs, and this resolved this strange behavior. Note that these precedence values match those of regular operators. Let me know if this is something that should be resolved, and I will create a PR.
That's a good find. I agree that it would be good in principle to specify these precedences in a way that makes your example expression typecheck. But this is a big change since other projects might already depend on a different precedence.
It would be great to take a large open source project that uses Clay, and see if it still typechecks with the precedences changed. Do you have an idea?
Well, I haven't even used Clay myself, and I'm quite new to Haskell, so I don't know. I will try to do some research on that. If you know any projects, let me know, I would gladly check it.
I'm not a big Clay user myself yet ;) I've just written 5 lines of it so far on my website. A good starting point is this: http://packdeps.haskellers.com/reverse/clay But I can't find any that use the color operators. If you can't find any projects using the operators prominently either, it's safe to break/change. So feel free to create a PR in that case :)
I believe you solved this already in #195, right?
@turion No, I didn't. I'm still not sure if I should make this change. I tried finding projects that use Clay, but the website you gave seems to only have those from Hackage, which are mostly libraries, while any web project could possibly use Clay, and I'm not sure if there is a way to find out.
Oh, but you uploaded a commit doing this to https://github.com/sebastiaanvisser/clay/pull/195/commits, and I merged it.
I think it is fine to have this change, it just triggers a version bump. Possibly a few projects will break, but the will appear in the changelogs.
If you agree, we can close this issue for now.
I'm so sorry! I thought I removed this change before commiting. I do agree that this change should stay now, because I, just as you, could not find any projects using this specific behavior of color operators. Thanks!
No worries :) I'll close then.
I found probably unexpected behavior of operators
+.
,-.
,*.
in Color.hs module. Example with steps to reproduce (starting at the project root):Note that when doing
:info +.
in ghci, it does not show precedence, and if you check the definition, there is no precedence there too. I suspect the problem here is that+.
,-.
and*.
(the only three defined in Color.hs) have precedence higher than*
, which doesn't really make sense. I do not know what is default operator precedence in Haskell, and I always thought that it is required to specify precedence when declaring custom operators, but I could not find it within the entire Clay code. I think this should be fixed by explicitly specifying operator precedence of+.
,-.
and*.
in Color.hs.