-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Param traversal fails for nested lists (also nested Maybes etc) #88
Comments
I've seen a version of this. In this case it fails to compile with generic-lens 1.1.0.0 on ghc 8.6.3 {-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE TypeApplications #-}
module GenericLensMinimalExample where
import GHC.Generics (Generic)
import Data.Generics.Product (param, Rec(..))
import Control.Lens (over)
data Foo a = Foo a deriving (Eq, Show, Generic)
data Bar b = Bar b deriving (Eq, Show, Generic)
data FooBar c = FooBar (Foo (Bar c)) deriving (Eq, Show, Generic)
foo :: FooBar Int -> FooBar String
foo = over (param @0) show
GenericLensMinimalExample.hs:19:13: error:
• Couldn't match type ‘Int’ with ‘[Char]’
arising from a functional dependency between:
constraint ‘Data.Generics.Product.Param.GHasParamRec
'Nothing (Foo (Bar Int)) (Foo (Bar [Char])) Int [Char]’
arising from a use of ‘param’
instance ‘Data.Generics.Product.Param.GHasParamRec
'Nothing a a c d’
at <no location info>
• In the first argument of ‘over’, namely ‘(param @0)’
In the expression: over (param @0) show
In an equation for ‘foo’: foo = over (param @0) show |
kcsongor
added a commit
that referenced
this issue
Jan 26, 2020
This is achieved by reusing HasTypes (as described in the paper)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just stumbled upon what looks like inconsistent behavior of auto derived traversal and generic-lens while employing nested lists (deep traversal?). Minimal example below (tested with generic-lens 1.1.0.0 and ghc 8.2.2):
We expect the results to be MT [[2]] in both cases, but generic-lens outputs MT [[1]].
The text was updated successfully, but these errors were encountered: