-
Notifications
You must be signed in to change notification settings - Fork 116
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
Deprecate auto
?
#304
Comments
I'm not super opposed to doing this. You're right,
|
I think the other big usage would be times and dates, UTCTime et al. Not many other common types that do pretty-printing via Read. maybeReader of parseTimeM is the right thing to do there, might even be a good canned example for the Haddock...
If you feel like proceeding, would suggest adding a new Read-based function and adding a comprehensive deprecation message so users have to opt in to the sketchy functionality, GDPR-style.
I have been bitten by this enough times that I’ll gladly do the work 😅 let me know how ya feel
… On May 31, 2018, at 5:11 PM, Huw Campbell ***@***.***> wrote:
I'm not super opposed to doing this.
You're right, Read is terrible (and actually doesn't work very well on the command line for most things, due to quoting, Haskell's capitalisation of constructors, and shell expansion primitives). But I do need to balance ease of use and backwards compatibility as well.
integral and fractional would probably cover most use cases where auto currently works cleanly. Are there actually any more?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@thumphries pointed out that one can write a monomorphic reader in the meantime, e.g. import Options.Applicative (ReadM, maybeReader)
import Safe (readMay)
int :: ReadM Int
int = maybeReader readMaybe |
A compromise here might be for the docs to just encourage people to always use an explicit type application with |
Haven't really thought this through for more than a minute, but wondering if there's any interest in eventually deprecating
auto
in favour of more concrete readers.It's been a reliable source of bugs for me / teams I've worked on, since someone inevitably ends up using
auto
for a string type or a newtyped string/integral. These tend to appear both when writing initial parsers and when changing code a module or two away, in the same wayshow
tends to create subtle non-local bugs when refactoring.Would involve adding
integralOption
/fractionalOption
for the cases where you might actually wantRead
, then deprecatingauto
. Users who want to keep using custom parsers can usemaybeReader
/eitherReader
so their intent is made clear in the code.The text was updated successfully, but these errors were encountered: