小编bob*_*uza的帖子

箭头(->)作为Haskell数据构造函数

我对箭头及其在数据构造函数中的实际含义感到困惑。我什至对它进行编译感到惊讶,但我不知道如何使用它。

如果我尝试将其用作数据构造函数的名称,则它不会解析,并且我不确定如何进一步解释它。如果我将其解释为函数类型,则数据构造函数没有名称,这对我也没有意义。

data Type
  = TBool
  | TInt
  | Arrow Type Type
  | (->) Type Type

test :: Type 
test = Arrow TBool TInt -- Ok

test' :: Type
test' = (->) TBool TInt -- Parse Error on input '->'
Run Code Online (Sandbox Code Playgroud)

haskell

10
推荐指数
1
解决办法
191
查看次数

标签 统计

haskell ×1