-
Notifications
You must be signed in to change notification settings - Fork 29
Fix GNFData instance for V1 #19
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
Comments
I agree, but is there any reason you chose |
I thought I remembered some trouble getting the right error message, but I On Jul 17, 2016 9:29 AM, "Ryan Scott" [email protected] wrote:
|
Indeed, I was confused. The problem I remembered with newtype Void = Void Void where the error behavior of |
Why can't it just be |
Make `grnf` for `V1` a well-defined function that forces its (bottom) argument rather than making the function itself bottom. Fixes haskell#19
@rwbarton, it can be, but I don't think that's nearly as clear, since the |
Make `grnf` for `V1` a well-defined function that forces its (bottom) argument rather than making the function itself bottom. Fixes #19
@RyanGlScott @treeowl just double-checking, can you think of any (reasonable) program that could break or change its semantics due to this change when upgrading from deepseq-1.4.2 to the unreleased deepseq-1.4.3? |
As far as a change in semantics goes, it depends on whether you're using a very recent GHC or not. If you're using any GHC up to 8.2, then I don't think you'd notice much of a difference at all. The reason being is that the old instance Generic Empty where
from x = M1 $ case x of
_ -> error "No generic representation for empty datatype Empty"
... So you'll still get an exception, just with a different error message. In GHC 8.4/HEAD, however, instance Generic Empty where
from x = M1 $ case x of {}
... So in GHC 8.4, you can actually observe the difference between, say, {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Foo where
import Control.DeepSeq
import Control.Exception
import GHC.Generics
data Empty deriving Generic
instance NFData Empty
empty :: Empty
empty = let x = x in x
main :: IO ()
main = evaluate (rnf empty) `catch` \(_ :: SomeException) -> putStrLn "Caught error" With GHC 8.4 and |
Currently, we have
For old GHC, we should have
For newer GHC, we should have
The text was updated successfully, but these errors were encountered: