summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/T3590.hs
blob: ec2caf9564146e0cf1666d4e7ad1be76f418f0de (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
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}

-- #3590: a bug in typechecking of sections

module T3590 where

import Data.Kind (Type)

newtype ListT m a =
  ListT { runListT :: m (Maybe (a, ListT m a)) }

class Monad (ItemM l) => List l where
  type ItemM l :: Type -> Type
  joinL :: [ItemM l (l a) -> l a]

instance Monad m => List (ListT m) where
  type ItemM (ListT m) = m
  joinL = [ ListT . (>>= runListT)      -- Right section
          , ListT . (runListT <<=)      -- Left section
          ]

(<<=) :: Monad m => (a -> m b) -> m a -> m b
(<<=) k m = m >>= k