不在范围内:类型构造函数或 class ‘∼’

Not in scope: type constructor or class ‘∼’

我正在尝试编译来自 Maguire 的 Thinking with Types:

的代码片段
{-# LANGUAGE TypeOperators #-}

data Expr_ a
    = (a ∼ Int) => LitInt_ Int
    | (a ∼ Bool) => LitBool_ Bool
    | (a ∼ Int) => Add_ (Expr_ Int) (Expr_ Int)
    | (a ∼ Bool) => Not_ (Expr_ Bool)
    | If_ (Expr_ Bool) (Expr_ a) (Expr_ a)

使用 GHCi 8.10.4 版,我得到以下信息:

λ> :l TypeEquality.hs 
[1 of 1] Compiling Main             ( TypeEquality.hs, interpreted )

TypeEquality.hs:4:10: error:
    Not in scope: type constructor or class ‘∼’
  |
4 |     = (a ∼ Int) => LitInt_ Int
  |          ^

TypeEquality.hs:5:10: error:
    Not in scope: type constructor or class ‘∼’
  |
5 |     | (a ∼ Bool) => LitBool_ Bool
  |          ^

TypeEquality.hs:6:10: error:
    Not in scope: type constructor or class ‘∼’
  |
6 |     | (a ∼ Int) => Add_ (Expr_ Int) (Expr_ Int)
  |          ^

TypeEquality.hs:7:10: error:
    Not in scope: type constructor or class ‘∼’
  |
7 |     | (a ∼ Bool) => Not_ (Expr_ Bool)
  |          ^
Failed, no modules loaded.

是否有可以编译的语言编译指示?

真正的问题是我复制并粘贴了书中的代码,~ 符号被格式化为 相似但不相同 !我可能不会是最后一个犯这个错误的人,所以希望搜索错误信息能找到这个 post.

以下将编译:

{-# LANGUAGE GADTs #-}

data Expr_ a
    = (a ~ Int) => LitInt_ Int
    | (a ~ Bool) => LitBool_ Bool
    | (a ~ Int) => Add_ (Expr_ Int) (Expr_ Int)
    | (a ~ Bool) => Not_ (Expr_ Bool)
    | If_ (Expr_ Bool) (Expr_ a) (Expr_ a)