/usr/share/doc/libghc-streaming-commons-doc/html/streaming-commons.txt is in libghc-streaming-commons-doc 0.1.15-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 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Common lower-level functions needed by various streaming data libraries
--
-- Provides low-dependency functionality commonly needed by various
-- streaming data libraries, such as conduit and pipes.
@package streaming-commons
@version 0.1.15
module Data.Streaming.Zlib.Lowlevel
data ZStreamStruct
type ZStream' = Ptr ZStreamStruct
zstreamNew :: IO ZStream'
data Strategy
StrategyDefault :: Strategy
StrategyFiltered :: Strategy
StrategyHuffman :: Strategy
StrategyRLE :: Strategy
StrategyFixed :: Strategy
deflateInit2 :: ZStream' -> Int -> WindowBits -> Int -> Strategy -> IO ()
inflateInit2 :: ZStream' -> WindowBits -> IO ()
c_free_z_stream_inflate :: FunPtr (ZStream' -> IO ())
c_free_z_stream_deflate :: FunPtr (ZStream' -> IO ())
c_set_avail_in :: ZStream' -> Ptr CChar -> CUInt -> IO ()
c_set_avail_out :: ZStream' -> Ptr CChar -> CUInt -> IO ()
c_get_avail_out :: ZStream' -> IO CUInt
c_get_avail_in :: ZStream' -> IO CUInt
c_get_next_in :: ZStream' -> IO (Ptr CChar)
c_call_inflate_noflush :: ZStream' -> IO CInt
c_call_deflate_noflush :: ZStream' -> IO CInt
c_call_deflate_finish :: ZStream' -> IO CInt
c_call_deflate_flush :: ZStream' -> IO CInt
c_call_deflate_full_flush :: ZStream' -> IO CInt
c_call_deflate_set_dictionary :: ZStream' -> Ptr CChar -> CUInt -> IO ()
c_call_inflate_set_dictionary :: ZStream' -> Ptr CChar -> CUInt -> IO ()
instance GHC.Enum.Enum Data.Streaming.Zlib.Lowlevel.Strategy
instance GHC.Classes.Ord Data.Streaming.Zlib.Lowlevel.Strategy
instance GHC.Classes.Eq Data.Streaming.Zlib.Lowlevel.Strategy
instance GHC.Show.Show Data.Streaming.Zlib.Lowlevel.Strategy
-- | This is a middle-level wrapper around the zlib C API. It allows you to
-- work fully with bytestrings and not touch the FFI at all, but is still
-- low-level enough to allow you to implement high-level abstractions
-- such as enumerators. Significantly, it does not use lazy IO.
--
-- You'll probably need to reference the docs a bit to understand the
-- WindowBits parameters below, but a basic rule of thumb is 15 is for
-- zlib compression, and 31 for gzip compression.
--
-- A simple streaming compressor in pseudo-code would look like:
--
-- <pre>
-- def <- initDeflate ...
-- popper <- feedDeflate def rawContent
-- pullPopper popper
-- ...
-- finishDeflate def sendCompressedData
-- </pre>
--
-- You can see a more complete example is available in the included
-- file-test.hs.
module Data.Streaming.Zlib
-- | The state of an inflation (eg, decompression) process. All allocated
-- memory is automatically reclaimed by the garbage collector. Also can
-- contain the inflation dictionary that is used for decompression.
data Inflate
-- | Initialize an inflation process with the given <a>WindowBits</a>. You
-- will need to call <a>feedInflate</a> to feed compressed data to this
-- and <a>finishInflate</a> to extract the final chunk of decompressed
-- data.
initInflate :: WindowBits -> IO Inflate
-- | Initialize an inflation process with the given <a>WindowBits</a>.
-- Unlike initInflate a dictionary for inflation is set which must match
-- the one set during compression.
initInflateWithDictionary :: WindowBits -> ByteString -> IO Inflate
-- | Feed the given <a>ByteString</a> to the inflater. Return a
-- <a>Popper</a>, an IO action that returns the decompressed data a chunk
-- at a time. The <a>Popper</a> must be called to exhaustion before using
-- the <a>Inflate</a> object again.
--
-- Note that this function automatically buffers the output to
-- <a>defaultChunkSize</a>, and therefore you won't get any data from the
-- popper until that much decompressed data is available. After you have
-- fed all of the compressed data to this function, you can extract your
-- final chunk of decompressed data using <a>finishInflate</a>.
feedInflate :: Inflate -> ByteString -> IO Popper
-- | As explained in <a>feedInflate</a>, inflation buffers your
-- decompressed data. After you call <a>feedInflate</a> with your last
-- chunk of compressed data, you will likely have some data still sitting
-- in the buffer. This function will return it to you.
finishInflate :: Inflate -> IO ByteString
-- | Flush the inflation buffer. Useful for interactive application.
--
-- This is actually a synonym for <a>finishInflate</a>. It is provided
-- for its more semantic name.
--
-- Since 0.0.3
flushInflate :: Inflate -> IO ByteString
-- | Retrieve any data remaining after inflating. For more information on
-- motivation, see:
--
-- <a>https://github.com/fpco/streaming-commons/issues/20</a>
--
-- Since 0.1.11
getUnusedInflate :: Inflate -> IO ByteString
-- | The state of a deflation (eg, compression) process. All allocated
-- memory is automatically reclaimed by the garbage collector.
data Deflate
-- | Initialize a deflation process with the given compression level and
-- <a>WindowBits</a>. You will need to call <a>feedDeflate</a> to feed
-- uncompressed data to this and <a>finishDeflate</a> to extract the
-- final chunks of compressed data.
initDeflate :: Int -> WindowBits -> IO Deflate
-- | Initialize an deflation process with the given compression level and
-- <a>WindowBits</a>. Unlike initDeflate a dictionary for deflation is
-- set.
initDeflateWithDictionary :: Int -> ByteString -> WindowBits -> IO Deflate
-- | Feed the given <a>ByteString</a> to the deflater. Return a
-- <a>Popper</a>, an IO action that returns the compressed data a chunk
-- at a time. The <a>Popper</a> must be called to exhaustion before using
-- the <a>Deflate</a> object again.
--
-- Note that this function automatically buffers the output to
-- <a>defaultChunkSize</a>, and therefore you won't get any data from the
-- popper until that much compressed data is available. After you have
-- fed all of the decompressed data to this function, you can extract
-- your final chunks of compressed data using <a>finishDeflate</a>.
feedDeflate :: Deflate -> ByteString -> IO Popper
-- | As explained in <a>feedDeflate</a>, deflation buffers your compressed
-- data. After you call <a>feedDeflate</a> with your last chunk of
-- uncompressed data, use this to flush the rest of the data and signal
-- end of input.
finishDeflate :: Deflate -> Popper
-- | Flush the deflation buffer. Useful for interactive application.
-- Internally this passes Z_SYNC_FLUSH to the zlib library.
--
-- Unlike <a>finishDeflate</a>, <a>flushDeflate</a> does not signal end
-- of input, meaning you can feed more uncompressed data afterward.
--
-- Since 0.0.3
flushDeflate :: Deflate -> Popper
-- | Full flush the deflation buffer. Useful for interactive applications
-- where previously streamed data may not be available. Using
-- <a>fullFlushDeflate</a> too often can seriously degrade compression.
-- Internally this passes Z_FULL_FLUSH to the zlib library.
--
-- Like <a>flushDeflate</a>, <a>fullFlushDeflate</a> does not signal end
-- of input, meaning you can feed more uncompressed data afterward.
--
-- Since 0.1.5
fullFlushDeflate :: Deflate -> Popper
-- | This specifies the size of the compression window. Larger values of
-- this parameter result in better compression at the expense of higher
-- memory usage.
--
-- The compression window size is the value of the the window bits raised
-- to the power 2. The window bits must be in the range <tt>8..15</tt>
-- which corresponds to compression window sizes of 256b to 32Kb. The
-- default is 15 which is also the maximum size.
--
-- The total amount of memory used depends on the window bits and the
-- <a>MemoryLevel</a>. See the <a>MemoryLevel</a> for the details.
data WindowBits :: *
WindowBits :: Int -> WindowBits
-- | The default <a>WindowBits</a> is 15 which is also the maximum size.
defaultWindowBits :: WindowBits
-- | Exception that can be thrown from the FFI code. The parameter is the
-- numerical error code from the zlib library. Quoting the zlib.h file
-- directly:
--
-- <ul>
-- <li>#define Z_OK 0</li>
-- <li>#define Z_STREAM_END 1</li>
-- <li>#define Z_NEED_DICT 2</li>
-- <li>#define Z_ERRNO (-1)</li>
-- <li>#define Z_STREAM_ERROR (-2)</li>
-- <li>#define Z_DATA_ERROR (-3)</li>
-- <li>#define Z_MEM_ERROR (-4)</li>
-- <li>#define Z_BUF_ERROR (-5)</li>
-- <li>#define Z_VERSION_ERROR (-6)</li>
-- </ul>
data ZlibException
ZlibException :: Int -> ZlibException
-- | An IO action that returns the next chunk of data, returning
-- <a>Nothing</a> when there is no more data to be popped.
type Popper = IO PopperRes
data PopperRes
PRDone :: PopperRes
PRNext :: !ByteString -> PopperRes
PRError :: !ZlibException -> PopperRes
instance GHC.Show.Show Data.Streaming.Zlib.PopperRes
instance GHC.Show.Show Data.Streaming.Zlib.ZlibException
instance GHC.Exception.Exception Data.Streaming.Zlib.ZlibException
module Data.Streaming.Process.Internal
-- | Wraps up the standard <tt>ProcessHandle</tt> to avoid the
-- <tt>waitForProcess</tt> deadlock. See the linked documentation from
-- the module header for more information.
--
-- Since 0.1.4
data StreamingProcessHandle
StreamingProcessHandle :: ProcessHandle -> (TMVar ExitCode) -> StreamingProcessHandle
-- | Class for all things which can be used to provide standard input.
--
-- Since 0.1.4
class InputSource a
isStdStream :: InputSource a => (Maybe Handle -> IO a, Maybe StdStream)
-- | Class for all things which can be used to consume standard output or
-- error.
--
-- Since 0.1.4
class OutputSink a
osStdStream :: OutputSink a => (Maybe Handle -> IO a, Maybe StdStream)
instance Data.Streaming.Process.Internal.InputSource GHC.IO.Handle.Types.Handle
instance Data.Streaming.Process.Internal.OutputSink GHC.IO.Handle.Types.Handle
-- | A full tutorial for this module is available on FP School of Haskell:
-- <a>https://www.fpcomplete.com/user/snoyberg/library-documentation/data-conduit-process</a>.
--
-- Note that, while the tutorial covers <tt>Data.Streaming.Process</tt>,
-- this module is the basis of the streaming version, and almost all
-- concepts there apply here.
module Data.Streaming.Process
-- | The primary function for running a process. Note that, with the
-- exception of <a>UseProvidedHandle</a>, the values for <tt>std_in</tt>,
-- <tt>std_out</tt> and <tt>std_err</tt> will be ignored by this
-- function.
--
-- Since 0.1.4
streamingProcess :: (MonadIO m, InputSource stdin, OutputSink stdout, OutputSink stderr) => CreateProcess -> m (stdin, stdout, stderr, StreamingProcessHandle)
-- | Inherit the stream from the current process.
--
-- Since 0.1.4
data Inherited
Inherited :: Inherited
-- | Close the stream with the child process.
--
-- Since 0.1.4
data ClosedStream
ClosedStream :: ClosedStream
-- | Use the <tt>Handle</tt> provided by the <tt>CreateProcess</tt> value.
-- This would allow you, for example, to open up a <tt>Handle</tt> to a
-- file, set it as <tt>std_out</tt>, and avoid any additional overhead of
-- dealing with providing that data to your process.
--
-- Since 0.1.4
data UseProvidedHandle
UseProvidedHandle :: UseProvidedHandle
-- | Wraps up the standard <tt>ProcessHandle</tt> to avoid the
-- <tt>waitForProcess</tt> deadlock. See the linked documentation from
-- the module header for more information.
--
-- Since 0.1.4
data StreamingProcessHandle
-- | Blocking call to wait for a process to exit.
--
-- Since 0.1.4
waitForStreamingProcess :: MonadIO m => StreamingProcessHandle -> m ExitCode
-- | STM version of <tt>waitForStreamingProcess</tt>.
--
-- Since 0.1.4
waitForStreamingProcessSTM :: StreamingProcessHandle -> STM ExitCode
-- | Non-blocking call to check for a process exit code.
--
-- Since 0.1.4
getStreamingProcessExitCode :: MonadIO m => StreamingProcessHandle -> m (Maybe ExitCode)
-- | STM version of <tt>getStreamingProcessExitCode</tt>.
--
-- Since 0.1.4
getStreamingProcessExitCodeSTM :: StreamingProcessHandle -> STM (Maybe ExitCode)
-- | Get the raw <tt>ProcessHandle</tt> from a
-- <tt>StreamingProcessHandle</tt>. Note that you should avoid using this
-- to get the process exit code, and instead use the provided functions.
--
-- Since 0.1.4
streamingProcessHandleRaw :: StreamingProcessHandle -> ProcessHandle
-- | Get the <tt>TMVar</tt> storing the process exit code. In general, one
-- of the above functions should be used instead to avoid accidentally
-- corrupting the variable's state..
--
-- Since 0.1.4
streamingProcessHandleTMVar :: StreamingProcessHandle -> TMVar ExitCode
-- | Class for all things which can be used to provide standard input.
--
-- Since 0.1.4
class InputSource a
-- | Class for all things which can be used to consume standard output or
-- error.
--
-- Since 0.1.4
class OutputSink a
-- | Run a process and supply its streams to the given callback function.
-- After the callback completes, wait for the process to complete and
-- check its exit code. If the exit code is not a success, throw a
-- <a>ProcessExitedUnsuccessfully</a>.
--
-- Since 0.1.7
withCheckedProcess :: (InputSource stdin, OutputSink stderr, OutputSink stdout, MonadIO m) => CreateProcess -> (stdin -> stdout -> stderr -> m b) -> m b
-- | Indicates that a process exited with an non-success exit code.
--
-- Since 0.1.7
data ProcessExitedUnsuccessfully
ProcessExitedUnsuccessfully :: CreateProcess -> ExitCode -> ProcessExitedUnsuccessfully
instance Data.Streaming.Process.Internal.InputSource Data.Streaming.Process.ClosedStream
instance Data.Streaming.Process.Internal.InputSource Data.Streaming.Process.Inherited
instance Data.Streaming.Process.Internal.InputSource Data.Streaming.Process.UseProvidedHandle
instance Data.Streaming.Process.Internal.OutputSink Data.Streaming.Process.ClosedStream
instance Data.Streaming.Process.Internal.OutputSink Data.Streaming.Process.Inherited
instance Data.Streaming.Process.Internal.OutputSink Data.Streaming.Process.UseProvidedHandle
instance GHC.Show.Show Data.Streaming.Process.ProcessExitedUnsuccessfully
instance GHC.Exception.Exception Data.Streaming.Process.ProcessExitedUnsuccessfully
module Data.Streaming.Network.Internal
-- | Settings for a TCP server. It takes a port to listen on, and an
-- optional hostname to bind to.
data ServerSettings
ServerSettings :: !Int -> !HostPreference -> !(Maybe Socket) -> !(Socket -> IO ()) -> !Bool -> !Int -> ServerSettings
[serverPort] :: ServerSettings -> !Int
[serverHost] :: ServerSettings -> !HostPreference
-- | listening socket
[serverSocket] :: ServerSettings -> !(Maybe Socket)
[serverAfterBind] :: ServerSettings -> !(Socket -> IO ())
[serverNeedLocalAddr] :: ServerSettings -> !Bool
[serverReadBufferSize] :: ServerSettings -> !Int
-- | Settings for a TCP client, specifying how to connect to the server.
data ClientSettings
ClientSettings :: !Int -> !ByteString -> !Family -> !Int -> ClientSettings
[clientPort] :: ClientSettings -> !Int
[clientHost] :: ClientSettings -> !ByteString
[clientAddrFamily] :: ClientSettings -> !Family
[clientReadBufferSize] :: ClientSettings -> !Int
-- | Which host to bind.
--
-- Note: The <tt>IsString</tt> instance recognizes the following special
-- values:
--
-- <ul>
-- <li><tt>*</tt> means <tt>HostAny</tt></li>
-- <li><tt>*4</tt> means <tt>HostIPv4</tt></li>
-- <li><tt>!4</tt> means <tt>HostIPv4Only</tt></li>
-- <li><tt>*6</tt> means <tt>HostIPv6</tt></li>
-- <li><tt>!6</tt> means <tt>HostIPv6Only</tt></li>
-- </ul>
--
-- Any other values is treated as a hostname. As an example, to bind to
-- the IPv4 local host only, use "127.0.0.1".
data HostPreference
HostAny :: HostPreference
HostIPv4 :: HostPreference
HostIPv4Only :: HostPreference
HostIPv6 :: HostPreference
HostIPv6Only :: HostPreference
Host :: String -> HostPreference
-- | Representation of a single UDP message
data Message
Message :: {-# UNPACK #-} !ByteString -> !SockAddr -> Message
[msgData] :: Message -> {-# UNPACK #-} !ByteString
[msgSender] :: Message -> !SockAddr
-- | The data passed to an <tt>Application</tt>.
data AppData
AppData :: !(IO ByteString) -> !(ByteString -> IO ()) -> !SockAddr -> !(Maybe SockAddr) -> !(IO ()) -> Maybe Socket -> AppData
[appRead'] :: AppData -> !(IO ByteString)
[appWrite'] :: AppData -> !(ByteString -> IO ())
[appSockAddr'] :: AppData -> !SockAddr
[appLocalAddr'] :: AppData -> !(Maybe SockAddr)
[appCloseConnection'] :: AppData -> !(IO ())
[appRawSocket'] :: AppData -> Maybe Socket
-- | Settings for a Unix domain sockets server.
data ServerSettingsUnix
ServerSettingsUnix :: !FilePath -> !(Socket -> IO ()) -> !Int -> ServerSettingsUnix
[serverPath] :: ServerSettingsUnix -> !FilePath
[serverAfterBindUnix] :: ServerSettingsUnix -> !(Socket -> IO ())
[serverReadBufferSizeUnix] :: ServerSettingsUnix -> !Int
-- | Settings for a Unix domain sockets client.
data ClientSettingsUnix
ClientSettingsUnix :: !FilePath -> !Int -> ClientSettingsUnix
[clientPath] :: ClientSettingsUnix -> !FilePath
[clientReadBufferSizeUnix] :: ClientSettingsUnix -> !Int
-- | The data passed to a Unix domain sockets <tt>Application</tt>.
data AppDataUnix
AppDataUnix :: !(IO ByteString) -> !(ByteString -> IO ()) -> AppDataUnix
[appReadUnix] :: AppDataUnix -> !(IO ByteString)
[appWriteUnix] :: AppDataUnix -> !(ByteString -> IO ())
instance GHC.Read.Read Data.Streaming.Network.Internal.HostPreference
instance GHC.Show.Show Data.Streaming.Network.Internal.HostPreference
instance GHC.Classes.Ord Data.Streaming.Network.Internal.HostPreference
instance GHC.Classes.Eq Data.Streaming.Network.Internal.HostPreference
instance Data.String.IsString Data.Streaming.Network.Internal.HostPreference
module Data.Streaming.Network
-- | Settings for a TCP server. It takes a port to listen on, and an
-- optional hostname to bind to.
data ServerSettings
-- | Settings for a TCP client, specifying how to connect to the server.
data ClientSettings
-- | Which host to bind.
--
-- Note: The <tt>IsString</tt> instance recognizes the following special
-- values:
--
-- <ul>
-- <li><tt>*</tt> means <tt>HostAny</tt></li>
-- <li><tt>*4</tt> means <tt>HostIPv4</tt></li>
-- <li><tt>!4</tt> means <tt>HostIPv4Only</tt></li>
-- <li><tt>*6</tt> means <tt>HostIPv6</tt></li>
-- <li><tt>!6</tt> means <tt>HostIPv6Only</tt></li>
-- </ul>
--
-- Any other values is treated as a hostname. As an example, to bind to
-- the IPv4 local host only, use "127.0.0.1".
data HostPreference
-- | Representation of a single UDP message
data Message
Message :: {-# UNPACK #-} !ByteString -> !SockAddr -> Message
[msgData] :: Message -> {-# UNPACK #-} !ByteString
[msgSender] :: Message -> !SockAddr
-- | The data passed to an <tt>Application</tt>.
data AppData
-- | Settings for a Unix domain sockets server.
data ServerSettingsUnix
-- | Settings for a Unix domain sockets client.
data ClientSettingsUnix
-- | The data passed to a Unix domain sockets <tt>Application</tt>.
data AppDataUnix
-- | Smart constructor.
serverSettingsTCP :: Int -> HostPreference -> ServerSettings
-- | Create a server settings that uses an already available listening
-- socket. Any port and host modifications made to this value will be
-- ignored.
--
-- Since 0.1.1
serverSettingsTCPSocket :: Socket -> ServerSettings
-- | Smart constructor.
clientSettingsTCP :: Int -> ByteString -> ClientSettings
-- | Smart constructor.
serverSettingsUDP :: Int -> HostPreference -> ServerSettings
-- | Smart constructor.
clientSettingsUDP :: Int -> ByteString -> ClientSettings
-- | Smart constructor.
serverSettingsUnix :: FilePath -> ServerSettingsUnix
-- | Smart constructor.
clientSettingsUnix :: FilePath -> ClientSettingsUnix
message :: ByteString -> SockAddr -> Message
class HasPort a
portLens :: (HasPort a, Functor f) => (Int -> f Int) -> a -> f a
class HasAfterBind a
afterBindLens :: (HasAfterBind a, Functor f) => ((Socket -> IO ()) -> f (Socket -> IO ())) -> a -> f a
class HasReadWrite a
readLens :: (HasReadWrite a, Functor f) => (IO ByteString -> f (IO ByteString)) -> a -> f a
writeLens :: (HasReadWrite a, Functor f) => ((ByteString -> IO ()) -> f (ByteString -> IO ())) -> a -> f a
-- | Since 0.1.13
class HasReadBufferSize a
readBufferSizeLens :: (HasReadBufferSize a, Functor f) => (Int -> f Int) -> a -> f a
class HasPath a
pathLens :: (HasPath a, Functor f) => (FilePath -> f FilePath) -> a -> f a
setPort :: HasPort a => Int -> a -> a
setHost :: ByteString -> ClientSettings -> ClientSettings
-- | Set the address family for the given settings.
--
-- Since 0.1.3
setAddrFamily :: Family -> ClientSettings -> ClientSettings
setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a
setNeedLocalAddr :: Bool -> ServerSettings -> ServerSettings
-- | Set buffer size used when reading from socket.
--
-- Since 0.1.13
setReadBufferSize :: HasReadBufferSize a => Int -> a -> a
setPath :: HasPath a => FilePath -> a -> a
getPort :: HasPort a => a -> Int
getHost :: ClientSettings -> ByteString
-- | Get the address family for the given settings.
--
-- Since 0.1.3
getAddrFamily :: ClientSettings -> Family
getAfterBind :: HasAfterBind a => a -> (Socket -> IO ())
getNeedLocalAddr :: ServerSettings -> Bool
-- | Get buffer size used when reading from socket.
--
-- Since 0.1.13
getReadBufferSize :: HasReadBufferSize a => a -> Int
getPath :: HasPath a => a -> FilePath
appRead :: HasReadWrite a => a -> IO ByteString
appWrite :: HasReadWrite a => a -> ByteString -> IO ()
appSockAddr :: AppData -> SockAddr
appLocalAddr :: AppData -> Maybe SockAddr
-- | Close the underlying connection. One possible use case is simulating
-- connection failures in a test suite.
--
-- Since 0.1.6
appCloseConnection :: AppData -> IO ()
-- | Get the raw socket for this <tt>AppData</tt>, if available.
--
-- Since 0.1.12
appRawSocket :: AppData -> Maybe Socket
-- | Attempt to bind a listening <tt>Socket</tt> on the given host/port
-- using given <tt>SocketType</tt>. If no host is given, will use the
-- first address available.
bindPortGen :: SocketType -> Int -> HostPreference -> IO Socket
-- | Bind to a random port number. Especially useful for writing network
-- tests.
--
-- This will attempt 30 different port numbers before giving up and
-- throwing an exception.
--
-- Since 0.1.1
bindRandomPortGen :: SocketType -> HostPreference -> IO (Int, Socket)
-- | Attempt to connect to the given host/port using given
-- <tt>SocketType</tt>.
getSocketGen :: SocketType -> String -> Int -> IO (Socket, AddrInfo)
-- | Attempt to connect to the given host<i>port</i>address family using
-- given <tt>SocketType</tt>.
--
-- Since 0.1.3
getSocketFamilyGen :: SocketType -> String -> Int -> Family -> IO (Socket, AddrInfo)
-- | Try to accept a connection, recovering automatically from exceptions.
--
-- As reported by Kazu against Warp, "resource exhausted (Too many open
-- files)" may be thrown by accept(). This function will catch that
-- exception, wait a second, and then try again.
acceptSafe :: Socket -> IO (Socket, SockAddr)
unassignedPorts :: UArray Int Int
-- | Get a port from the IANA list of unassigned ports.
--
-- Internally, this function uses an <tt>IORef</tt> to cycle through the
-- list of ports
getUnassignedPort :: IO Int
-- | Attempt to bind a listening <tt>Socket</tt> on the given host/port. If
-- no host is given, will use the first address available.
-- <tt>maxListenQueue</tt> is topically 128 which is too short for high
-- performance servers. So, we specify 'max 2048 maxListenQueue' to the
-- listen queue.
bindPortTCP :: Int -> HostPreference -> IO Socket
-- | Bind a random TCP port.
--
-- See <a>bindRandomPortGen</a>.
--
-- Since 0.1.1
bindRandomPortTCP :: HostPreference -> IO (Int, Socket)
-- | Attempt to connect to the given host/port.
getSocketTCP :: ByteString -> Int -> IO (Socket, SockAddr)
-- | Attempt to connect to the given host<i>port</i>address family.
--
-- Since 0.1.3
getSocketFamilyTCP :: ByteString -> Int -> Family -> IO (Socket, SockAddr)
safeRecv :: Socket -> Int -> IO ByteString
-- | Run an <tt>Application</tt> with the given settings. This function
-- will create a new listening socket, accept connections on it, and
-- spawn a new thread for each connection.
runTCPServer :: ServerSettings -> (AppData -> IO ()) -> IO a
-- | Run an <tt>Application</tt> by connecting to the specified server.
runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO a
type ConnectionHandle = Socket -> SockAddr -> Maybe SockAddr -> IO ()
runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO a
-- | Attempt to bind a listening <tt>Socket</tt> on the given host/port. If
-- no host is given, will use the first address available.
bindPortUDP :: Int -> HostPreference -> IO Socket
-- | Bind a random UDP port.
--
-- See <a>bindRandomPortGen</a>
--
-- Since 0.1.1
bindRandomPortUDP :: HostPreference -> IO (Int, Socket)
-- | Attempt to connect to the given host/port.
getSocketUDP :: String -> Int -> IO (Socket, AddrInfo)
-- | Attempt to bind a listening Unix domain socket at the given path.
bindPath :: FilePath -> IO Socket
-- | Attempt to connect to the given Unix domain socket path.
getSocketUnix :: FilePath -> IO Socket
-- | Run an <tt>Application</tt> with the given settings. This function
-- will create a new listening socket, accept connections on it, and
-- spawn a new thread for each connection.
runUnixServer :: ServerSettingsUnix -> (AppDataUnix -> IO ()) -> IO a
-- | Run an <tt>Application</tt> by connecting to the specified server.
runUnixClient :: ClientSettingsUnix -> (AppDataUnix -> IO a) -> IO a
instance Data.Streaming.Network.HasPort Data.Streaming.Network.Internal.ServerSettings
instance Data.Streaming.Network.HasPort Data.Streaming.Network.Internal.ClientSettings
instance Data.Streaming.Network.HasPath Data.Streaming.Network.Internal.ServerSettingsUnix
instance Data.Streaming.Network.HasPath Data.Streaming.Network.Internal.ClientSettingsUnix
instance Data.Streaming.Network.HasAfterBind Data.Streaming.Network.Internal.ServerSettings
instance Data.Streaming.Network.HasAfterBind Data.Streaming.Network.Internal.ServerSettingsUnix
instance Data.Streaming.Network.HasReadBufferSize Data.Streaming.Network.Internal.ServerSettings
instance Data.Streaming.Network.HasReadBufferSize Data.Streaming.Network.Internal.ClientSettings
instance Data.Streaming.Network.HasReadBufferSize Data.Streaming.Network.Internal.ServerSettingsUnix
instance Data.Streaming.Network.HasReadBufferSize Data.Streaming.Network.Internal.ClientSettingsUnix
instance Data.Streaming.Network.HasReadWrite Data.Streaming.Network.Internal.AppData
instance Data.Streaming.Network.HasReadWrite Data.Streaming.Network.Internal.AppDataUnix
-- | Streaming functions for interacting with the filesystem.
module Data.Streaming.Filesystem
data DirStream :: *
-- | <tt>openDirStream dir</tt> calls <tt>opendir</tt> to obtain a
-- directory stream for <tt>dir</tt>.
openDirStream :: FilePath -> IO DirStream
readDirStream :: DirStream -> IO (Maybe FilePath)
-- | <tt>closeDirStream dp</tt> calls <tt>closedir</tt> to close the
-- directory stream <tt>dp</tt>.
closeDirStream :: DirStream -> IO ()
data FileType
FTFile :: FileType
-- | symlink to file
FTFileSym :: FileType
FTDirectory :: FileType
-- | symlink to a directory
FTDirectorySym :: FileType
FTOther :: FileType
getFileType :: FilePath -> IO FileType
instance GHC.Classes.Ord Data.Streaming.Filesystem.FileType
instance GHC.Classes.Eq Data.Streaming.Filesystem.FileType
instance GHC.Read.Read Data.Streaming.Filesystem.FileType
instance GHC.Show.Show Data.Streaming.Filesystem.FileType
-- | The standard <tt>openFile</tt> call on Windows causing problematic
-- file locking in some cases. This module provides a cross-platform file
-- reading API without the file locking problems on Windows.
--
-- This module <i>always</i> opens files in binary mode.
--
-- <tt>readChunk</tt> will return an empty <tt>ByteString</tt> on EOF.
module Data.Streaming.FileRead
data ReadHandle
openFile :: FilePath -> IO ReadHandle
closeFile :: ReadHandle -> IO ()
readChunk :: ReadHandle -> IO ByteString
-- | Buffers for <tt>Builder</tt>s. This is a partial copy of
-- blaze-builder-0.3.3.4's
-- <a>Blaze.ByteString.Builder.Internal.Buffer</a> module, which was
-- removed in blaze-builder-0.4.
--
-- If you are using blaze-builder 0.3.*, this module just re-exports from
-- <a>Blaze.ByteString.Builder.Internal.Buffer</a>.
--
-- Since 0.1.10.0
module Data.Streaming.ByteString.Builder.Buffer
-- | A buffer <tt>Buffer fpbuf p0 op ope</tt> describes a buffer with the
-- underlying byte array <tt>fpbuf..ope</tt>, the currently written slice
-- <tt>p0..op</tt> and the free space <tt>op..ope</tt>.
--
-- Since 0.1.10.0
data Buffer
Buffer :: {-# UNPACK #-} !(ForeignPtr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> {-# UNPACK #-} !(Ptr Word8) -> Buffer
-- | The size of the free space of the buffer.
--
-- Since 0.1.10.0
freeSize :: Buffer -> Int
-- | The size of the written slice in the buffer.
--
-- Since 0.1.10.0
sliceSize :: Buffer -> Int
-- | The size of the whole byte array underlying the buffer.
--
-- Since 0.1.10.0
bufferSize :: Buffer -> Int
-- | <tt>allocBuffer size</tt> allocates a new buffer of size
-- <tt>size</tt>.
--
-- Since 0.1.10.0
allocBuffer :: Int -> IO Buffer
-- | Resets the beginning of the next slice and the next free byte such
-- that the whole buffer can be filled again.
--
-- Since 0.1.10.0
reuseBuffer :: Buffer -> Buffer
-- | Move the beginning of the slice to the next free byte such that the
-- remaining free space of the buffer can be filled further. This
-- operation is safe and can be used to fill the remaining part of the
-- buffer after a direct insertion of a bytestring or a flush.
--
-- Since 0.1.10.0
nextSlice :: Int -> Buffer -> Maybe Buffer
-- | Update the end of slice pointer.
--
-- Since 0.1.10.0
updateEndOfSlice :: Buffer -> Ptr Word8 -> Buffer
-- | Convert the buffer to a bytestring. This operation is unsafe in the
-- sense that created bytestring shares the underlying byte array with
-- the buffer. Hence, depending on the later use of this buffer (e.g., if
-- it gets reset and filled again) referential transparency may be lost.
--
-- Since 0.1.10.0
unsafeFreezeBuffer :: Buffer -> ByteString
-- | Convert a buffer to a non-empty bytestring. See
-- <a>unsafeFreezeBuffer</a> for the explanation of why this operation
-- may be unsafe.
--
-- Since 0.1.10.0
unsafeFreezeNonEmptyBuffer :: Buffer -> Maybe ByteString
-- | A buffer allocation strategy <tt>(buf0, nextBuf)</tt> specifies the
-- initial buffer to use and how to compute a new buffer <tt>nextBuf
-- minSize buf</tt> with at least size <tt>minSize</tt> from a filled
-- buffer <tt>buf</tt>. The double nesting of the <tt>IO</tt> monad helps
-- to ensure that the reference to the filled buffer <tt>buf</tt> is lost
-- as soon as possible, but the new buffer doesn't have to be allocated
-- too early.
--
-- Since 0.1.10.0
type BufferAllocStrategy = (IO Buffer, Int -> Buffer -> IO (IO Buffer))
-- | The simplest buffer allocation strategy: whenever a buffer is
-- requested, allocate a new one that is big enough for the next build
-- step to execute.
--
-- NOTE that this allocation strategy may spill quite some memory upon
-- direct insertion of a bytestring by the builder. Thats no problem for
-- garbage collection, but it may lead to unreasonably high memory
-- consumption in special circumstances.
--
-- Since 0.1.10.0
allNewBuffersStrategy :: Int -> BufferAllocStrategy
-- | An unsafe, but possibly more efficient buffer allocation strategy:
-- reuse the buffer, if it is big enough for the next build step to
-- execute.
--
-- Since 0.1.10.0
reuseBufferStrategy :: IO Buffer -> BufferAllocStrategy
defaultStrategy :: BufferAllocStrategy
-- | Convert a stream of bytestring <tt>Builder</tt>s into a stream of
-- <tt>ByteString</tt>s.
--
-- Adapted from blaze-builder-enumerator, written by Michael Snoyman and
-- Simon Meier.
--
-- Note that the functions here can work in any monad built on top of
-- <tt>IO</tt> or <tt>ST</tt>.
--
-- Also provides <tt>toByteStringIO*</tt> like
-- <a>Blaze.ByteString.Builder</a>s, for <a>Data.ByteString.Builder</a>.
--
-- Since 0.1.9
module Data.Streaming.ByteString.Builder
type BuilderRecv = Builder -> IO BuilderPopper
-- | Provides a series of <tt>ByteString</tt>s until empty, at which point
-- it provides an empty <tt>ByteString</tt>.
--
-- Since 0.1.10.0
type BuilderPopper = IO ByteString
type BuilderFinish = IO (Maybe ByteString)
newByteStringBuilderRecv :: BufferAllocStrategy -> IO (BuilderRecv, BuilderFinish)
-- | Run the builder with a <a>defaultChunkSize</a>d buffer and execute the
-- given <a>IO</a> action whenever the buffer is full or gets flushed.
--
-- <pre>
-- <a>toByteStringIO</a> = <a>toByteStringIOWith</a> <a>defaultChunkSize</a>
-- </pre>
--
-- Since 0.1.9
toByteStringIO :: (ByteString -> IO ()) -> Builder -> IO ()
-- | <tt>toByteStringIOWith bufSize io b</tt> runs the builder <tt>b</tt>
-- with a buffer of at least the size <tt>bufSize</tt> and executes the
-- <a>IO</a> action <tt>io</tt> whenever the buffer is full.
--
-- Compared to <tt>toLazyByteStringWith</tt> this function requires less
-- allocation, as the output buffer is only allocated once at the start
-- of the serialization and whenever something bigger than the current
-- buffer size has to be copied into the buffer, which should happen very
-- seldomly for the default buffer size of 32kb. Hence, the pressure on
-- the garbage collector is reduced, which can be an advantage when
-- building long sequences of bytes.
--
-- Since 0.1.9
toByteStringIOWith :: Int -> (ByteString -> IO ()) -> Builder -> IO ()
-- | Use a pre-existing buffer to <a>toByteStringIOWith</a>.
--
-- Since 0.1.9
toByteStringIOWithBuffer :: Int -> (ByteString -> IO ()) -> Builder -> ForeignPtr Word8 -> IO ()
-- | A buffer <tt>Buffer fpbuf p0 op ope</tt> describes a buffer with the
-- underlying byte array <tt>fpbuf..ope</tt>, the currently written slice
-- <tt>p0..op</tt> and the free space <tt>op..ope</tt>.
--
-- Since 0.1.10.0
data Buffer
-- | The size of the free space of the buffer.
--
-- Since 0.1.10.0
freeSize :: Buffer -> Int
-- | The size of the written slice in the buffer.
--
-- Since 0.1.10.0
sliceSize :: Buffer -> Int
-- | The size of the whole byte array underlying the buffer.
--
-- Since 0.1.10.0
bufferSize :: Buffer -> Int
-- | <tt>allocBuffer size</tt> allocates a new buffer of size
-- <tt>size</tt>.
--
-- Since 0.1.10.0
allocBuffer :: Int -> IO Buffer
-- | Resets the beginning of the next slice and the next free byte such
-- that the whole buffer can be filled again.
--
-- Since 0.1.10.0
reuseBuffer :: Buffer -> Buffer
-- | Move the beginning of the slice to the next free byte such that the
-- remaining free space of the buffer can be filled further. This
-- operation is safe and can be used to fill the remaining part of the
-- buffer after a direct insertion of a bytestring or a flush.
--
-- Since 0.1.10.0
nextSlice :: Int -> Buffer -> Maybe Buffer
-- | Convert the buffer to a bytestring. This operation is unsafe in the
-- sense that created bytestring shares the underlying byte array with
-- the buffer. Hence, depending on the later use of this buffer (e.g., if
-- it gets reset and filled again) referential transparency may be lost.
--
-- Since 0.1.10.0
unsafeFreezeBuffer :: Buffer -> ByteString
-- | Convert a buffer to a non-empty bytestring. See
-- <a>unsafeFreezeBuffer</a> for the explanation of why this operation
-- may be unsafe.
--
-- Since 0.1.10.0
unsafeFreezeNonEmptyBuffer :: Buffer -> Maybe ByteString
-- | A buffer allocation strategy <tt>(buf0, nextBuf)</tt> specifies the
-- initial buffer to use and how to compute a new buffer <tt>nextBuf
-- minSize buf</tt> with at least size <tt>minSize</tt> from a filled
-- buffer <tt>buf</tt>. The double nesting of the <tt>IO</tt> monad helps
-- to ensure that the reference to the filled buffer <tt>buf</tt> is lost
-- as soon as possible, but the new buffer doesn't have to be allocated
-- too early.
--
-- Since 0.1.10.0
type BufferAllocStrategy = (IO Buffer, Int -> Buffer -> IO (IO Buffer))
-- | The simplest buffer allocation strategy: whenever a buffer is
-- requested, allocate a new one that is big enough for the next build
-- step to execute.
--
-- NOTE that this allocation strategy may spill quite some memory upon
-- direct insertion of a bytestring by the builder. Thats no problem for
-- garbage collection, but it may lead to unreasonably high memory
-- consumption in special circumstances.
--
-- Since 0.1.10.0
allNewBuffersStrategy :: Int -> BufferAllocStrategy
-- | An unsafe, but possibly more efficient buffer allocation strategy:
-- reuse the buffer, if it is big enough for the next build step to
-- execute.
--
-- Since 0.1.10.0
reuseBufferStrategy :: IO Buffer -> BufferAllocStrategy
defaultStrategy :: BufferAllocStrategy
-- | Typeclass to stream blaze-builder and bytestring(-builder)
-- <tt>Builder</tt>s.
--
-- Since 0.1.10.0
module Data.Streaming.ByteString.Builder.Class
-- | Typeclass to stream blaze-builder (< 0.4) and bytestring(-builder)
-- <tt>Builder</tt>s. This is primarily to aid the transition from
-- blaze-builder to bytestring <tt>Builder</tt>s (if using blaze-builder
-- >= 0.4, there is only one instance, since the <tt>Builder</tt> type
-- is shared).
--
-- Since 0.1.10.0
class Monoid b => StreamingBuilder b
newBuilderRecv :: StreamingBuilder b => BufferAllocStrategy -> IO (b -> IO BuilderPopper, BuilderFinish)
builderFlush :: StreamingBuilder b => b
instance Data.Streaming.ByteString.Builder.Class.StreamingBuilder Data.ByteString.Builder.Internal.Builder
-- | Convert a stream of blaze-builder <tt>Builder</tt>s into a stream of
-- <tt>ByteString</tt>s.
--
-- Adapted from blaze-builder-enumerator, written by myself and Simon
-- Meier.
--
-- Note: if you have blaze-builder >= 0.4, <a>newBlazeRecv</a> just
-- calls <a>newByteStringBuilderRecv</a>
module Data.Streaming.Blaze
type BlazeRecv = Builder -> IO BlazePopper
-- | Provides a series of <tt>ByteString</tt>s until empty, at which point
-- it provides an empty <tt>ByteString</tt>.
--
-- Since 0.1.2
type BlazePopper = IO ByteString
type BlazeFinish = IO (Maybe ByteString)
newBlazeRecv :: BufferAllocStrategy -> IO (BlazeRecv, BlazeFinish)
-- | A buffer <tt>Buffer fpbuf p0 op ope</tt> describes a buffer with the
-- underlying byte array <tt>fpbuf..ope</tt>, the currently written slice
-- <tt>p0..op</tt> and the free space <tt>op..ope</tt>.
--
-- Since 0.1.10.0
data Buffer
-- | The size of the free space of the buffer.
--
-- Since 0.1.10.0
freeSize :: Buffer -> Int
-- | The size of the written slice in the buffer.
--
-- Since 0.1.10.0
sliceSize :: Buffer -> Int
-- | The size of the whole byte array underlying the buffer.
--
-- Since 0.1.10.0
bufferSize :: Buffer -> Int
-- | <tt>allocBuffer size</tt> allocates a new buffer of size
-- <tt>size</tt>.
--
-- Since 0.1.10.0
allocBuffer :: Int -> IO Buffer
-- | Resets the beginning of the next slice and the next free byte such
-- that the whole buffer can be filled again.
--
-- Since 0.1.10.0
reuseBuffer :: Buffer -> Buffer
-- | Move the beginning of the slice to the next free byte such that the
-- remaining free space of the buffer can be filled further. This
-- operation is safe and can be used to fill the remaining part of the
-- buffer after a direct insertion of a bytestring or a flush.
--
-- Since 0.1.10.0
nextSlice :: Int -> Buffer -> Maybe Buffer
-- | Convert the buffer to a bytestring. This operation is unsafe in the
-- sense that created bytestring shares the underlying byte array with
-- the buffer. Hence, depending on the later use of this buffer (e.g., if
-- it gets reset and filled again) referential transparency may be lost.
--
-- Since 0.1.10.0
unsafeFreezeBuffer :: Buffer -> ByteString
-- | Convert a buffer to a non-empty bytestring. See
-- <a>unsafeFreezeBuffer</a> for the explanation of why this operation
-- may be unsafe.
--
-- Since 0.1.10.0
unsafeFreezeNonEmptyBuffer :: Buffer -> Maybe ByteString
-- | A buffer allocation strategy <tt>(buf0, nextBuf)</tt> specifies the
-- initial buffer to use and how to compute a new buffer <tt>nextBuf
-- minSize buf</tt> with at least size <tt>minSize</tt> from a filled
-- buffer <tt>buf</tt>. The double nesting of the <tt>IO</tt> monad helps
-- to ensure that the reference to the filled buffer <tt>buf</tt> is lost
-- as soon as possible, but the new buffer doesn't have to be allocated
-- too early.
--
-- Since 0.1.10.0
type BufferAllocStrategy = (IO Buffer, Int -> Buffer -> IO (IO Buffer))
-- | The simplest buffer allocation strategy: whenever a buffer is
-- requested, allocate a new one that is big enough for the next build
-- step to execute.
--
-- NOTE that this allocation strategy may spill quite some memory upon
-- direct insertion of a bytestring by the builder. Thats no problem for
-- garbage collection, but it may lead to unreasonably high memory
-- consumption in special circumstances.
--
-- Since 0.1.10.0
allNewBuffersStrategy :: Int -> BufferAllocStrategy
-- | An unsafe, but possibly more efficient buffer allocation strategy:
-- reuse the buffer, if it is big enough for the next build step to
-- execute.
--
-- Since 0.1.10.0
reuseBufferStrategy :: IO Buffer -> BufferAllocStrategy
defaultStrategy :: BufferAllocStrategy
-- | Provides a stream-based approach to decoding Unicode data. Each
-- function below works the same way: you give it a chunk of data, and it
-- gives back a <tt>DecodeResult</tt>. If the parse was a success, then
-- you get a chunk of <tt>Text</tt> (possibly empty) and a continuation
-- parsing function. If the parse was a failure, you get a chunk of
-- successfully decoded <tt>Text</tt> (possibly empty) and the unconsumed
-- bytes.
--
-- In order to indicate end of stream, you pass an empty
-- <tt>ByteString</tt> to the decode function. This call may result in a
-- failure, if there were unused bytes left over from a previous step
-- which formed part of a code sequence.
module Data.Streaming.Text
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- UTF-8 encoding.
decodeUtf8 :: ByteString -> DecodeResult
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- UTF-8 encoding.
decodeUtf8Pure :: ByteString -> DecodeResult
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- little endian UTF-16 encoding.
decodeUtf16LE :: ByteString -> DecodeResult
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- big endian UTF-16 encoding.
decodeUtf16BE :: ByteString -> DecodeResult
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- little endian UTF-32 encoding.
decodeUtf32LE :: ByteString -> DecodeResult
-- | <i>O(n)</i> Convert a <a>ByteString</a> into a 'Stream Char', using
-- big endian UTF-32 encoding.
decodeUtf32BE :: ByteString -> DecodeResult
data DecodeResult
DecodeResultSuccess :: !Text -> !(ByteString -> DecodeResult) -> DecodeResult
DecodeResultFailure :: !Text -> !ByteString -> DecodeResult
instance Foreign.Storable.Storable Data.Streaming.Text.DecoderState
instance GHC.Num.Num Data.Streaming.Text.DecoderState
instance GHC.Show.Show Data.Streaming.Text.DecoderState
instance GHC.Classes.Eq Data.Streaming.Text.DecoderState
instance Foreign.Storable.Storable Data.Streaming.Text.CodePoint
instance GHC.Num.Num Data.Streaming.Text.CodePoint
instance GHC.Show.Show Data.Streaming.Text.CodePoint
instance GHC.Classes.Eq Data.Streaming.Text.CodePoint
instance GHC.Show.Show Data.Streaming.Text.S
|