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

Why deepseq infix revert? #74

Closed
phadej opened this issue Nov 14, 2021 · 3 comments
Closed

Why deepseq infix revert? #74

phadej opened this issue Nov 14, 2021 · 3 comments

Comments

@phadej
Copy link
Contributor

phadej commented Nov 14, 2021

1.4.6.1

Revert infixr 0 deepseq; this is a breaking change and requires a major version bump

It has been discussed in #56, https://mail.haskell.org/pipermail/libraries/2020-April/030361.html

I also remember (but fail to find discussions) that this change is one where not adhering to SHOULD in PVP is justified. The major bump in deepseq version library would (especially now) make people angry for no reason, and the change doesn't break anything, as deepseq combinator cannot be meaningfully chained with its current infixl 9.

@mixphix
Copy link
Collaborator

mixphix commented Nov 14, 2021

If you think this is justifiably minor-release-worthy, I'll add it to 1.4.7.0 before it gets pinned to GHC here.

@phadej
Copy link
Contributor Author

phadej commented Nov 14, 2021

Christiaan's example is very convincing. I find hard time coming up with an example where changing fixity would break things.

OTOH, doing a search on Hackage shows that there are many packages
which define NFData instances like:

yarr

instance Shape sh => NFData (UArray CV CVL sh a) where
    rnf (Convoluted sh tch iforce bget center cget) =
        sh `deepseq` tch `seq` iforce `seq`
            bget `seq` center `deepseq` cget `seq` ()
    {-# INLINE rnf #-}

or windns

instance NFData DnsRecord where
  rnf (DnsRecord n y t d) = n `deepseq` y `deepseq` t `deepseq` d `deepseq` ()

or vty

instance NFData Image where
  rnf EmptyImage = ()
  rnf (CropRight i w h) = i `deepseq` w `seq` h `seq` ()
  rnf (CropLeft i s w h) = i `deepseq` s `seq` w `seq` h `seq` ()
  rnf (CropBottom i w h) = i `deepseq` w `seq` h `seq` ()

or haddock

rnf doc = case doc of
  DocEmpty                  -> ()
  DocAppend a b             -> a `deepseq` b `deepseq` ()

None of these would break, but I'd argue instead work as a reader
would think of, forcing things left-to-right.

The yarr example is interesting as it's currently

    rnf (Convoluted sh tch iforce bget center cget) =
        (sh `deepseq` tch) `seq` iforce `seq`
            bget `seq` (center `deepseq` cget) `seq` ()

which works, but i'm sure not what the author intended.


There are also few occurences which look like:

x `deepseq` f x $ y

or

x `deepseq` f x $! y

which will still work as $ and $! are infixr 0 themselves.

@mixphix
Copy link
Collaborator

mixphix commented Nov 14, 2021

Added in v1.4.7.0.

@mixphix mixphix closed this as completed Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants