Git Product home page Git Product logo

Comments (2)

phadej avatar phadej commented on June 2, 2024

The issue is reproducible only with GHC-8.0 and GHC-8.2


With

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
import Prelude
import GHC.Generics
import Control.Lens
import Data.Generics.Product

data Foo = Foo { name :: String } deriving (Show, Generic)

test1 :: Foo -> String
test1 foo = foo ^. field @"name"

test2 :: Foo -> Int
test2 bar = bar ^. field @"name"

GHC-8.4.4

[1 of 1] Compiling Main             ( lleak.hs, interpreted )

lleak.hs:15:20: error:
    • Couldn't match type ‘[Char]’ with ‘Int’
        arising from a use of ‘field’
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: bar ^. field @"name"
      In an equation for ‘test2’: test2 bar = bar ^. field @"name"
   |
15 | test2 bar = bar ^. field @"name"
   |                    ^^^^^^^^^^^^^

GHC-8.0.2

[1 of 1] Compiling Main             ( lleak.hs, interpreted )

lleak.hs:12:20: error:
    • Couldn't match type ‘Int’ with ‘[Char]’
        arising from a functional dependency between constraints:
          ‘generic-lens-1.1.0.0:Data.Generics.Product.Internal.GLens.GLens
             (Data.Generics.Product.Fields.HasTotalFieldPSym "name")
             (K1 R String)
             (K1 R String)
             [Char]
             [Char]’
            arising from a use of ‘field’ at lleak.hs:12:20-32
          ‘generic-lens-1.1.0.0:Data.Generics.Product.Internal.GLens.GLens
             (Data.Generics.Product.Fields.HasTotalFieldPSym "name")
             (K1 R String)
             (K1 R String)
             Int
             Int’
            arising from a use of ‘field’ at lleak.hs:15:20-32
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: foo ^. field @"name"
      In an equation for ‘test1’: test1 foo = foo ^. field @"name"

lleak.hs:15:20: error:
    • Couldn't match type ‘[Char]’ with ‘Int’
        arising from a use of ‘field’
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: bar ^. field @"name"
      In an equation for ‘test2’: test2 bar = bar ^. field @"name"
Failed, modules loaded: none.

GHC-8.2.2

[1 of 1] Compiling Main             ( lleak.hs, interpreted )

lleak.hs:12:20: error:
    • Couldn't match type ‘Int’ with ‘[Char]’
        arising from a functional dependency between constraints:
          ‘generic-lens-1.1.0.0:Data.Generics.Product.Internal.GLens.GLens
             (Data.Generics.Product.Fields.HasTotalFieldPSym "name")
             (K1 R String)
             (K1 R String)
             [Char]
             [Char]’
            arising from a use of ‘field’ at lleak.hs:12:20-32
          ‘generic-lens-1.1.0.0:Data.Generics.Product.Internal.GLens.GLens
             (Data.Generics.Product.Fields.HasTotalFieldPSym "name")
             (K1 R String)
             (K1 R String)
             Int
             Int’
            arising from a use of ‘field’ at lleak.hs:15:20-32
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: foo ^. field @"name"
      In an equation for ‘test1’: test1 foo = foo ^. field @"name"
   |
12 | test1 foo = foo ^. field @"name"
   |                    ^^^^^^^^^^^^^

lleak.hs:15:20: error:
    • Couldn't match type ‘[Char]’ with ‘Int’
        arising from a use of ‘field’
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: bar ^. field @"name"
      In an equation for ‘test2’: test2 bar = bar ^. field @"name"
   |
15 | test2 bar = bar ^. field @"name"
   |                    ^^^^^^^^^^^^^
Failed, no modules loaded.

GHC-8.6.2

[1 of 1] Compiling Main             ( lleak.hs, interpreted )

lleak.hs:15:20: error:
    • Couldn't match type ‘[Char]’ with ‘Int’
        arising from a use of ‘field’
    • In the second argument of ‘(^.)’, namely ‘field @"name"’
      In the expression: bar ^. field @"name"
      In an equation for ‘test2’: test2 bar = bar ^. field @"name"
   |
15 | test2 bar = bar ^. field @"name"
   |                    ^^^^^^^^^^^^^
Failed, no modules loaded.

from generic-lens.

oliver-batchelor avatar oliver-batchelor commented on June 2, 2024

from generic-lens.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.