on master help sign in
Get generic prism closer
commitd539770ffdfba825651c5bdd7f24d8f048c7a8db authorMatthew Pickering <matthewtpickering@gmail.com> dateFri 19 Jan 2018, 14:51 (9 years ago) parent5d8b507
3 files changed+6−6
generic-lens.cabal+1−1 src/Data/Generics/Sum/Subtype.hs+3−2 test/Spec.hs+2−3
generic-lens.cabal+1−1
@@ -90,7 +90,7 @@ test-suite generic-lens-test
9090 , HUnit
9191
9292 default-language: Haskell2010
93− ghc-options: -Wall -O2 -dsuppress-all
93+ ghc-options: -Wall -O2
9494 if flag(dump-core)
9595 build-depends: dump-core
9696 ghc-options: -fplugin=DumpCore -fplugin-opt DumpCore:core-html
src/Data/Generics/Sum/Subtype.hs+3−2
@@ -89,7 +89,7 @@ class AsSubtype sub sup where
8989 -- >>> duck ^? _Sub :: Maybe FourLeggedAnimal
9090 -- Nothing
9191 _Sub :: Prism' sup sub
92− _Sub eta = prism injectSub projectSub eta
92+ _Sub = prism injectSub projectSub
9393 {-# INLINE _Sub #-}
9494
9595 -- |Injects a subtype into a supertype (upcast).
@@ -108,7 +108,8 @@ instance
108108 , GAsSubtype (Rep sub) (Rep sup)
109109 ) => AsSubtype sub sup where
110110
111− _Sub f = prismRavel (prismPRavel (repIso . _GSub . fromIso repIso)) f
111+ _Sub f = prismRavel (repIso . _GSub . fromIso repIso) f
112+ {-# INLINE _Sub #-}
112113
113114-- See Note [Uncluttering type signatures]
114115instance {-# OVERLAPPING #-} AsSubtype a Void where
test/Spec.hs+2−3
@@ -1,5 +1,5 @@
11{-# OPTIONS_GHC -O -fplugin Test.Inspection.Plugin #-}
2−{-# OPTIONS_GHC -dsuppress-all #-}
2+{-# OPTIONS_GHC -dsuppress-unfoldings #-}
33
44{-# LANGUAGE AllowAmbiguousTypes #-}
55{-# LANGUAGE DataKinds #-}
@@ -102,8 +102,7 @@ subtypePrismManual eta = prism g f eta
102102 f s1 = case s1 of
103103 A c -> Right (A2 c)
104104 B i -> Right (B2 i)
105− C _ -> Left s1
106− D _ -> Left s1
105+ _ -> Left s1
107106 g (A2 c) = A c
108107 g (B2 i) = B i
109108