简体   繁体   English

在 sml 中获取 ''a 类型而不是 'a

[英]getting ''a type instead of 'a in sml

I've written a hash-table for an sml assignment.我已经为 sml 分配编写了一个哈希表。 I've made a polymorphic builder for the hashtable but when I use the insert function I created, I get a comparable type (''a instead of 'a) although i'm not making any comparisons that include the type.我已经为哈希表创建了一个多态构建器,但是当我使用我创建的插入 function 时,我得到了一个可比较的类型(''a 而不是 'a),尽管我没有进行任何包含该类型的比较。 Does anyone maybe has an idea why?有没有人知道为什么? I'm sorry if my code is a bit messy i've highlighted the important parts, the rest are just helper functions.很抱歉,如果我的代码有点混乱,我已经突出显示了重要部分,rest 只是辅助函数。

code and signature代码和签名在此处输入图像描述

the solution is using a switch case instead of "if" comparisons, that way the compiler can get mixed up and assume a type needs to be comparable although it does not.解决方案是使用 switch case 而不是“if”比较,这样编译器可能会混淆并假设一个类型需要比较,尽管它不需要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM