/usr/share/doc/libghc-text-doc/html/Data-Text-Foreign.html is in libghc-text-doc 0.11.1.13-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Data.Text.Foreign</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Text-Foreign.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Data-Text-Foreign.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">text-0.11.1.13: An efficient packed Unicode text type.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>GHC</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>bos@serpentine.com, rtomharper@googlemail.com,
duncan@haskell.org</td></tr><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Data.Text.Foreign</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Interoperability with native code
</a></li><li><a href="#g:2">Safe conversion functions
</a></li><li><a href="#g:3">Unsafe conversion code
</a></li><li><a href="#g:4">Low-level manipulation
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Support for using <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> data with native code via the Haskell
foreign function interface.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:I16">I16</a> </li><li class="src short"><a href="#v:fromPtr">fromPtr</a> :: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a> -> <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="Data-Text-Internal.html#t:Text">Text</a></li><li class="src short"><a href="#v:useAsPtr">useAsPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a> -> <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:asForeignPtr">asForeignPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a>, <a href="Data-Text-Foreign.html#t:I16">I16</a>)</li><li class="src short"><a href="#v:lengthWord16">lengthWord16</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><a href="#v:unsafeCopyToPtr">unsafeCopyToPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc-doc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:dropWord16">dropWord16</a> :: <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a></li><li class="src short"><a href="#v:takeWord16">takeWord16</a> :: <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a></li></ul></div><div id="interface"><h1 id="g:1">Interoperability with native code
</h1><div class="doc"><p>The <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> type is implemented using arrays that are not guaranteed
to have a fixed address in the Haskell heap. All communication with
native code must thus occur by copying data back and forth.
</p><p>The <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> type's internal representation is UTF-16, using the
platform's native endianness. This makes copied data suitable for
use with native libraries that use a similar representation, such
as ICU. To interoperate with native libraries that use different
internal representations, such as UTF-8 or UTF-32, consider using
the functions in the <code><a href="Data-Text.html#t:Encoding">Encoding</a></code> module.
</p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:I16" class="def">I16</a> <a href="src/Data-Text-Foreign.html#I16" class="link">Source</a></p><div class="doc"><p>A type representing a number of UTF-16 code units.
</p></div><div class="subs instances"><p id="control.i:I16" class="caption collapser" onclick="toggleSection('i:I16')">Instances</p><div id="section.i:I16" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Prelude.html#t:Bounded">Bounded</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Prelude.html#t:Enum">Enum</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Eq.html#t:Eq">Eq</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Prelude.html#t:Integral">Integral</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Prelude.html#t:Num">Num</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Ord.html#t:Ord">Ord</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Text-Read.html#t:Read">Read</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Prelude.html#t:Real">Real</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Text-Show.html#t:Show">Show</a> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:2">Safe conversion functions
</h1><div class="top"><p class="src"><a name="v:fromPtr" class="def">fromPtr</a><a href="src/Data-Text-Foreign.html#fromPtr" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></td><td class="doc"><p>source array
</p></td></tr><tr><td class="src">-> <a href="Data-Text-Foreign.html#t:I16">I16</a></td><td class="doc"><p>length of source array (in <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> units)
</p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="Data-Text-Internal.html#t:Text">Text</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p><em>O(n)</em> Create a new <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> from a <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a></code> <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> by copying the
contents of the array.
</p></div></div><div class="top"><p class="src"><a name="v:useAsPtr" class="def">useAsPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a> -> <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a) -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a<a href="src/Data-Text-Foreign.html#useAsPtr" class="link">Source</a></p><div class="doc"><p><em>O(n)</em> Perform an action on a temporary, mutable copy of a
<code><a href="Data-Text-Internal.html#t:Text">Text</a></code>. The copy is freed as soon as the action returns.
</p></div></div><div class="top"><p class="src"><a name="v:asForeignPtr" class="def">asForeignPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a>, <a href="Data-Text-Foreign.html#t:I16">I16</a>)<a href="src/Data-Text-Foreign.html#asForeignPtr" class="link">Source</a></p><div class="doc"><p><em>O(n)</em> Make a mutable copy of a <code><a href="Data-Text-Internal.html#t:Text">Text</a></code>.
</p></div></div><h1 id="g:3">Unsafe conversion code
</h1><div class="top"><p class="src"><a name="v:lengthWord16" class="def">lengthWord16</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a><a href="src/Data-Text-Unsafe.html#lengthWord16" class="link">Source</a></p><div class="doc"><p><em>O(1)</em> Return the length of a <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> in units of <code>Word16</code>. This
is useful for sizing a target array appropriately before using
<code>unsafeCopyToPtr</code>.
</p></div></div><div class="top"><p class="src"><a name="v:unsafeCopyToPtr" class="def">unsafeCopyToPtr</a> :: <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Foreign-Ptr.html#t:Ptr">Ptr</a> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a> -> <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc-doc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Data-Text-Foreign.html#unsafeCopyToPtr" class="link">Source</a></p><div class="doc"><p><em>O(n)</em> Copy a <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> to an array. The array is assumed to be big
enough to hold the contents of the entire <code><a href="Data-Text-Internal.html#t:Text">Text</a></code>.
</p></div></div><h1 id="g:4">Low-level manipulation
</h1><div class="doc"><p>Foreign functions that use UTF-16 internally may return indices in
units of <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> instead of characters. These functions may
safely be used with such indices, as they will adjust offsets if
necessary to preserve the validity of a Unicode string.
</p></div><div class="top"><p class="src"><a name="v:dropWord16" class="def">dropWord16</a> :: <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a><a href="src/Data-Text-Foreign.html#dropWord16" class="link">Source</a></p><div class="doc"><p><em>O(1)</em> Return the suffix of the <code><a href="Data-Text-Internal.html#t:Text">Text</a></code>, with <code>n</code> <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> units
dropped from its beginning.
</p><p>If <code>n</code> would cause the <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> to begin inside a surrogate pair, the
beginning of the suffix will be advanced by one additional <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code>
unit to maintain its validity.
</p></div></div><div class="top"><p class="src"><a name="v:takeWord16" class="def">takeWord16</a> :: <a href="Data-Text-Foreign.html#t:I16">I16</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a> -> <a href="Data-Text-Internal.html#t:Text">Text</a><a href="src/Data-Text-Foreign.html#takeWord16" class="link">Source</a></p><div class="doc"><p><em>O(1)</em> Return the prefix of the <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> of <code>n</code> <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> units in
length.
</p><p>If <code>n</code> would cause the <code><a href="Data-Text-Internal.html#t:Text">Text</a></code> to end inside a surrogate pair, the
end of the prefix will be advanced by one additional <code><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.5.0.0/Data-Word.html#t:Word16">Word16</a></code> unit
to maintain its validity.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>
|