Skip to content
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

NoThunks instance for Solo #45

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## next version

* `NoThunks` instance for `Data.Tuple.Solo`.
* `NoThunks` instances for `Data.Semigroup` and `Data.Monoid` newtype wrappers.

## 0.1.5 -- 2023-10-29
Expand Down
17 changes: 17 additions & 0 deletions src/NoThunks/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
import Data.Sequence (Seq)
import Data.Set (Set)
import Data.Time
#if MIN_VERSION_base(4,16,0)
import Data.Tuple (Solo (..))
#endif
import Data.Void (Void)
import Data.Word
import GHC.Stack
Expand Down Expand Up @@ -506,6 +509,20 @@
deriving via (f a) instance NoThunks (f a) => NoThunks (Monoid.Alt f a)
deriving via (f a) instance NoThunks (f a) => NoThunks (Monoid.Ap f a)

{-------------------------------------------------------------------------------
Solo
-------------------------------------------------------------------------------}

#if MIN_VERSION_base(4,16,0)
-- GHC-9.2
instance NoThunks a => NoThunks (Solo a) where
wNoThunks ctx (Solo a) = wNoThunks ("Solo" : ctx) a

Check warning on line 519 in src/NoThunks/Class.hs

View workflow job for this annotation

GitHub Actions / build (9.6)

In the use of data constructor ‘Solo’

Check warning on line 519 in src/NoThunks/Class.hs

View workflow job for this annotation

GitHub Actions / build (9.6)

In the use of data constructor ‘Solo’

Check warning on line 519 in src/NoThunks/Class.hs

View workflow job for this annotation

GitHub Actions / build (9.8)

In the use of data constructor ‘Solo’

Check warning on line 519 in src/NoThunks/Class.hs

View workflow job for this annotation

GitHub Actions / build (9.8)

In the use of data constructor ‘Solo’
#elif MIN_VERSION_base(4,17,0)
-- GHC-9.4 and newer
instance NoThunks a => NoThunks (Solo a) where
wNoThunks ctx (MkSolo a) = wNoThunks ("Solo" : ctx) a
#endif
Comment on lines +516 to +524

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be the other way around (first the MIN_VERSION_base(4,17,0) case, then the MIN_VERSION_base(4,16,0) case). Currently, the first case is also picked for GHC 9.4 and newer.


{-------------------------------------------------------------------------------
Mutable Vars
-------------------------------------------------------------------------------}
Expand Down
Loading