summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T9612.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-09-26 10:53:32 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-09-26 12:34:51 +0100
commit1a88f9a4fb373ce52284996212fc23b06848b1c0 (patch)
treef47edfba08918411312ea1825d5392d3cde43caf /testsuite/tests/typecheck/should_fail/T9612.hs
parent8c9d0ce490506fdc60d9f25d4b80774180cf92ce (diff)
downloadhaskell-1a88f9a4fb373ce52284996212fc23b06848b1c0.tar.gz
Improve error messages from functional dependencies
Reponding to Trac #9612: * Track the CtOrigin of a Derived equality, arising from a functional dependency * And report it clearly in the error stream This relies on a previous commit, in which I stop dropping Derived insolubles on the floor.
Diffstat (limited to 'testsuite/tests/typecheck/should_fail/T9612.hs')
-rw-r--r--testsuite/tests/typecheck/should_fail/T9612.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_fail/T9612.hs b/testsuite/tests/typecheck/should_fail/T9612.hs
new file mode 100644
index 0000000000..a332c47b04
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T9612.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances, FunctionalDependencies, MultiParamTypeClasses #-}
+module T9612 where
+import Data.Monoid
+import Control.Monad.Trans.Writer.Lazy( Writer, WriterT )
+import Data.Functor.Identity( Identity )
+
+class (Monoid w, Monad m) => MonadWriter w m | m -> w where
+ writer :: (a,w) -> m a
+ tell :: w -> m ()
+ listen :: m a -> m (a, w)
+ pass :: m (a, w -> w) -> m a
+
+f ::(Eq a) => a -> (Int, a) -> Writer [(Int, a)] (Int, a)
+f y (n,x) {- | y == x = return (n+1, x)
+ | otherwise = -}
+ = do tell (n,x)
+ return (1,y)
+
+
+instance (Monoid w, Monad m) => MonadWriter w (WriterT w m) where