[英]Haskell custom data type expression
If I have the custom data type as follows: 如果我具有以下自定义数据类型:
data MyType :: * -> * where
Zero:: MyType a
One:: a -> MyType a
Two:: MyType a -> MyType b -> MyType (a,b)
Is it the same as writing them as: 与编写它们是否一样:
data MyType a = Zero
| One a
Is the above correct? 以上正确吗? And how do I represent Two? 我怎么代表两个?
This has to be done via GADT. 这必须通过GADT完成。 The trick is to enable KindSignature in your program. 诀窍是在程序中启用KindSignature。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.