Queue.hs 的一部分:
module Queue ( Queue, emptyQueue, isEmptyQueue, enQueue, deQueue ) where
data Queue a = EmptyQueue | Single a | Q a ( Queue a ) a deriving (Show, Eq)
emptyQueue :: Queue a
emptyQueue = EmptyQueue
enQueue :: a -> Queue a -> Queue a
enQueue x EmptyQueue = Single x
enQueue x (Single q) = Q q (EmptyQueue) x
enQueue x (Q qf q qb) = Q qf (enQueue qb q) x
我正在使用打印,看看他们是否一一正确。现在我想用 HUint 来测试它们。
主要.hs:
module Main where
import Queue
import Test.HUnit
test1 = TestCase $ assertEqual "" (Single 'a'::Queue Char) $ enQueue 'a' emptyQueue
tests = TestList [TestLabel "test1" test1]
main = do runTestTT tests
这是我得到的:
*Queue> :r
[2 of 2] Compiling Main ( Main.hs, interpreted )
Main.hs:5:36: Not in scope: data constructor ‘Single’
Failed, modules loaded: Queue.
那么我该如何解决呢?