extra icon indicating copy to clipboard operation
extra copied to clipboard

Use `#if MIN_VERSION_base` rather than `#if GLASGOW_HASKELL`

Open andreasabel opened this issue 6 months ago • 0 comments

When reading Data.List.NonEmpty.Extra, I noticed conditionals (#if) querying the GHC version to avoid clashes with new functions introduced into base. https://github.com/ndmitchell/extra/blob/c9ac297911f15c68616ab2ea04bd2a5ff003227f/src/Data/List/NonEmpty/Extra.hs#L142 These conditionals should really query the version of base instead. There is a comprehensive translation table at https://www.snoyman.com/base/ .

Also, maybe more importantly, the current pattern of conditionals will lead to different APIs exported by Data.List.NonEmpty.Extra depending on which version of GHC it was compiled with. This is suboptimal, to say the least. The exported API should be stable across GHC (and base) versions. So functions that entered base later should simply be reexported, not dropped from the API.

The current logic is like a virus: users in multi-GHC settings have to replicate analogous conditionals if they want to import such only conditionally present functions.

andreasabel avatar Jul 01 '25 06:07 andreasabel