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

Rules for takeWhile and dropWhile #275

Merged
merged 4 commits into from
Sep 4, 2020

Conversation

Bodigrim
Copy link
Contributor

Closes #176.

Copy link
Member

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

While reviewing this, I was looking for example incantations of break[Byte] and span[Byte], but couldn't find any in the documentation. Does this sound worth fixing/tracking?

@Bodigrim
Copy link
Contributor Author

@sjakobi do you mean bytestring documentation?

{-# RULES
"ByteString specialise break (x ==)" forall x.
break (x `eqWord8`) = breakByte x
"ByteString specialise break (== x)" forall x.
break (`eqWord8` x) = breakByte x
#-}

{-# RULES
"ByteString specialise span (x ==)" forall x.
span (x `eqWord8`) = spanByte x
"ByteString specialise span (== x)" forall x.
span (`eqWord8` x) = spanByte x
#-}

@sjakobi
Copy link
Member

sjakobi commented Aug 29, 2020

@sjakobi do you mean bytestring documentation?

Yeah. I realized too late that I could simply look at base's documentation of break and span for [].

@Bodigrim
Copy link
Contributor Author

OK, I decided to grab an opportunity to improve documentation for this functions as well.

Copy link
Contributor

@vdukhovni vdukhovni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits in the docs

Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString/Lazy.hs Outdated Show resolved Hide resolved
Data/ByteString/Lazy.hs Outdated Show resolved Hide resolved
Data/ByteString/Lazy.hs Outdated Show resolved Hide resolved
Data/ByteString/Lazy.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Outdated Show resolved Hide resolved
@Bodigrim
Copy link
Contributor Author

@vdukhovni sorry, I'm not a native speaker, but what is wrong with "a {part/suffix/prefix} of xs, elements of which bla-bla-bla"?

@vdukhovni
Copy link
Contributor

@vdukhovni sorry, I'm not a native speaker, but what is wrong with "a {part/suffix/prefix} of xs, elements of which bla-bla-bla"?

As an inserted clause, "elements of which satisfy ...", to me sounds closer to the kind of language one might find in legal contracts, than in day-to-day English... It might be best in the positive case to write:

a {part/suffix/prefix} of xs, whose elements all bla-bla-bla,

and in the negative case

a {part/suffix/prefix} of xs, none of whose elements bla-bla-bla

With the only possibly confusing case being with "break" which returns both parts, and so then adds ", and the rest ...", with some confusion about what the "and ..." is associated with.

That's part of the reason I wanted to eliminated the inserted clause and go with " a ... of xs all/none of whose elements ..., and the rest ...".

What do you think?

@Bodigrim
Copy link
Contributor Author

@vdukhovni how is it looking now?

@vdukhovni
Copy link
Contributor

@vdukhovni how is it looking now?

Better. Thanks.

@Bodigrim Bodigrim added this to the 0.11.0.0 milestone Sep 4, 2020
@Bodigrim Bodigrim merged commit a0714e6 into haskell:master Sep 4, 2020
@Bodigrim Bodigrim deleted the takewhile-dropwhile-rules branch September 4, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We have no rules for takeWhile and dropWhile, unlike the ones for span and break.
3 participants