Opened 3 years ago

Closed 3 years ago

#10142 closed bug (fixed)

Documentation for Ix is contradictory around minimal definition

Reported by: goldfire Owned by: hvr
Priority: normal Milestone: 7.10.1
Component: Core Libraries Version: 7.8.4
Keywords: Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D709
Wiki Page:

Description

The Haddock documentation for Ix here says that the minimal definition requires range, index, and inRange. But then it says that the minimal definition requires range and inRange. It seems that Haddock is inferring a MINIMAL definition where none is in the code. Perhaps a MINIMAL should be added.

Change History (5)

comment:1 Changed 3 years ago by hvr

Owner: changed from ekmett to hvr

so while range and inRange have no default implementation, index has one that is recursive:

        -- Must specify one of index, unsafeIndex

        -- 'index' is typically over-ridden in instances, with essentially
        -- the same code, but using indexError instead of hopelessIndexError
        -- Reason: we have 'Show' at the instances
    {-# INLINE index #-}  -- See Note [Inlining index]
    index b i | inRange b i = unsafeIndex b i
              | otherwise   = hopelessIndexError

    unsafeIndex b i = index b i

So the minimal pragma should specify that we minimally need

range && inRange && (index || unsafeIndex)

I'll make a patch rightaway...

comment:2 Changed 3 years ago by hvr

Differential Rev(s): Phab:D709
Status: newpatch

comment:3 Changed 3 years ago by hvr

Milestone: 7.10.1

comment:4 Changed 3 years ago by Herbert Valerio Riedel <hvr@…>

In 7a2d65a4d93273c89fbb1d19e282d5933c67c7ca/ghc:

Define proper `MINIMAL` pragma for `class Ix`

Summary: This addresses #10142

Reviewers: goldfire, austin, ekmett

Reviewed By: austin, ekmett

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D709

GHC Trac Issues: #10142

comment:5 Changed 3 years ago by hvr

Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.