on master help sign in
Fix Bifunctor test on 8.0.2
commit3a6e50ed659661ce6459a8d678a2bb18e2159bc0 authorCsongor Kiss <kiss.csongor.kiss@gmail.com> dateThu 22 Mar 2018, 05:20 (9 years ago) parentf5c880e
1 file changed+6−4
test/Bifunctor.hs+6−4
test/Bifunctor.hs+6−4
@@ -24,7 +24,8 @@ data Tree a w = Leaf a
2424 | WithWeight (Tree a w) w
2525 deriving (Show, Eq, Generic)
2626
27−deriving instance Bifunctor Tree
27+instance Bifunctor Tree where
28+ bimap = gbimap
2829
2930mytree :: Tree Int Int
3031mytree = Fork (WithWeight (Leaf 42) 1)
@@ -34,12 +35,13 @@ mytreeBimapped :: Tree Int String
3435mytreeBimapped = Fork (WithWeight (Leaf 84) "1")
3536 (WithWeight (Fork (Leaf 176) (Leaf 74)) "2")
3637
37−-- Derivable Bifunctor
38+--------------------------------------------------------------------------------
39+
3840class Bifunctor p where
3941 bimap :: (a -> c) -> (b -> d) -> p a b -> p c d
4042
41− default bimap ::
43+gbimap ::
4244 ( HasParam 0 (p a b) (p a d) b d
4345 , HasParam 1 (p a d) (p c d) a c
4446 ) => (a -> c) -> (b -> d) -> p a b -> p c d
45− bimap f g s = s & param @0 %~ g & param @1 %~ f
47+gbimap f g s = s & param @0 %~ g & param @1 %~ f