Control.Exception文档中说我可以按照以下方式创建自己的异常:
data MyException = ThisException | ThatException
deriving (Show, Typeable)
instance Exception MyException
如果我将这个粘贴到一个文件中,并编译(在导入Control.Exception和Data.Typeable之后),会得到如下结果:
exp.hs:6:20:
Can't make a derived instance of `Typeable MyException'
(You need -XDeriveDataTypeable to derive an instance for this class)
In the data type declaration for `MyException'
我需要打开这个扩展程序才能使用用户定义的异常吗?如果不是,请提供一个示例。谢谢。