我写了两个模块.第一个被称为DhtTypes:
module DhtTypes (Bencode, encode, TransactionID, Hash20Bytes) where
-- import stuff
class Bencode a where
encode :: a -> ByteString.ByteString
data TransactionID = TransactionID Int.Int16
data Hash20Bytes = Hash20Bytes [Word.Word8]
-- stuff
Run Code Online (Sandbox Code Playgroud)
第二个是MessageTypes:
module MessageTypes () where
-- import stuff
import DhtTypes
data PingR = PingR TransactionID Hash20Bytes
-- stuff
Run Code Online (Sandbox Code Playgroud)
这是我加载MessageTypesGHCi 时发生的事情:
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading …Run Code Online (Sandbox Code Playgroud)