Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow trailing comments #30

Closed
kazu-yamamoto opened this issue May 1, 2012 · 6 comments
Closed

Allow trailing comments #30

kazu-yamamoto opened this issue May 1, 2012 · 6 comments
Milestone

Comments

@kazu-yamamoto
Copy link
Collaborator

A given term is enclosed with "(" and ")" when it is passed to quickCheck.
This does not allow trailing comments. For instance,

prop> some is ==> valid (delete (head is) (fromList is)) -- delete root
prop> some is ==> valid $ delete (last is) (fromList is) -- delete leaf
prop> some is ==> valid $ delete x (fromList is) -- delete non-member

(where "some" ensures non-empty list and "valid" ensures a tree is well-formed)

Using $ instead of () solves this problem. But it breaks a literal with type notation. For instance

prop> True :: Bool

But is this important? I guess typical properties have binary operators which can be parsed even if there are type notations.

@sol
Copy link
Owner

sol commented May 1, 2012

@kazu-yamamoto I agree that True :: Bool is not important. But I'm not yet sure if we can exclude such cases in general.

Say we have a type class Foo.

class Foo where

instance Foo Int where

And a property p.

p :: Foo a => a -> Bool

Then the user might want to write.

prop> p :: Int -> Bool

Any thoughts?

@kazu-yamamoto
Copy link
Collaborator Author

If this is important, we can write:

prop> (p :: Int -> Bool)

I think that we should more flexible one to users. I guess that "$" is more flexible than "()" at this moment.
What do you think?

@sol
Copy link
Owner

sol commented May 2, 2012

The user would still need to know about this. How would you document it and make sure that the user actually reads it?

Saying something like "Trailing comments do not work!" is relatively clear.

An other approach would be to strip trailing comments; but we may run into other corner cases here. I'm really not sure what to do here.

@kazu-yamamoto
Copy link
Collaborator Author

Just for image:

With trailing comments:
http://mew.org/~kazu/tmp/Data-Set-Splay.html#v:delete

Without trailing comments:
http://mew.org/~kazu/tmp/Data-Set-Splay2.html#v:delete

Which do yo prefer?

BTW, I guess dropping trailing comments is possible but its implementation would be troublesome.

@sol
Copy link
Owner

sol commented May 2, 2012

Personally I prefer the second.

In the first, the comments look too much like being part of the property. I think trailing comments could be useful, but only if they get a different layout (e.g. normal font weight, italic, and gray text color). Something similar to this.

prop> xs == ys -- xs always equals ys

That would again require parsing.

I agree that striping trailing comments could be troublesome. The longer I think about it, the less I like it.

So what to do? I'd tend to just document that trailing comments are not supported. What do you think?

@kazu-yamamoto
Copy link
Collaborator Author

OK. Let's not allow trailing comments at this moment. We can get back this issue if users actually require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants