Ticket #168 (new defect)

Opened 4 years ago

Last modified 14 months ago

Hoogle backend attaches [incoherent] to instance documentation

Reported by: NeilMitchell Owned by:
Priority: major Milestone:
Version: Keywords:
Cc: ndmitchell@…

Description

Given the input file below, when running haddock --hoogle Haddock.hs I get the output below. There are 3 obvious bugs, all of which I think were introduced when rewriting various bits to move to using the GHC library (there was a bug number 3, which got fixed in Haddock 2.8).

I'm also tracking this bug at: http://code.google.com/p/ndmitchell/issues/detail?id=390

{-# LANGUAGE TypeOperators, IncoherentInstances #-}

module Haddock where


-- | BUG 1: bug1 will not have any documentation
class  BUG1 a  where
    -- | This documentation is dropped
    bug1 :: Integer -> a


data a :**: b = Bug2 -- ^ BUG 2: The :**: is prefix without brackets


-- | BUG 4: The instance below has [incoherent] on it
bug4 :: (); bug4 = ()
instance Num ()
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

@package main

module Haddock

-- | BUG 1: bug1 will not have any documentation
class BUG1 a
bug1 :: BUG1 a => Integer -> a
data (:**:) a b

-- | BUG 2: The :**: is prefix without brackets
Bug2 :: :**: a b

-- | BUG 4: The instance below has [incoherent] on it
bug4 :: ()
instance [incoherent] Num ()

Change History

Changed 4 years ago by NeilMitchell

  • cc ndmitchell@… added

Changed 4 years ago by NeilMitchell

An additional bug, if you look at the output from mtl you see:

newtype StateT s m :: (* -> *) a :: * -> (* -> *) -> * -> * StateT :: (s -> m (a, s)) -> StateT s a runStateT :: StateT s a -> s -> m (a, s)

Note the wrong kind signatures, and the missing m in the StateT types of the second two functions. This StateT is defined in transformers as:

newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }

Changed 2 years ago by anonymous

  • milestone 2.7.0 deleted

Milestone 2.7.0 deleted

Changed 14 months ago by Fūzetsu

  • version 2.8.1 deleted
  • summary changed from Errors in --hoogle output to Hoogle backend attaches [incoherent] to instance documentation

Bug 1 moved to ticket #259 for easier tracking. I'll be looking at it now.

Regards to bug 2: With input

{-# LANGUAGE TypeOperators #-}
module TypeOperators where

data a :**: b = Foo -- ^ The :**: is prefix without brackets

I get

-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

@package main

module TypeOperators
data (:**:) a b

-- | The :**: is prefix without brackets
Foo :: (:**:) a b

so that's fixed, was probably on GHC side of things. I'll add a regression test in a bit.

I'm changing this ticket to now deal with bug 4 then. Unfortunately I'm not even sure where to start on that one so I wouldn't hold my breath. If you can provide minimum input, expected output and reasoning for that output, that would help!

Changed 14 months ago by NeilMitchell

{-# LANGUAGE IncoherentInstances #-}
module Haddock where
instance Num ()

Produces:

@package main
module Haddock
instance [incoherent] Num ()

I expect the [incoherent] not to be there, since it isn't legal Haskell syntax. I suspect the IncoherentInstances pragma causes the instance to be annotated by GHC (fine), and then the pretty-printer for Hoogle uses the GHC pretty-printer which includes the annotation in the output (incorrect).

Note: See TracTickets for help on using tickets.