@@ -10,6 +10,7 @@
1010{-# LANGUAGE ScopedTypeVariables #-}
1111{-# LANGUAGE TypeApplications #-}
1212{-# LANGUAGE TemplateHaskell #-}
13+{-# LANGUAGE OverloadedLabels #-}
1314
1415module Main where
1516
@@ -23,6 +24,9 @@ import System.Exit
2324import Data.Generics.Internal.VL.Lens
2425import Data.Generics.Internal.VL.Prism
2526import Data.Generics.Internal.VL.Traversal
27+import Control.Lens (_1, (+~))
28+import Data.Function ((&))
29+import Data.Generics.Labels ()
2630
2731-- This is sufficient at we only want to test that they typecheck
2832import Test24 ()
@@ -223,6 +227,12 @@ sum2TypePrism = _Typed @Int
223227sum2TypePrismChar :: Prism Sum2 Sum2 Char Char
224228sum2TypePrismChar = _Typed @Char
225229
230+data SumOfProducts =
231+ RecA { foo :: Int, valA :: String }
232+ | RecB { foo :: Int, valB :: Bool }
233+ | RecC { foo :: Int }
234+ deriving (Show, Eq, Generic)
235+
226236tests :: Test
227237tests = TestList $ map mkHUnitTest
228238 [ $(inspectTest $ 'fieldALensManual === 'fieldALensName)
@@ -247,6 +257,14 @@ tests = TestList $ map mkHUnitTest
247257 -- TODO [1.0.0.0]: these tests pass with the new implementation
248258-- , $(inspectTest $ 'sum3Param1Manual === 'sum3Param1Derived)
249259-- , $(inspectTest $ 'sum3Param2Manual === 'sum3Param2Derived)
260+ ] ++
261+ -- Tests for overloaded labels
262+ [ (valLabel ^. #foo ) ~=? 3
263+ , (valLabel & #foo +~ 10 ) ~=? RecB 13 True
264+ , (valLabel ^? #_RecB ) ~=? Just (3, True)
265+ , (valLabel ^? #_RecB . _1) ~=? Just 3
266+ , (valLabel ^? #_RecC ) ~=? Nothing
250267 ]
268+ where valLabel = RecB 3 True
251269
252270-- TODO: add test for traversals over multiple types