Replies: 7 comments
-
I figured out how to define lenses manually as a workaround:
|
Beta Was this translation helpful? Give feedback.
-
I have also seen this here which uses GHC 9.2: #650 @gelisam helpfully directed me to look more closely at the The snippets rely on it: beam/docs/tutorials/tutorial2.md Lines 237 to 240 in 9446193 This says |
Beta Was this translation helpful? Give feedback.
-
I hit the same issue at 9.2.7. Writing the type signature by hand still (with |
Beta Was this translation helpful? Give feedback.
-
@berberman and @yaitskov Have you tried Module Foo where
import Database.Beam
import Lens.Micro
data FooT f = Foo { _fooInt :: C f Int } deriving (Generic, Beamable)
type Foo = FooT Identity
fooName :: Lens Foo Foo Int Int
Foo (LensFor fooName) = tableLenses |
Beta Was this translation helpful? Give feedback.
-
@arguri, it only works for data with 1 field (i.e. newtype)
|
Beta Was this translation helpful? Give feedback.
-
For more fields you would need to add Signatures for each field and ignore the other fields, e.g. module Foo where
import Database.Beam
import Lens.Micro
data Foo { fooName :: C f Int, fooId :: C f String } deriving (Generic, Beamable)
fooName :: Lens Foo Foo Int Int
fooId :: Lens Foo Foo String String
Foo (LensFor fooName) _ = tableLenses
Foo _ (LensFor fooId) = tableLenses At least that worked for me. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I see - every lens binding should have dedicated expression and they cannot be batched in one data constructor. |
Beta Was this translation helpful? Give feedback.
-
After upgrading GHC version from 8.10.7 to 9.2.4 following snippets fails:
Beta Was this translation helpful? Give feedback.
All reactions