Type safe iconv wrapper https://github.com/adinapoli/iconv-typed#readme
|Latest on Hackage:||0.2.0.0|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
- Type safe iconv wrapper
An experiment in bringing type safety to the iconv package.
- Usage Example
This is almost a drop-in replacement. Compare the original code from
module Main where import Codec.Text.IConv main :: IO () main = print $ convert "UTF-8" "LATIN1" "hello"
With the equivalent in
module Main where import Codec.Text.IConv.Typed main :: IO () main = print $ convert @"UTF-8" @"LATIN1" "hello"
As a result, this code will compile and run only if the passed encoding resolves to a supported encoding (as retrieved at compile time by calling "iconv -l"). For example, the following won't compile:
main = print $ convert @"UFT-8" "LATIN1" "hello"
UFT is mispelled.
Using GHC < 8.0 that doesn't supports
TypeInType? No problem, we've got you covered!
module Main where import Codec.Text.IConv.Typed main :: IO () main = print $ convert (E :: E "UTF-8") (E :: E "LATIN1") "hello"