Do Haskell imports have side effects?

后端 未结 1 1025
名媛妹妹
名媛妹妹 2021-02-06 23:30

I wrote some code a while ago which uses OverloadedStrings to create ByteStrings from hex-encoded String literals, which it decodes using the functions

相关标签:
1条回答
  • 2021-02-07 00:18

    In Haskell, typeclass instances are always exported and imported--you can't hide them. This is usually referred to as the "open world assumption".

    This means that typeclass instances are also exported transitively: if you import a library with an instance, it gets exported from your module as well.

    In this case, the IsString instance is in Data.ByteString.Char8, which is imported by Data.ByteString.Base16. You should be able to replace your import with:

    import Data.ByteString.Char8 ()
    

    There is a nice SO question giving some information on the open world assumption, if you're interested.

    0 讨论(0)
提交回复
热议问题