@@ -81,13 +81,24 @@ class AsType a s where
8181 -- Just 2
8282 _Typed :: Prism' s a
8383
84+ -- |Inject by type.
85+ injectTyped :: a -> s
86+
87+ -- |Project by type.
88+ projectTyped :: s -> Maybe a
89+
8490instance
8591 ( Generic s
8692 , ErrorUnlessOne a s (CountPartialType a (Rep s))
8793 , GAsType (Rep s) a
8894 ) => AsType a s where
8995
90− _Typed = repIso . _GTyped
96+ _Typed
97+ = repIso . _GTyped
98+ injectTyped
99+ = to . ginjectTyped
100+ projectTyped
101+ = either (const Nothing) Just . gprojectTyped . from
91102
92103type family ErrorUnlessOne (a :: Type) (s :: Type) (count :: Count) :: Constraint where
93104 ErrorUnlessOne a s 'None