summaryrefslogtreecommitdiff
path: root/testsuite/tests/safeHaskell/unsafeLibs/BadImport03.hs
blob: 835009a276cc4dedd1bf86128541a6d2b3345e25 (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
{-# LANGUAGE Safe #-}
{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}

-- | Here we used typeable to produce an illegal value
-- Now using SAFE though so will fail
module Main where

import Data.Typeable

import BadImport02_A

deriving instance Typeable Nat

data NInt = NInt Int deriving Show

instance Typeable NInt where
    typeOf _ = typeOf (undefined::Nat)

main = do
    let a = succ' $ zero
        Just n@(NInt z) = (cast a) :: Maybe NInt
        n' = NInt (-z)
        Just m = (cast n') :: Maybe Nat
     
    putStrLn $ showNat a
    putStrLn $ show n
    putStrLn $ showNat m
    return ()