haskell / deepseq

Deep evaluation of data structures
http://hackage.haskell.org/package/deepseq
Other
40 stars 29 forks source link

Why deepseq infix revert? #74

Closed phadej closed 2 years ago

phadej commented 2 years ago

1.4.6.1

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

It has been discussed in https://github.com/haskell/deepseq/pull/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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Added in v1.4.7.0.