This file is indexed.

/usr/share/doc/libghc-mmap-doc/html/System-IO-MMap.html is in libghc-mmap-doc 0.5.9-5build1.

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!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>System.IO.MMap</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_System-IO-MMap.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/System-IO-MMap.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">mmap-0.5.9: Memory mapped files for POSIX and Windows</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) Gracjan Polak 2009</td></tr><tr><th>License</th><td>BSD-style</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">System.IO.MMap</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Mapping mode</a></li><li><a href="#g:2">Memory mapped files strict interface</a></li><li><a href="#g:3">Memory mapped files lazy interface</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This library provides a wrapper to mmap(2) or MapViewOfFile,
 allowing files or devices to be lazily loaded into memory as strict
 or lazy ByteStrings, ForeignPtrs or plain Ptrs, using the virtual
 memory subsystem to do on-demand loading.  Modifications are also
 supported.</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:Mode">Mode</a><ul class="subs"><li>= <a href="#v:ReadOnly">ReadOnly</a></li><li>| <a href="#v:ReadWrite">ReadWrite</a></li><li>| <a href="#v:WriteCopy">WriteCopy</a></li><li>| <a href="#v:ReadWriteEx">ReadWriteEx</a></li></ul></li><li class="src short"><a href="#v:mmapFilePtr">mmapFilePtr</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</li><li class="src short"><a href="#v:mmapWithFilePtr">mmapWithFilePtr</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> (), <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:mmapFileForeignPtr">mmapFileForeignPtr</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</li><li class="src short"><a href="#v:mmapFileByteString">mmapFileByteString</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:munmapFilePtr">munmapFilePtr</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:mmapFileForeignPtrLazy">mmapFileForeignPtrLazy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)]</li><li class="src short"><a href="#v:mmapFileByteStringLazy">mmapFileByteStringLazy</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="doc"><p>This module is an interface to <code>mmap(2)</code> system call under POSIX
 (Unix, Linux, Mac OS X) and <code>CreateFileMapping</code>, <code>MapViewOfFile</code> under
 Windows.</p><p>We can consider mmap as lazy IO pushed into the virtual memory
 subsystem.</p><p>It is only safe to mmap a file if you know you are the sole
 user. Otherwise referential transparency may be or may be not
 compromised. Sadly semantics differ much between operating systems.</p><p>In case of IO errors all function use <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-C-Error.html#v:throwErrno">throwErrno</a></code> or <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-C-Error.html#v:throwErrnoPath">throwErrnoPath</a></code>.</p><p>In case of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a></code> or <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a></code> functions the storage
 manager is used to free the mapped memory. When the garbage
 collector notices there are no further references to the mapped
 memory, a call to <code>munmap</code> is made. It is not necessary to do this
 yourself. In tight memory situations it may be profitable to use
 <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-Mem.html#v:performGC">performGC</a></code> or <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#v:finalizeForeignPtr">finalizeForeignPtr</a></code> to force an unmap
 action. You can also use <code><a href="System-IO-MMap.html#v:mmapWithFilePtr">mmapWithFilePtr</a></code> that uses scope based
 resource allocation.</p><p>To free resources returned as Ptr use <code><a href="System-IO-MMap.html#v:munmapFilePtr">munmapFilePtr</a></code>.</p><p>For modes <code><a href="System-IO-MMap.html#v:ReadOnly">ReadOnly</a></code>, <code><a href="System-IO-MMap.html#v:ReadWrite">ReadWrite</a></code> and <code><a href="System-IO-MMap.html#v:WriteCopy">WriteCopy</a></code> file must exist
 before mapping it into memory. It also needs to have correct
 permissions for reading and/or writing (depending on mode). In
 <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> the file will be created with default permissions if
 it does not exist.</p><p>If mode is <code><a href="System-IO-MMap.html#v:ReadWrite">ReadWrite</a></code>, <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> or <code><a href="System-IO-MMap.html#v:WriteCopy">WriteCopy</a></code> the returned
 memory region may be written to with <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Storable.html#v:poke">poke</a></code> and
 friends. In <code><a href="System-IO-MMap.html#v:WriteCopy">WriteCopy</a></code> mode changes will not be written to disk.
 It is an error to modify mapped memory in <code><a href="System-IO-MMap.html#v:ReadOnly">ReadOnly</a></code> mode. If is
 undefined if and how changes from external changes affect your
 mmapped regions, they may reflect in your memory or may not and
 this note applies equally to all modes.</p><p>Range specified may be <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#v:Nothing">Nothing</a></code>, in this case whole file will be
 mapped. Otherwise range should be 'Just (offset,size)' where
 offsets is the beginning byte of file region to map and size tells
 mapping length. There are no alignment requirements. Returned Ptr or
 ForeignPtr will be aligned to page size boundary and you'll be
 given offset to your data. Both <code>offset</code> and <code>size</code> must be
 nonnegative.  Sum <code>offset + size</code> should not be greater than file
 length, except in <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> mode when file will be extended to
 cover whole range. We do allow <code>size</code> to be 0 and we do mmap files
 of 0 length. If your offset is 0 you are guaranteed to receive page
 aligned pointer back. You are required to give explicit range in
 case of <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> even if the file exists.</p><p>File extension in <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> mode seems to use sparse files
 whenever supported by oprating system and therefore returns
 immediatelly as postpones real block allocation for later.</p><p>For more details about mmap and its consequences see:</p><ul><li><a href="http://opengroup.org/onlinepubs/009695399/functions/mmap.html">http://opengroup.org/onlinepubs/009695399/functions/mmap.html</a></li><li><a href="http://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html">http://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html</a></li><li><a href="http://msdn2.microsoft.com/en-us/library/aa366781(VS.85).aspx">http://msdn2.microsoft.com/en-us/library/aa366781(VS.85).aspx</a></li></ul><p>Questions and Answers</p><ul><li>Q: What happens if somebody writes to my mmapped file? A:
 Undefined. System is free to not synchronize write system call and
 mmap so nothing is sure. So this might be reflected in your memory
 or not.  This applies even in <code><a href="System-IO-MMap.html#v:WriteCopy">WriteCopy</a></code> mode.</li><li>Q: What happens if I map <code><a href="System-IO-MMap.html#v:ReadWrite">ReadWrite</a></code> and change memory? A: After
 some time in will be written to disk. It is unspecified when this
 happens.</li><li>Q: What if somebody removes my file? A: Undefined. File with
 mmapped region is treated by system as open file. Removing such
 file works the same way as removing open file and different systems
 have different ideas what to do in such case.</li><li>Q: Why can't I open my file for writting after mmaping it? A:
 File needs to be unmapped first. Either make sure you don't
 reference memory mapped regions and force garbage collection (this
 is hard to do) or better yet use mmaping with explicit memory
 management.</li><li>Q: Can I map region after end of file? A: You need to use
 <code><a href="System-IO-MMap.html#v:ReadWriteEx">ReadWriteEx</a></code> mode.</li></ul></div><h1 id="g:1">Mapping mode</h1><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Mode" class="def">Mode</a> <a href="src/System-IO-MMap.html#Mode" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></p><div class="doc"><p>Mode of mapping. Four cases are supported.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:ReadOnly" class="def">ReadOnly</a></td><td class="doc"><p>file is mapped read-only, file must
 exist</p></td></tr><tr><td class="src"><a id="v:ReadWrite" class="def">ReadWrite</a></td><td class="doc"><p>file is mapped read-write, file must
 exist</p></td></tr><tr><td class="src"><a id="v:WriteCopy" class="def">WriteCopy</a></td><td class="doc"><p>file is mapped read-write, but changes
 aren't propagated to disk, file must exist</p></td></tr><tr><td class="src"><a id="v:ReadWriteEx" class="def">ReadWriteEx</a></td><td class="doc"><p>file is mapped read-write, if file does
 not exist it will be created with default
 permissions, region parameter specifies
 size, if file size is lower it will be
 extended with zeros</p></td></tr></table></div><div class="subs instances"><p id="control.i:Mode" class="caption collapser" onclick="toggleSection('i:Mode')">Instances</p><div id="section.i:Mode" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Mode:Enum:1" class="instance expander" onclick="toggleSection('i:id:Mode:Enum:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Prelude.html#t:Enum">Enum</a> <a href="System-IO-MMap.html#t:Mode">Mode</a></span> <a href="src/System-IO-MMap.html#line-165" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Mode:Enum:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:succ">succ</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:succ" class="selflink">#</a></p><p class="src"><a href="#v:pred">pred</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:pred" class="selflink">#</a></p><p class="src"><a href="#v:toEnum">toEnum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:toEnum" class="selflink">#</a></p><p class="src"><a href="#v:fromEnum">fromEnum</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> <a href="#v:fromEnum" class="selflink">#</a></p><p class="src"><a href="#v:enumFrom">enumFrom</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:enumFrom" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThen">enumFromThen</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:enumFromThen" class="selflink">#</a></p><p class="src"><a href="#v:enumFromTo">enumFromTo</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:enumFromTo" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThenTo">enumFromThenTo</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:enumFromThenTo" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Mode:Eq:2" class="instance expander" onclick="toggleSection('i:id:Mode:Eq:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="System-IO-MMap.html#t:Mode">Mode</a></span> <a href="src/System-IO-MMap.html#line-165" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Mode:Eq:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Mode:Ord:3" class="instance expander" onclick="toggleSection('i:id:Mode:Ord:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Ord.html#t:Ord">Ord</a> <a href="System-IO-MMap.html#t:Mode">Mode</a></span> <a href="src/System-IO-MMap.html#line-165" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Mode:Ord:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Ord.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(&lt;)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(&lt;=)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(&gt;)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(&gt;=)</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62--61-" class="selflink">#</a></p><p class="src"><a href="#v:max">max</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:max" class="selflink">#</a></p><p class="src"><a href="#v:min">min</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:min" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Mode:Read:4" class="instance expander" onclick="toggleSection('i:id:Mode:Read:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Read.html#t:Read">Read</a> <a href="System-IO-MMap.html#t:Mode">Mode</a></span> <a href="src/System-IO-MMap.html#line-165" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Mode:Read:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="System-IO-MMap.html#t:Mode">Mode</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="System-IO-MMap.html#t:Mode">Mode</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Mode:Show:5" class="instance expander" onclick="toggleSection('i:id:Mode:Show:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:Show">Show</a> <a href="System-IO-MMap.html#t:Mode">Mode</a></span> <a href="src/System-IO-MMap.html#line-165" class="link">Source</a> <a href="#t:Mode" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Mode:Show:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="System-IO-MMap.html#t:Mode">Mode</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="System-IO-MMap.html#t:Mode">Mode</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h1 id="g:2">Memory mapped files strict interface</h1><div class="top"><p class="src"><a id="v:mmapFilePtr" class="def">mmapFilePtr</a> <a href="src/System-IO-MMap.html#mmapFilePtr" class="link">Source</a> <a href="#v:mmapFilePtr" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to mmap</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a></td><td class="doc"><p>access mode</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>(ptr,rawsize,offset,size)</p></td></tr></table></div><div class="doc"><p>The <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code> function maps a file or device into memory,
 returning a tuple <code>(ptr,rawsize,offset,size)</code> where:</p><ul><li><code>ptr</code> is pointer to mmapped region</li><li><code>rawsize</code> is length (in bytes) of mapped data, rawsize might be
 greater than size because of alignment</li><li><code>offset</code> tell where your data lives: <code>plusPtr ptr offset</code></li><li><code>size</code> your data length (in bytes)</li></ul><p>If <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code> fails for some reason, a <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-C-Error.html#v:throwErrno">throwErrno</a></code> is used.</p><p>Use <code>munmapFilePtr ptr rawsize</code> to unmap memory.</p><p>Memory mapped files will behave as if they were read lazily
 pages from the file will be loaded into memory on demand.</p></div></div><div class="top"><p class="src"><a id="v:mmapWithFilePtr" class="def">mmapWithFilePtr</a> <a href="src/System-IO-MMap.html#mmapWithFilePtr" class="link">Source</a> <a href="#v:mmapWithFilePtr" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to mmap</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a></td><td class="doc"><p>access mode</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> (), <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc"><p>action to run</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> a</td><td class="doc"><p>result of action</p></td></tr></table></div><div class="doc"><p>Memory map region of file using autounmap semantics. See
 <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code> for description of parameters.  The <code>action</code> will be
 executed with tuple <code>(ptr,size)</code> as single argument. This is the
 pointer to mapped data already adjusted and size of requested
 region. Return value is that of action.</p></div></div><div class="top"><p class="src"><a id="v:mmapFileForeignPtr" class="def">mmapFileForeignPtr</a> <a href="src/System-IO-MMap.html#mmapFileForeignPtr" class="link">Source</a> <a href="#v:mmapFileForeignPtr" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to map</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a></td><td class="doc"><p>access mode</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>foreign pointer to beginning of raw region,
 offset to your data and size of your data</p></td></tr></table></div><div class="doc"><p>Maps region of file and returns it as <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a></code>. See <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code> for details.</p></div></div><div class="top"><p class="src"><a id="v:mmapFileByteString" class="def">mmapFileByteString</a> <a href="src/System-IO-MMap.html#mmapFileByteString" class="link">Source</a> <a href="#v:mmapFileByteString" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to map</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a></td><td class="doc"><p>bytestring with file contents</p></td></tr></table></div><div class="doc"><p>Maps region of file and returns it as <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html#t:ByteString">ByteString</a></code>.  File is
 mapped in in <code><a href="System-IO-MMap.html#v:ReadOnly">ReadOnly</a></code> mode. See <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code> for details.</p></div></div><div class="top"><p class="src"><a id="v:munmapFilePtr" class="def">munmapFilePtr</a> <a href="src/System-IO-MMap.html#munmapFilePtr" class="link">Source</a> <a href="#v:munmapFilePtr" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-Ptr.html#t:Ptr">Ptr</a> a</td><td class="doc"><p>pointer</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc"><p>rawsize</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Unmaps memory region. As parameters use values marked as ptr and
 rawsize in description of <code><a href="System-IO-MMap.html#v:mmapFilePtr">mmapFilePtr</a></code>.</p></div></div><h1 id="g:3">Memory mapped files lazy interface</h1><div class="top"><p class="src"><a id="v:mmapFileForeignPtrLazy" class="def">mmapFileForeignPtrLazy</a> <a href="src/System-IO-MMap.html#mmapFileForeignPtrLazy" class="link">Source</a> <a href="#v:mmapFileForeignPtrLazy" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to mmap</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-MMap.html#t:Mode">Mode</a></td><td class="doc"><p>access mode</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> [(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Foreign-ForeignPtr.html#t:ForeignPtr">ForeignPtr</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int">Int</a>)]</td><td class="doc"><p>(ptr,offset,size)</p></td></tr></table></div><div class="doc"><p>The <code><a href="System-IO-MMap.html#v:mmapFileForeignPtrLazy">mmapFileForeignPtrLazy</a></code> function maps a file or device into
 memory, returning a list of tuples with the same meaning as in
 function <code><a href="System-IO-MMap.html#v:mmapFileForeignPtr">mmapFileForeignPtr</a></code>.</p><p>Chunks are really mapped into memory at the first inspection of a
 chunk. They are kept in memory while they are referenced, garbage
 collector takes care of the later.</p></div></div><div class="top"><p class="src"><a id="v:mmapFileByteStringLazy" class="def">mmapFileByteStringLazy</a> <a href="src/System-IO-MMap.html#mmapFileByteStringLazy" class="link">Source</a> <a href="#v:mmapFileByteStringLazy" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>name of file to map</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Maybe.html#t:Maybe">Maybe</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Int.html#t:Int64">Int64</a>)</td><td class="doc"><p>range to map, maps whole file if Nothing</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></td><td class="doc"><p>bytestring with file content</p></td></tr></table></div><div class="doc"><p>Maps region of file and returns it as <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></code>. File is
 mapped in in <code><a href="System-IO-MMap.html#v:ReadOnly">ReadOnly</a></code> mode. See <code><a href="System-IO-MMap.html#v:mmapFileForeignPtrLazy">mmapFileForeignPtrLazy</a></code> for
 details.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>