From 9038baee1737d106ca72feacd5336f340bf7aed4 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Thu, 11 Feb 2021 13:54:23 -0800 Subject: [PATCH] More tests of overlapping methods --- test/functional/Tactic.hs | 3 +++ test/testdata/tactic/Fgmap.hs | 2 ++ test/testdata/tactic/Fgmap.hs.expected | 2 ++ test/testdata/tactic/FmapJoin.hs | 2 ++ test/testdata/tactic/FmapJoin.hs.expected | 2 ++ test/testdata/tactic/FmapJoinInLet.hs | 4 ++++ test/testdata/tactic/FmapJoinInLet.hs.expected | 4 ++++ 7 files changed, 19 insertions(+) create mode 100644 test/testdata/tactic/Fgmap.hs create mode 100644 test/testdata/tactic/Fgmap.hs.expected create mode 100644 test/testdata/tactic/FmapJoin.hs create mode 100644 test/testdata/tactic/FmapJoin.hs.expected create mode 100644 test/testdata/tactic/FmapJoinInLet.hs create mode 100644 test/testdata/tactic/FmapJoinInLet.hs.expected diff --git a/test/functional/Tactic.hs b/test/functional/Tactic.hs index 6e33a96a90..d46dc8ff29 100644 --- a/test/functional/Tactic.hs +++ b/test/functional/Tactic.hs @@ -117,6 +117,9 @@ tests = testGroup , expectFail "GoldenFish.hs" 5 18 Auto "" , goldenTest "GoldenArbitrary.hs" 25 13 Auto "" , goldenTest "FmapBoth.hs" 2 12 Auto "" + , goldenTest "FmapJoin.hs" 2 14 Auto "" + , goldenTest "Fgmap.hs" 2 9 Auto "" + , goldenTest "FmapJoinInLet.hs" 4 19 Auto "" ] diff --git a/test/testdata/tactic/Fgmap.hs b/test/testdata/tactic/Fgmap.hs new file mode 100644 index 0000000000..de1968474e --- /dev/null +++ b/test/testdata/tactic/Fgmap.hs @@ -0,0 +1,2 @@ +fgmap :: (Functor f, Functor g) => (a -> b) -> (f (g a) -> f (g b)) +fgmap = _ diff --git a/test/testdata/tactic/Fgmap.hs.expected b/test/testdata/tactic/Fgmap.hs.expected new file mode 100644 index 0000000000..98345b23c9 --- /dev/null +++ b/test/testdata/tactic/Fgmap.hs.expected @@ -0,0 +1,2 @@ +fgmap :: (Functor f, Functor g) => (a -> b) -> (f (g a) -> f (g b)) +fgmap = (\ fab fga -> fmap (\ a -> fmap fab a) fga) diff --git a/test/testdata/tactic/FmapJoin.hs b/test/testdata/tactic/FmapJoin.hs new file mode 100644 index 0000000000..98a40133ea --- /dev/null +++ b/test/testdata/tactic/FmapJoin.hs @@ -0,0 +1,2 @@ +fJoin :: (Monad m, Monad f) => f (m (m a)) -> f (m a) +fJoin = fmap _ diff --git a/test/testdata/tactic/FmapJoin.hs.expected b/test/testdata/tactic/FmapJoin.hs.expected new file mode 100644 index 0000000000..733e090b72 --- /dev/null +++ b/test/testdata/tactic/FmapJoin.hs.expected @@ -0,0 +1,2 @@ +fJoin :: (Monad m, Monad f) => f (m (m a)) -> f (m a) +fJoin = fmap (\ mma -> (>>=) mma (\ ma -> ma)) diff --git a/test/testdata/tactic/FmapJoinInLet.hs b/test/testdata/tactic/FmapJoinInLet.hs new file mode 100644 index 0000000000..e6fe6cbd0d --- /dev/null +++ b/test/testdata/tactic/FmapJoinInLet.hs @@ -0,0 +1,4 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +fJoin :: forall f m a. (Monad m, Monad f) => f (m (m a)) -> f (m a) +fJoin = let f = (_ :: m (m a) -> m a) in fmap f diff --git a/test/testdata/tactic/FmapJoinInLet.hs.expected b/test/testdata/tactic/FmapJoinInLet.hs.expected new file mode 100644 index 0000000000..b8bf0cdd07 --- /dev/null +++ b/test/testdata/tactic/FmapJoinInLet.hs.expected @@ -0,0 +1,4 @@ +{-# LANGUAGE ScopedTypeVariables #-} + +fJoin :: forall f m a. (Monad m, Monad f) => f (m (m a)) -> f (m a) +fJoin = let f = ( (\ mma -> (>>=) mma (\ ma -> ma)) :: m (m a) -> m a) in fmap f