summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/T3955.hs
blob: 3f37fb6e1aafb88a2ade115283690082f9b3d9ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}

-- Test for #3955

module T3955 where

import Control.Applicative (Applicative(..))
import Control.Monad (liftM, ap)

class (Monad m) => MonadReader r m
newtype Reader r a = Reader { runReader :: r -> a }

instance Functor (Reader r) where
    fmap = liftM

instance Applicative (Reader r) where
    pure = error "urk"
    (<*>) = ap

instance Monad (Reader r) where
  (>>=)  = error "urk"

instance MonadReader r (Reader r)

newtype T a x = T (Reader a x)
    deriving (Functor, Applicative, Monad, MonadReader a)

{-
[1 of 1] Compiling Main             ( bug.hs, interpreted )
mkUsageInfo: internal name? a{tv amy}
Ok, modules loaded: Main.
-}