summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell/ghci/p15.script
blob: 3faeec9df905f7560c89cd359ab3ebeef0acb0e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Test restricted functionality: Data.Typeable
:unset +s
:set -XSafe
:set -XDeriveDataTypeable
:set -XStandaloneDeriving

:m + Data.Typeable

data H = H {h :: String} deriving (Typeable, Show)

data G = G [Int] deriving (Show)

instance Typeable G where { typeOf _ = typeOf (undefined :: H) }

let x = H "Hello"
let y = G [0]

x
y

let (Just y_as_H) = (cast y) :: Maybe H
y_as_H