-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | GHC style name Z-encoding and Z-decoding
--   
--   Implements GHC's name mangling. This code was taken directly from the
--   GHC source.
@package zenc
@version 0.1.2

-- | The Z-encoding
--   
--   This is the main name-encoding and decoding function. It encodes any
--   string into a string that is acceptable as a C name. This is code was
--   originally part of GHC and used right before emitting a symbol name
--   into the compiled C or asm code. This library was created as this
--   encoding is useful when working with GHC compiled code or generally
--   when C-compatible name mangling is desired.
module Text.Encoding.Z

-- | The basic encoding scheme is this:
--   
--   
--   
- Tuples (,,,) are coded as Z3T
--   
- Alphabetic characters (upper and lower) and digits all translate
--   to themselves; except Z, which translates to ZZ and
--   z, which translates to zz We need both so that we
--   can preserve the variable/tycon distinction
--   
- Most other printable characters translate to zx or
--   Zx for some alphabetic character x
--   
- The others translate as znnnU where nnn is the
--   decimal number of the character
--   
--   
--   
--   Before          After
--   --------------------------
--   Trak            Trak
--   foo_wib         foozuwib
--   >               zg
--   >1              zg1
--   foo#            foozh
--   foo##           foozhzh
--   foo##1          foozhzh1
--   fooZ            fooZZ
--   :+              ZCzp
--   ()              Z0T     0-tuple
--   (,,,,)          Z5T     5-tuple
--   (# #)           Z1H     unboxed 1-tuple (note the space)
--   (#,,,,#)        Z5H     unboxed 5-tuple
--           (NB: There is no Z1T nor Z0H.)
--   
zEncodeString :: UserString -> EncodedString

-- | The inverse of zEncodeString
zDecodeString :: EncodedString -> UserString
type UserString = String
type EncodedString = String
