on master help sign in
Fix deep typed traversal
commit14abda554d6e5b6edcdcca68e71e0d3e5534b843 authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateThu 8 Feb 2018, 16:30 (9 years ago) parent565302c
1 file changed+11−2
src/Data/Generics/Product/Types.hs+11−2
src/Data/Generics/Product/Types.hs+11−2
@@ -53,11 +53,20 @@ instance
5353class HasTypesDeep a s where
5454 typesDeep :: Traversal' s a
5555
56+class Or a b where
57+ foldOr :: Applicative g => (a -> g a) -> b -> g b
58+
59+instance Or a a where
60+ foldOr f a = f a
61+
62+instance {-# OVERLAPPABLE #-} Or a b where
63+ foldOr _ = pure
64+
5665instance
57− ( HasConstraints' ((~) a) s
66+ ( HasConstraints' (Or a) s
5867 ) => HasTypesDeep a s where
5968
60− typesDeep f s = constraints' @((~) a) f s
69+ typesDeep f s = constraints' @(Or a) (foldOr f) s
6170
6271--------------------------------------------------------------------------------
6372type family Primitive a :: Bool where