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


-- | Case insensitive string comparison
--   
--   The module <tt>Data.CaseInsensitive</tt> provides the <a>CI</a> type
--   constructor which can be parameterised by a string-like type like:
--   <a>String</a>, <a>ByteString</a>, <a>Text</a>, etc.. Comparisons of
--   values of the resulting type will be insensitive to cases.
@package case-insensitive
@version 1.2.1.0


-- | This module is intended to be imported qualified. May I suggest:
--   
--   <pre>
--   import           Data.CaseInsensitive  ( CI )
--   import qualified Data.CaseInsensitive as CI
--   </pre>
--   
--   <i>Note that the FoldCase instance for ByteStrings is only</i>
--   <i>guaranteed to be correct for ISO-8859-1 encoded strings!</i>
module Data.CaseInsensitive

-- | A <tt>CI s</tt> provides <i>C</i>ase <i>I</i>nsensitive comparison for
--   the string-like type <tt>s</tt> (for example: <tt>String</tt>,
--   <a>Text</a>, <a>ByteString</a>, etc.).
--   
--   Note that <tt>CI s</tt> has an instance for <a>IsString</a> which
--   together with the <tt>OverloadedStrings</tt> language extension allows
--   you to write case insensitive string literals as in:
--   
--   <pre>
--   &gt; ("Content-Type" :: <a>CI</a> <a>Text</a>) == ("CONTENT-TYPE" :: <a>CI</a> <a>Text</a>)
--   True
--   </pre>
data CI s

-- | Make the given string-like value case insensitive.
mk :: FoldCase s => s -> CI s

-- | Retrieve the original string-like value.
original :: CI s -> s

-- | Retrieve the case folded string-like value. (Also see
--   <a>foldCase</a>).
foldedCase :: CI s -> s

-- | Transform the original string-like value but keep it case insensitive.
map :: FoldCase s2 => (s1 -> s2) -> CI s1 -> CI s2

-- | Transform the original string-like value but keep it case insensitive.
traverse :: (FoldCase s2, Applicative f) => (s1 -> f s2) -> CI s1 -> f (CI s2)

-- | Class of string-like types that support folding cases.
--   
--   <i>Note</i>: In some languages, case conversion is a locale- and
--   context-dependent operation. The <tt>foldCase</tt> method is
--   <i>not</i> intended to be locale sensitive. Programs that require
--   locale sensitivity should use appropriate versions of the case mapping
--   functions from the <tt>text-icu</tt> package:
--   <a>http://hackage.haskell.org/package/text-icu</a>
class FoldCase s
foldCase :: FoldCase s => s -> s


-- | Provides an unsafe way to create a case insensitive string-like value.
module Data.CaseInsensitive.Unsafe

-- | Constructs a <a>CI</a> from an already case folded string-like value.
--   The given string is used both as the <a>original</a> as well as the
--   <a>foldedCase</a>.
--   
--   This function is unsafe since the compiler can't guarantee that the
--   provided string is case folded.
unsafeMk :: FoldCase s => s -> CI s
