Comments (2)
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.
from generic-lens.
Related Issues (20)
- Add criterion benchmarks
- A 'field'-like traversal? HOT 2
- Unclear type error when `HasType` constraint is missing
- HasField' and nested labels don't play along well HOT 2
- Revert #120 HOT 3
- Issues with large tuples HOT 3
- Build failure with GHC 9.0 HOT 7
- generic-optics-2.0.0.0 testsuite failing in Stackage Nightly HOT 1
- Recursing with typed as well as types HOT 3
- A different approach to fields HOT 4
- Make Param representationally polymorphic
- generic-lens-core fails to build on GHC 9.2 HOT 5
- generic-lens allows modification of private data structures HOT 10
- Compatibility with text 2.0
- Generic Product Field Traversals HOT 4
- Reflexive instances for AsType? HOT 5
- Const and Identity instances for `HasAny` HOT 1
- Should _Ctor return an Iso for single constructor types?
- Make use of unrestricted `OverloadedLabels` HOT 1
- Typechanging `param` fails (with poor error message) when some subtype ignores the parameter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generic-lens.