Skip to content

Commit

Permalink
Use wherefrom-compat
Browse files Browse the repository at this point in the history
This provides a compatibility shim around the wherefrom function allowing a stable interface to be used for more versions of GHC.

In particular it should insulate users of the library from future breaking changes
  • Loading branch information
TeofilC committed Feb 1, 2024
1 parent 4ef360e commit 13b20ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions nothunks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ flag vector
default: True
manual: True

flag wherefrom
description: Access IPE information using wherefrom-compat
default: True
manual: False

library
exposed-modules: NoThunks.Class

Expand All @@ -54,6 +59,8 @@ library
build-depends: text >= 1.2 && < 1.3 || >= 2 && < 2.2
if flag(vector)
build-depends: vector >= 0.12 && < 0.14
if flag(wherefrom)
build-depends: wherefrom-compat >= 0.1.1.0 && < 0.2.0.0

hs-source-dirs: src
default-language: Haskell2010
Expand Down
6 changes: 3 additions & 3 deletions src/NoThunks/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ import GHC.Stack
import Numeric.Natural
#endif

#if MIN_VERSION_base(4,18,0)
import GHC.InfoProv
#if MIN_VERSION_base(4,16,0)
import GHC.InfoProv.Compat
#endif

import qualified Control.Concurrent.MVar as MVar
Expand Down Expand Up @@ -231,7 +231,7 @@ newtype ThunkInfo = ThunkInfo { thunkInfo :: Either Context Info }
deriving Show

getThunkInfo :: Context -> a -> IO ThunkInfo
#if MIN_VERSION_base(4,18,0)
#if MIN_VERSION_base(4,16,0)
getThunkInfo ctxt a = ThunkInfo . maybe (Left ctxt) (Right . fmt) <$> whereFrom a
where
fmt :: InfoProv -> Info
Expand Down

0 comments on commit 13b20ab

Please sign in to comment.