【发布时间】:2011-01-06 11:19:04
【问题描述】:
我一直在为我的索引使用新类型包装器以避免错误,我有一些这样的代码:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype PersonIdx = PersonIdx Int
deriving (Enum, Eq, Integral, Num, Ord, Real, Show)
要派生Integral,还必须派生其所有依赖项(因此上面列出了类型类)。
有没有办法让它继承Integral 的所有依赖项?我会想象这样的事情:
newtype PersonIdx = PersonIdx Int
deriving (Integral(..))
【问题讨论】:
标签: haskell typeclass derived-types deriving