Haskell部分类型比较
我一直在试图在给定上下文的情况下显示一个函数,以显示简单的lambda演算的减少数据类型。为此,我需要将一种格式
a :-> b
与一种格式
a
进行比较,我还没有能够找到部分比较这样的数据类型的方法,即检查一件事情的类型是否包含另一种类型。如果有一种简单的方法可以做到这一点,我似乎找不到在线上。 这些类型是通用的,可以是任何东西(例如,可以是(foo: - > bar): - > int或其他任何东西,这就是为什么我不能只使用基本类型的原因)
Ive been trying to make a function for displaying the reduced data type of simple lambda calculus given a context. For this I need to compare a type of format
a :-> b
to a type of format
a
I havent been able to find a way of partially comparing the types of data like this, i.e. checking whether the type of one thing contains the type of another. If there's a simple way to do this I cant seem to find it online.
These types are generic and can be anything (e.g. a could be (Foo :-> Bar) :-> Int or anything really, which is why I cant just use a base type)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我并不是100%清楚您想要的东西,但是假设它是这样的:
那么您可以写出类似的内容:
那是您在谈论的事情吗?
要对Typechecking进行更高级的处理,您需要阅读有关统一的信息。 Google应该帮助您入门。我还可以强烈推荐书籍类型和编程语言。
I'm not 100% clear on exactly what you want, but suppose it were like this:
Then you could write something like:
Is that the kind of thing you're talking about?
For a more advanced treatment of typechecking, you'll want to read about unification. Google should help get you started. I can also strongly recommend the book Types and Programming Languages.