on master help sign in
Fix
commit396171648012314038a0acddbcadf5299b506fbe authorparsonsmatt <parsonsmatt@gmail.com> dateTue 20 Nov 2018, 12:27 (8 years ago) parent829952f
2 files changed+21
src/Data/Generics/Product/Typed.hs+4 test/Test71.hs+17
src/Data/Generics/Product/Typed.hs+4
@@ -116,6 +116,10 @@ instance
116116
117117 typed f s = VL.ravel (repLens . glens @(HasTotalTypePSym a)) f s
118118
119+instance {-# OVERLAPPING #-} HasType a a where
120+ typed = id
121+ {-# INLINE typed #-}
122+
119123-- See Note [Uncluttering type signatures]
120124instance {-# OVERLAPPING #-} HasType a Void where
121125 typed = undefined
test/Test71.hsnew file+17
@@ -0,0 +1,17 @@
1+{-# LANGUAGE FlexibleContexts, DeriveGeneric, TypeApplications #-}
2+
3+module Test71 where
4+
5+import GHC.Generics
6+import Control.Lens
7+import Data.Generics.Product
8+
9+data Foobar = Foobar Int Char String
10+ deriving Generic
11+
12+foo :: HasType Foobar ctx => ctx -> Char
13+foo ctx = case view (typed @Foobar) ctx of
14+ Foobar _ c _ -> c
15+
16+bar :: Char
17+bar = foo (Foobar 3 'a' "Hello")