Re:http://d.hatena.ne.jp/syd_syd/20050120#p1
appAndShow (Func f) (Obj x) = let f' = fromJust $ cast f in show $ f' x
だと、f'の型は、引数の型はObjの中身から決まりますが、返り値については
- showの引数なので Show a
- castの返り値となっている関数のものだから Typeable a
-- (Obj (x :: x)) f' :: (Typeable a, Show a) => x -> a
ということしかわからないからです。
例えば、
appAndShow (Func f) (Obj x) = let f' = fromJust $ cast f in show $ (f' x :: String)
なら
appAndShow func val
で呼ばれると、cast fはNothingになります。