Commits

Maxime Henrion committed 99f82b4

Add a comment explaining why it's important to pattern match on the U1
constructor of the U1 instance.

Comments (0)

Files changed (1)

src/Control/DeepSeq.hs

   grnf :: f a -> ()
 
 instance GDeepSeq U1 where
+  -- It is important to pattern match on the U1 constructor here. If we didn't
+  -- and used an underscore pattern, the following equality wouldn't hold:
+  --   x `deepseq` () = x `seq` () = _|_
+  --     where x = undefined :: T
+  -- with T being () or any unit-shaped type with a DeepSeq instance.
   grnf U1 = ()
 
 instance DeepSeq a => GDeepSeq (K1 i a) where