summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/TcStaticPointers02.hs
blob: 9b51aeedfea58b6bded3eb939c1b28b9c8d196e6 (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
34
35
36
37
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE StaticPointers     #-}

module StaticPointers02 where

import GHC.StaticPtr
import Data.Typeable

f2 :: Typeable a => StaticPtr (a -> a)
f2 = static id

f3 :: StaticPtr (Char -> Int)
f3 = static method

f4 :: Typeable a => StaticPtr (T a -> a)
f4 = static t_field

g :: Int -> Int
g = id

f5 :: Typeable a => StaticPtr (a -> a)
f5 = static (id . id)

f6 :: Typeable a => StaticPtr (a -> IO a)
f6 = static return

f7 :: Typeable a => StaticPtr (a -> IO a)
f7 = static (\x -> getLine >> return x)

data T a = T { t_field :: a }
  deriving Typeable

class C a where
  method :: a -> Int

instance C Char where
  method = const 0