#13206 closed bug (fixed)

Error in GHC.Generics documentation

Reported by: dsf Owned by:
Priority: normal Milestone: 8.2.1
Component: libraries/base Version: 8.0.1
Keywords: Generics Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The Generic instance shown as automatically derived for the Tree type should read

instance Generic (Tree a) where
    type Rep (Tree a) =
        D1 ('MetaData "Tree" "Main" "package-name" 'False)
           (C1 ('MetaCons "Leaf" 'PrefixI 'False)
            (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 a)) :+:
            C1 ('MetaCons "Leaf" 'PrefixI 'False)
            (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 (Tree a)) :*:
             S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 (Tree a)))))
    from (Leaf f) = M1 (L1 (M1 (M1 (K1 f))))
    from (Node f g) = M1 (R1 (M1 ((M1 (K1 f)) :*: (M1 (K1 g)))))
    to (M1 (L1 (M1 (M1 (K1 f))))) = Leaf f
    to (M1 (R1 (M1 ((M1 (K1 f)) :*: (M1 (K1 g)))))) = Node f g

Change History (7)

comment:1 Changed 21 months ago by dsf

I mean

instance Generic (Tree a) where
    type Rep (Tree a) =
        D1 ('MetaData "Tree" "Main" "package-name" 'False)
           (C1 ('MetaCons "Leaf" 'PrefixI 'False)
            (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 a)) :+:
            C1 ('MetaCons "Leaf" 'PrefixI 'False)
            (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 (Tree a)) :*:
             S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
             (Rec0 (Tree a))))
    from (Leaf f) = M1 (L1 (M1 (M1 (K1 f))))
    from (Node f g) = M1 (R1 (M1 ((M1 (K1 f)) :*: (M1 (K1 g)))))
    to (M1 (L1 (M1 (M1 (K1 f))))) = Leaf f
    to (M1 (R1 (M1 ((M1 (K1 f)) :*: (M1 (K1 g)))))) = Node f g

comment:2 Changed 21 months ago by RyanGlScott

Keywords: Generics added

Forgive me for being slow, but which specific lines in the current GHC.Generics source code are wrong? And what in particular do you wish to change? It's hard to discern from all the autogenerated noise.

comment:3 Changed 21 months ago by dsf

If you go to https://hackage.haskell.org/package/base-4.9.1.0/docs/GHC-Generics.html it is the second block of code. It is near the top of http://git.haskell.org/ghc.git/blob_plain/HEAD:/libraries/base/GHC/Generics.hs. I'm only talking about the comments.

Last edited 21 months ago by dsf (previous) (diff)

comment:4 Changed 21 months ago by RyanGlScott

dsf, I presume you're referring to this? http://git.haskell.org/ghc.git/blob/4441f90738e27ea7ba368723f27d19c03093aa66:/libraries/base/GHC/Generics.hs#l75

Granted, my eyes aren't as sharp as they used to be, but from a glance, that Rep (Tree a) instance appears to be the same as yours. So can you point to the specific part that you claim is incorrect?

Last edited 21 months ago by RyanGlScott (previous) (diff)

comment:5 Changed 21 months ago by dsf

It turns out its just this:

--- old	2017-01-29 21:28:30.598988361 -0800
+++ new	2017-01-29 21:28:46.650987621 -0800
@@ -2,7 +2,7 @@
     type Rep (Tree a) =
         D1 ('MetaData "Tree" "Main" "package-name" 'False)
            (C1 ('MetaCons "Leaf" 'PrefixI 'False)
-            (S1 '(MetaSel 'Nothing
+            (S1 ('MetaSel 'Nothing
                           'NoSourceUnpackedness
                           'NoSourceStrictness
                           'DecidedLazy)

comment:6 Changed 21 months ago by Ryan Scott <ryan.gl.scott@…>

In f60287c4/ghc:

Fix mismatched tick in GHC.Generics documentation

[ci skip]

A Generic derivation example in the documentation of GHC.Generics put a tick
(used for datatype promotion) in the wrong place.

Fixes #13206.

comment:7 Changed 21 months ago by RyanGlScott

Milestone: 8.2.1
Resolution: fixed
Status: newclosed

Ah, sharp eye! Thanks for the catch, I've since applied your fix in HEAD.

Note: See TracTickets for help on using tickets.