Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Inefficient attempt at UTF-8 magics.
To encode UTF-8 strings to bytestrings at compile time, we really need more
support from the compiler. We can go Char -> Natural
, but we can't go Natural
-> [Natural]
where each value is <= 255
. Doing so is hard without bit
twiddling.
The best we can do is get reify the Symbol
directly, then encode as UTF-8 at
runtime. It's a bit of a farce, and we can't derive a CBLen
instance, but
works just fine. Actually, I dunno, it might be faster than the bytewise magic
handling, depending on how GHC optimizes its instances.
Documentation
symVal :: forall str. KnownSymbol str => String Source #
encodeStringUtf8 :: String -> ByteString Source #