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

Avoid Data.List.{head,tail} #259

Merged
merged 3 commits into from
Nov 20, 2022
Merged

Avoid Data.List.{head,tail} #259

merged 3 commits into from
Nov 20, 2022

Conversation

Bodigrim
Copy link
Contributor

CLC has approved the proposal to add {-# WARNING #-} to Data.List.{head,tail} (haskell/core-libraries-committee#87). It means that usage of head and tail will emit compile-time warnings.

This patch eliminates the only usage of head in unix.

Copy link
Member

@hasufell hasufell left a comment

Choose a reason for hiding this comment

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

This changes behaviour though right? Passing in an empty dir wasn't possible before this patch?

@Bodigrim
Copy link
Contributor Author

@hasufell good point. I filed #260 to track the issue with mdir = Just "", but scaled back this PR to preserve the existing (partial) semantics, making the very minimal change just to avoid head and tail. How does it look now?

@hasufell
Copy link
Member

Sure, but why does head cause a warning and last doesn't?

@Bodigrim
Copy link
Contributor Author

The CLC proposal asked to add {-# WARNING #-} for head and tail only, but not for last and init. The rationale behind that was that it is considerably more difficult to migrate away from last and init: one cannot easily replace them with pattern matching and there is no unsnoc :: [a] -> Maybe ([a], a) available.

@hasufell
Copy link
Member

The CLC proposal asked to add {-# WARNING #-} for head and tail only, but not for last and init. The rationale behind that was that it is considerably more difficult to migrate away from last and init: one cannot easily replace them with pattern matching and there is no unsnoc :: [a] -> Maybe ([a], a) available.

I wouldn't mind if we inline unsnoc internally until it hits base.

https://hackage.haskell.org/package/extra-1.7.12/docs/src/Data.List.Extra.html#unsnoc

@Bodigrim
Copy link
Contributor Author

@hasufell good to go? I replaced last with our own unsnoc.

@Bodigrim Bodigrim merged commit d212fc3 into haskell:master Nov 20, 2022
@Bodigrim Bodigrim deleted the avoid-head-and-tail branch November 20, 2022 09:44
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

Successfully merging this pull request may close these issues.

2 participants