blob: 76379b6c008d2e547f72c61b54c26b5e2ab002e8 (
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
|
{-# LANGUAGE QuantifiedConstraints, PolyKinds, ScopedTypeVariables
, StandaloneDeriving, RoleAnnotations, TypeApplications
, UndecidableInstances, InstanceSigs
, GeneralizedNewtypeDeriving #-}
module T9123a where
import Data.Coerce
class MyMonad m where
join :: m (m a) -> m a
newtype StateT s m a = StateT (s -> m (a, s))
type role StateT nominal representational nominal -- as inferred
instance MyMonad m => MyMonad (StateT s m) where
join = error "urk" -- A good impl exists, but is not
-- of interest for this test case
newtype IntStateT m a = IntStateT (StateT Int m a)
type role IntStateT representational nominal -- as inferred
instance (MyMonad m, forall p q. Coercible p q => Coercible (m p) (m q))
=> MyMonad (IntStateT m) where
join :: forall a. IntStateT m (IntStateT m a) -> IntStateT m a
join = coerce @(StateT Int m (StateT Int m a) -> StateT Int m a)
@(IntStateT m (IntStateT m a) -> IntStateT m a)
join
|