Skip to content

FunctorWithIndex.imap (or Eq) in version 0.6.2.1 is broken #730

@blackgnezdo

Description

@blackgnezdo

This test passes in GHC 8.6.4 and fails in 8.10.1 with lens-4.19.2:

import Control.Lens
import GHC.Exts (IsList(..))
import qualified Data.IntMap as IM

main :: IO ()
main = do
    let f i a = 5 + i * a
        g i a = a + 2 * i
        m = fromList [(-2,1),(0,-4)] :: IM.IntMap Int
        -- This is a FunctorWithIndex law.
        x = imap f (imap g m)
        y = imap (\i -> f i . g i) m
    print m
    print x
    print y
    print $ x == y

8.6 prints the expected:

fromList [(-2,1),(0,-4)]
fromList [(-2,11),(0,5)]
fromList [(-2,11),(0,5)]
True

8.10 prints:

fromList [(-2,1),(0,-4)]
fromList [(-2,11),(0,5)]
fromList [(0,5),(-2,11)]
False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions