Question

I was fairly sure that a while back GHC added the ability to explicitly set the character encoding on a Handle. However, when I look in System.IO, I don't see anything relating to character encodings. (I have Haskell Platform 2012.4.0.0)

Am I blind, or simply mistaken?

Was it helpful?

Solution

I investigated where the function is hiding.

Summary: Make sure to use System.IO from package base, not from package haskell2010.

Details: Hoogle tells me that there is System.IO.hSetEncoding in the latest base package.

Checking the documentation about the Haskell platform 2012.4.0.0, I see a System.IO module from the haskell2010 package. And that module doesn't seem to contain hSetEncoding.

But do not despair, there seems to also be the System.IO from base which contains hSetEncoding.

So I guess you just have to make sure that you use the System.IO from base and not from haskell2010.

OTHER TIPS

Oh my God!

OK, I just figured this out.

  1. It appears that there are two packages that both export System.IO - the base package and the haskell2010 package.
  2. The two versions of the module are different. Specifically, only the module from base has all the character encoding stuff in it.
  3. When you go to the locally-installed module index, it only shows you the version of System.IO that's included in haskell2010 - without all the character encoding stuff.

It appears the only way to see the version from base is to click on some other module exported from base, then click "Contents", then navigate to System.IO from there. Then it shows you the correct module!

Counter-intuitive, much? o_O

OK, so I've found my function now, but man, Haddock should probably do a better job of handling this obscure edge-case...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top