Problem: text-2.1 has Data.Text.IO.Utf8 whose name conflicts with
our module with the same name.
Solution: our module contains 2 functions: `readFile` and `writeFile`.
They are implemented differently from `text` versions, but look
semantically equivalent. Our functions are also polymorphic in the
monad type, but that's orthogonal to the purpose of this package,
so we can sacrifice this polymorphism.
So it looks like our module doesn't add much value anymore and should
be deleted.
However, it's a good practice to deprecate something before deleting,
so we deprecate this module instead. It will be deleted in a future
version.
Note that the same module for lazy Text remains intact, since there
are apparently no such functions for lazy Text in text-2.1.
Problem: tests do not compile when text-2.1 is used, because
there are is a conflict in module names.
`Data.Text.IO.Utf8` was added to `text` in version 2.1.
GHC reports ambiguous modules error.
Solution: specify the package explicitly using the PackageImports
extension.
Problem: We have introduced a new template for Haskell libraries and
need to update this package according to this template.
Solution: Use new template, bump dependencies, remove unused license,
apply formatting and hlint suggestions.
The old interface only allowed one to perform terminal detection on a
handle and change it to UTF-8 if it was not a terminal. Turns our, it
makes sense to sometimes leave the original encoding on a handle even if
it does not point to a terminal.
* Change the interface to separate these two use-cases.
* Extract main-wrappers to a new `Main` module.
Previously the code was using stdout for testing the terminal detection
functionality. However, there is no guarantee that the tests will always
be running with stdout attached to a terminal.
Create a fresh pseudo-terminal instead and use it instead of stdout.
* Split out the actual encoding choice logic into a separate Internal
module to make it possible to cover it with tests.
* Make this function a little more efficient compared to the previous
purely pure function.
* Keep a completely pure function as a specficiation for ease of reading
and for testing by comparing the actualy function to the pure one.
* Add tests that check that the pure function makes sense.
* Add tests that compare the output of the real function to the output
of the pure function on some real handles.
* Add tests that check that functions that are supposed to actually
modify the encoding of a handle actually do modify it.