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

-- | Here we used typeable to produce an illegal value
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 ()