相关疑难解决方法(0)

Haskell类型中波形符的含义(类型相等)

我一直在搞乱这个fix功能,我碰巧遇到了这个问题:

? let fix f = let x = f x in x
? fix (+)

<interactive>:15:5:
    Occurs check: cannot construct the infinite type: t ~ t -> t
    Expected type: t -> t
      Actual type: t -> t -> t
    Relevant bindings include it :: t (bound at <interactive>:15:1)
    In the first argument of ‘fix’, namely ‘(+)’
    In the expression: fix (+)
Run Code Online (Sandbox Code Playgroud)

我完全知道为什么会出现这个错误,但我注意到那里有一个有趣的签名:t ~ t -> t.这种类型意味着什么?什么代字号在haskell中的类型签名中意味着什么?他们在哪里使用?

haskell types tilde

12
推荐指数
1
解决办法
3824
查看次数

标签 统计

haskell ×1

tilde ×1

types ×1