【发布时间】:2016-10-28 22:40:21
【问题描述】:
我试图在 Haskell 中实现两个堆栈队列,但在我的代码的第一个部分我得到了这个错误。
TwoStacksQueue.hs:3:5:
Ambiguous occurrence ‘empty’
It could refer to either ‘DataStructures.Queue.TwoStacksQueue.empty’,
defined at TwoStacksQueue.hs:15:1
or ‘LS.empty’,
imported from ‘DataStructures.Stack.LinearStack’
这是代码(我什至不能以 isEmpty 开头):
module DataStructures.Queue.TwoStacksQueue
( Queue
, empty
, isEmpty
, enqueue
, dequeue
, first
) where
import DataStructures.Stack.LinearStack as LS
data Queue a = Empty | Node a (Stack a) (Stack a)
empty :: Queue a
empty = Empty
【问题讨论】:
-
查看行号 - 错误在您的导出列表中。您导出
empty但范围内有两个这样的名称。你可能想要import qualified DataStructures.Stack...