logo
首页技术栈工具库讨论
enumerator
enumerator
Deprecated Typical buffer–based incremental I/O is based around a single loop, which reads data from some source (such as a socket or file), transforms it, and generates one or more outputs (such as a line count, HTTP responses, or modified file). Although efficient and safe, these loops are all single–purpose; it is difficult or impossible to compose buffer–based processing loops. Haskell’s concept of “lazy I/O” allows pure code to operate on data from an external source. However, lazy I/O has several shortcomings. Most notably, resources such as memory and file handles can be retained for arbitrarily long periods of time, causing unpredictable performance and error conditions. Enumerators are an efficient, predictable, and safe alternative to lazy I/O. Discovered by Oleg Kiselyov, they allow large datasets to be processed in near–constant space by pure code. Although somewhat more complex to write, using enumerators instead of lazy I/O produces more correct programs. This library contains an enumerator implementation for Haskell, designed to be both simple and efficient. Three core types are defined, along with numerous helper functions: Iteratee: Data sinks, analogous to left folds. Iteratees consume a sequence of input values, and generate a single output value. Many iteratees are designed to perform side effects (such as printing to stdout), so they can also be used as monad transformers. Enumerator: Data sources, which generate input sequences. Typical enumerators read from a file handle, socket, random number generator, or other external stream. To operate, enumerators are passed an iteratee, and provide that iteratee with input until either the iteratee has completed its computation, or EOF. Enumeratee: Data transformers, which operate as both enumerators and iteratees. Enumeratees read from an outer enumerator, and provide the transformed data to an inner iteratee.
hashtables
hashtables
This package provides a couple of different implementations of mutable hash tables in the ST monad, as well as a typeclass abstracting their common operations, and a set of wrappers to use the hash tables in the IO monad. QUICK START: documentation for the hash table operations is provided in the Data.HashTable.Class module, and the IO wrappers (which most users will probably prefer) are located in the Data.HashTable.IO module. This package currently contains three hash table implementations: Data.HashTable.ST.Cuckoo contains an implementation of "cuckoo hashing" as introduced by Pagh and Rodler in 2001 (see http://en.wikipedia.org/wiki/Cuckoo_hashing). Cuckoo hashing has worst-case O(1) lookups and can reach a high "load factor", in which the table can perform acceptably well even when approaching 90% full. Randomized testing shows this implementation of cuckoo hashing to be slightly faster on insert and slightly slower on lookup than Data.HashTable.ST.Basic, while being more space efficient by about a half-word per key-value mapping. Cuckoo hashing, like the basic hash table implementation using linear probing, can suffer from long delays when the table is resized. Data.HashTable.ST.Basic contains a basic open-addressing hash table using linear probing as the collision strategy. On a pure speed basis it should currently be the fastest available Haskell hash table implementation for lookups, although it has a higher memory overhead than the other tables and can suffer from long delays when the table is resized because all of the elements in the table need to be rehashed. Data.HashTable.ST.Linear contains a linear hash table (see http://en.wikipedia.org/wiki/Linear_hashing), which trades some insert and lookup performance for higher space efficiency and much shorter delays when expanding the table. In most cases, benchmarks show this table to be currently slightly faster than Data.HashTable from the Haskell base library. It is recommended to create a concrete type alias in your code when using this package, i.e.: Firstly, this makes it easy to switch to a different hash table implementation, and secondly, using a concrete type rather than leaving your functions abstract in the HashTable class should allow GHC to optimize away the typeclass dictionaries. This package accepts a couple of different cabal flags: unsafe-tricks, default ON. If this flag is enabled, we use some unsafe GHC-specific tricks to save indirections (namely unsafeCoerce# and reallyUnsafePtrEquality#. These techniques rely on assumptions about the behaviour of the GHC runtime system and, although they've been tested and should be safe under normal conditions, are slightly dangerous. Caveat emptor. In particular, these techniques are incompatible with HPC code coverage reports. sse42, default OFF. If this flag is enabled, we use some SSE 4.2 instructions (see http://en.wikipedia.org/wiki/SSE4, first available on Intel Core 2 processors) to speed up cache-line searches for cuckoo hashing. bounds-checking, default OFF. If this flag is enabled, array accesses are bounds-checked. debug, default OFF. If turned on, we'll rudely spew debug output to stdout. portable, default OFF. If this flag is enabled, we use only pure Haskell code and try not to use unportable GHC extensions. Turning this flag on forces unsafe-tricks and sse42 OFF. Please send bug reports to https://github.com/gregorycollins/hashtables/issues.
hdirect
hdirect
HaskellDirect is an IDL compiler for Haskell, which offers a helping hand to the Haskell programmer that wants to better interact with and reuse external code. Interfacing Haskell code to external code involves the conversion of values between the Haskell world and the outside, as data representations and details of how memory is managed, are worlds apart at times. Manually writing the boilerplate code that takes care of this conversion is about as exciting as watching grass grow and, as a result, error prone. Using an Interface Definition Language (IDL) as basis, HaskellDirect automates the generation of such impedance matching code, generating all the necessary marshaling code for you. With IDL, the functionality provided by a programming interface is specified in a programming language neutral framework. The HaskellDirect IDL compiler converts this specification into a set of method stubs. Depending on how the compiler is invoked, these stubs can be used to: Call upon external functions from within Haskell, HaskellDirect creates bindings to external (C-callable) libraries. Let external code call upon Haskell functions, HaskellDirect creates foreign/external language interfaces to Haskell libraries. Call COM (Microsoft's Component Object Model) methods from Haskell, HaskellDirect helps you use Microsoft COM components from within Haskell. The generated stubs can be used with Hugs98 or GHC. Create COM method wrappers, HaskellDirect packages up Haskell code as COM components. The HaskellDirect IDL compiler currently groks both the OSF DCE dialect of IDL (including the various extensions introduced by the Microsoft IDL compiler) and the OMG IIOP/CORBA dialect. (Only the former can be used for describing COM interfaces.)
hydrogen-prelude
hydrogen-prelude
[Index] Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info For package maintainers and hackage trustees A Prelude that exports much of the standard library (more then Prelude), without conflicts. If for example you were to import Prelude and Data.List or Data.Foldable you will run into ambiguous imports (regarding foldr for example). This Prelude aims at exporting the most general functions (in this case foldr from Data.Foldable). It also pulls in some default packages like cereal for serialization and containers for data types like Map and Set. Every datatype exported by this Prelude comes with instances for Serialize. Longs story short, instead of: it suffices to: Beyond existing functions from well-known standard packages, this prelude defines a few utilities (mostly aimed at unifying functionality across different packages, like containers and array). (!) is provided for several data types which associate a key and a value. Instances are defined for Check whether the element on the right is contained in the collection on the left. Instances are defined for A little bit like fmap but defined differently on some datatypes (applies e.g. to both components of a tuple). Instances are defined for Hydrogen Prelude exports fmap as map - the way it ought to be. A handy shortcut for undefined. Use it to pipe things from one function to the other, left to right: The head of the list, or the default given as first argument. Wrap anything that is showable (can be used to build heterogeneous lists). Combines predicates. A longhand for the type of lists, if you prefer this more wordy version. A class that provides the def function for default values for types. Instances of MonadPlus automatically have an instance where def = mzero. Default instances for most primitive types are also provided. Provides the *$* operator which is your all-purpose application operator. It does uncurrying (if you want to apply a tupel result of a function to a function that is curryied, works with tupels of up to 5 components) and also works with Applicative, i.e. it also does fmap . uncurry: The Hydrogen Prelude offers you the functions and datatypes from these modules, all with one import: from base from array from cereal from containers from hashable form hydrogen-multimap from hydrogen-version from regex-tdfa from time from transformers from uuid from base from strict from base from directory from filepath from process from random Mostly with XTypeFamilies and XStandaloneDeriving. Yes, for now at least. https://www.youtube.com/watch?v=rbBX6aEzEz8