aesiniath / http-streams

Haskell HTTP client library for use with io-streams
https://hackage.haskell.org/package/http-streams
BSD 3-Clause "New" or "Revised" License
50 stars 48 forks source link

http-streams defines an `IsString Builder` orphan instance #24

Closed hvr closed 11 years ago

hvr commented 11 years ago

Since Haskell does not allow to control the import/export of typeclass instances, or as is written in the Haskell Wiki:

Type class instances are special in that they don't have a name and cannot be imported explicitly. This also means that they cannot be excluded explicitly. All instances defined in a module A are imported automatically when importing A, or importing any module that imports A, directly or indirectly.

And here's evidence to show, that http-streams leaks the IsString Builder instance, as soon as Network.Http.Types is imported (indirectly):

$ ghci
GHCi, version 7.6.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> import Data.String
λ> import Blaze.ByteString.Builder (Builder)
λ> :info IsString
class IsString a where
  fromString :: String -> a
    -- Defined in `Data.String'
instance IsString [Char] -- Defined in `Data.String'

λ> import Network.Http.Client 
λ> :info IsString
class IsString a where
  fromString :: String -> a
    -- Defined in `Data.String'
instance IsString Builder -- Defined in `http-streams-0.4.0.1:Network.Http.Types'
instance IsString [Char] -- Defined in `Data.String'
istathar commented 11 years ago

So @gregorycollins suggests that an instance be submitted upstream to @meiersi ... I gather that Builder is moving to bytestring, so is this a patch against blaze-builder or bytestring?

AfC

gregorycollins commented 11 years ago

Probably both. We're not quite ready to move to bytestring-builder across the board yet, which is why io-streams is still using blaze-builder.

On Thu, Apr 25, 2013 at 10:04 AM, Andrew Cowie notifications@github.comwrote:

So @gregorycollins https://github.com/gregorycollins suggests that an instance be submitted upstream to @meiersi https://github.com/meiersi... I gather that Builder is moving to bytestring, so is this a patch against blaze-builder or bytestring?

AfC

— Reply to this email directly or view it on GitHubhttps://github.com/afcowie/http-streams/issues/24#issuecomment-16993454 .

Gregory Collins greg@gregorycollins.net