考虑 Haskell 的Generic课程:
class Generic a where
-- | Generic representation type
type Rep a :: * -> *
-- | Convert from the datatype to its representation
from :: a -> (Rep a) x
-- | Convert from the representation to the datatype
to :: (Rep a) x -> a
Run Code Online (Sandbox Code Playgroud)
我很好奇为什么它没有写成如下:
class Generic a where
-- | Generic representation type
type Rep a :: *
-- | Convert from the datatype to its representation
from :: a -> Rep a
-- | Convert from the representation to the datatype
to :: Rep a -> a
Run Code Online (Sandbox Code Playgroud)
更具体地说,类型变量x在标准定义中代表什么?
| 归档时间: |
|
| 查看次数: |
112 次 |
| 最近记录: |