summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T9612.hs
blob: a332c47b04eb55e0fb59ca0e5cb94e225d4af5ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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