导入顺序对 ByteString 类型签名的影响

Effect of import order on ByteString type signature

我对 GHCI 在 Data.ByteStringData.ByteString.Char8 周围的行为感到困惑。如果我使用以下导入加载文件

import qualified Data.Text as T
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as BC
import qualified Data.Text.Encoding as E

我明白了

*Main> :t E.encodeUtf8
E.encodeUtf8 :: T.Text -> BC.ByteString

如果我将第二个和第三个导入行反转为

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as B
import qualified Data.Text.Encoding as E

我明白了

*Main> :t E.encodeUtf8
E.encodeUtf8 :: T.Text -> B.ByteString

我认为 Data.ByteStringData.ByteString.Char8 共享相同的 ByteString 类型,但我不知道如何理解它。

我认为 sjakobi 的评论回答了这个问题:

These modules do export the very same ByteString type. The difference between these modules is in the functions they expose.