有没有办法在 ghci 中查看特定类型的 Typeclass 定义?
例如,Maybe
定义如下:
instance Functor Maybe where
fmap f (Just x) = Just (f x)
fmap f Nothing = Nothing
我可以在 ghci 中看到这个吗?
当我:info
在 ghci 中使用时,我得到了这个:
Prelude> :i Maybe
data Maybe a = Nothing | Just a -- Defined in `Data.Maybe'
instance Eq a => Eq (Maybe a) -- Defined in `Data.Maybe'
instance Monad Maybe -- Defined in `Data.Maybe'
instance Functor Maybe -- Defined in `Data.Maybe'
instance Ord a => Ord (Maybe a) -- Defined in `Data.Maybe'
instance Read a => Read (Maybe a) -- Defined in `GHC.Read'
instance Show a => Show (Maybe a) -- Defined in `GHC.Show'
在上面的输出中,我想看看它是如何在 Data.Maybe 中定义为Functor
. 无论如何在 ghci 中看到?