-
Notifications
You must be signed in to change notification settings - Fork 242
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
Redundant uses of with
#1937
Comments
I think there was an era of doing Agda development where some people were over-enthusiastic users of My opinion:
For the specimen you give, I prefer the |
I don't know whether it's an actual problem but it could be why people reached for |
I wonder if the recent features (not yet merged) to do more controlled abstraction and unfolding might be a more disciplined way to achieve this. That people may have done hacks with |
Re: recent features. I notice that |
You'd definitely have to ask that on the agda board or the Zulip, the agda devs don't monitor stdlib chat all that closely. |
Yes, and at the Delft AIM (I hope) |
See also my solution to @omelkonian 's agda issue 5833. |
Besides the merged PR, I think this is best kept open, but maybe handled piecemeal going forward? |
Removing this form the specific v2.1 milestone in favour of keeping it open as a recurrent issue (at least until such time as we deem it is 'closed') |
I have recently undertaken a study of all the uses of
with
instdlib
(there are 650-700 of them, for the sake of a ballpark figure), and discovered some surprising things as a result. Two things (at least) leap out:with
on boolean subexpressions, in place ofif_then_else_
(there are over 100 of these alone, sometimes but not always in the context of more complex pattern-matching analysis);with
to introduce a name for a recursive call on a function, not subsequently analysed by pattern matching.The purpose of this issue is to draw attention to such uses, and ask whether they should be replaced/refactored away in favour of 'simpler' definitions. The first seems now to be 'idiomatic' Agda: I'm certainly not arguing per se for uses of
if_then_else_
, but it is striking that we (seem to) have adopted a style self-consciously not like 'ordinary' functional programming, even when that is available.A specimen example of the second case is given the following, in
Data.List.Properties
:whose final defining clause could, much more straightforwardly, be replaced by
splitAt-defn (suc n) (x ∷ xs) = cong (Prod.map (x ∷_) id) (splitAt-defn n xs)
The text was updated successfully, but these errors were encountered: