小编J.K*_*vji的帖子

导入时如何隐藏操作员?

这是我的代码,试图重新定义*.只有在*以前隐藏时才能实现:

import Prelude hiding (*)

(*) :: Int -> Int -> Int
x * 0 = 0
x * y = x + x*(y-1)
Run Code Online (Sandbox Code Playgroud)

但它不起作用:

$ ghci test.hs
Run Code Online (Sandbox Code Playgroud)

GHCi,版本8.0.1:http ://www.haskell.org/ghc/:?求助

test.hs:1:24:错误:输入'*'解析错误

失败,模块加载:无.

前奏>

我可以隐藏其他功能:

import Prelude hiding (read)

import Prelude hiding (show)
Run Code Online (Sandbox Code Playgroud)

虽然它并不适用于运营商一样工作*,+,-.

我该如何隐藏它们?

haskell

7
推荐指数
1
解决办法
602
查看次数

标签 统计

haskell ×1