haskell - 为什么 Haskell 的 'Generic' 类类型族 'Rep a' 被注释为类型构造函数,而不是类型?
问题描述
考虑 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
我很好奇为什么它没有写成如下:
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
更具体地说,类型变量x
在标准定义中代表什么?
解决方案
这样做是为了允许Generic
和Generic1
类共享它们的大部分表示类型。这是否真的是一个好主意是值得商榷的。尽量忽略多余的参数。
推荐阅读
- python - 具有多个条件的掩码列表/张量?
- r - p值<0.05时如何自动应用事后检验
- azure-data-factory - ADF 复制活动 - 如何操作输出文件名
- reactjs - 在 Cloudinary 上传小部件回调中访问 useState 状态
- javascript - 尝试替换旧数组时使用无效数据调用 DocumentReference.update()
- shell - 以 sh 启动时 Zsh 不执行大括号扩展?
- tensorflow - Keras:如何在每个时期更改随机数?
- python - 带有 python 的 Tika 服务器对大文件返回 None,但适用于小 pdf 的文件
- java - 如何从java中的另一个类访问对象?
- php - 使用客户满意度按优先级排序票证