summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/simpl014.hs
blob: 34aba15a95bbe0a1defca64069ba1ff542f24488 (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
{-# OPTIONS_GHC -Wno-redundant-constraints -Wno-simplifiable-class-constraints #-}
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE RankNTypes, GADTs, FlexibleContexts #-}

-- This one make SpecConstr generate bogus code (hence -O2),
-- with a lint error, in GHC 6.4.1
-- C.f. https://gitlab.haskell.org/ghc/ghc/issues/737

module ShouldCompile where

 data IHandler st where
     IHandler :: forall st ev res.
                 Serialize (TxContext ev) => String -> IO ev
                 -> (res -> IO ()) -> Ev st ev res -> IHandler st
     -- Weird test case: (Serialize (TxContext ev)) is simplifiable

 data Ev st ev res  = Ev
 data TxContext evt = TxContext
 data TxConfig      = TxConfig
 data M    a        = M a

 class Serialize a where
 instance Serialize a => Serialize (TxContext a)
 instance Serialize Int
 instance Serialize ()

 data IHR st = forall res ev. Serialize (TxContext ev) => IHR (TxContext ev)


 runHandler :: M (IHR st) ->  IHandler st -> IO ()
 runHandler queue ih@(IHandler tstring inp out run) = runHandler queue ih