Queue.hs
module Queue (Queue(..)) where Import Prelude hiding (head.tail) class Queue q where empty :: q a isEmpty :: q a-> Bool snoc :: q a-> a->q a head :: q a -> a tail :: q a-> qa
BatchedQueue.hs
module BatchedQueue (BatchedQueue(BQ,check)) where Import Prelude hiding (head.tail) Import Queue data BatchedQueuea = BQ [a] [a] check [] r = BQ (reverse r) [] check f r = BQ f r instance QueueBatchedQueue where empty = BQ [] [] isEmpty (BQ f r) = null f snoc (BQ f i) x = check f (x: r) head (BQ [] _) = error "empty queue" head (BQ (x : f) t) = x tail (BQ [] _) = error "empty queue" tail (BQ (x: f) r) = check f r
main.hs
module Main where import Queue import BatchedQueue import Data.Typeable main :: IO() main = putStrLn("hello world")
Above are three source files I try to compile,but after I typed at current working directory,
ghc -o main.out main.hs
I got an error
[2 of 3] Compiling BatchedQueue ( BatchedQueue.hs, BatchedQueue.o ) BatchedQueue.hs:1:21: The export item ‘BatchedQueue(BQ, check)’ attempts to export constructors or class methods that are not visible here
How do I solved this,I searched google,but really have no idea why.Thanks.