我面临以下问题:我在一个模块中定义了一个类型类的多个实例,但不想导出所有这些实例。我怎样才能做到这一点?
module SomeModule
( calculate
)
where
class Something a where
calculate :: a -> Int
instance Something Double where
calculate x = calculate $ roundToInt x
instance Something Int where
calculate x = doSomething x
roundToInt :: Double -> Int
roundToInt = round
doSomething :: Int -> Int
doSomething _ = 42
Run Code Online (Sandbox Code Playgroud)
在这个(简化的)示例中,我有两个Something相互依赖的类型类实例,但我只想导出Doubles 而不是Ints的实例。但在我的示例中,两个实例都被隐式导出。有办法解决吗?