summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun044.hs19
1 files changed, 7 insertions, 12 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun044.hs b/testsuite/tests/typecheck/should_run/tcrun044.hs
index 0a2413c928..031cd40bde 100644
--- a/testsuite/tests/typecheck/should_run/tcrun044.hs
+++ b/testsuite/tests/typecheck/should_run/tcrun044.hs
@@ -2,31 +2,26 @@
import qualified Data.Set as S
--- You can't write this as an associated type synonym
--- because it is indexed in more arguments than those
--- bound by the class
---
--- A better solution would be index it only in "m"
--- but then how do we write the instance for []?
-type family RMonadCtxt m a :: Constraint
-
class RMonad m where
+ type RMonadCtxt m a :: Constraint
returnR :: (RMonadCtxt m a) => a -> m a
bindR :: (RMonadCtxt m a, RMonadCtxt m b) => m a -> (a -> m b) -> m b
-type instance RMonadCtxt [] a = ()
instance RMonad [] where
+ type RMonadCtxt [] a = ()
returnR x = [x]
bindR = flip concatMap
-type instance RMonadCtxt S.Set a = Ord a
instance RMonad S.Set where
+ type RMonadCtxt S.Set a = Ord a
returnR x = S.singleton x
bindR mx fxmy = S.fromList [y | x <- S.toList mx, y <- S.toList (fxmy x)]
main = do
- print $ (returnR 1 ++ returnR 2) `bindR` (\x -> returnR (x + 1) ++ returnR (x + 2))
- print $ (returnR 1 `S.union` returnR 2) `bindR` (\x -> returnR (x + 1) `S.union` returnR (x + 2))
+ print $ (returnR 1 ++ returnR 2) `bindR`
+ (\x -> returnR (x + 1) ++ returnR (x + 2))
+ print $ (returnR 1 `S.union` returnR 2) `bindR`
+ (\x -> returnR (x + 1) `S.union` returnR (x + 2))