ndmitchell / extra

Extra Haskell functions
Other
94 stars 37 forks source link

fix ghc-9.7 compilation errors #106

Closed shayne-fletcher closed 1 year ago

shayne-fletcher commented 1 year ago

i happened to try building with ghc built from head today (ghc.9.7.20230617) and found it failed with some ambiguities. this seems to fix it. tested with cabal new-build all

ndmitchell commented 1 year ago

Thanks for the PR! I applied some of this in 5447cd1c48226789c79844c97226bf9bc2b55d42 and an alternative to other parts in 173409ff83ca6c0098e313143f58c2edb88fc755. Does that all work for you now?

shayne-fletcher commented 1 year ago

nearly. the unsnoc problem remains.

extra               > /private/var/folders/rj/q93vlym52875_k7nwz_c3wth0000gn/T/stack-19d020feeadbf370/extra-1.7.13/src/Data/List/Extra.hs:202:24: error: [GHC-87543]
extra               >     Ambiguous occurrence ‘unsnoc’.
extra               >     It could refer to
extra               >        either ‘Data.List.unsnoc’,
extra               >               imported from ‘Data.List’ at src/Data/List/Extra.hs:41:1-16
extra               >               (and originally defined in ‘GHC.List’),
extra               >            or ‘Data.List.Extra.unsnoc’,
extra               >               defined at src/Data/List/Extra.hs:199:1.
extra               >     |        
extra               > 202 |     where Just (a,b) = unsnoc xs
extra               >     |                        ^^^^^^
ndmitchell commented 1 year ago

Oops. Put the conditions in backwards. Can you try again?

shayne-fletcher commented 1 year ago

looks good, builds now. there are warnings. confirmed that adding {-# OPTIONS_GHC -Wno-duplicate-exports -Wno-x-partial #-} to the top of 'Data.List.Extra.hs' suppresses them.

src/Data/List/Extra.hs:21:23: warning: [GHC-47854] [-Wduplicate-exports]
    ‘!?’ is exported by ‘(!?)’ and ‘module Data.List’
   |
21 |     headDef, lastDef, (!?), notNull, list, unsnoc, cons, snoc,
   |                       ^^^^

src/Data/List/Extra.hs:21:44: warning: [GHC-47854] [-Wduplicate-exports]
    ‘unsnoc’ is exported by ‘unsnoc’ and ‘module Data.List’
   |
21 |     headDef, lastDef, (!?), notNull, list, unsnoc, cons, snoc,
   |                                            ^^^^^^

src/Data/List/Extra.hs:498:31: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Prelude, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
    |
498 | groupSort = map (\x -> (fst $ head x, map snd x)) . groupOn fst . sortOn fst
    |                               ^^^^
shayne-fletcher commented 1 year ago

fixed by a stack starting at 5447cd1c48226789c79844c97226bf9bc2b55d42

ndmitchell commented 1 year ago

Thanks! Just releasing a new extra now