scion-browser (empty) → 0.1.3
raw patch · 38 files changed
+24605/−0 lines, 38 filesdep +Cabaldep +HTTPdep +aesonsetup-changed
Dependencies added: Cabal, HTTP, aeson, attoparsec, base, bytestring, cereal, containers, deepseq, derive, directory, filepath, ghc, ghc-paths, haskeline, haskell-src-exts, mtl, parallel-io, parsec, process, tar, text, unix, utf8-string, zlib
Files
- Setup.hs +2/−0
- data/base-unicode-symbols.txt +347/−0
- data/containers.txt +2909/−0
- data/ghc-mtl.txt +56/−0
- data/ghc-prim.txt +1158/−0
- data/haskell2010.txt +4715/−0
- data/haskell98.txt +2532/−0
- data/html.txt +272/−0
- data/vector.txt +8948/−0
- data/wai.txt +127/−0
- data/warp.txt +91/−0
- docs/LICENSE +29/−0
- scion-browser.cabal +117/−0
- scion-browser.cabal~ +172/−0
- src/Main.hs +28/−0
- src/Scion/Browser.hs +35/−0
- src/Scion/Browser/Build.hs +184/−0
- src/Scion/Browser/FileUtil.hs +90/−0
- src/Scion/Browser/FromMissingH.hs +98/−0
- src/Scion/Browser/Instances/Json.hs +131/−0
- src/Scion/Browser/Instances/NFData.hs +85/−0
- src/Scion/Browser/Instances/Serialize.hs +498/−0
- src/Scion/Browser/Parser.hs +98/−0
- src/Scion/Browser/Parser/Documentable.hs +88/−0
- src/Scion/Browser/Parser/Internal.hs +543/−0
- src/Scion/Browser/Query.hs +110/−0
- src/Scion/Browser/TempFile.hs +220/−0
- src/Scion/Browser/Types.hs +90/−0
- src/Scion/Browser/Util.hs +48/−0
- src/Scion/Hoogle.hs +46/−0
- src/Scion/Hoogle/Instances/Json.hs +28/−0
- src/Scion/Hoogle/Parser.hs +122/−0
- src/Scion/Hoogle/Types.hs +15/−0
- src/Scion/Hoogle/Util.hs +117/−0
- src/Scion/Packages.hs +200/−0
- src/Server/Commands.hs +163/−0
- test/Scion/Browser/ParserTests.hs +84/−0
- test/Test.hs +9/−0
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ data/base-unicode-symbols.txt view
@@ -0,0 +1,347 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Unicode alternatives for common functions and operators+-- +-- This package defines new symbols for a number of functions and+-- operators in the base package.+-- +-- All symbols are documented with their actual definition and+-- information regarding their Unicode code point. They should be+-- completely interchangeable with their definitions.+-- +-- For further Unicode goodness you can enable the <tt>UnicodeSyntax</tt>+-- language extension [1]. This extension enables Unicode characters to+-- be used to stand for certain ASCII character sequences, i.e. → instead+-- of <tt>-></tt>, ∀ instead of <tt>forall</tt> and many others.+-- +-- Original idea by Péter Diviánszky.+-- +-- [1]+-- <a>http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax</a>+@package base-unicode-symbols+@version 0.2.1.5+++module Data.Ord.Unicode++-- | (≤) = (<a><=</a>)+-- +-- U+2264, LESS-THAN OR EQUAL TO+(≤) :: Ord α => α -> α -> Bool++-- | (≥) = (<a>>=</a>)+-- +-- U+2265, GREATER-THAN OR EQUAL TO+(≥) :: Ord α => α -> α -> Bool++-- | (≮) = (<a>>=</a>)+-- +-- U+226E, NOT LESS-THAN+(≮) :: Ord α => α -> α -> Bool++-- | (≯) = (<a><=</a>)+-- +-- U+226F, NOT GREATER-THAN+(≯) :: Ord α => α -> α -> Bool+++module Data.Monoid.Unicode++-- | (∅) = <a>mempty</a>+-- +-- U+2205, EMPTY SET+(∅) :: Monoid α => α++-- | (⊕) = <a>mappend</a>+-- +-- U+2295, CIRCLED PLUS+(⊕) :: Monoid α => α -> α -> α+++module Data.List.Unicode++-- | (⧺) = (<a>++</a>)+-- +-- U+29FA, DOUBLE PLUS+(⧺) :: [α] -> [α] -> [α]++-- | (∈) = <a>elem</a>+-- +-- U+2208, ELEMENT OF+(∈) :: Eq α => α -> [α] -> Bool++-- | (∋) = <a>flip</a> (∈)+-- +-- U+220B, CONTAINS AS MEMBER+(∋) :: Eq α => [α] -> α -> Bool++-- | (∉) = <a>notElem</a>+-- +-- U+2209, NOT AN ELEMENT OF+(∉) :: Eq α => α -> [α] -> Bool++-- | (∌) = <a>flip</a> (∉)+-- +-- U+220C, DOES NOT CONTAIN AS MEMBER+(∌) :: Eq α => [α] -> α -> Bool++-- | (∪) = <a>union</a>+-- +-- U+222A, UNION+(∪) :: Eq α => [α] -> [α] -> [α]++-- | (∖) = (<a>\\</a>)+-- +-- U+2216, SET MINUS+(∖) :: Eq α => [α] -> [α] -> [α]++-- | Symmetric difference+-- +-- a ∆ b = (a ∖ b) ∪ (b ∖ a)+-- +-- U+2206, INCREMENT+(∆) :: Eq α => [α] -> [α] -> [α]++-- | (∩) = <a>intersect</a>+-- +-- U+2229, INTERSECTION+(∩) :: Eq α => [α] -> [α] -> [α]+++module Data.Function.Unicode++-- | (∘) = (<a>.</a>)+-- +-- U+2218, RING OPERATOR+(∘) :: (β -> γ) -> (α -> β) -> (α -> γ)+++module Data.Foldable.Unicode++-- | (∈) = <a>elem</a>+-- +-- U+2208, ELEMENT OF+(∈) :: (Foldable t, Eq α) => α -> t α -> Bool++-- | (∋) = <a>flip</a> (∈)+-- +-- U+220B, CONTAINS AS MEMBER+(∋) :: (Foldable t, Eq α) => t α -> α -> Bool++-- | (∉) = <a>notElem</a>+-- +-- U+2209, NOT AN ELEMENT OF+(∉) :: (Foldable t, Eq α) => α -> t α -> Bool++-- | (∌) = <a>flip</a> (∉)+-- +-- U+220C, DOES NOT CONTAIN AS MEMBER+(∌) :: (Foldable t, Eq α) => t α -> α -> Bool+++module Data.Eq.Unicode++-- | (≡) = (<a>==</a>)+-- +-- U+2261, IDENTICAL TO+(≡) :: Eq α => α -> α -> Bool++-- | (≢) = (<a>/=</a>)+-- +-- U+2262, NOT IDENTICAL TO+(≢) :: Eq α => α -> α -> Bool++-- | (≠) = (<a>/=</a>)+-- +-- U+2260, NOT EQUAL TO+(≠) :: Eq α => α -> α -> Bool+++module Data.Bool.Unicode++-- | (∧) = (<a>&&</a>)+-- +-- U+2227, LOGICAL AND+(∧) :: Bool -> Bool -> Bool++-- | (∨) = (<a>||</a>)+-- +-- U+2228, LOGICAL OR+(∨) :: Bool -> Bool -> Bool++-- | (¬) = <a>not</a>+-- +-- U+00AC, NOT SIGN+(¬) :: Bool -> Bool+++module Prelude.Unicode++-- | (¬) = <a>not</a>+-- +-- U+00AC, NOT SIGN+(¬) :: Bool -> Bool++-- | (∧) = (<a>&&</a>)+-- +-- U+2227, LOGICAL AND+(∧) :: Bool -> Bool -> Bool++-- | (∨) = (<a>||</a>)+-- +-- U+2228, LOGICAL OR+(∨) :: Bool -> Bool -> Bool++-- | (≡) = (<a>==</a>)+-- +-- U+2261, IDENTICAL TO+(≡) :: Eq α => α -> α -> Bool++-- | (≢) = (<a>/=</a>)+-- +-- U+2262, NOT IDENTICAL TO+(≢) :: Eq α => α -> α -> Bool++-- | (≠) = (<a>/=</a>)+-- +-- U+2260, NOT EQUAL TO+(≠) :: Eq α => α -> α -> Bool++-- | (≤) = (<a><=</a>)+-- +-- U+2264, LESS-THAN OR EQUAL TO+(≤) :: Ord α => α -> α -> Bool++-- | (≥) = (<a>>=</a>)+-- +-- U+2265, GREATER-THAN OR EQUAL TO+(≥) :: Ord α => α -> α -> Bool++-- | (≮) = (<a>>=</a>)+-- +-- U+226E, NOT LESS-THAN+(≮) :: Ord α => α -> α -> Bool++-- | (≯) = (<a><=</a>)+-- +-- U+226F, NOT GREATER-THAN+(≯) :: Ord α => α -> α -> Bool++-- | π = <a>pi</a>+-- +-- U+03C0, GREEK SMALL LETTER PI+π :: Floating α => α++-- | (÷) = (<a>/</a>)+-- +-- U+00F7, DIVISION SIGN+(÷) :: Fractional α => α -> α -> α++-- | (⋅) = (<a>*</a>)+-- +-- U+22C5, DOT OPERATOR+(⋅) :: Num α => α -> α -> α++-- | (∘) = (<a>.</a>)+-- +-- U+2218, RING OPERATOR+(∘) :: (β -> γ) -> (α -> β) -> (α -> γ)++-- | (⧺) = (<a>++</a>)+-- +-- U+29FA, DOUBLE PLUS+(⧺) :: [α] -> [α] -> [α]++-- | (∈) = <a>elem</a>+-- +-- U+2208, ELEMENT OF+(∈) :: Eq α => α -> [α] -> Bool++-- | (∉) = <a>notElem</a>+-- +-- U+2209, NOT AN ELEMENT OF+(∉) :: Eq α => α -> [α] -> Bool++-- | (⊥) = <a>undefined</a>+-- +-- U+22A5, UP TACK+(⊥) :: α+++module Control.Monad.Unicode++-- | (≫=) = (<a>>>=</a>)+-- +-- (U+226B, MUCH GREATER-THAN) + (U+3D, EQUALS SIGN)+(≫=) :: Monad m => m α -> (α -> m β) -> m β++-- | (≫) = (<a>>></a>)+-- +-- U+226B, MUCH GREATER-THAN+(≫) :: Monad m => m α -> m β -> m β++-- | (=≪) = (<a>=<<</a>)+-- +-- (U+3D, EQUALS SIGN) + (U+226A, MUCH LESS-THAN)+(=≪) :: Monad m => (α -> m β) -> m α -> m β+++module Control.Applicative.Unicode++-- | (⊛) = <a><*></a>+-- +-- U+229B, CIRCLED ASTERISK OPERATOR+(⊛) :: Applicative f => f (α -> β) -> f α -> f β++-- | (∅) = <a>empty</a>+-- +-- U+2205, EMPTY SET+(∅) :: Alternative f => f α+++module Control.Category.Unicode++-- | (∘) = (<a>.</a>)+-- +-- U+2218, RING OPERATOR+(∘) :: Category ⇝ => (β ⇝ γ) -> (α ⇝ β) -> (α ⇝ γ)++-- | (⋙) = (<a>>>></a>)+-- +-- U+22D9, VERY MUCH GREATER-THAN+(⋙) :: Category ⇝ => (α ⇝ β) -> (β ⇝ γ) -> (α ⇝ γ)++-- | (⋘) = (<a><<<</a>)+-- +-- U+22D8, VERY MUCH LESS-THAN+(⋘) :: Category ⇝ => (β ⇝ γ) -> (α ⇝ β) -> (α ⇝ γ)+++module Control.Arrow.Unicode++-- | (⋙) = (<a>>>></a>)+-- +-- U+22D9, VERY MUCH GREATER-THAN+(⋙) :: Category ⇝ => (α ⇝ β) -> (β ⇝ γ) -> (α ⇝ γ)++-- | (⋘) = (<a><<<</a>)+-- +-- U+22D8, VERY MUCH LESS-THAN+(⋘) :: Category ⇝ => (β ⇝ γ) -> (α ⇝ β) -> (α ⇝ γ)++-- | (⁂) = (<a>***</a>)+-- +-- U+2042, ASTERISM+(⁂) :: Arrow ⇝ => (α ⇝ β) -> (α' ⇝ β') -> (α, α') ⇝ (β, β')++-- | (⧻) = (<a>+++</a>)+-- +-- U+29FB, TRIPLE PLUS+(⧻) :: ArrowChoice ⇝ => (α ⇝ β) -> (α' ⇝ β') -> (Either α α' ⇝ Either β β')++-- | (⫴) = (<a>|||</a>)+-- +-- U+2AF4, TRIPLE VERTICAL BAR BINARY RELATION+(⫴) :: ArrowChoice ⇝ => (α ⇝ δ) -> (β ⇝ δ) -> (Either α β ⇝ δ)
+ data/containers.txt view
@@ -0,0 +1,2909 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Assorted concrete container types+-- +-- This package contains efficient general-purpose implementations of+-- various basic immutable container types. The declared cost of each+-- operation is either worst-case or amortized, but remains valid even if+-- structures are shared.+@package containers+@version 0.4.0.0+++-- | An efficient implementation of sets.+-- +-- Since many function names (but not the type name) clash with+-- <a>Prelude</a> names, this module is usually imported+-- <tt>qualified</tt>, e.g.+-- +-- <pre>+-- import Data.Set (Set)+-- import qualified Data.Set as Set+-- </pre>+-- +-- The implementation of <a>Set</a> is based on <i>size balanced</i>+-- binary trees (or trees of <i>bounded balance</i>) as described by:+-- +-- <ul>+-- <li>Stephen Adams, "<i>Efficient sets: a balancing act</i>", Journal+-- of Functional Programming 3(4):553-562, October 1993,+-- <a>http://www.swiss.ai.mit.edu/~adams/BB/</a>.</li>+-- <li>J. Nievergelt and E.M. Reingold, "<i>Binary search trees of+-- bounded balance</i>", SIAM journal of computing 2(1), March 1973.</li>+-- </ul>+-- +-- Note that the implementation is <i>left-biased</i> -- the elements of+-- a first argument are always preferred to the second, for example in+-- <a>union</a> or <a>insert</a>. Of course, left-biasing can only be+-- observed when equality is an equivalence relation instead of+-- structural equality.+module Data.Set++-- | A set of values <tt>a</tt>.+data Set a++-- | <i>O(n+m)</i>. See <a>difference</a>.+(\\) :: Ord a => Set a -> Set a -> Set a++-- | <i>O(1)</i>. Is this the empty set?+null :: Set a -> Bool++-- | <i>O(1)</i>. The number of elements in the set.+size :: Set a -> Int++-- | <i>O(log n)</i>. Is the element in the set?+member :: Ord a => a -> Set a -> Bool++-- | <i>O(log n)</i>. Is the element not in the set?+notMember :: Ord a => a -> Set a -> Bool++-- | <i>O(n+m)</i>. Is this a subset? <tt>(s1 <a>isSubsetOf</a> s2)</tt>+-- tells whether <tt>s1</tt> is a subset of <tt>s2</tt>.+isSubsetOf :: Ord a => Set a -> Set a -> Bool++-- | <i>O(n+m)</i>. Is this a proper subset? (ie. a subset but not equal).+isProperSubsetOf :: Ord a => Set a -> Set a -> Bool++-- | <i>O(1)</i>. The empty set.+empty :: Set a++-- | <i>O(1)</i>. Create a singleton set.+singleton :: a -> Set a++-- | <i>O(log n)</i>. Insert an element in a set. If the set already+-- contains an element equal to the given value, it is replaced with the+-- new value.+insert :: Ord a => a -> Set a -> Set a++-- | <i>O(log n)</i>. Delete an element from a set.+delete :: Ord a => a -> Set a -> Set a++-- | <i>O(n+m)</i>. The union of two sets, preferring the first set when+-- equal elements are encountered. The implementation uses the efficient+-- <i>hedge-union</i> algorithm. Hedge-union is more efficient on (bigset+-- <a>union</a> smallset).+union :: Ord a => Set a -> Set a -> Set a++-- | The union of a list of sets: (<tt><a>unions</a> == <a>foldl</a>+-- <a>union</a> <a>empty</a></tt>).+unions :: Ord a => [Set a] -> Set a++-- | <i>O(n+m)</i>. Difference of two sets. The implementation uses an+-- efficient <i>hedge</i> algorithm comparable with <i>hedge-union</i>.+difference :: Ord a => Set a -> Set a -> Set a++-- | <i>O(n+m)</i>. The intersection of two sets. Elements of the result+-- come from the first set, so for example+-- +-- <pre>+-- import qualified Data.Set as S+-- data AB = A | B deriving Show+-- instance Ord AB where compare _ _ = EQ+-- instance Eq AB where _ == _ = True+-- main = print (S.singleton A `S.intersection` S.singleton B,+-- S.singleton B `S.intersection` S.singleton A)+-- </pre>+-- +-- prints <tt>(fromList [A],fromList [B])</tt>.+intersection :: Ord a => Set a -> Set a -> Set a++-- | <i>O(n)</i>. Filter all elements that satisfy the predicate.+filter :: Ord a => (a -> Bool) -> Set a -> Set a++-- | <i>O(n)</i>. Partition the set into two sets, one with all elements+-- that satisfy the predicate and one with all elements that don't+-- satisfy the predicate. See also <a>split</a>.+partition :: Ord a => (a -> Bool) -> Set a -> (Set a, Set a)++-- | <i>O(log n)</i>. The expression (<tt><a>split</a> x set</tt>) is a+-- pair <tt>(set1,set2)</tt> where <tt>set1</tt> comprises the elements+-- of <tt>set</tt> less than <tt>x</tt> and <tt>set2</tt> comprises the+-- elements of <tt>set</tt> greater than <tt>x</tt>.+split :: Ord a => a -> Set a -> (Set a, Set a)++-- | <i>O(log n)</i>. Performs a <a>split</a> but also returns whether the+-- pivot element was found in the original set.+splitMember :: Ord a => a -> Set a -> (Set a, Bool, Set a)++-- | <i>O(n*log n)</i>. <tt><a>map</a> f s</tt> is the set obtained by+-- applying <tt>f</tt> to each element of <tt>s</tt>.+-- +-- It's worth noting that the size of the result may be smaller if, for+-- some <tt>(x,y)</tt>, <tt>x /= y && f x == f y</tt>+map :: (Ord a, Ord b) => (a -> b) -> Set a -> Set b++-- | <i>O(n)</i>. The+-- +-- <tt><a>mapMonotonic</a> f s == <a>map</a> f s</tt>, but works only+-- when <tt>f</tt> is monotonic. <i>The precondition is not checked.</i>+-- Semi-formally, we have:+-- +-- <pre>+-- and [x < y ==> f x < f y | x <- ls, y <- ls] +-- ==> mapMonotonic f s == map f s+-- where ls = toList s+-- </pre>+mapMonotonic :: (a -> b) -> Set a -> Set b++-- | <i>O(n)</i>. Fold over the elements of a set in an unspecified order.+fold :: (a -> b -> b) -> b -> Set a -> b++-- | <i>O(log n)</i>. The minimal element of a set.+findMin :: Set a -> a++-- | <i>O(log n)</i>. The maximal element of a set.+findMax :: Set a -> a++-- | <i>O(log n)</i>. Delete the minimal element.+deleteMin :: Set a -> Set a++-- | <i>O(log n)</i>. Delete the maximal element.+deleteMax :: Set a -> Set a++-- | <i>O(log n)</i>. Delete and find the minimal element.+-- +-- <pre>+-- deleteFindMin set = (findMin set, deleteMin set)+-- </pre>+deleteFindMin :: Set a -> (a, Set a)++-- | <i>O(log n)</i>. Delete and find the maximal element.+-- +-- <pre>+-- deleteFindMax set = (findMax set, deleteMax set)+-- </pre>+deleteFindMax :: Set a -> (a, Set a)++-- | <i>O(log n)</i>. Retrieves the maximal key of the set, and the set+-- stripped of that element, or <a>Nothing</a> if passed an empty set.+maxView :: Set a -> Maybe (a, Set a)++-- | <i>O(log n)</i>. Retrieves the minimal key of the set, and the set+-- stripped of that element, or <a>Nothing</a> if passed an empty set.+minView :: Set a -> Maybe (a, Set a)++-- | <i>O(n)</i>. The elements of a set.+elems :: Set a -> [a]++-- | <i>O(n)</i>. Convert the set to a list of elements.+toList :: Set a -> [a]++-- | <i>O(n*log n)</i>. Create a set from a list of elements.+fromList :: Ord a => [a] -> Set a++-- | <i>O(n)</i>. Convert the set to an ascending list of elements.+toAscList :: Set a -> [a]++-- | <i>O(n)</i>. Build a set from an ascending list in linear time. <i>The+-- precondition (input list is ascending) is not checked.</i>+fromAscList :: Eq a => [a] -> Set a++-- | <i>O(n)</i>. Build a set from an ascending list of distinct elements+-- in linear time. <i>The precondition (input list is strictly ascending)+-- is not checked.</i>+fromDistinctAscList :: [a] -> Set a++-- | <i>O(n)</i>. Show the tree that implements the set. The tree is shown+-- in a compressed, hanging format.+showTree :: Show a => Set a -> String++-- | <i>O(n)</i>. The expression (<tt>showTreeWith hang wide map</tt>)+-- shows the tree that implements the set. If <tt>hang</tt> is+-- <tt>True</tt>, a <i>hanging</i> tree is shown otherwise a rotated tree+-- is shown. If <tt>wide</tt> is <a>True</a>, an extra wide version is+-- shown.+-- +-- <pre>+-- Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1..5]+-- 4+-- +--2+-- | +--1+-- | +--3+-- +--5+-- +-- Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1..5]+-- 4+-- |+-- +--2+-- | |+-- | +--1+-- | |+-- | +--3+-- |+-- +--5+-- +-- Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1..5]+-- +--5+-- |+-- 4+-- |+-- | +--3+-- | |+-- +--2+-- |+-- +--1+-- </pre>+showTreeWith :: Show a => Bool -> Bool -> Set a -> String++-- | <i>O(n)</i>. Test if the internal set structure is valid.+valid :: Ord a => Set a -> Bool+instance Typeable1 Set+instance (Read a, Ord a) => Read (Set a)+instance Show a => Show (Set a)+instance Ord a => Ord (Set a)+instance Eq a => Eq (Set a)+instance (Data a, Ord a) => Data (Set a)+instance Foldable Set+instance Ord a => Monoid (Set a)+++-- | An efficient implementation of maps from keys to values+-- (dictionaries).+-- +-- Since many function names (but not the type name) clash with+-- <a>Prelude</a> names, this module is usually imported+-- <tt>qualified</tt>, e.g.+-- +-- <pre>+-- import Data.Map (Map)+-- import qualified Data.Map as Map+-- </pre>+-- +-- The implementation of <a>Map</a> is based on <i>size balanced</i>+-- binary trees (or trees of <i>bounded balance</i>) as described by:+-- +-- <ul>+-- <li>Stephen Adams, "<i>Efficient sets: a balancing act</i>", Journal+-- of Functional Programming 3(4):553-562, October 1993,+-- <a>http://www.swiss.ai.mit.edu/~adams/BB/</a>.</li>+-- <li>J. Nievergelt and E.M. Reingold, "<i>Binary search trees of+-- bounded balance</i>", SIAM journal of computing 2(1), March 1973.</li>+-- </ul>+-- +-- Note that the implementation is <i>left-biased</i> -- the elements of+-- a first argument are always preferred to the second, for example in+-- <a>union</a> or <a>insert</a>.+-- +-- Operation comments contain the operation time complexity in the Big-O+-- notation <a>http://en.wikipedia.org/wiki/Big_O_notation</a>.+module Data.Map++-- | A Map from keys <tt>k</tt> to values <tt>a</tt>.+data Map k a++-- | <i>O(log n)</i>. Find the value at a key. Calls <a>error</a> when the+-- element can not be found.+-- +-- <pre>+-- fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map+-- fromList [(5,'a'), (3,'b')] ! 5 == 'a'+-- </pre>+(!) :: Ord k => Map k a -> k -> a++-- | Same as <a>difference</a>.+(\\) :: Ord k => Map k a -> Map k b -> Map k a++-- | <i>O(1)</i>. Is the map empty?+-- +-- <pre>+-- Data.Map.null (empty) == True+-- Data.Map.null (singleton 1 'a') == False+-- </pre>+null :: Map k a -> Bool++-- | <i>O(1)</i>. The number of elements in the map.+-- +-- <pre>+-- size empty == 0+-- size (singleton 1 'a') == 1+-- size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3+-- </pre>+size :: Map k a -> Int++-- | <i>O(log n)</i>. Is the key a member of the map? See also+-- <a>notMember</a>.+-- +-- <pre>+-- member 5 (fromList [(5,'a'), (3,'b')]) == True+-- member 1 (fromList [(5,'a'), (3,'b')]) == False+-- </pre>+member :: Ord k => k -> Map k a -> Bool++-- | <i>O(log n)</i>. Is the key not a member of the map? See also+-- <a>member</a>.+-- +-- <pre>+-- notMember 5 (fromList [(5,'a'), (3,'b')]) == False+-- notMember 1 (fromList [(5,'a'), (3,'b')]) == True+-- </pre>+notMember :: Ord k => k -> Map k a -> Bool++-- | <i>O(log n)</i>. Lookup the value at a key in the map.+-- +-- The function will return the corresponding value as <tt>(<a>Just</a>+-- value)</tt>, or <a>Nothing</a> if the key isn't in the map.+-- +-- An example of using <tt>lookup</tt>:+-- +-- <pre>+-- import Prelude hiding (lookup)+-- import Data.Map+-- +-- employeeDept = fromList([("John","Sales"), ("Bob","IT")])+-- deptCountry = fromList([("IT","USA"), ("Sales","France")])+-- countryCurrency = fromList([("USA", "Dollar"), ("France", "Euro")])+-- +-- employeeCurrency :: String -> Maybe String+-- employeeCurrency name = do+-- dept <- lookup name employeeDept+-- country <- lookup dept deptCountry+-- lookup country countryCurrency+-- +-- main = do+-- putStrLn $ "John's currency: " ++ (show (employeeCurrency "John"))+-- putStrLn $ "Pete's currency: " ++ (show (employeeCurrency "Pete"))+-- </pre>+-- +-- The output of this program:+-- +-- <pre>+-- John's currency: Just "Euro"+-- Pete's currency: Nothing+-- </pre>+lookup :: Ord k => k -> Map k a -> Maybe a++-- | <i>O(log n)</i>. The expression <tt>(<a>findWithDefault</a> def k+-- map)</tt> returns the value at key <tt>k</tt> or returns default value+-- <tt>def</tt> when the key is not in the map.+-- +-- <pre>+-- findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'+-- findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'+-- </pre>+findWithDefault :: Ord k => a -> k -> Map k a -> a++-- | <i>O(1)</i>. The empty map.+-- +-- <pre>+-- empty == fromList []+-- size empty == 0+-- </pre>+empty :: Map k a++-- | <i>O(1)</i>. A map with a single element.+-- +-- <pre>+-- singleton 1 'a' == fromList [(1, 'a')]+-- size (singleton 1 'a') == 1+-- </pre>+singleton :: k -> a -> Map k a++-- | <i>O(log n)</i>. Insert a new key and value in the map. If the key is+-- already present in the map, the associated value is replaced with the+-- supplied value. <a>insert</a> is equivalent to <tt><a>insertWith</a>+-- <a>const</a></tt>.+-- +-- <pre>+-- insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]+-- insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]+-- insert 5 'x' empty == singleton 5 'x'+-- </pre>+insert :: Ord k => k -> a -> Map k a -> Map k a++-- | <i>O(log n)</i>. Insert with a function, combining new value and old+-- value. <tt><a>insertWith</a> f key value mp</tt> will insert the pair+-- (key, value) into <tt>mp</tt> if key does not exist in the map. If the+-- key does exist, the function will insert the pair <tt>(key, f+-- new_value old_value)</tt>.+-- +-- <pre>+-- insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]+-- insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]+-- insertWith (++) 5 "xxx" empty == singleton 5 "xxx"+-- </pre>+insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a++-- | Same as <a>insertWith</a>, but the combining function is applied+-- strictly. This is often the most desirable behavior.+-- +-- For example, to update a counter:+-- +-- <pre>+-- insertWith' (+) k 1 m+-- </pre>+insertWith' :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a++-- | <i>O(log n)</i>. Insert with a function, combining key, new value and+-- old value. <tt><a>insertWithKey</a> f key value mp</tt> will insert+-- the pair (key, value) into <tt>mp</tt> if key does not exist in the+-- map. If the key does exist, the function will insert the pair+-- <tt>(key,f key new_value old_value)</tt>. Note that the key passed to+-- f is the same key passed to <a>insertWithKey</a>.+-- +-- <pre>+-- let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value+-- insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")]+-- insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]+-- insertWithKey f 5 "xxx" empty == singleton 5 "xxx"+-- </pre>+insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a++-- | Same as <a>insertWithKey</a>, but the combining function is applied+-- strictly.+insertWithKey' :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a++-- | <i>O(log n)</i>. Combines insert operation with old value retrieval.+-- The expression (<tt><a>insertLookupWithKey</a> f k x map</tt>) is a+-- pair where the first element is equal to (<tt><a>lookup</a> k+-- map</tt>) and the second element equal to (<tt><a>insertWithKey</a> f+-- k x map</tt>).+-- +-- <pre>+-- let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value+-- insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")])+-- insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")])+-- insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")+-- </pre>+-- +-- This is how to define <tt>insertLookup</tt> using+-- <tt>insertLookupWithKey</tt>:+-- +-- <pre>+-- let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t+-- insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])+-- insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])+-- </pre>+insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)++-- | <i>O(log n)</i>. A strict version of <a>insertLookupWithKey</a>.+insertLookupWithKey' :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)++-- | <i>O(log n)</i>. Delete a key and its value from the map. When the key+-- is not a member of the map, the original map is returned.+-- +-- <pre>+-- delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- delete 5 empty == empty+-- </pre>+delete :: Ord k => k -> Map k a -> Map k a++-- | <i>O(log n)</i>. Update a value at a specific key with the result of+-- the provided function. When the key is not a member of the map, the+-- original map is returned.+-- +-- <pre>+-- adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]+-- adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- adjust ("new " ++) 7 empty == empty+-- </pre>+adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a++-- | <i>O(log n)</i>. Adjust a value at a specific key. When the key is not+-- a member of the map, the original map is returned.+-- +-- <pre>+-- let f key x = (show key) ++ ":new " ++ x+-- adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]+-- adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- adjustWithKey f 7 empty == empty+-- </pre>+adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a++-- | <i>O(log n)</i>. The expression (<tt><a>update</a> f k map</tt>)+-- updates the value <tt>x</tt> at <tt>k</tt> (if it is in the map). If+-- (<tt>f x</tt>) is <a>Nothing</a>, the element is deleted. If it is+-- (<tt><a>Just</a> y</tt>), the key <tt>k</tt> is bound to the new value+-- <tt>y</tt>.+-- +-- <pre>+-- let f x = if x == "a" then Just "new a" else Nothing+-- update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]+-- update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a++-- | <i>O(log n)</i>. The expression (<tt><a>updateWithKey</a> f k+-- map</tt>) updates the value <tt>x</tt> at <tt>k</tt> (if it is in the+-- map). If (<tt>f k x</tt>) is <a>Nothing</a>, the element is deleted.+-- If it is (<tt><a>Just</a> y</tt>), the key <tt>k</tt> is bound to the+-- new value <tt>y</tt>.+-- +-- <pre>+-- let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing+-- updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]+-- updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a++-- | <i>O(log n)</i>. Lookup and update. See also <a>updateWithKey</a>. The+-- function returns changed value, if it is updated. Returns the original+-- key value if the map entry is deleted.+-- +-- <pre>+-- let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing+-- updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")])+-- updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")])+-- updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")+-- </pre>+updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)++-- | <i>O(log n)</i>. The expression (<tt><a>alter</a> f k map</tt>) alters+-- the value <tt>x</tt> at <tt>k</tt>, or absence thereof. <a>alter</a>+-- can be used to insert, delete, or update a value in a <a>Map</a>. In+-- short : <tt><a>lookup</a> k (<a>alter</a> f k m) = f (<a>lookup</a> k+-- m)</tt>.+-- +-- <pre>+-- let f _ = Nothing+-- alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- +-- let f _ = Just "c"+-- alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")]+-- alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")]+-- </pre>+alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a++-- | <i>O(n+m)</i>. The expression (<tt><a>union</a> t1 t2</tt>) takes the+-- left-biased union of <tt>t1</tt> and <tt>t2</tt>. It prefers+-- <tt>t1</tt> when duplicate keys are encountered, i.e.+-- (<tt><a>union</a> == <a>unionWith</a> <a>const</a></tt>). The+-- implementation uses the efficient <i>hedge-union</i> algorithm.+-- Hedge-union is more efficient on (bigset `<a>union</a>` smallset).+-- +-- <pre>+-- union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]+-- </pre>+union :: Ord k => Map k a -> Map k a -> Map k a++-- | <i>O(n+m)</i>. Union with a combining function. The implementation+-- uses the efficient <i>hedge-union</i> algorithm.+-- +-- <pre>+-- unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]+-- </pre>+unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a++-- | <i>O(n+m)</i>. Union with a combining function. The implementation+-- uses the efficient <i>hedge-union</i> algorithm. Hedge-union is more+-- efficient on (bigset `<a>union</a>` smallset).+-- +-- <pre>+-- let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value+-- unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]+-- </pre>+unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a++-- | The union of a list of maps: (<tt><a>unions</a> == <a>foldl</a>+-- <a>union</a> <a>empty</a></tt>).+-- +-- <pre>+-- unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]+-- == fromList [(3, "b"), (5, "a"), (7, "C")]+-- unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]+-- == fromList [(3, "B3"), (5, "A3"), (7, "C")]+-- </pre>+unions :: Ord k => [Map k a] -> Map k a++-- | The union of a list of maps, with a combining operation:+-- (<tt><a>unionsWith</a> f == <a>foldl</a> (<a>unionWith</a> f)+-- <a>empty</a></tt>).+-- +-- <pre>+-- unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]+-- == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]+-- </pre>+unionsWith :: Ord k => (a -> a -> a) -> [Map k a] -> Map k a++-- | <i>O(n+m)</i>. Difference of two maps. Return elements of the first+-- map not existing in the second map. The implementation uses an+-- efficient <i>hedge</i> algorithm comparable with <i>hedge-union</i>.+-- +-- <pre>+-- difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"+-- </pre>+difference :: Ord k => Map k a -> Map k b -> Map k a++-- | <i>O(n+m)</i>. Difference with a combining function. When two equal+-- keys are encountered, the combining function is applied to the values+-- of these keys. If it returns <a>Nothing</a>, the element is discarded+-- (proper set difference). If it returns (<tt><a>Just</a> y</tt>), the+-- element is updated with a new value <tt>y</tt>. The implementation+-- uses an efficient <i>hedge</i> algorithm comparable with+-- <i>hedge-union</i>.+-- +-- <pre>+-- let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing+-- differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])+-- == singleton 3 "b:B"+-- </pre>+differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a++-- | <i>O(n+m)</i>. Difference with a combining function. When two equal+-- keys are encountered, the combining function is applied to the key and+-- both values. If it returns <a>Nothing</a>, the element is discarded+-- (proper set difference). If it returns (<tt><a>Just</a> y</tt>), the+-- element is updated with a new value <tt>y</tt>. The implementation+-- uses an efficient <i>hedge</i> algorithm comparable with+-- <i>hedge-union</i>.+-- +-- <pre>+-- let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing+-- differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])+-- == singleton 3 "3:b|B"+-- </pre>+differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a++-- | <i>O(n+m)</i>. Intersection of two maps. Return data in the first map+-- for the keys existing in both maps. (<tt><a>intersection</a> m1 m2 ==+-- <a>intersectionWith</a> <a>const</a> m1 m2</tt>).+-- +-- <pre>+-- intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"+-- </pre>+intersection :: Ord k => Map k a -> Map k b -> Map k a++-- | <i>O(n+m)</i>. Intersection with a combining function.+-- +-- <pre>+-- intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"+-- </pre>+intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c++-- | <i>O(n+m)</i>. Intersection with a combining function. Intersection is+-- more efficient on (bigset `<a>intersection</a>` smallset).+-- +-- <pre>+-- let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar+-- intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"+-- </pre>+intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c++-- | <i>O(n)</i>. Map a function over all values in the map.+-- +-- <pre>+-- map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]+-- </pre>+map :: (a -> b) -> Map k a -> Map k b++-- | <i>O(n)</i>. Map a function over all values in the map.+-- +-- <pre>+-- let f key x = (show key) ++ ":" ++ x+-- mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]+-- </pre>+mapWithKey :: (k -> a -> b) -> Map k a -> Map k b++-- | <i>O(n)</i>. The function <a>mapAccum</a> threads an accumulating+-- argument through the map in ascending order of keys.+-- +-- <pre>+-- let f a b = (a ++ b, b ++ "X")+-- mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])+-- </pre>+mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)++-- | <i>O(n)</i>. The function <a>mapAccumWithKey</a> threads an+-- accumulating argument through the map in ascending order of keys.+-- +-- <pre>+-- let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")+-- mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])+-- </pre>+mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)++-- | <i>O(n)</i>. The function <tt>mapAccumR</tt> threads an accumulating+-- argument through the map in descending order of keys.+mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)++-- | <i>O(n*log n)</i>. <tt><a>mapKeys</a> f s</tt> is the map obtained by+-- applying <tt>f</tt> to each key of <tt>s</tt>.+-- +-- The size of the result may be smaller if <tt>f</tt> maps two or more+-- distinct keys to the same new key. In this case the value at the+-- smallest of these keys is retained.+-- +-- <pre>+-- mapKeys (+ 1) (fromList [(5,"a"), (3,"b")]) == fromList [(4, "b"), (6, "a")]+-- mapKeys (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "c"+-- mapKeys (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "c"+-- </pre>+mapKeys :: Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a++-- | <i>O(n*log n)</i>. <tt><a>mapKeysWith</a> c f s</tt> is the map+-- obtained by applying <tt>f</tt> to each key of <tt>s</tt>.+-- +-- The size of the result may be smaller if <tt>f</tt> maps two or more+-- distinct keys to the same new key. In this case the associated values+-- will be combined using <tt>c</tt>.+-- +-- <pre>+-- mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab"+-- mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"+-- </pre>+mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a++-- | <i>O(n)</i>. <tt><a>mapKeysMonotonic</a> f s == <a>mapKeys</a> f+-- s</tt>, but works only when <tt>f</tt> is strictly monotonic. That is,+-- for any values <tt>x</tt> and <tt>y</tt>, if <tt>x</tt> <+-- <tt>y</tt> then <tt>f x</tt> < <tt>f y</tt>. <i>The precondition is+-- not checked.</i> Semi-formally, we have:+-- +-- <pre>+-- and [x < y ==> f x < f y | x <- ls, y <- ls] +-- ==> mapKeysMonotonic f s == mapKeys f s+-- where ls = keys s+-- </pre>+-- +-- This means that <tt>f</tt> maps distinct original keys to distinct+-- resulting keys. This function has better performance than+-- <a>mapKeys</a>.+-- +-- <pre>+-- mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")]) == fromList [(6, "b"), (10, "a")]+-- valid (mapKeysMonotonic (\ k -> k * 2) (fromList [(5,"a"), (3,"b")])) == True+-- valid (mapKeysMonotonic (\ _ -> 1) (fromList [(5,"a"), (3,"b")])) == False+-- </pre>+mapKeysMonotonic :: (k1 -> k2) -> Map k1 a -> Map k2 a++-- | <i>O(n)</i>. Fold the values in the map, such that <tt><a>fold</a> f z+-- == <a>foldr</a> f z . <a>elems</a></tt>. For example,+-- +-- <pre>+-- elems map = fold (:) [] map+-- </pre>+-- +-- <pre>+-- let f a len = len + (length a)+-- fold f 0 (fromList [(5,"a"), (3,"bbb")]) == 4+-- </pre>+fold :: (a -> b -> b) -> b -> Map k a -> b++-- | <i>O(n)</i>. Fold the keys and values in the map, such that+-- <tt><a>foldWithKey</a> f z == <a>foldr</a> (<a>uncurry</a> f) z .+-- <a>toAscList</a></tt>. For example,+-- +-- <pre>+-- keys map = foldWithKey (\k x ks -> k:ks) [] map+-- </pre>+-- +-- <pre>+-- let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"+-- foldWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"+-- </pre>+-- +-- This is identical to <a>foldrWithKey</a>, and you should use that one+-- instead of this one. This name is kept for backward compatibility.+foldWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b++-- | <i>O(n)</i>. Post-order fold. The function will be applied from the+-- lowest value to the highest.+foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b++-- | <i>O(n)</i>. Pre-order fold. The function will be applied from the+-- highest value to the lowest.+foldlWithKey :: (b -> k -> a -> b) -> b -> Map k a -> b++-- | <i>O(n)</i>. Return all elements of the map in the ascending order of+-- their keys.+-- +-- <pre>+-- elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]+-- elems empty == []+-- </pre>+elems :: Map k a -> [a]++-- | <i>O(n)</i>. Return all keys of the map in ascending order.+-- +-- <pre>+-- keys (fromList [(5,"a"), (3,"b")]) == [3,5]+-- keys empty == []+-- </pre>+keys :: Map k a -> [k]++-- | <i>O(n)</i>. The set of all keys of the map.+-- +-- <pre>+-- keysSet (fromList [(5,"a"), (3,"b")]) == Data.Set.fromList [3,5]+-- keysSet empty == Data.Set.empty+-- </pre>+keysSet :: Map k a -> Set k++-- | <i>O(n)</i>. Return all key/value pairs in the map in ascending key+-- order.+-- +-- <pre>+-- assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- assocs empty == []+-- </pre>+assocs :: Map k a -> [(k, a)]++-- | <i>O(n)</i>. Convert to a list of key/value pairs.+-- +-- <pre>+-- toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- toList empty == []+-- </pre>+toList :: Map k a -> [(k, a)]++-- | <i>O(n*log n)</i>. Build a map from a list of key/value pairs. See+-- also <a>fromAscList</a>. If the list contains more than one value for+-- the same key, the last value for the key is retained.+-- +-- <pre>+-- fromList [] == empty+-- fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]+-- fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]+-- </pre>+fromList :: Ord k => [(k, a)] -> Map k a++-- | <i>O(n*log n)</i>. Build a map from a list of key/value pairs with a+-- combining function. See also <a>fromAscListWith</a>.+-- +-- <pre>+-- fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]+-- fromListWith (++) [] == empty+-- </pre>+fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a++-- | <i>O(n*log n)</i>. Build a map from a list of key/value pairs with a+-- combining function. See also <a>fromAscListWithKey</a>.+-- +-- <pre>+-- let f k a1 a2 = (show k) ++ a1 ++ a2+-- fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]+-- fromListWithKey f [] == empty+-- </pre>+fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a++-- | <i>O(n)</i>. Convert to an ascending list.+-- +-- <pre>+-- toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- </pre>+toAscList :: Map k a -> [(k, a)]++-- | <i>O(n)</i>. Convert to a descending list.+toDescList :: Map k a -> [(k, a)]++-- | <i>O(n)</i>. Build a map from an ascending list in linear time. <i>The+-- precondition (input list is ascending) is not checked.</i>+-- +-- <pre>+-- fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]+-- fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]+-- valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True+-- valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False+-- </pre>+fromAscList :: Eq k => [(k, a)] -> Map k a++-- | <i>O(n)</i>. Build a map from an ascending list in linear time with a+-- combining function for equal keys. <i>The precondition (input list is+-- ascending) is not checked.</i>+-- +-- <pre>+-- fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]+-- valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True+-- valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False+-- </pre>+fromAscListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a++-- | <i>O(n)</i>. Build a map from an ascending list in linear time with a+-- combining function for equal keys. <i>The precondition (input list is+-- ascending) is not checked.</i>+-- +-- <pre>+-- let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2+-- fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]+-- valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True+-- valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False+-- </pre>+fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a++-- | <i>O(n)</i>. Build a map from an ascending list of distinct elements+-- in linear time. <i>The precondition is not checked.</i>+-- +-- <pre>+-- fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]+-- valid (fromDistinctAscList [(3,"b"), (5,"a")]) == True+-- valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == False+-- </pre>+fromDistinctAscList :: [(k, a)] -> Map k a++-- | <i>O(n)</i>. Filter all values that satisfy the predicate.+-- +-- <pre>+-- filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty+-- filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty+-- </pre>+filter :: Ord k => (a -> Bool) -> Map k a -> Map k a++-- | <i>O(n)</i>. Filter all keys/values that satisfy the predicate.+-- +-- <pre>+-- filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+filterWithKey :: Ord k => (k -> a -> Bool) -> Map k a -> Map k a++-- | <i>O(n)</i>. Partition the map according to a predicate. The first map+-- contains all elements that satisfy the predicate, the second all+-- elements that fail the predicate. See also <a>split</a>.+-- +-- <pre>+-- partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")+-- partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)+-- partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])+-- </pre>+partition :: Ord k => (a -> Bool) -> Map k a -> (Map k a, Map k a)++-- | <i>O(n)</i>. Partition the map according to a predicate. The first map+-- contains all elements that satisfy the predicate, the second all+-- elements that fail the predicate. See also <a>split</a>.+-- +-- <pre>+-- partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b")+-- partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)+-- partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])+-- </pre>+partitionWithKey :: Ord k => (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)++-- | <i>O(n)</i>. Map values and collect the <a>Just</a> results.+-- +-- <pre>+-- let f x = if x == "a" then Just "new a" else Nothing+-- mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"+-- </pre>+mapMaybe :: Ord k => (a -> Maybe b) -> Map k a -> Map k b++-- | <i>O(n)</i>. Map keys/values and collect the <a>Just</a> results.+-- +-- <pre>+-- let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing+-- mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"+-- </pre>+mapMaybeWithKey :: Ord k => (k -> a -> Maybe b) -> Map k a -> Map k b++-- | <i>O(n)</i>. Map values and separate the <a>Left</a> and <a>Right</a>+-- results.+-- +-- <pre>+-- let f a = if a < "c" then Left a else Right a+-- mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])+-- +-- mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- </pre>+mapEither :: Ord k => (a -> Either b c) -> Map k a -> (Map k b, Map k c)++-- | <i>O(n)</i>. Map keys/values and separate the <a>Left</a> and+-- <a>Right</a> results.+-- +-- <pre>+-- let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)+-- mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])+-- +-- mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])+-- </pre>+mapEitherWithKey :: Ord k => (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)++-- | <i>O(log n)</i>. The expression (<tt><a>split</a> k map</tt>) is a+-- pair <tt>(map1,map2)</tt> where the keys in <tt>map1</tt> are smaller+-- than <tt>k</tt> and the keys in <tt>map2</tt> larger than <tt>k</tt>.+-- Any key equal to <tt>k</tt> is found in neither <tt>map1</tt> nor+-- <tt>map2</tt>.+-- +-- <pre>+-- split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])+-- split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")+-- split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")+-- split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)+-- split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)+-- </pre>+split :: Ord k => k -> Map k a -> (Map k a, Map k a)++-- | <i>O(log n)</i>. The expression (<tt><a>splitLookup</a> k map</tt>)+-- splits a map just like <a>split</a> but also returns <tt><a>lookup</a>+-- k map</tt>.+-- +-- <pre>+-- splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")])+-- splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a")+-- splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a")+-- splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty)+-- splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)+-- </pre>+splitLookup :: Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)++-- | <i>O(n+m)</i>. This function is defined as (<tt><a>isSubmapOf</a> =+-- <a>isSubmapOfBy</a> (==)</tt>).+isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool++-- | <i>O(n+m)</i>. The expression (<tt><a>isSubmapOfBy</a> f t1 t2</tt>)+-- returns <a>True</a> if all keys in <tt>t1</tt> are in tree+-- <tt>t2</tt>, and when <tt>f</tt> returns <a>True</a> when applied to+-- their respective values. For example, the following expressions are+-- all <a>True</a>:+-- +-- <pre>+-- isSubmapOfBy (==) (fromList [('a',1)]) (fromList [('a',1),('b',2)])+-- isSubmapOfBy (<=) (fromList [('a',1)]) (fromList [('a',1),('b',2)])+-- isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1),('b',2)])+-- </pre>+-- +-- But the following are all <a>False</a>:+-- +-- <pre>+-- isSubmapOfBy (==) (fromList [('a',2)]) (fromList [('a',1),('b',2)])+-- isSubmapOfBy (<) (fromList [('a',1)]) (fromList [('a',1),('b',2)])+-- isSubmapOfBy (==) (fromList [('a',1),('b',2)]) (fromList [('a',1)])+-- </pre>+isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool++-- | <i>O(n+m)</i>. Is this a proper submap? (ie. a submap but not equal).+-- Defined as (<tt><a>isProperSubmapOf</a> = <a>isProperSubmapOfBy</a>+-- (==)</tt>).+isProperSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool++-- | <i>O(n+m)</i>. Is this a proper submap? (ie. a submap but not equal).+-- The expression (<tt><a>isProperSubmapOfBy</a> f m1 m2</tt>) returns+-- <a>True</a> when <tt>m1</tt> and <tt>m2</tt> are not equal, all keys+-- in <tt>m1</tt> are in <tt>m2</tt>, and when <tt>f</tt> returns+-- <a>True</a> when applied to their respective values. For example, the+-- following expressions are all <a>True</a>:+-- +-- <pre>+-- isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- </pre>+-- +-- But the following are all <a>False</a>:+-- +-- <pre>+-- isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)])+-- isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)])+-- isProperSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- </pre>+isProperSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool++-- | <i>O(log n)</i>. Lookup the <i>index</i> of a key. The index is a+-- number from <i>0</i> up to, but not including, the <a>size</a> of the+-- map.+-- +-- <pre>+-- isJust (lookupIndex 2 (fromList [(5,"a"), (3,"b")])) == False+-- fromJust (lookupIndex 3 (fromList [(5,"a"), (3,"b")])) == 0+-- fromJust (lookupIndex 5 (fromList [(5,"a"), (3,"b")])) == 1+-- isJust (lookupIndex 6 (fromList [(5,"a"), (3,"b")])) == False+-- </pre>+lookupIndex :: Ord k => k -> Map k a -> Maybe Int++-- | <i>O(log n)</i>. Return the <i>index</i> of a key. The index is a+-- number from <i>0</i> up to, but not including, the <a>size</a> of the+-- map. Calls <a>error</a> when the key is not a <a>member</a> of the+-- map.+-- +-- <pre>+-- findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map+-- findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0+-- findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1+-- findIndex 6 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map+-- </pre>+findIndex :: Ord k => k -> Map k a -> Int++-- | <i>O(log n)</i>. Retrieve an element by <i>index</i>. Calls+-- <a>error</a> when an invalid index is used.+-- +-- <pre>+-- elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b")+-- elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a")+-- elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- </pre>+elemAt :: Int -> Map k a -> (k, a)++-- | <i>O(log n)</i>. Update the element at <i>index</i>. Calls+-- <a>error</a> when an invalid index is used.+-- +-- <pre>+-- updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")]+-- updateAt (\ _ _ -> Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")]+-- updateAt (\ _ _ -> Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- updateAt (\ _ _ -> Just "x") (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- updateAt (\_ _ -> Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- updateAt (\_ _ -> Nothing) 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- updateAt (\_ _ -> Nothing) 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- updateAt (\_ _ -> Nothing) (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- </pre>+updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a++-- | <i>O(log n)</i>. Delete the element at <i>index</i>. Defined as+-- (<tt><a>deleteAt</a> i map = <a>updateAt</a> (k x ->+-- <a>Nothing</a>) i map</tt>).+-- +-- <pre>+-- deleteAt 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- deleteAt 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- deleteAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- deleteAt (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range+-- </pre>+deleteAt :: Int -> Map k a -> Map k a++-- | <i>O(log n)</i>. The minimal key of the map. Calls <a>error</a> is the+-- map is empty.+-- +-- <pre>+-- findMin (fromList [(5,"a"), (3,"b")]) == (3,"b")+-- findMin empty Error: empty map has no minimal element+-- </pre>+findMin :: Map k a -> (k, a)++-- | <i>O(log n)</i>. The maximal key of the map. Calls <a>error</a> is the+-- map is empty.+-- +-- <pre>+-- findMax (fromList [(5,"a"), (3,"b")]) == (5,"a")+-- findMax empty Error: empty map has no maximal element+-- </pre>+findMax :: Map k a -> (k, a)++-- | <i>O(log n)</i>. Delete the minimal key. Returns an empty map if the+-- map is empty.+-- +-- <pre>+-- deleteMin (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(5,"a"), (7,"c")]+-- deleteMin empty == empty+-- </pre>+deleteMin :: Map k a -> Map k a++-- | <i>O(log n)</i>. Delete the maximal key. Returns an empty map if the+-- map is empty.+-- +-- <pre>+-- deleteMax (fromList [(5,"a"), (3,"b"), (7,"c")]) == fromList [(3,"b"), (5,"a")]+-- deleteMax empty == empty+-- </pre>+deleteMax :: Map k a -> Map k a++-- | <i>O(log n)</i>. Delete and find the minimal element.+-- +-- <pre>+-- deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")]) +-- deleteFindMin Error: can not return the minimal element of an empty map+-- </pre>+deleteFindMin :: Map k a -> ((k, a), Map k a)++-- | <i>O(log n)</i>. Delete and find the maximal element.+-- +-- <pre>+-- deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")])+-- deleteFindMax empty Error: can not return the maximal element of an empty map+-- </pre>+deleteFindMax :: Map k a -> ((k, a), Map k a)++-- | <i>O(log n)</i>. Update the value at the minimal key.+-- +-- <pre>+-- updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]+-- updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateMin :: (a -> Maybe a) -> Map k a -> Map k a++-- | <i>O(log n)</i>. Update the value at the maximal key.+-- +-- <pre>+-- updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]+-- updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- </pre>+updateMax :: (a -> Maybe a) -> Map k a -> Map k a++-- | <i>O(log n)</i>. Update the value at the minimal key.+-- +-- <pre>+-- updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]+-- updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a++-- | <i>O(log n)</i>. Update the value at the maximal key.+-- +-- <pre>+-- updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]+-- updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- </pre>+updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a++-- | <i>O(log n)</i>. Retrieves the value associated with minimal key of+-- the map, and the map stripped of that element, or <a>Nothing</a> if+-- passed an empty map.+-- +-- <pre>+-- minView (fromList [(5,"a"), (3,"b")]) == Just ("b", singleton 5 "a")+-- minView empty == Nothing+-- </pre>+minView :: Map k a -> Maybe (a, Map k a)++-- | <i>O(log n)</i>. Retrieves the value associated with maximal key of+-- the map, and the map stripped of that element, or <a>Nothing</a> if+-- passed an+-- +-- <pre>+-- maxView (fromList [(5,"a"), (3,"b")]) == Just ("a", singleton 3 "b")+-- maxView empty == Nothing+-- </pre>+maxView :: Map k a -> Maybe (a, Map k a)++-- | <i>O(log n)</i>. Retrieves the minimal (key,value) pair of the map,+-- and the map stripped of that element, or <a>Nothing</a> if passed an+-- empty map.+-- +-- <pre>+-- minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a")+-- minViewWithKey empty == Nothing+-- </pre>+minViewWithKey :: Map k a -> Maybe ((k, a), Map k a)++-- | <i>O(log n)</i>. Retrieves the maximal (key,value) pair of the map,+-- and the map stripped of that element, or <a>Nothing</a> if passed an+-- empty map.+-- +-- <pre>+-- maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b")+-- maxViewWithKey empty == Nothing+-- </pre>+maxViewWithKey :: Map k a -> Maybe ((k, a), Map k a)++-- | <i>O(n)</i>. Show the tree that implements the map. The tree is shown+-- in a compressed, hanging format. See <a>showTreeWith</a>.+showTree :: (Show k, Show a) => Map k a -> String++-- | <i>O(n)</i>. The expression (<tt><a>showTreeWith</a> showelem hang+-- wide map</tt>) shows the tree that implements the map. Elements are+-- shown using the <tt>showElem</tt> function. If <tt>hang</tt> is+-- <a>True</a>, a <i>hanging</i> tree is shown otherwise a rotated tree+-- is shown. If <tt>wide</tt> is <a>True</a>, an extra wide version is+-- shown.+-- +-- <pre>+-- Map> let t = fromDistinctAscList [(x,()) | x <- [1..5]]+-- Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True False t+-- (4,())+-- +--(2,())+-- | +--(1,())+-- | +--(3,())+-- +--(5,())+-- +-- Map> putStrLn $ showTreeWith (\k x -> show (k,x)) True True t+-- (4,())+-- |+-- +--(2,())+-- | |+-- | +--(1,())+-- | |+-- | +--(3,())+-- |+-- +--(5,())+-- +-- Map> putStrLn $ showTreeWith (\k x -> show (k,x)) False True t+-- +--(5,())+-- |+-- (4,())+-- |+-- | +--(3,())+-- | |+-- +--(2,())+-- |+-- +--(1,())+-- </pre>+showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String++-- | <i>O(n)</i>. Test if the internal map structure is valid.+-- +-- <pre>+-- valid (fromAscList [(3,"b"), (5,"a")]) == True+-- valid (fromAscList [(5,"a"), (3,"b")]) == False+-- </pre>+valid :: Ord k => Map k a -> Bool+instance Typeable2 Map+instance (Show k, Show a) => Show (Map k a)+instance (Ord k, Read k, Read e) => Read (Map k e)+instance Foldable (Map k)+instance Traversable (Map k)+instance Functor (Map k)+instance (Ord k, Ord v) => Ord (Map k v)+instance (Eq k, Eq a) => Eq (Map k a)+instance (Data k, Data a, Ord k) => Data (Map k a)+instance Ord k => Monoid (Map k v)+++-- | An efficient implementation of integer sets.+-- +-- Since many function names (but not the type name) clash with+-- <a>Prelude</a> names, this module is usually imported+-- <tt>qualified</tt>, e.g.+-- +-- <pre>+-- import Data.IntSet (IntSet)+-- import qualified Data.IntSet as IntSet+-- </pre>+-- +-- The implementation is based on <i>big-endian patricia trees</i>. This+-- data structure performs especially well on binary operations like+-- <a>union</a> and <a>intersection</a>. However, my benchmarks show that+-- it is also (much) faster on insertions and deletions when compared to+-- a generic size-balanced set implementation (see <a>Data.Set</a>).+-- +-- <ul>+-- <li>Chris Okasaki and Andy Gill, "<i>Fast Mergeable Integer Maps</i>",+-- Workshop on ML, September 1998, pages 77-86,+-- <a>http://citeseer.ist.psu.edu/okasaki98fast.html</a></li>+-- <li>D.R. Morrison, "/PATRICIA -- Practical Algorithm To Retrieve+-- Information Coded In Alphanumeric/", Journal of the ACM, 15(4),+-- October 1968, pages 514-534.</li>+-- </ul>+-- +-- Many operations have a worst-case complexity of <i>O(min(n,W))</i>.+-- This means that the operation can become linear in the number of+-- elements with a maximum of <i>W</i> -- the number of bits in an+-- <a>Int</a> (32 or 64).+module Data.IntSet++-- | A set of integers.+data IntSet++-- | <i>O(n+m)</i>. See <a>difference</a>.+(\\) :: IntSet -> IntSet -> IntSet++-- | <i>O(1)</i>. Is the set empty?+null :: IntSet -> Bool++-- | <i>O(n)</i>. Cardinality of the set.+size :: IntSet -> Int++-- | <i>O(min(n,W))</i>. Is the value a member of the set?+member :: Int -> IntSet -> Bool++-- | <i>O(min(n,W))</i>. Is the element not in the set?+notMember :: Int -> IntSet -> Bool++-- | <i>O(n+m)</i>. Is this a subset? <tt>(s1 <a>isSubsetOf</a> s2)</tt>+-- tells whether <tt>s1</tt> is a subset of <tt>s2</tt>.+isSubsetOf :: IntSet -> IntSet -> Bool++-- | <i>O(n+m)</i>. Is this a proper subset? (ie. a subset but not equal).+isProperSubsetOf :: IntSet -> IntSet -> Bool++-- | <i>O(1)</i>. The empty set.+empty :: IntSet++-- | <i>O(1)</i>. A set of one element.+singleton :: Int -> IntSet++-- | <i>O(min(n,W))</i>. Add a value to the set. When the value is already+-- an element of the set, it is replaced by the new one, ie.+-- <a>insert</a> is left-biased.+insert :: Int -> IntSet -> IntSet++-- | <i>O(min(n,W))</i>. Delete a value in the set. Returns the original+-- set when the value was not present.+delete :: Int -> IntSet -> IntSet++-- | <i>O(n+m)</i>. The union of two sets.+union :: IntSet -> IntSet -> IntSet++-- | The union of a list of sets.+unions :: [IntSet] -> IntSet++-- | <i>O(n+m)</i>. Difference between two sets.+difference :: IntSet -> IntSet -> IntSet++-- | <i>O(n+m)</i>. The intersection of two sets.+intersection :: IntSet -> IntSet -> IntSet++-- | <i>O(n)</i>. Filter all elements that satisfy some predicate.+filter :: (Int -> Bool) -> IntSet -> IntSet++-- | <i>O(n)</i>. partition the set according to some predicate.+partition :: (Int -> Bool) -> IntSet -> (IntSet, IntSet)++-- | <i>O(min(n,W))</i>. The expression (<tt><a>split</a> x set</tt>) is a+-- pair <tt>(set1,set2)</tt> where <tt>set1</tt> comprises the elements+-- of <tt>set</tt> less than <tt>x</tt> and <tt>set2</tt> comprises the+-- elements of <tt>set</tt> greater than <tt>x</tt>.+-- +-- <pre>+-- split 3 (fromList [1..5]) == (fromList [1,2], fromList [4,5])+-- </pre>+split :: Int -> IntSet -> (IntSet, IntSet)++-- | <i>O(min(n,W))</i>. Performs a <a>split</a> but also returns whether+-- the pivot element was found in the original set.+splitMember :: Int -> IntSet -> (IntSet, Bool, IntSet)++-- | <i>O(min(n,W))</i>. The minimal element of the set.+findMin :: IntSet -> Int++-- | <i>O(min(n,W))</i>. The maximal element of a set.+findMax :: IntSet -> Int++-- | <i>O(min(n,W))</i>. Delete the minimal element.+deleteMin :: IntSet -> IntSet++-- | <i>O(min(n,W))</i>. Delete the maximal element.+deleteMax :: IntSet -> IntSet++-- | <i>O(min(n,W))</i>. Delete and find the minimal element.+-- +-- <pre>+-- deleteFindMin set = (findMin set, deleteMin set)+-- </pre>+deleteFindMin :: IntSet -> (Int, IntSet)++-- | <i>O(min(n,W))</i>. Delete and find the maximal element.+-- +-- <pre>+-- deleteFindMax set = (findMax set, deleteMax set)+-- </pre>+deleteFindMax :: IntSet -> (Int, IntSet)++-- | <i>O(min(n,W))</i>. Retrieves the maximal key of the set, and the set+-- stripped of that element, or <a>Nothing</a> if passed an empty set.+maxView :: IntSet -> Maybe (Int, IntSet)++-- | <i>O(min(n,W))</i>. Retrieves the minimal key of the set, and the set+-- stripped of that element, or <a>Nothing</a> if passed an empty set.+minView :: IntSet -> Maybe (Int, IntSet)++-- | <i>O(n*min(n,W))</i>. <tt><a>map</a> f s</tt> is the set obtained by+-- applying <tt>f</tt> to each element of <tt>s</tt>.+-- +-- It's worth noting that the size of the result may be smaller if, for+-- some <tt>(x,y)</tt>, <tt>x /= y && f x == f y</tt>+map :: (Int -> Int) -> IntSet -> IntSet++-- | <i>O(n)</i>. Fold over the elements of a set in an unspecified order.+-- +-- <pre>+-- sum set == fold (+) 0 set+-- elems set == fold (:) [] set+-- </pre>+fold :: (Int -> b -> b) -> b -> IntSet -> b++-- | <i>O(n)</i>. The elements of a set. (For sets, this is equivalent to+-- toList)+elems :: IntSet -> [Int]++-- | <i>O(n)</i>. Convert the set to a list of elements.+toList :: IntSet -> [Int]++-- | <i>O(n*min(n,W))</i>. Create a set from a list of integers.+fromList :: [Int] -> IntSet++-- | <i>O(n)</i>. Convert the set to an ascending list of elements.+toAscList :: IntSet -> [Int]++-- | <i>O(n)</i>. Build a set from an ascending list of elements. <i>The+-- precondition (input list is ascending) is not checked.</i>+fromAscList :: [Int] -> IntSet++-- | <i>O(n)</i>. Build a set from an ascending list of distinct elements.+-- <i>The precondition (input list is strictly ascending) is not+-- checked.</i>+fromDistinctAscList :: [Int] -> IntSet++-- | <i>O(n)</i>. Show the tree that implements the set. The tree is shown+-- in a compressed, hanging format.+showTree :: IntSet -> String++-- | <i>O(n)</i>. The expression (<tt><a>showTreeWith</a> hang wide+-- map</tt>) shows the tree that implements the set. If <tt>hang</tt> is+-- <a>True</a>, a <i>hanging</i> tree is shown otherwise a rotated tree+-- is shown. If <tt>wide</tt> is <a>True</a>, an extra wide version is+-- shown.+showTreeWith :: Bool -> Bool -> IntSet -> String+instance Typeable IntSet+instance Read IntSet+instance Show IntSet+instance Ord IntSet+instance Eq IntSet+instance Data IntSet+instance Monoid IntSet+++-- | An efficient implementation of maps from integer keys to values.+-- +-- Since many function names (but not the type name) clash with+-- <a>Prelude</a> names, this module is usually imported+-- <tt>qualified</tt>, e.g.+-- +-- <pre>+-- import Data.IntMap (IntMap)+-- import qualified Data.IntMap as IntMap+-- </pre>+-- +-- The implementation is based on <i>big-endian patricia trees</i>. This+-- data structure performs especially well on binary operations like+-- <a>union</a> and <a>intersection</a>. However, my benchmarks show that+-- it is also (much) faster on insertions and deletions when compared to+-- a generic size-balanced map implementation (see <a>Data.Map</a>).+-- +-- <ul>+-- <li>Chris Okasaki and Andy Gill, "<i>Fast Mergeable Integer Maps</i>",+-- Workshop on ML, September 1998, pages 77-86,+-- <a>http://citeseer.ist.psu.edu/okasaki98fast.html</a></li>+-- <li>D.R. Morrison, "/PATRICIA -- Practical Algorithm To Retrieve+-- Information Coded In Alphanumeric/", Journal of the ACM, 15(4),+-- October 1968, pages 514-534.</li>+-- </ul>+-- +-- Operation comments contain the operation time complexity in the Big-O+-- notation <a>http://en.wikipedia.org/wiki/Big_O_notation</a>. Many+-- operations have a worst-case complexity of <i>O(min(n,W))</i>. This+-- means that the operation can become linear in the number of elements+-- with a maximum of <i>W</i> -- the number of bits in an <a>Int</a> (32+-- or 64).+module Data.IntMap++-- | A map of integers to values <tt>a</tt>.+data IntMap a+type Key = Int++-- | <i>O(min(n,W))</i>. Find the value at a key. Calls <a>error</a> when+-- the element can not be found.+-- +-- <pre>+-- fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map+-- fromList [(5,'a'), (3,'b')] ! 5 == 'a'+-- </pre>+(!) :: IntMap a -> Key -> a++-- | Same as <a>difference</a>.+(\\) :: IntMap a -> IntMap b -> IntMap a++-- | <i>O(1)</i>. Is the map empty?+-- +-- <pre>+-- Data.IntMap.null (empty) == True+-- Data.IntMap.null (singleton 1 'a') == False+-- </pre>+null :: IntMap a -> Bool++-- | <i>O(n)</i>. Number of elements in the map.+-- +-- <pre>+-- size empty == 0+-- size (singleton 1 'a') == 1+-- size (fromList([(1,'a'), (2,'c'), (3,'b')])) == 3+-- </pre>+size :: IntMap a -> Int++-- | <i>O(min(n,W))</i>. Is the key a member of the map?+-- +-- <pre>+-- member 5 (fromList [(5,'a'), (3,'b')]) == True+-- member 1 (fromList [(5,'a'), (3,'b')]) == False+-- </pre>+member :: Key -> IntMap a -> Bool++-- | <i>O(log n)</i>. Is the key not a member of the map?+-- +-- <pre>+-- notMember 5 (fromList [(5,'a'), (3,'b')]) == False+-- notMember 1 (fromList [(5,'a'), (3,'b')]) == True+-- </pre>+notMember :: Key -> IntMap a -> Bool++-- | <i>O(min(n,W))</i>. Lookup the value at a key in the map. See also+-- <tt>Data.Map.lookup</tt>.+lookup :: Key -> IntMap a -> Maybe a++-- | <i>O(min(n,W))</i>. The expression <tt>(<a>findWithDefault</a> def k+-- map)</tt> returns the value at key <tt>k</tt> or returns <tt>def</tt>+-- when the key is not an element of the map.+-- +-- <pre>+-- findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'+-- findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'+-- </pre>+findWithDefault :: a -> Key -> IntMap a -> a++-- | <i>O(1)</i>. The empty map.+-- +-- <pre>+-- empty == fromList []+-- size empty == 0+-- </pre>+empty :: IntMap a++-- | <i>O(1)</i>. A map of one element.+-- +-- <pre>+-- singleton 1 'a' == fromList [(1, 'a')]+-- size (singleton 1 'a') == 1+-- </pre>+singleton :: Key -> a -> IntMap a++-- | <i>O(min(n,W))</i>. Insert a new key/value pair in the map. If the key+-- is already present in the map, the associated value is replaced with+-- the supplied value, i.e. <a>insert</a> is equivalent to+-- <tt><a>insertWith</a> <a>const</a></tt>.+-- +-- <pre>+-- insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]+-- insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]+-- insert 5 'x' empty == singleton 5 'x'+-- </pre>+insert :: Key -> a -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. Insert with a combining function.+-- <tt><a>insertWith</a> f key value mp</tt> will insert the pair (key,+-- value) into <tt>mp</tt> if key does not exist in the map. If the key+-- does exist, the function will insert <tt>f new_value old_value</tt>.+-- +-- <pre>+-- insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]+-- insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]+-- insertWith (++) 5 "xxx" empty == singleton 5 "xxx"+-- </pre>+insertWith :: (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. Insert with a combining function.+-- <tt><a>insertWithKey</a> f key value mp</tt> will insert the pair+-- (key, value) into <tt>mp</tt> if key does not exist in the map. If the+-- key does exist, the function will insert <tt>f key new_value+-- old_value</tt>.+-- +-- <pre>+-- let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value+-- insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")]+-- insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]+-- insertWithKey f 5 "xxx" empty == singleton 5 "xxx"+-- </pre>+insertWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. The expression (<tt><a>insertLookupWithKey</a> f k+-- x map</tt>) is a pair where the first element is equal to+-- (<tt><a>lookup</a> k map</tt>) and the second element equal to+-- (<tt><a>insertWithKey</a> f k x map</tt>).+-- +-- <pre>+-- let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value+-- insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")])+-- insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")])+-- insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")+-- </pre>+-- +-- This is how to define <tt>insertLookup</tt> using+-- <tt>insertLookupWithKey</tt>:+-- +-- <pre>+-- let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t+-- insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])+-- insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])+-- </pre>+insertLookupWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> (Maybe a, IntMap a)++-- | <i>O(min(n,W))</i>. Delete a key and its value from the map. When the+-- key is not a member of the map, the original map is returned.+-- +-- <pre>+-- delete 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- delete 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- delete 5 empty == empty+-- </pre>+delete :: Key -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. Adjust a value at a specific key. When the key is+-- not a member of the map, the original map is returned.+-- +-- <pre>+-- adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]+-- adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- adjust ("new " ++) 7 empty == empty+-- </pre>+adjust :: (a -> a) -> Key -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. Adjust a value at a specific key. When the key is+-- not a member of the map, the original map is returned.+-- +-- <pre>+-- let f key x = (show key) ++ ":new " ++ x+-- adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]+-- adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- adjustWithKey f 7 empty == empty+-- </pre>+adjustWithKey :: (Key -> a -> a) -> Key -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. The expression (<tt><a>update</a> f k map</tt>)+-- updates the value <tt>x</tt> at <tt>k</tt> (if it is in the map). If+-- (<tt>f x</tt>) is <a>Nothing</a>, the element is deleted. If it is+-- (<tt><a>Just</a> y</tt>), the key <tt>k</tt> is bound to the new value+-- <tt>y</tt>.+-- +-- <pre>+-- let f x = if x == "a" then Just "new a" else Nothing+-- update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]+-- update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+update :: (a -> Maybe a) -> Key -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. The expression (<tt><a>update</a> f k map</tt>)+-- updates the value <tt>x</tt> at <tt>k</tt> (if it is in the map). If+-- (<tt>f k x</tt>) is <a>Nothing</a>, the element is deleted. If it is+-- (<tt><a>Just</a> y</tt>), the key <tt>k</tt> is bound to the new value+-- <tt>y</tt>.+-- +-- <pre>+-- let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing+-- updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]+-- updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]+-- updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateWithKey :: (Key -> a -> Maybe a) -> Key -> IntMap a -> IntMap a++-- | <i>O(min(n,W))</i>. Lookup and update. The function returns original+-- value, if it is updated. This is different behavior than+-- <tt>Data.Map.updateLookupWithKey</tt>. Returns the original key value+-- if the map entry is deleted.+-- +-- <pre>+-- let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing+-- updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:new a")])+-- updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")])+-- updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")+-- </pre>+updateLookupWithKey :: (Key -> a -> Maybe a) -> Key -> IntMap a -> (Maybe a, IntMap a)++-- | <i>O(log n)</i>. The expression (<tt><a>alter</a> f k map</tt>) alters+-- the value <tt>x</tt> at <tt>k</tt>, or absence thereof. <a>alter</a>+-- can be used to insert, delete, or update a value in an <a>IntMap</a>.+-- In short : <tt><a>lookup</a> k (<a>alter</a> f k m) = f (<a>lookup</a>+-- k m)</tt>.+alter :: (Maybe a -> Maybe a) -> Int -> IntMap a -> IntMap a++-- | <i>O(n+m)</i>. The (left-biased) union of two maps. It prefers the+-- first map when duplicate keys are encountered, i.e. (<tt><a>union</a>+-- == <a>unionWith</a> <a>const</a></tt>).+-- +-- <pre>+-- union (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "a"), (7, "C")]+-- </pre>+union :: IntMap a -> IntMap a -> IntMap a++-- | <i>O(n+m)</i>. The union with a combining function.+-- +-- <pre>+-- unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]+-- </pre>+unionWith :: (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a++-- | <i>O(n+m)</i>. The union with a combining function.+-- +-- <pre>+-- let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value+-- unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]+-- </pre>+unionWithKey :: (Key -> a -> a -> a) -> IntMap a -> IntMap a -> IntMap a++-- | The union of a list of maps.+-- +-- <pre>+-- unions [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]+-- == fromList [(3, "b"), (5, "a"), (7, "C")]+-- unions [(fromList [(5, "A3"), (3, "B3")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "a"), (3, "b")])]+-- == fromList [(3, "B3"), (5, "A3"), (7, "C")]+-- </pre>+unions :: [IntMap a] -> IntMap a++-- | The union of a list of maps, with a combining operation.+-- +-- <pre>+-- unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]+-- == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]+-- </pre>+unionsWith :: (a -> a -> a) -> [IntMap a] -> IntMap a++-- | <i>O(n+m)</i>. Difference between two maps (based on keys).+-- +-- <pre>+-- difference (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 3 "b"+-- </pre>+difference :: IntMap a -> IntMap b -> IntMap a++-- | <i>O(n+m)</i>. Difference with a combining function.+-- +-- <pre>+-- let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing+-- differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])+-- == singleton 3 "b:B"+-- </pre>+differenceWith :: (a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a++-- | <i>O(n+m)</i>. Difference with a combining function. When two equal+-- keys are encountered, the combining function is applied to the key and+-- both values. If it returns <a>Nothing</a>, the element is discarded+-- (proper set difference). If it returns (<tt><a>Just</a> y</tt>), the+-- element is updated with a new value <tt>y</tt>.+-- +-- <pre>+-- let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing+-- differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])+-- == singleton 3 "3:b|B"+-- </pre>+differenceWithKey :: (Key -> a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a++-- | <i>O(n+m)</i>. The (left-biased) intersection of two maps (based on+-- keys).+-- +-- <pre>+-- intersection (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "a"+-- </pre>+intersection :: IntMap a -> IntMap b -> IntMap a++-- | <i>O(n+m)</i>. The intersection with a combining function.+-- +-- <pre>+-- intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"+-- </pre>+intersectionWith :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c++-- | <i>O(n+m)</i>. The intersection with a combining function.+-- +-- <pre>+-- let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar+-- intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"+-- </pre>+intersectionWithKey :: (Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c++-- | <i>O(n)</i>. Map a function over all values in the map.+-- +-- <pre>+-- map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]+-- </pre>+map :: (a -> b) -> IntMap a -> IntMap b++-- | <i>O(n)</i>. Map a function over all values in the map.+-- +-- <pre>+-- let f key x = (show key) ++ ":" ++ x+-- mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]+-- </pre>+mapWithKey :: (Key -> a -> b) -> IntMap a -> IntMap b++-- | <i>O(n)</i>. The function <tt><a>mapAccum</a></tt> threads an+-- accumulating argument through the map in ascending order of keys.+-- +-- <pre>+-- let f a b = (a ++ b, b ++ "X")+-- mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])+-- </pre>+mapAccum :: (a -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)++-- | <i>O(n)</i>. The function <tt><a>mapAccumWithKey</a></tt> threads an+-- accumulating argument through the map in ascending order of keys.+-- +-- <pre>+-- let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")+-- mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])+-- </pre>+mapAccumWithKey :: (a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)++-- | <i>O(n)</i>. The function <tt><tt>mapAccumR</tt></tt> threads an+-- accumulating argument through the map in descending order of keys.+mapAccumRWithKey :: (a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)++-- | <i>O(n)</i>. Fold the values in the map, such that <tt><a>fold</a> f z+-- == <tt>Prelude.foldr</tt> f z . <a>elems</a></tt>. For example,+-- +-- <pre>+-- elems map = fold (:) [] map+-- </pre>+-- +-- <pre>+-- let f a len = len + (length a)+-- fold f 0 (fromList [(5,"a"), (3,"bbb")]) == 4+-- </pre>+fold :: (a -> b -> b) -> b -> IntMap a -> b++-- | <i>O(n)</i>. Fold the keys and values in the map, such that+-- <tt><a>foldWithKey</a> f z == <tt>Prelude.foldr</tt> (<a>uncurry</a>+-- f) z . <a>toAscList</a></tt>. For example,+-- +-- <pre>+-- keys map = foldWithKey (\k x ks -> k:ks) [] map+-- </pre>+-- +-- <pre>+-- let f k a result = result ++ "(" ++ (show k) ++ ":" ++ a ++ ")"+-- foldWithKey f "Map: " (fromList [(5,"a"), (3,"b")]) == "Map: (5:a)(3:b)"+-- </pre>+foldWithKey :: (Key -> a -> b -> b) -> b -> IntMap a -> b++-- | <i>O(n)</i>. Return all elements of the map in the ascending order of+-- their keys.+-- +-- <pre>+-- elems (fromList [(5,"a"), (3,"b")]) == ["b","a"]+-- elems empty == []+-- </pre>+elems :: IntMap a -> [a]++-- | <i>O(n)</i>. Return all keys of the map in ascending order.+-- +-- <pre>+-- keys (fromList [(5,"a"), (3,"b")]) == [3,5]+-- keys empty == []+-- </pre>+keys :: IntMap a -> [Key]++-- | <i>O(n*min(n,W))</i>. The set of all keys of the map.+-- +-- <pre>+-- keysSet (fromList [(5,"a"), (3,"b")]) == Data.IntSet.fromList [3,5]+-- keysSet empty == Data.IntSet.empty+-- </pre>+keysSet :: IntMap a -> IntSet++-- | <i>O(n)</i>. Return all key/value pairs in the map in ascending key+-- order.+-- +-- <pre>+-- assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- assocs empty == []+-- </pre>+assocs :: IntMap a -> [(Key, a)]++-- | <i>O(n)</i>. Convert the map to a list of key/value pairs.+-- +-- <pre>+-- toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- toList empty == []+-- </pre>+toList :: IntMap a -> [(Key, a)]++-- | <i>O(n*min(n,W))</i>. Create a map from a list of key/value pairs.+-- +-- <pre>+-- fromList [] == empty+-- fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]+-- fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]+-- </pre>+fromList :: [(Key, a)] -> IntMap a++-- | <i>O(n*min(n,W))</i>. Create a map from a list of key/value pairs with+-- a combining function. See also <a>fromAscListWith</a>.+-- +-- <pre>+-- fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]+-- fromListWith (++) [] == empty+-- </pre>+fromListWith :: (a -> a -> a) -> [(Key, a)] -> IntMap a++-- | <i>O(n*min(n,W))</i>. Build a map from a list of key/value pairs with+-- a combining function. See also fromAscListWithKey'.+-- +-- <pre>+-- fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]+-- fromListWith (++) [] == empty+-- </pre>+fromListWithKey :: (Key -> a -> a -> a) -> [(Key, a)] -> IntMap a++-- | <i>O(n)</i>. Convert the map to a list of key/value pairs where the+-- keys are in ascending order.+-- +-- <pre>+-- toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]+-- </pre>+toAscList :: IntMap a -> [(Key, a)]++-- | <i>O(n)</i>. Build a map from a list of key/value pairs where the keys+-- are in ascending order.+-- +-- <pre>+-- fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]+-- fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]+-- </pre>+fromAscList :: [(Key, a)] -> IntMap a++-- | <i>O(n)</i>. Build a map from a list of key/value pairs where the keys+-- are in ascending order, with a combining function on equal keys.+-- <i>The precondition (input list is ascending) is not checked.</i>+-- +-- <pre>+-- fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]+-- </pre>+fromAscListWith :: (a -> a -> a) -> [(Key, a)] -> IntMap a++-- | <i>O(n)</i>. Build a map from a list of key/value pairs where the keys+-- are in ascending order, with a combining function on equal keys.+-- <i>The precondition (input list is ascending) is not checked.</i>+-- +-- <pre>+-- fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]+-- </pre>+fromAscListWithKey :: (Key -> a -> a -> a) -> [(Key, a)] -> IntMap a++-- | <i>O(n)</i>. Build a map from a list of key/value pairs where the keys+-- are in ascending order and all distinct. <i>The precondition (input+-- list is strictly ascending) is not checked.</i>+-- +-- <pre>+-- fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]+-- </pre>+fromDistinctAscList :: [(Key, a)] -> IntMap a++-- | <i>O(n)</i>. Filter all values that satisfy some predicate.+-- +-- <pre>+-- filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty+-- filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty+-- </pre>+filter :: (a -> Bool) -> IntMap a -> IntMap a++-- | <i>O(n)</i>. Filter all keys/values that satisfy some predicate.+-- +-- <pre>+-- filterWithKey (\k _ -> k > 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+filterWithKey :: (Key -> a -> Bool) -> IntMap a -> IntMap a++-- | <i>O(n)</i>. Partition the map according to some predicate. The first+-- map contains all elements that satisfy the predicate, the second all+-- elements that fail the predicate. See also <a>split</a>.+-- +-- <pre>+-- partition (> "a") (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")+-- partition (< "x") (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)+-- partition (> "x") (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])+-- </pre>+partition :: (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)++-- | <i>O(n)</i>. Partition the map according to some predicate. The first+-- map contains all elements that satisfy the predicate, the second all+-- elements that fail the predicate. See also <a>split</a>.+-- +-- <pre>+-- partitionWithKey (\ k _ -> k > 3) (fromList [(5,"a"), (3,"b")]) == (singleton 5 "a", singleton 3 "b")+-- partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) == (fromList [(3, "b"), (5, "a")], empty)+-- partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3, "b"), (5, "a")])+-- </pre>+partitionWithKey :: (Key -> a -> Bool) -> IntMap a -> (IntMap a, IntMap a)++-- | <i>O(n)</i>. Map values and collect the <a>Just</a> results.+-- +-- <pre>+-- let f x = if x == "a" then Just "new a" else Nothing+-- mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"+-- </pre>+mapMaybe :: (a -> Maybe b) -> IntMap a -> IntMap b++-- | <i>O(n)</i>. Map keys/values and collect the <a>Just</a> results.+-- +-- <pre>+-- let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing+-- mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"+-- </pre>+mapMaybeWithKey :: (Key -> a -> Maybe b) -> IntMap a -> IntMap b++-- | <i>O(n)</i>. Map values and separate the <a>Left</a> and <a>Right</a>+-- results.+-- +-- <pre>+-- let f a = if a < "c" then Left a else Right a+-- mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])+-- +-- mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- </pre>+mapEither :: (a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)++-- | <i>O(n)</i>. Map keys/values and separate the <a>Left</a> and+-- <a>Right</a> results.+-- +-- <pre>+-- let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)+-- mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])+-- +-- mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])+-- == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])+-- </pre>+mapEitherWithKey :: (Key -> a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)++-- | <i>O(log n)</i>. The expression (<tt><a>split</a> k map</tt>) is a+-- pair <tt>(map1,map2)</tt> where all keys in <tt>map1</tt> are lower+-- than <tt>k</tt> and all keys in <tt>map2</tt> larger than <tt>k</tt>.+-- Any key equal to <tt>k</tt> is found in neither <tt>map1</tt> nor+-- <tt>map2</tt>.+-- +-- <pre>+-- split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])+-- split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")+-- split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")+-- split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)+-- split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)+-- </pre>+split :: Key -> IntMap a -> (IntMap a, IntMap a)++-- | <i>O(log n)</i>. Performs a <a>split</a> but also returns whether the+-- pivot key was found in the original map.+-- +-- <pre>+-- splitLookup 2 (fromList [(5,"a"), (3,"b")]) == (empty, Nothing, fromList [(3,"b"), (5,"a")])+-- splitLookup 3 (fromList [(5,"a"), (3,"b")]) == (empty, Just "b", singleton 5 "a")+-- splitLookup 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Nothing, singleton 5 "a")+-- splitLookup 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", Just "a", empty)+-- splitLookup 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], Nothing, empty)+-- </pre>+splitLookup :: Key -> IntMap a -> (IntMap a, Maybe a, IntMap a)++-- | <i>O(n+m)</i>. Is this a submap? Defined as (<tt><a>isSubmapOf</a> =+-- <a>isSubmapOfBy</a> (==)</tt>).+isSubmapOf :: Eq a => IntMap a -> IntMap a -> Bool++-- | <i>O(n+m)</i>. The expression (<tt><a>isSubmapOfBy</a> f m1 m2</tt>)+-- returns <a>True</a> if all keys in <tt>m1</tt> are in <tt>m2</tt>, and+-- when <tt>f</tt> returns <a>True</a> when applied to their respective+-- values. For example, the following expressions are all <a>True</a>:+-- +-- <pre>+-- isSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- isSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)])+-- </pre>+-- +-- But the following are all <a>False</a>:+-- +-- <pre>+-- isSubmapOfBy (==) (fromList [(1,2)]) (fromList [(1,1),(2,2)])+-- isSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- isSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)])+-- </pre>+isSubmapOfBy :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool++-- | <i>O(n+m)</i>. Is this a proper submap? (ie. a submap but not equal).+-- Defined as (<tt><a>isProperSubmapOf</a> = <a>isProperSubmapOfBy</a>+-- (==)</tt>).+isProperSubmapOf :: Eq a => IntMap a -> IntMap a -> Bool++-- | <i>O(n+m)</i>. Is this a proper submap? (ie. a submap but not equal).+-- The expression (<tt><a>isProperSubmapOfBy</a> f m1 m2</tt>) returns+-- <a>True</a> when <tt>m1</tt> and <tt>m2</tt> are not equal, all keys+-- in <tt>m1</tt> are in <tt>m2</tt>, and when <tt>f</tt> returns+-- <a>True</a> when applied to their respective values. For example, the+-- following expressions are all <a>True</a>:+-- +-- <pre>+-- isProperSubmapOfBy (==) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- isProperSubmapOfBy (<=) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- </pre>+-- +-- But the following are all <a>False</a>:+-- +-- <pre>+-- isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1),(2,2)])+-- isProperSubmapOfBy (==) (fromList [(1,1),(2,2)]) (fromList [(1,1)])+-- isProperSubmapOfBy (<) (fromList [(1,1)]) (fromList [(1,1),(2,2)])+-- </pre>+isProperSubmapOfBy :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool++-- | <i>O(log n)</i>. Retrieves the maximal key of the map, and the map+-- stripped of that element, or <a>Nothing</a> if passed an empty map.+maxView :: IntMap a -> Maybe (a, IntMap a)++-- | <i>O(log n)</i>. Retrieves the minimal key of the map, and the map+-- stripped of that element, or <a>Nothing</a> if passed an empty map.+minView :: IntMap a -> Maybe (a, IntMap a)++-- | <i>O(log n)</i>. The minimal key of the map.+findMin :: IntMap a -> (Int, a)++-- | <i>O(log n)</i>. The maximal key of the map.+findMax :: IntMap a -> (Int, a)++-- | <i>O(log n)</i>. Delete the minimal key. An error is thrown if the+-- IntMap is already empty. Note, this is not the same behavior Map.+deleteMin :: IntMap a -> IntMap a++-- | <i>O(log n)</i>. Delete the maximal key. An error is thrown if the+-- IntMap is already empty. Note, this is not the same behavior Map.+deleteMax :: IntMap a -> IntMap a++-- | <i>O(log n)</i>. Delete and find the minimal element.+deleteFindMin :: IntMap a -> (a, IntMap a)++-- | <i>O(log n)</i>. Delete and find the maximal element.+deleteFindMax :: IntMap a -> (a, IntMap a)++-- | <i>O(log n)</i>. Update the value at the minimal key.+-- +-- <pre>+-- updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]+-- updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateMin :: (a -> a) -> IntMap a -> IntMap a++-- | <i>O(log n)</i>. Update the value at the maximal key.+-- +-- <pre>+-- updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]+-- updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- </pre>+updateMax :: (a -> a) -> IntMap a -> IntMap a++-- | <i>O(log n)</i>. Update the value at the minimal key.+-- +-- <pre>+-- updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]+-- updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"+-- </pre>+updateMinWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a++-- | <i>O(log n)</i>. Update the value at the maximal key.+-- +-- <pre>+-- updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]+-- updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"+-- </pre>+updateMaxWithKey :: (Key -> a -> a) -> IntMap a -> IntMap a++-- | <i>O(log n)</i>. Retrieves the minimal (key,value) pair of the map,+-- and the map stripped of that element, or <a>Nothing</a> if passed an+-- empty map.+-- +-- <pre>+-- minViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((3,"b"), singleton 5 "a")+-- minViewWithKey empty == Nothing+-- </pre>+minViewWithKey :: IntMap a -> Maybe ((Key, a), IntMap a)++-- | <i>O(log n)</i>. Retrieves the maximal (key,value) pair of the map,+-- and the map stripped of that element, or <a>Nothing</a> if passed an+-- empty map.+-- +-- <pre>+-- maxViewWithKey (fromList [(5,"a"), (3,"b")]) == Just ((5,"a"), singleton 3 "b")+-- maxViewWithKey empty == Nothing+-- </pre>+maxViewWithKey :: IntMap a -> Maybe ((Key, a), IntMap a)++-- | <i>O(n)</i>. Show the tree that implements the map. The tree is shown+-- in a compressed, hanging format.+showTree :: Show a => IntMap a -> String++-- | <i>O(n)</i>. The expression (<tt><a>showTreeWith</a> hang wide+-- map</tt>) shows the tree that implements the map. If <tt>hang</tt> is+-- <a>True</a>, a <i>hanging</i> tree is shown otherwise a rotated tree+-- is shown. If <tt>wide</tt> is <a>True</a>, an extra wide version is+-- shown.+showTreeWith :: Show a => Bool -> Bool -> IntMap a -> String+instance Typeable1 IntMap+instance Read e => Read (IntMap e)+instance Show a => Show (IntMap a)+instance Functor IntMap+instance Ord a => Ord (IntMap a)+instance Eq a => Eq (IntMap a)+instance Data a => Data (IntMap a)+instance Traversable IntMap+instance Foldable IntMap+instance Monoid (IntMap a)+++-- | General purpose finite sequences. Apart from being finite and having+-- strict operations, sequences also differ from lists in supporting a+-- wider variety of operations efficiently.+-- +-- An amortized running time is given for each operation, with <i>n</i>+-- referring to the length of the sequence and <i>i</i> being the+-- integral index used by some operations. These bounds hold even in a+-- persistent (shared) setting.+-- +-- The implementation uses 2-3 finger trees annotated with sizes, as+-- described in section 4.2 of+-- +-- <ul>+-- <li>Ralf Hinze and Ross Paterson, "Finger trees: a simple+-- general-purpose data structure", <i>Journal of Functional+-- Programming</i> 16:2 (2006) pp 197-217.+-- <a>http://www.soi.city.ac.uk/~ross/papers/FingerTree.html</a></li>+-- </ul>+-- +-- <i>Note</i>: Many of these operations have the same names as similar+-- operations on lists in the <a>Prelude</a>. The ambiguity may be+-- resolved using either qualification or the <tt>hiding</tt> clause.+module Data.Sequence++-- | General-purpose finite sequences.+data Seq a++-- | <i>O(1)</i>. The empty sequence.+empty :: Seq a++-- | <i>O(1)</i>. A singleton sequence.+singleton :: a -> Seq a++-- | <i>O(1)</i>. Add an element to the left end of a sequence. Mnemonic: a+-- triangle with the single element at the pointy end.+(<|) :: a -> Seq a -> Seq a++-- | <i>O(1)</i>. Add an element to the right end of a sequence. Mnemonic:+-- a triangle with the single element at the pointy end.+(|>) :: Seq a -> a -> Seq a++-- | <i>O(log(min(n1,n2)))</i>. Concatenate two sequences.+(><) :: Seq a -> Seq a -> Seq a++-- | <i>O(n)</i>. Create a sequence from a finite list of elements. There+-- is a function <a>toList</a> in the opposite direction for all+-- instances of the <a>Foldable</a> class, including <a>Seq</a>.+fromList :: [a] -> Seq a++-- | <i>O(log n)</i>. <tt>replicate n x</tt> is a sequence consisting of+-- <tt>n</tt> copies of <tt>x</tt>.+replicate :: Int -> a -> Seq a++-- | <a>replicateA</a> is an <a>Applicative</a> version of+-- <a>replicate</a>, and makes <i>O(log n)</i> calls to <a><*></a>+-- and <a>pure</a>.+-- +-- <pre>+-- replicateA n x = sequenceA (replicate n x)+-- </pre>+replicateA :: Applicative f => Int -> f a -> f (Seq a)++-- | <a>replicateM</a> is a sequence counterpart of+-- <tt>Control.Monad.replicateM</tt>.+-- +-- <pre>+-- replicateM n x = sequence (replicate n x)+-- </pre>+replicateM :: Monad m => Int -> m a -> m (Seq a)++-- | <i>O(n)</i>. Constructs a sequence by repeated application of a+-- function to a seed value.+-- +-- <pre>+-- iterateN n f x = fromList (Prelude.take n (Prelude.iterate f x))+-- </pre>+iterateN :: Int -> (a -> a) -> a -> Seq a++-- | Builds a sequence from a seed value. Takes time linear in the number+-- of generated elements. <i>WARNING:</i> If the number of generated+-- elements is infinite, this method will not terminate.+unfoldr :: (b -> Maybe (a, b)) -> b -> Seq a++-- | <tt><a>unfoldl</a> f x</tt> is equivalent to <tt><a>reverse</a>+-- (<a>unfoldr</a> (swap . f) x)</tt>.+unfoldl :: (b -> Maybe (b, a)) -> b -> Seq a++-- | <i>O(1)</i>. Is this the empty sequence?+null :: Seq a -> Bool++-- | <i>O(1)</i>. The number of elements in the sequence.+length :: Seq a -> Int++-- | View of the left end of a sequence.+data ViewL a++-- | empty sequence+EmptyL :: ViewL a++-- | leftmost element and the rest of the sequence+(:<) :: a -> Seq a -> ViewL a++-- | <i>O(1)</i>. Analyse the left end of a sequence.+viewl :: Seq a -> ViewL a++-- | View of the right end of a sequence.+data ViewR a++-- | empty sequence+EmptyR :: ViewR a++-- | the sequence minus the rightmost element, and the rightmost element+(:>) :: Seq a -> a -> ViewR a++-- | <i>O(1)</i>. Analyse the right end of a sequence.+viewr :: Seq a -> ViewR a++-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a sequence of+-- reduced values from the left:+-- +-- <pre>+-- scanl f z (fromList [x1, x2, ...]) = fromList [z, z `f` x1, (z `f` x1) `f` x2, ...]+-- </pre>+scanl :: (a -> b -> a) -> a -> Seq b -> Seq a++-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value+-- argument:+-- +-- <pre>+-- scanl1 f (fromList [x1, x2, ...]) = fromList [x1, x1 `f` x2, ...]+-- </pre>+scanl1 :: (a -> a -> a) -> Seq a -> Seq a++-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>.+scanr :: (a -> b -> b) -> b -> Seq a -> Seq b++-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value+-- argument.+scanr1 :: (a -> a -> a) -> Seq a -> Seq a++-- | <i>O(n)</i>. Returns a sequence of all suffixes of this sequence,+-- longest first. For example,+-- +-- <pre>+-- tails (fromList "abc") = fromList [fromList "abc", fromList "bc", fromList "c", fromList ""]+-- </pre>+-- +-- Evaluating the <i>i</i>th suffix takes <i>O(log(min(i, n-i)))</i>, but+-- evaluating every suffix in the sequence takes <i>O(n)</i> due to+-- sharing.+tails :: Seq a -> Seq (Seq a)++-- | <i>O(n)</i>. Returns a sequence of all prefixes of this sequence,+-- shortest first. For example,+-- +-- <pre>+-- inits (fromList "abc") = fromList [fromList "", fromList "a", fromList "ab", fromList "abc"]+-- </pre>+-- +-- Evaluating the <i>i</i>th prefix takes <i>O(log(min(i, n-i)))</i>, but+-- evaluating every prefix in the sequence takes <i>O(n)</i> due to+-- sharing.+inits :: Seq a -> Seq (Seq a)++-- | <i>O(i)</i> where <i>i</i> is the prefix length. <a>takeWhileL</a>,+-- applied to a predicate <tt>p</tt> and a sequence <tt>xs</tt>, returns+-- the longest prefix (possibly empty) of <tt>xs</tt> of elements that+-- satisfy <tt>p</tt>.+takeWhileL :: (a -> Bool) -> Seq a -> Seq a++-- | <i>O(i)</i> where <i>i</i> is the suffix length. <a>takeWhileR</a>,+-- applied to a predicate <tt>p</tt> and a sequence <tt>xs</tt>, returns+-- the longest suffix (possibly empty) of <tt>xs</tt> of elements that+-- satisfy <tt>p</tt>.+-- +-- <tt><a>takeWhileR</a> p xs</tt> is equivalent to <tt><a>reverse</a>+-- (<a>takeWhileL</a> p (<a>reverse</a> xs))</tt>.+takeWhileR :: (a -> Bool) -> Seq a -> Seq a++-- | <i>O(i)</i> where <i>i</i> is the prefix length. <tt><a>dropWhileL</a>+-- p xs</tt> returns the suffix remaining after <tt><a>takeWhileL</a> p+-- xs</tt>.+dropWhileL :: (a -> Bool) -> Seq a -> Seq a++-- | <i>O(i)</i> where <i>i</i> is the suffix length. <tt><a>dropWhileR</a>+-- p xs</tt> returns the prefix remaining after <tt><a>takeWhileR</a> p+-- xs</tt>.+-- +-- <tt><a>dropWhileR</a> p xs</tt> is equivalent to <tt><a>reverse</a>+-- (<a>dropWhileL</a> p (<a>reverse</a> xs))</tt>.+dropWhileR :: (a -> Bool) -> Seq a -> Seq a++-- | <i>O(i)</i> where <i>i</i> is the prefix length. <a>spanl</a>, applied+-- to a predicate <tt>p</tt> and a sequence <tt>xs</tt>, returns a pair+-- whose first element is the longest prefix (possibly empty) of+-- <tt>xs</tt> of elements that satisfy <tt>p</tt> and the second element+-- is the remainder of the sequence.+spanl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)++-- | <i>O(i)</i> where <i>i</i> is the suffix length. <a>spanr</a>, applied+-- to a predicate <tt>p</tt> and a sequence <tt>xs</tt>, returns a pair+-- whose <i>first</i> element is the longest <i>suffix</i> (possibly+-- empty) of <tt>xs</tt> of elements that satisfy <tt>p</tt> and the+-- second element is the remainder of the sequence.+spanr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)++-- | <i>O(i)</i> where <i>i</i> is the breakpoint index. <a>breakl</a>,+-- applied to a predicate <tt>p</tt> and a sequence <tt>xs</tt>, returns+-- a pair whose first element is the longest prefix (possibly empty) of+-- <tt>xs</tt> of elements that <i>do not satisfy</i> <tt>p</tt> and the+-- second element is the remainder of the sequence.+-- +-- <tt><a>breakl</a> p</tt> is equivalent to <tt><a>spanl</a> (not .+-- p)</tt>.+breakl :: (a -> Bool) -> Seq a -> (Seq a, Seq a)++-- | <tt><a>breakr</a> p</tt> is equivalent to <tt><a>spanr</a> (not .+-- p)</tt>.+breakr :: (a -> Bool) -> Seq a -> (Seq a, Seq a)++-- | <i>O(n)</i>. The <a>partition</a> function takes a predicate+-- <tt>p</tt> and a sequence <tt>xs</tt> and returns sequences of those+-- elements which do and do not satisfy the predicate.+partition :: (a -> Bool) -> Seq a -> (Seq a, Seq a)++-- | <i>O(n)</i>. The <a>filter</a> function takes a predicate <tt>p</tt>+-- and a sequence <tt>xs</tt> and returns a sequence of those elements+-- which satisfy the predicate.+filter :: (a -> Bool) -> Seq a -> Seq a++-- | <i>O(n log n)</i>. <a>sort</a> sorts the specified <a>Seq</a> by the+-- natural ordering of its elements. The sort is stable. If stability is+-- not required, <a>unstableSort</a> can be considerably faster, and in+-- particular uses less memory.+sort :: Ord a => Seq a -> Seq a++-- | <i>O(n log n)</i>. <a>sortBy</a> sorts the specified <a>Seq</a>+-- according to the specified comparator. The sort is stable. If+-- stability is not required, <a>unstableSortBy</a> can be considerably+-- faster, and in particular uses less memory.+sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a++-- | <i>O(n log n)</i>. <a>unstableSort</a> sorts the specified <a>Seq</a>+-- by the natural ordering of its elements, but the sort is not stable.+-- This algorithm is frequently faster and uses less memory than+-- <a>sort</a>, and performs extremely well -- frequently twice as fast+-- as <a>sort</a> -- when the sequence is already nearly sorted.+unstableSort :: Ord a => Seq a -> Seq a++-- | <i>O(n log n)</i>. A generalization of <a>unstableSort</a>,+-- <a>unstableSortBy</a> takes an arbitrary comparator and sorts the+-- specified sequence. The sort is not stable. This algorithm is+-- frequently faster and uses less memory than <a>sortBy</a>, and+-- performs extremely well -- frequently twice as fast as <a>sortBy</a>+-- -- when the sequence is already nearly sorted.+unstableSortBy :: (a -> a -> Ordering) -> Seq a -> Seq a++-- | <i>O(log(min(i,n-i)))</i>. The element at the specified position,+-- counting from 0. The argument should thus be a non-negative integer+-- less than the size of the sequence. If the position is out of range,+-- <a>index</a> fails with an error.+index :: Seq a -> Int -> a++-- | <i>O(log(min(i,n-i)))</i>. Update the element at the specified+-- position. If the position is out of range, the original sequence is+-- returned.+adjust :: (a -> a) -> Int -> Seq a -> Seq a++-- | <i>O(log(min(i,n-i)))</i>. Replace the element at the specified+-- position. If the position is out of range, the original sequence is+-- returned.+update :: Int -> a -> Seq a -> Seq a++-- | <i>O(log(min(i,n-i)))</i>. The first <tt>i</tt> elements of a+-- sequence. If <tt>i</tt> is negative, <tt><a>take</a> i s</tt> yields+-- the empty sequence. If the sequence contains fewer than <tt>i</tt>+-- elements, the whole sequence is returned.+take :: Int -> Seq a -> Seq a++-- | <i>O(log(min(i,n-i)))</i>. Elements of a sequence after the first+-- <tt>i</tt>. If <tt>i</tt> is negative, <tt><a>drop</a> i s</tt> yields+-- the whole sequence. If the sequence contains fewer than <tt>i</tt>+-- elements, the empty sequence is returned.+drop :: Int -> Seq a -> Seq a++-- | <i>O(log(min(i,n-i)))</i>. Split a sequence at a given position.+-- <tt><a>splitAt</a> i s = (<a>take</a> i s, <a>drop</a> i s)</tt>.+splitAt :: Int -> Seq a -> (Seq a, Seq a)++-- | <a>elemIndexL</a> finds the leftmost index of the specified element,+-- if it is present, and otherwise <a>Nothing</a>.+elemIndexL :: Eq a => a -> Seq a -> Maybe Int++-- | <a>elemIndicesL</a> finds the indices of the specified element, from+-- left to right (i.e. in ascending order).+elemIndicesL :: Eq a => a -> Seq a -> [Int]++-- | <a>elemIndexR</a> finds the rightmost index of the specified element,+-- if it is present, and otherwise <a>Nothing</a>.+elemIndexR :: Eq a => a -> Seq a -> Maybe Int++-- | <a>elemIndicesR</a> finds the indices of the specified element, from+-- right to left (i.e. in descending order).+elemIndicesR :: Eq a => a -> Seq a -> [Int]++-- | <tt><a>findIndexL</a> p xs</tt> finds the index of the leftmost+-- element that satisfies <tt>p</tt>, if any exist.+findIndexL :: (a -> Bool) -> Seq a -> Maybe Int++-- | <tt><a>findIndicesL</a> p</tt> finds all indices of elements that+-- satisfy <tt>p</tt>, in ascending order.+findIndicesL :: (a -> Bool) -> Seq a -> [Int]++-- | <tt><a>findIndexR</a> p xs</tt> finds the index of the rightmost+-- element that satisfies <tt>p</tt>, if any exist.+findIndexR :: (a -> Bool) -> Seq a -> Maybe Int++-- | <tt><a>findIndicesR</a> p</tt> finds all indices of elements that+-- satisfy <tt>p</tt>, in descending order.+findIndicesR :: (a -> Bool) -> Seq a -> [Int]++-- | <a>foldlWithIndex</a> is a version of <a>foldl</a> that also provides+-- access to the index of each element.+foldlWithIndex :: (b -> Int -> a -> b) -> b -> Seq a -> b++-- | <a>foldrWithIndex</a> is a version of <a>foldr</a> that also provides+-- access to the index of each element.+foldrWithIndex :: (Int -> a -> b -> b) -> b -> Seq a -> b++-- | A generalization of <a>fmap</a>, <a>mapWithIndex</a> takes a mapping+-- function that also depends on the element's index, and applies it to+-- every element in the sequence.+mapWithIndex :: (Int -> a -> b) -> Seq a -> Seq b++-- | <i>O(n)</i>. The reverse of a sequence.+reverse :: Seq a -> Seq a++-- | <i>O(min(n1,n2))</i>. <a>zip</a> takes two sequences and returns a+-- sequence of corresponding pairs. If one input is short, excess+-- elements are discarded from the right end of the longer sequence.+zip :: Seq a -> Seq b -> Seq (a, b)++-- | <i>O(min(n1,n2))</i>. <a>zipWith</a> generalizes <a>zip</a> by zipping+-- with the function given as the first argument, instead of a tupling+-- function. For example, <tt>zipWith (+)</tt> is applied to two+-- sequences to take the sequence of corresponding sums.+zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c++-- | <i>O(min(n1,n2,n3))</i>. <a>zip3</a> takes three sequences and returns+-- a sequence of triples, analogous to <a>zip</a>.+zip3 :: Seq a -> Seq b -> Seq c -> Seq (a, b, c)++-- | <i>O(min(n1,n2,n3))</i>. <a>zipWith3</a> takes a function which+-- combines three elements, as well as three sequences and returns a+-- sequence of their point-wise combinations, analogous to+-- <a>zipWith</a>.+zipWith3 :: (a -> b -> c -> d) -> Seq a -> Seq b -> Seq c -> Seq d++-- | <i>O(min(n1,n2,n3,n4))</i>. <a>zip4</a> takes four sequences and+-- returns a sequence of quadruples, analogous to <a>zip</a>.+zip4 :: Seq a -> Seq b -> Seq c -> Seq d -> Seq (a, b, c, d)++-- | <i>O(min(n1,n2,n3,n4))</i>. <a>zipWith4</a> takes a function which+-- combines four elements, as well as four sequences and returns a+-- sequence of their point-wise combinations, analogous to+-- <a>zipWith</a>.+zipWith4 :: (a -> b -> c -> d -> e) -> Seq a -> Seq b -> Seq c -> Seq d -> Seq e+instance Eq a => Eq (ViewR a)+instance Ord a => Ord (ViewR a)+instance Show a => Show (ViewR a)+instance Read a => Read (ViewR a)+instance Data a => Data (ViewR a)+instance Eq a => Eq (ViewL a)+instance Ord a => Ord (ViewL a)+instance Show a => Show (ViewL a)+instance Read a => Read (ViewL a)+instance Data a => Data (ViewL a)+instance Traversable ViewR+instance Foldable ViewR+instance Functor ViewR+instance Typeable1 ViewR+instance Traversable ViewL+instance Foldable ViewL+instance Functor ViewL+instance Typeable1 ViewL+instance Applicative (State s)+instance Monad (State s)+instance Functor (State s)+instance Applicative Id+instance Monad Id+instance Functor Id+instance Traversable Elem+instance Foldable Elem+instance Functor Elem+instance Sized (Elem a)+instance Sized (Node a)+instance Traversable Node+instance Functor Node+instance Foldable Node+instance Sized a => Sized (Digit a)+instance Traversable Digit+instance Functor Digit+instance Foldable Digit+instance Traversable FingerTree+instance Functor FingerTree+instance Foldable FingerTree+instance Sized a => Sized (FingerTree a)+instance Data a => Data (Seq a)+instance Typeable1 Seq+instance Monoid (Seq a)+instance Read a => Read (Seq a)+instance Show a => Show (Seq a)+instance Ord a => Ord (Seq a)+instance Eq a => Eq (Seq a)+instance MonadPlus Seq+instance Monad Seq+instance Traversable Seq+instance Foldable Seq+instance Functor Seq+++-- | Multi-way trees (<i>aka</i> rose trees) and forests.+module Data.Tree++-- | Multi-way trees, also known as <i>rose trees</i>.+data Tree a+Node :: a -> Forest a -> Tree a++-- | label value+rootLabel :: Tree a -> a++-- | zero or more child trees+subForest :: Tree a -> Forest a+type Forest a = [Tree a]++-- | Neat 2-dimensional drawing of a tree.+drawTree :: Tree String -> String++-- | Neat 2-dimensional drawing of a forest.+drawForest :: Forest String -> String++-- | The elements of a tree in pre-order.+flatten :: Tree a -> [a]++-- | Lists of nodes at each level of the tree.+levels :: Tree a -> [[a]]++-- | Build a tree from a seed value+unfoldTree :: (b -> (a, [b])) -> b -> Tree a++-- | Build a forest from a list of seed values+unfoldForest :: (b -> (a, [b])) -> [b] -> Forest a++-- | Monadic tree builder, in depth-first order+unfoldTreeM :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a)++-- | Monadic forest builder, in depth-first order+unfoldForestM :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)++-- | Monadic tree builder, in breadth-first order, using an algorithm+-- adapted from <i>Breadth-First Numbering: Lessons from a Small Exercise+-- in Algorithm Design</i>, by Chris Okasaki, <i>ICFP'00</i>.+unfoldTreeM_BF :: Monad m => (b -> m (a, [b])) -> b -> m (Tree a)++-- | Monadic forest builder, in breadth-first order, using an algorithm+-- adapted from <i>Breadth-First Numbering: Lessons from a Small Exercise+-- in Algorithm Design</i>, by Chris Okasaki, <i>ICFP'00</i>.+unfoldForestM_BF :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a)+instance Eq a => Eq (Tree a)+instance Read a => Read (Tree a)+instance Show a => Show (Tree a)+instance Data a => Data (Tree a)+instance Foldable Tree+instance Traversable Tree+instance Monad Tree+instance Applicative Tree+instance Functor Tree+instance Typeable1 Tree+++-- | A version of the graph algorithms described in:+-- +-- <i>Lazy Depth-First Search and Linear Graph Algorithms in Haskell</i>,+-- by David King and John Launchbury.+module Data.Graph++-- | The strongly connected components of a directed graph, topologically+-- sorted.+stronglyConnComp :: Ord key => [(node, key, [key])] -> [SCC node]++-- | The strongly connected components of a directed graph, topologically+-- sorted. The function is the same as <a>stronglyConnComp</a>, except+-- that all the information about each node retained. This interface is+-- used when you expect to apply <a>SCC</a> to (some of) the result of+-- <a>SCC</a>, so you don't want to lose the dependency information.+stronglyConnCompR :: Ord key => [(node, key, [key])] -> [SCC (node, key, [key])]++-- | Strongly connected component.+data SCC vertex++-- | A single vertex that is not in any cycle.+AcyclicSCC :: vertex -> SCC vertex++-- | A maximal set of mutually reachable vertices.+CyclicSCC :: [vertex] -> SCC vertex++-- | The vertices of a strongly connected component.+flattenSCC :: SCC vertex -> [vertex]++-- | The vertices of a list of strongly connected components.+flattenSCCs :: [SCC a] -> [a]++-- | Adjacency list representation of a graph, mapping each vertex to its+-- list of successors.+type Graph = Table [Vertex]++-- | Table indexed by a contiguous set of vertices.+type Table a = Array Vertex a++-- | The bounds of a <a>Table</a>.+type Bounds = (Vertex, Vertex)++-- | An edge from the first vertex to the second.+type Edge = (Vertex, Vertex)++-- | Abstract representation of vertices.+type Vertex = Int++-- | Build a graph from a list of nodes uniquely identified by keys, with a+-- list of keys of nodes this node should have edges to. The out-list may+-- contain keys that don't correspond to nodes of the graph; they are+-- ignored.+graphFromEdges :: Ord key => [(node, key, [key])] -> (Graph, Vertex -> (node, key, [key]), key -> Maybe Vertex)++-- | Identical to <a>graphFromEdges</a>, except that the return value does+-- not include the function which maps keys to vertices. This version of+-- <a>graphFromEdges</a> is for backwards compatibility.+graphFromEdges' :: Ord key => [(node, key, [key])] -> (Graph, Vertex -> (node, key, [key]))++-- | Build a graph from a list of edges.+buildG :: Bounds -> [Edge] -> Graph++-- | The graph obtained by reversing all edges.+transposeG :: Graph -> Graph++-- | All vertices of a graph.+vertices :: Graph -> [Vertex]++-- | All edges of a graph.+edges :: Graph -> [Edge]++-- | A table of the count of edges from each node.+outdegree :: Graph -> Table Int++-- | A table of the count of edges into each node.+indegree :: Graph -> Table Int++-- | A spanning forest of the part of the graph reachable from the listed+-- vertices, obtained from a depth-first search of the graph starting at+-- each of the listed vertices in order.+dfs :: Graph -> [Vertex] -> Forest Vertex++-- | A spanning forest of the graph, obtained from a depth-first search of+-- the graph starting from each vertex in an unspecified order.+dff :: Graph -> Forest Vertex++-- | A topological sort of the graph. The order is partially specified by+-- the condition that a vertex <i>i</i> precedes <i>j</i> whenever+-- <i>j</i> is reachable from <i>i</i> but not vice versa.+topSort :: Graph -> [Vertex]++-- | The connected components of a graph. Two vertices are connected if+-- there is a path between them, traversing edges in either direction.+components :: Graph -> Forest Vertex++-- | The strongly connected components of a graph.+scc :: Graph -> Forest Vertex++-- | The biconnected components of a graph. An undirected graph is+-- biconnected if the deletion of any vertex leaves it connected.+bcc :: Graph -> Forest [Vertex]++-- | A list of vertices reachable from a given vertex.+reachable :: Graph -> Vertex -> [Vertex]++-- | Is the second vertex reachable from the first?+path :: Graph -> Vertex -> Vertex -> Bool+instance Monad (SetM s)
+ data/ghc-mtl.txt view
@@ -0,0 +1,56 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | An mtl compatible version of the Ghc-Api monads+-- and monad-transformers.+-- +-- Provides an <a>mtl</a> compatible version of the <a>GhcT</a>+-- monad-transformer defined in the 'GHC-API' since version 6.10.1.+@package ghc-mtl+@version 1.0.1.0++module Control.Monad.Ghc+data Ghc a+runGhc :: Maybe FilePath -> Ghc a -> IO a+data GhcT m a+runGhcT :: (Functor m, MonadCatchIO m) => Maybe FilePath -> GhcT m a -> m a++-- | A monad that has all the features needed by GHC API calls.+-- +-- In short, a GHC monad+-- +-- <ul>+-- <li>allows embedding of IO actions,</li>+-- <li>can log warnings,</li>+-- <li>allows handling of (extensible) exceptions, and</li>+-- <li>maintains a current session.</li>+-- </ul>+-- +-- If you do not use <a>Ghc</a> or <a>GhcT</a>, make sure to call+-- <tt>GHC.initGhcMonad</tt> before any call to the GHC API functions can+-- occur.+class (Functor m, MonadIO m, WarnLogMonad m, ExceptionMonad m) => GhcMonad m :: (* -> *)+getSession :: GhcMonad m => m HscEnv+setSession :: GhcMonad m => HscEnv -> m ()+instance Functor Ghc+instance Monad Ghc+instance WarnLogMonad Ghc+instance ExceptionMonad Ghc+instance MonadIO Ghc+instance GhcMonad Ghc+instance Functor m => Functor (MTLAdapter m)+instance Monad m => Monad (MTLAdapter m)+instance Functor m => Functor (GhcT m)+instance Monad m => Monad (GhcT m)+instance MonadCatchIO m => ExceptionMonad (MTLAdapter m)+instance MonadIO m => MonadIO (MTLAdapter m)+instance (Functor m, MonadCatchIO m) => GhcMonad (GhcT m)+instance MonadIO m => WarnLogMonad (GhcT m)+instance MonadCatchIO m => ExceptionMonad (GhcT m)+instance MonadCatchIO m => MonadCatchIO (GhcT m)+instance MonadIO m => MonadIO (GhcT m)+instance MonadIO m => MonadIO (GhcT m)+instance MonadTrans GhcT+instance MonadCatchIO Ghc+instance MonadIO Ghc
+ data/ghc-prim.txt view
@@ -0,0 +1,1158 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | GHC primitives+-- +-- GHC primitives.+@package ghc-prim+++-- | GHC magic. Use GHC.Exts from the base package instead of importing+-- this module directly.+module GHC.Magic++-- | The call '(inline f)' reduces to <tt>f</tt>, but <a>inline</a> has a+-- BuiltInRule that tries to inline <tt>f</tt> (if it has an unfolding)+-- unconditionally The <tt>NOINLINE</tt> pragma arranges that inline only+-- gets inlined (and hence eliminated) late in compilation, after the+-- rule has had a good chance to fire.+inline :: a -> a++module GHC.Generics+data Unit+Unit :: Unit+data (:+:) a b+Inl :: a -> :+: a b+Inr :: b -> :+: a b+data (:*:) a b+(:*:) :: a -> b -> :*: a b+++-- | GHC type definitions. Use GHC.Exts from the base package instead of+-- importing this module directly.+module GHC.Types++-- | The character type <a>Char</a> is an enumeration whose values+-- represent Unicode (or equivalently ISO/IEC 10646) characters (see+-- <a>http://www.unicode.org/</a> for details). This set extends the ISO+-- 8859-1 (Latin-1) character set (the first 256 charachers), which is+-- itself an extension of the ASCII character set (the first 128+-- characters). A character literal in Haskell has type <a>Char</a>.+-- +-- To convert a <a>Char</a> to or from the corresponding <a>Int</a> value+-- defined by Unicode, use <tt>Prelude.toEnum</tt> and+-- <tt>Prelude.fromEnum</tt> from the <tt>Prelude.Enum</tt> class+-- respectively (or equivalently <tt>ord</tt> and <tt>chr</tt>).+data Char+C# :: Char# -> Char++-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..+-- 2^29-1]</tt>. The exact range for a given implementation can be+-- determined by using <tt>Prelude.minBound</tt> and+-- <tt>Prelude.maxBound</tt> from the <tt>Prelude.Bounded</tt> class.+data Int+I# :: Int# -> Int++-- | Single-precision floating point numbers. It is desirable that this+-- type be at least equal in range and precision to the IEEE+-- single-precision type.+data Float+F# :: Float# -> Float++-- | Double-precision floating point numbers. It is desirable that this+-- type be at least equal in range and precision to the IEEE+-- double-precision type.+data Double+D# :: Double# -> Double++-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when+-- performed, does some I/O before returning a value of type <tt>a</tt>.+-- +-- There is really only one way to "perform" an I/O action: bind it to+-- <tt>Main.main</tt> in your program. When your program is run, the I/O+-- will be performed. It isn't possible to perform I/O from an arbitrary+-- function, unless that function is itself in the <a>IO</a> monad and+-- called at some point, directly or indirectly, from <tt>Main.main</tt>.+-- +-- <a>IO</a> is a monad, so <a>IO</a> actions can be combined using+-- either the do-notation or the <tt>>></tt> and <tt>>>=</tt>+-- operations from the <tt>Monad</tt> class.+newtype IO a+IO :: (State# RealWorld -> (# State# RealWorld, a #)) -> IO a++module GHC.Unit++-- | The unit datatype <tt>()</tt> has one non-undefined member, the+-- nullary constructor <tt>()</tt>.+data ()+() :: ()++module GHC.Debug+debugLn :: [Char] -> IO ()+debugErrLn :: [Char] -> IO ()++module GHC.Ordering+data Ordering+LT :: Ordering+EQ :: Ordering+GT :: Ordering+++-- | The tuple data types+module GHC.Tuple+data (,) a b+(,) :: a -> b -> (,) a b+data (,,) a b c+(,,) :: a -> b -> c -> (,,) a b c+data (,,,) a b c d+(,,,) :: a -> b -> c -> d -> (,,,) a b c d+data (,,,,) a b c d e+(,,,,) :: a -> b -> c -> d -> e -> (,,,,) a b c d e+data (,,,,,) a b c d e f+(,,,,,) :: a -> b -> c -> d -> e -> f -> (,,,,,) a b c d e f+data (,,,,,,) a b c d e f g+(,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> (,,,,,,) a b c d e f g+data (,,,,,,,) a b c d e f g h+(,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> (,,,,,,,) a b c d e f g h+data (,,,,,,,,) a b c d e f g h i+(,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> (,,,,,,,,) a b c d e f g h i+data (,,,,,,,,,) a b c d e f g h i j+(,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> (,,,,,,,,,) a b c d e f g h i j+data (,,,,,,,,,,) a b c d e f g h i j k+(,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> (,,,,,,,,,,) a b c d e f g h i j k+data (,,,,,,,,,,,) a b c d e f g h i j k l+(,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> (,,,,,,,,,,,) a b c d e f g h i j k l+data (,,,,,,,,,,,,) a b c d e f g h i j k l m+(,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> (,,,,,,,,,,,,) a b c d e f g h i j k l m+data (,,,,,,,,,,,,,) a b c d e f g h i j k l m n+(,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> (,,,,,,,,,,,,,) a b c d e f g h i j k l m n+data (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o+(,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> (,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o+data (,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p+(,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> (,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p+data (,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q+(,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> (,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q+data (,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r+(,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> (,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r+data (,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s+(,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> (,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s+data (,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t+(,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> (,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t+data (,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u+(,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> (,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u+data (,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v+(,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> (,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v+data (,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w+(,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> (,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w+data (,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x+(,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> (,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x+data (,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y+(,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> (,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y+data (,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z+(,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> (,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z+data (,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_+(,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> f__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> f__ -> g__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> f__ -> g__ -> h__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> f__ -> g__ -> h__ -> i__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__+data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__+(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) :: a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -> u -> v -> w -> x -> y -> z -> a_ -> b_ -> c_ -> d_ -> e_ -> f_ -> g_ -> h_ -> i_ -> j_ -> k_ -> l_ -> m_ -> n_ -> o_ -> p_ -> q_ -> r_ -> s_ -> t_ -> u_ -> v_ -> w_ -> x_ -> y_ -> z_ -> a__ -> b__ -> c__ -> d__ -> e__ -> f__ -> g__ -> h__ -> i__ -> j__ -> (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o p q r s t u v w x y z a_ b_ c_ d_ e_ f_ g_ h_ i_ j_ k_ l_ m_ n_ o_ p_ q_ r_ s_ t_ u_ v_ w_ x_ y_ z_ a__ b__ c__ d__ e__ f__ g__ h__ i__ j__++module GHC.Bool+data Bool+False :: Bool+True :: Bool+++-- | GHC's primitive types and operations. Use GHC.Exts from the base+-- package instead of importing this module directly.+module GHC.Prim+data Char#+gtChar# :: Char# -> Char# -> Bool+geChar# :: Char# -> Char# -> Bool+eqChar# :: Char# -> Char# -> Bool+neChar# :: Char# -> Char# -> Bool+ltChar# :: Char# -> Char# -> Bool+leChar# :: Char# -> Char# -> Bool+ord# :: Char# -> Int#+data Int#+(+#) :: Int# -> Int# -> Int#+(-#) :: Int# -> Int# -> Int#++-- | Low word of signed integer multiply.+(*#) :: Int# -> Int# -> Int#++-- | Return non-zero if there is any possibility that the upper word of a+-- signed integer multiply might contain useful information. Return zero+-- only if you are completely sure that no overflow can occur. On a+-- 32-bit platform, the recommmended implementation is to do a 32 x 32+-- -> 64 signed multiply, and subtract result[63:32] from (result[31]+-- >>signed 31). If this is zero, meaning that the upper word is+-- merely a sign extension of the lower one, no overflow can occur.+-- +-- On a 64-bit platform it is not always possible to acquire the top 64+-- bits of the result. Therefore, a recommended implementation is to take+-- the absolute value of both operands, and return 0 iff bits[63:31] of+-- them are zero, since that means that their magnitudes fit within 31+-- bits, so the magnitude of the product must fit into 62 bits.+-- +-- If in doubt, return non-zero, but do make an effort to create the+-- correct answer for small args, since otherwise the performance of+-- <tt>(*) :: Integer -> Integer -> Integer</tt> will be poor.+mulIntMayOflo# :: Int# -> Int# -> Int#++-- | Rounds towards zero.+quotInt# :: Int# -> Int# -> Int#++-- | Satisfies <tt>(quotInt# x y) *# y +# (remInt# x y) == x</tt>.+remInt# :: Int# -> Int# -> Int#+negateInt# :: Int# -> Int#++-- | Add with carry. First member of result is (wrapped) sum; second member+-- is 0 iff no overflow occured.+addIntC# :: Int# -> Int# -> (# Int#, Int# #)++-- | Subtract with carry. First member of result is (wrapped) difference;+-- second member is 0 iff no overflow occured.+subIntC# :: Int# -> Int# -> (# Int#, Int# #)+(>#) :: Int# -> Int# -> Bool+(>=#) :: Int# -> Int# -> Bool+(==#) :: Int# -> Int# -> Bool+(/=#) :: Int# -> Int# -> Bool+(<#) :: Int# -> Int# -> Bool+(<=#) :: Int# -> Int# -> Bool+chr# :: Int# -> Char#+int2Word# :: Int# -> Word#+int2Float# :: Int# -> Float#+int2Double# :: Int# -> Double#++-- | Shift left. Result undefined if shift amount is not in the range 0 to+-- word size - 1 inclusive.+uncheckedIShiftL# :: Int# -> Int# -> Int#++-- | Shift right arithmetic. Result undefined if shift amount is not in the+-- range 0 to word size - 1 inclusive.+uncheckedIShiftRA# :: Int# -> Int# -> Int#++-- | Shift right logical. Result undefined if shift amount is not in the+-- range 0 to word size - 1 inclusive.+uncheckedIShiftRL# :: Int# -> Int# -> Int#+data Word#+plusWord# :: Word# -> Word# -> Word#+minusWord# :: Word# -> Word# -> Word#+timesWord# :: Word# -> Word# -> Word#+quotWord# :: Word# -> Word# -> Word#+remWord# :: Word# -> Word# -> Word#+and# :: Word# -> Word# -> Word#+or# :: Word# -> Word# -> Word#+xor# :: Word# -> Word# -> Word#+not# :: Word# -> Word#++-- | Shift left logical. Result undefined if shift amount is not in the+-- range 0 to word size - 1 inclusive.+uncheckedShiftL# :: Word# -> Int# -> Word#++-- | Shift right logical. Result undefined if shift amount is not in the+-- range 0 to word size - 1 inclusive.+uncheckedShiftRL# :: Word# -> Int# -> Word#+word2Int# :: Word# -> Int#+gtWord# :: Word# -> Word# -> Bool+geWord# :: Word# -> Word# -> Bool+eqWord# :: Word# -> Word# -> Bool+neWord# :: Word# -> Word# -> Bool+ltWord# :: Word# -> Word# -> Bool+leWord# :: Word# -> Word# -> Bool+narrow8Int# :: Int# -> Int#+narrow16Int# :: Int# -> Int#+narrow32Int# :: Int# -> Int#+narrow8Word# :: Word# -> Word#+narrow16Word# :: Word# -> Word#+narrow32Word# :: Word# -> Word#+data Double#+(>##) :: Double# -> Double# -> Bool+(>=##) :: Double# -> Double# -> Bool+(==##) :: Double# -> Double# -> Bool+(/=##) :: Double# -> Double# -> Bool+(<##) :: Double# -> Double# -> Bool+(<=##) :: Double# -> Double# -> Bool+(+##) :: Double# -> Double# -> Double#+(-##) :: Double# -> Double# -> Double#+(*##) :: Double# -> Double# -> Double#+(/##) :: Double# -> Double# -> Double#+negateDouble# :: Double# -> Double#++-- | Truncates a <tt>Double</tt>. Results are undefined if the truncation+-- if truncation yields a value outside the range of <tt>Int#</tt>.+double2Int# :: Double# -> Int#+double2Float# :: Double# -> Float#+expDouble# :: Double# -> Double#+logDouble# :: Double# -> Double#+sqrtDouble# :: Double# -> Double#+sinDouble# :: Double# -> Double#+cosDouble# :: Double# -> Double#+tanDouble# :: Double# -> Double#+asinDouble# :: Double# -> Double#+acosDouble# :: Double# -> Double#+atanDouble# :: Double# -> Double#+sinhDouble# :: Double# -> Double#+coshDouble# :: Double# -> Double#+tanhDouble# :: Double# -> Double#++-- | Exponentiation.+(**##) :: Double# -> Double# -> Double#++-- | Convert to integer. First component of the result is -1 or 1,+-- indicating the sign of the mantissa. The next two are the high and low+-- 32 bits of the mantissa respectively, and the last is the exponent.+decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #)+data Float#+gtFloat# :: Float# -> Float# -> Bool+geFloat# :: Float# -> Float# -> Bool+eqFloat# :: Float# -> Float# -> Bool+neFloat# :: Float# -> Float# -> Bool+ltFloat# :: Float# -> Float# -> Bool+leFloat# :: Float# -> Float# -> Bool+plusFloat# :: Float# -> Float# -> Float#+minusFloat# :: Float# -> Float# -> Float#+timesFloat# :: Float# -> Float# -> Float#+divideFloat# :: Float# -> Float# -> Float#+negateFloat# :: Float# -> Float#++-- | Truncates a <tt>Float</tt>. Results are undefined if the truncation if+-- truncation yields a value outside the range of <tt>Int#</tt>.+float2Int# :: Float# -> Int#+expFloat# :: Float# -> Float#+logFloat# :: Float# -> Float#+sqrtFloat# :: Float# -> Float#+sinFloat# :: Float# -> Float#+cosFloat# :: Float# -> Float#+tanFloat# :: Float# -> Float#+asinFloat# :: Float# -> Float#+acosFloat# :: Float# -> Float#+atanFloat# :: Float# -> Float#+sinhFloat# :: Float# -> Float#+coshFloat# :: Float# -> Float#+tanhFloat# :: Float# -> Float#+powerFloat# :: Float# -> Float# -> Float#+float2Double# :: Float# -> Double#++-- | Convert to integers. First <tt>Int#</tt> in result is the mantissa;+-- second is the exponent.+decodeFloat_Int# :: Float# -> (# Int#, Int# #)+data Array# a+data MutableArray# s a++-- | Create a new mutable array with the specified number of elements, in+-- the specified state thread, with each element containing the specified+-- initial value.+newArray# :: Int# -> a -> State# s -> (# State# s, MutableArray# s a #)+sameMutableArray# :: MutableArray# s a -> MutableArray# s a -> Bool++-- | Read from specified index of mutable array. Result is not yet+-- evaluated.+readArray# :: MutableArray# s a -> Int# -> State# s -> (# State# s, a #)++-- | Write to specified index of mutable array.+writeArray# :: MutableArray# s a -> Int# -> a -> State# s -> State# s++-- | Read from specified index of immutable array. Result is packaged into+-- an unboxed singleton; the result itself is not yet evaluated.+indexArray# :: Array# a -> Int# -> (# a #)++-- | Make a mutable array immutable, without copying.+unsafeFreezeArray# :: MutableArray# s a -> State# s -> (# State# s, Array# a #)++-- | Make an immutable array mutable, without copying.+unsafeThawArray# :: Array# a -> State# s -> (# State# s, MutableArray# s a #)+data ByteArray#+data MutableByteArray# s++-- | Create a new mutable byte array of specified size (in bytes), in the+-- specified state thread.+newByteArray# :: Int# -> State# s -> (# State# s, MutableByteArray# s #)++-- | Create a mutable byte array that the GC guarantees not to move.+newPinnedByteArray# :: Int# -> State# s -> (# State# s, MutableByteArray# s #)++-- | Create a mutable byte array, aligned by the specified amount, that the+-- GC guarantees not to move.+newAlignedPinnedByteArray# :: Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)++-- | Intended for use with pinned arrays; otherwise very unsafe!+byteArrayContents# :: ByteArray# -> Addr#+sameMutableByteArray# :: MutableByteArray# s -> MutableByteArray# s -> Bool++-- | Make a mutable byte array immutable, without copying.+unsafeFreezeByteArray# :: MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)++-- | Return the size of the array in bytes.+sizeofByteArray# :: ByteArray# -> Int#++-- | Return the size of the array in bytes.+sizeofMutableByteArray# :: MutableByteArray# s -> Int#++-- | Read 8-bit character; offset in bytes.+indexCharArray# :: ByteArray# -> Int# -> Char#++-- | Read 31-bit character; offset in 4-byte words.+indexWideCharArray# :: ByteArray# -> Int# -> Char#+indexIntArray# :: ByteArray# -> Int# -> Int#+indexWordArray# :: ByteArray# -> Int# -> Word#+indexAddrArray# :: ByteArray# -> Int# -> Addr#+indexFloatArray# :: ByteArray# -> Int# -> Float#+indexDoubleArray# :: ByteArray# -> Int# -> Double#+indexStablePtrArray# :: ByteArray# -> Int# -> StablePtr# a+indexInt8Array# :: ByteArray# -> Int# -> Int#+indexInt16Array# :: ByteArray# -> Int# -> Int#+indexInt32Array# :: ByteArray# -> Int# -> Int#+indexInt64Array# :: ByteArray# -> Int# -> Int#+indexWord8Array# :: ByteArray# -> Int# -> Word#+indexWord16Array# :: ByteArray# -> Int# -> Word#+indexWord32Array# :: ByteArray# -> Int# -> Word#+indexWord64Array# :: ByteArray# -> Int# -> Word#++-- | Read 8-bit character; offset in bytes.+readCharArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)++-- | Read 31-bit character; offset in 4-byte words.+readWideCharArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)+readIntArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readWordArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readAddrArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)+readFloatArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)+readDoubleArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)+readStablePtrArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)+readInt8Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt16Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt32Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt64Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readWord8Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord16Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord32Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord64Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)++-- | Write 8-bit character; offset in bytes.+writeCharArray# :: MutableByteArray# s -> Int# -> Char# -> State# s -> State# s++-- | Write 31-bit character; offset in 4-byte words.+writeWideCharArray# :: MutableByteArray# s -> Int# -> Char# -> State# s -> State# s+writeIntArray# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeWordArray# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeAddrArray# :: MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s+writeFloatArray# :: MutableByteArray# s -> Int# -> Float# -> State# s -> State# s+writeDoubleArray# :: MutableByteArray# s -> Int# -> Double# -> State# s -> State# s+writeStablePtrArray# :: MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s+writeInt8Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt16Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt32Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt64Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeWord8Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord16Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord32Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord64Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s++-- | An arbitrary machine address assumed to point outside the+-- garbage-collected heap.+data Addr#++-- | The null address.+nullAddr# :: Addr#+plusAddr# :: Addr# -> Int# -> Addr#++-- | Result is meaningless if two <tt>Addr#</tt>s are so far apart that+-- their difference doesn't fit in an <tt>Int#</tt>.+minusAddr# :: Addr# -> Addr# -> Int#++-- | Return the remainder when the <tt>Addr#</tt> arg, treated like an+-- <tt>Int#</tt>, is divided by the <tt>Int#</tt> arg.+remAddr# :: Addr# -> Int# -> Int#++-- | Coerce directly from address to int. Strongly deprecated.+addr2Int# :: Addr# -> Int#++-- | Coerce directly from int to address. Strongly deprecated.+int2Addr# :: Int# -> Addr#+gtAddr# :: Addr# -> Addr# -> Bool+geAddr# :: Addr# -> Addr# -> Bool+eqAddr# :: Addr# -> Addr# -> Bool+neAddr# :: Addr# -> Addr# -> Bool+ltAddr# :: Addr# -> Addr# -> Bool+leAddr# :: Addr# -> Addr# -> Bool++-- | Reads 8-bit character; offset in bytes.+indexCharOffAddr# :: Addr# -> Int# -> Char#++-- | Reads 31-bit character; offset in 4-byte words.+indexWideCharOffAddr# :: Addr# -> Int# -> Char#+indexIntOffAddr# :: Addr# -> Int# -> Int#+indexWordOffAddr# :: Addr# -> Int# -> Word#+indexAddrOffAddr# :: Addr# -> Int# -> Addr#+indexFloatOffAddr# :: Addr# -> Int# -> Float#+indexDoubleOffAddr# :: Addr# -> Int# -> Double#+indexStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a+indexInt8OffAddr# :: Addr# -> Int# -> Int#+indexInt16OffAddr# :: Addr# -> Int# -> Int#+indexInt32OffAddr# :: Addr# -> Int# -> Int#+indexInt64OffAddr# :: Addr# -> Int# -> Int#+indexWord8OffAddr# :: Addr# -> Int# -> Word#+indexWord16OffAddr# :: Addr# -> Int# -> Word#+indexWord32OffAddr# :: Addr# -> Int# -> Word#+indexWord64OffAddr# :: Addr# -> Int# -> Word#++-- | Reads 8-bit character; offset in bytes.+readCharOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Char# #)++-- | Reads 31-bit character; offset in 4-byte words.+readWideCharOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Char# #)+readIntOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readWordOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readAddrOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Addr# #)+readFloatOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Float# #)+readDoubleOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Double# #)+readStablePtrOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)+readInt8OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt16OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt32OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt64OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readWord8OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord16OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord32OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord64OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+writeCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s+writeWideCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s+writeIntOffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeWordOffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeAddrOffAddr# :: Addr# -> Int# -> Addr# -> State# s -> State# s+writeFloatOffAddr# :: Addr# -> Int# -> Float# -> State# s -> State# s+writeDoubleOffAddr# :: Addr# -> Int# -> Double# -> State# s -> State# s+writeStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a -> State# s -> State# s+writeInt8OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt16OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt32OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt64OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeWord8OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord16OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord32OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord64OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s++-- | A <tt>MutVar#</tt> behaves like a single-element mutable array.+data MutVar# s a++-- | Create <tt>MutVar#</tt> with specified initial value in specified+-- state thread.+newMutVar# :: a -> State# s -> (# State# s, MutVar# s a #)++-- | Read contents of <tt>MutVar#</tt>. Result is not yet evaluated.+readMutVar# :: MutVar# s a -> State# s -> (# State# s, a #)++-- | Write contents of <tt>MutVar#</tt>.+writeMutVar# :: MutVar# s a -> a -> State# s -> State# s+sameMutVar# :: MutVar# s a -> MutVar# s a -> Bool+atomicModifyMutVar# :: MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)+catch# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (b -> State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+raise# :: a -> b+raiseIO# :: a -> State# (RealWorld) -> (# State# (RealWorld), b #)+maskAsyncExceptions# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+maskUninterruptible# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+unmaskAsyncExceptions# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+getMaskingState# :: State# (RealWorld) -> (# State# (RealWorld), Int# #)+data TVar# s a+atomically# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+retry# :: State# (RealWorld) -> (# State# (RealWorld), a #)+catchRetry# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+catchSTM# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (b -> State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+check# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), () #)++-- | Create a new <tt>TVar#</tt> holding a specified initial value.+newTVar# :: a -> State# s -> (# State# s, TVar# s a #)++-- | Read contents of <tt>TVar#</tt>. Result is not yet evaluated.+readTVar# :: TVar# s a -> State# s -> (# State# s, a #)++-- | Read contents of <tt>TVar#</tt> outside an STM transaction+readTVarIO# :: TVar# s a -> State# s -> (# State# s, a #)++-- | Write contents of <tt>TVar#</tt>.+writeTVar# :: TVar# s a -> a -> State# s -> State# s+sameTVar# :: TVar# s a -> TVar# s a -> Bool++-- | A shared mutable variable (<i>not</i> the same as a+-- <tt>MutVar#</tt>!). (Note: in a non-concurrent implementation,+-- <tt>(MVar# a)</tt> can be represented by <tt>(MutVar# (Maybe+-- a))</tt>.)+data MVar# s a++-- | Create new <tt>MVar#</tt>; initially empty.+newMVar# :: State# s -> (# State# s, MVar# s a #)++-- | If <tt>MVar#</tt> is empty, block until it becomes full. Then remove+-- and return its contents, and set it empty.+takeMVar# :: MVar# s a -> State# s -> (# State# s, a #)++-- | If <tt>MVar#</tt> is empty, immediately return with integer 0 and+-- value undefined. Otherwise, return with integer 1 and contents of+-- <tt>MVar#</tt>, and set <tt>MVar#</tt> empty.+tryTakeMVar# :: MVar# s a -> State# s -> (# State# s, Int#, a #)++-- | If <tt>MVar#</tt> is full, block until it becomes empty. Then store+-- value arg as its new contents.+putMVar# :: MVar# s a -> a -> State# s -> State# s++-- | If <tt>MVar#</tt> is full, immediately return with integer 0.+-- Otherwise, store value arg as <tt>MVar#</tt>'s new contents, and+-- return with integer 1.+tryPutMVar# :: MVar# s a -> a -> State# s -> (# State# s, Int# #)+sameMVar# :: MVar# s a -> MVar# s a -> Bool++-- | Return 1 if <tt>MVar#</tt> is empty; 0 otherwise.+isEmptyMVar# :: MVar# s a -> State# s -> (# State# s, Int# #)++-- | Sleep specified number of microseconds.+delay# :: Int# -> State# s -> State# s++-- | Block until input is available on specified file descriptor.+waitRead# :: Int# -> State# s -> State# s++-- | Block until output is possible on specified file descriptor.+waitWrite# :: Int# -> State# s -> State# s++-- | <tt>State#</tt> is the primitive, unlifted type of states. It has one+-- type parameter, thus <tt>State# RealWorld</tt>, or <tt>State# s</tt>,+-- where s is a type variable. The only purpose of the type parameter is+-- to keep different state threads separate. It is represented by nothing+-- at all.+data State# s++-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it+-- is not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate+-- values of type <tt>RealWorld</tt>; it's only used in the type system,+-- to parameterise <tt>State#</tt>.+data RealWorld++-- | (In a non-concurrent implementation, this can be a singleton type,+-- whose (unique) value is returned by <tt>myThreadId#</tt>. The other+-- operations can be omitted.)+data ThreadId#+fork# :: a -> State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+forkOn# :: Int# -> a -> State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+killThread# :: ThreadId# -> a -> State# (RealWorld) -> State# (RealWorld)+yield# :: State# (RealWorld) -> State# (RealWorld)+myThreadId# :: State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+labelThread# :: ThreadId# -> Addr# -> State# (RealWorld) -> State# (RealWorld)+isCurrentThreadBound# :: State# (RealWorld) -> (# State# (RealWorld), Int# #)+noDuplicate# :: State# (RealWorld) -> State# (RealWorld)+threadStatus# :: ThreadId# -> State# (RealWorld) -> (# State# (RealWorld), Int# #)+data Weak# b+mkWeak# :: o -> b -> c -> State# (RealWorld) -> (# State# (RealWorld), Weak# b #)+mkWeakForeignEnv# :: o -> b -> Addr# -> Addr# -> Int# -> Addr# -> State# (RealWorld) -> (# State# (RealWorld), Weak# b #)+deRefWeak# :: Weak# a -> State# (RealWorld) -> (# State# (RealWorld), Int#, a #)+finalizeWeak# :: Weak# a -> State# (RealWorld) -> (# State# (RealWorld), Int#, State# (RealWorld) -> (# State# (RealWorld), () #) #)+touch# :: o -> State# (RealWorld) -> State# (RealWorld)+data StablePtr# a+data StableName# a+makeStablePtr# :: a -> State# (RealWorld) -> (# State# (RealWorld), StablePtr# a #)+deRefStablePtr# :: StablePtr# a -> State# (RealWorld) -> (# State# (RealWorld), a #)+eqStablePtr# :: StablePtr# a -> StablePtr# a -> Int#+makeStableName# :: a -> State# (RealWorld) -> (# State# (RealWorld), StableName# a #)+eqStableName# :: StableName# a -> StableName# a -> Int#+stableNameToInt# :: StableName# a -> Int#+reallyUnsafePtrEquality# :: a -> a -> Int#+par# :: a -> Int#+getSpark# :: State# s -> (# State# s, Int#, a #)++-- | Returns the number of sparks in the local spark pool.+numSparks# :: State# s -> (# State# s, Int# #)+parGlobal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#+parLocal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#+parAt# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#+parAtAbs# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#+parAtRel# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#+parAtForNow# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#+dataToTag# :: a -> Int#+tagToEnum# :: Int# -> a++-- | Primitive bytecode type.+data BCO#++-- | Convert an <tt>Addr#</tt> to a followable type.+addrToHValue# :: Addr# -> (# a #)+mkApUpd0# :: BCO# -> (# a #)+newBCO# :: ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)+unpackClosure# :: a -> (# Addr#, Array# b, ByteArray# #)+getApStackVal# :: a -> Int# -> (# Int#, b #)+traceCcs# :: a -> b -> b++-- | Evaluates its first argument to head normal form, and then returns its+-- second argument as the result.+seq :: a -> b -> b++-- | The call <tt>(inline f)</tt> arranges that f is inlined, regardless of+-- its size. More precisely, the call <tt>(inline f)</tt> rewrites to the+-- right-hand side of <tt>f</tt>'s definition. This allows the programmer+-- to control inlining from a particular call site rather than the+-- definition site of the function (c.f. <tt>INLINE</tt> pragmas in+-- User's Guide, Section 7.10.3, "INLINE and NOINLINE pragmas").+-- +-- This inlining occurs regardless of the argument to the call or the+-- size of <tt>f</tt>'s definition; it is unconditional. The main caveat+-- is that <tt>f</tt>'s definition must be visible to the compiler. That+-- is, <tt>f</tt> must be <tt>let</tt>-bound in the current scope. If no+-- inlining takes place, the <tt>inline</tt> function expands to the+-- identity function in Phase zero; so its use imposes no overhead.+-- +-- It is good practice to mark the function with an INLINABLE pragma at+-- its definition, (a) so that GHC guarantees to expose its unfolding+-- regardless of size, and (b) so that you have control over exactly what+-- is inlined.+inline :: a -> a++-- | The <tt>lazy</tt> function restrains strictness analysis a little. The+-- call <tt>(lazy e)</tt> means the same as <tt>e</tt>, but <tt>lazy</tt>+-- has a magical property so far as strictness analysis is concerned: it+-- is lazy in its first argument, even though its semantics is strict.+-- After strictness analysis has run, calls to <tt>lazy</tt> are inlined+-- to be the identity function.+-- +-- This behaviour is occasionally useful when controlling evaluation+-- order. Notably, <tt>lazy</tt> is used in the library definition of+-- <tt>Control.Parallel.par</tt>:+-- +-- <pre>+-- par :: a -> b -> b+-- </pre>+-- +-- <pre>+-- par x y = case (par# x) of _ -> lazy y+-- </pre>+-- +-- If <tt>lazy</tt> were not lazy, <tt>par</tt> would look strict in+-- <tt>y</tt> which would defeat the whole purpose of <tt>par</tt>.+-- +-- Like <tt>seq</tt>, the argument of <tt>lazy</tt> can have an unboxed+-- type.+lazy :: a -> a++-- | The type constructor <tt>Any</tt> is type to which you can unsafely+-- coerce any lifted type, and back.+-- +-- <ul>+-- <li>It is lifted, and hence represented by a pointer</li>+-- <li>It does not claim to be a <i>data</i> type, and that's important+-- for the code generator, because the code gen may <i>enter</i> a data+-- value but never enters a function value.</li>+-- </ul>+-- +-- It's also used to instantiate un-constrained type variables after type+-- checking. For example+-- +-- <pre>+-- length Any []+-- </pre>+-- +-- Annoyingly, we sometimes need <tt>Any</tt>s of other kinds, such as+-- <tt>(* -> *)</tt> etc. This is a bit like tuples. We define a+-- couple of useful ones here, and make others up on the fly. If any of+-- these others end up being exported into interface files, we'll get a+-- crash; at least until we add interface-file syntax to support them.+data Any a++-- | The function <tt>unsafeCoerce#</tt> allows you to side-step the+-- typechecker entirely. That is, it allows you to coerce any type into+-- any other type. If you use this function, you had better get it right,+-- otherwise segmentation faults await. It is generally used when you+-- want to write a program that you know is well-typed, but where+-- Haskell's type system is not expressive enough to prove that it is+-- well typed.+-- +-- The following uses of <tt>unsafeCoerce#</tt> are supposed to work+-- (i.e. not lead to spurious compile-time or run-time crashes):+-- +-- <ul>+-- <li>Casting any lifted type to <tt>Any</tt></li>+-- <li>Casting <tt>Any</tt> back to the real type</li>+-- <li>Casting an unboxed type to another unboxed type of the same size+-- (but not coercions between floating-point and integral types)</li>+-- <li>Casting between two types that have the same runtime+-- representation. One case is when the two types differ only in+-- "phantom" type parameters, for example <tt>Ptr Int</tt> to <tt>Ptr+-- Float</tt>, or <tt>[Int]</tt> to <tt>[Float]</tt> when the list is+-- known to be empty. Also, a <tt>newtype</tt> of a type <tt>T</tt> has+-- the same representation at runtime as <tt>T</tt>.</li>+-- </ul>+-- +-- Other uses of <tt>unsafeCoerce#</tt> are undefined. In particular, you+-- should not use <tt>unsafeCoerce#</tt> to cast a T to an algebraic data+-- type D, unless T is also an algebraic data type. For example, do not+-- cast <tt>Int->Int</tt> to <tt>Bool</tt>, even if you later cast+-- that <tt>Bool</tt> back to <tt>Int->Int</tt> before applying it.+-- The reasons have to do with GHC's internal representation details (for+-- the congnoscenti, data values can be entered but function closures+-- cannot). If you want a safe type to cast things to, use <tt>Any</tt>,+-- which is not an algebraic data type.+unsafeCoerce# :: a -> b++-- | Emits an event via the RTS tracing framework. The contents of the+-- event is the zero-terminated byte string passed as the first argument.+-- The event will be emitted either to the .eventlog file, or to stderr,+-- depending on the runtime RTS flags.+traceEvent# :: Addr# -> State# s -> State# s++module GHC.PrimopWrappers+gtChar# :: Char# -> Char# -> Bool+geChar# :: Char# -> Char# -> Bool+eqChar# :: Char# -> Char# -> Bool+neChar# :: Char# -> Char# -> Bool+ltChar# :: Char# -> Char# -> Bool+leChar# :: Char# -> Char# -> Bool+ord# :: Char# -> Int#+(+#) :: Int# -> Int# -> Int#+(-#) :: Int# -> Int# -> Int#+(*#) :: Int# -> Int# -> Int#+mulIntMayOflo# :: Int# -> Int# -> Int#+quotInt# :: Int# -> Int# -> Int#+remInt# :: Int# -> Int# -> Int#+negateInt# :: Int# -> Int#+addIntC# :: Int# -> Int# -> (# Int#, Int# #)+subIntC# :: Int# -> Int# -> (# Int#, Int# #)+(>#) :: Int# -> Int# -> Bool+(>=#) :: Int# -> Int# -> Bool+(==#) :: Int# -> Int# -> Bool+(/=#) :: Int# -> Int# -> Bool+(<#) :: Int# -> Int# -> Bool+(<=#) :: Int# -> Int# -> Bool+chr# :: Int# -> Char#+int2Word# :: Int# -> Word#+int2Float# :: Int# -> Float#+int2Double# :: Int# -> Double#+uncheckedIShiftL# :: Int# -> Int# -> Int#+uncheckedIShiftRA# :: Int# -> Int# -> Int#+uncheckedIShiftRL# :: Int# -> Int# -> Int#+plusWord# :: Word# -> Word# -> Word#+minusWord# :: Word# -> Word# -> Word#+timesWord# :: Word# -> Word# -> Word#+quotWord# :: Word# -> Word# -> Word#+remWord# :: Word# -> Word# -> Word#+and# :: Word# -> Word# -> Word#+or# :: Word# -> Word# -> Word#+xor# :: Word# -> Word# -> Word#+not# :: Word# -> Word#+uncheckedShiftL# :: Word# -> Int# -> Word#+uncheckedShiftRL# :: Word# -> Int# -> Word#+word2Int# :: Word# -> Int#+gtWord# :: Word# -> Word# -> Bool+geWord# :: Word# -> Word# -> Bool+eqWord# :: Word# -> Word# -> Bool+neWord# :: Word# -> Word# -> Bool+ltWord# :: Word# -> Word# -> Bool+leWord# :: Word# -> Word# -> Bool+narrow8Int# :: Int# -> Int#+narrow16Int# :: Int# -> Int#+narrow32Int# :: Int# -> Int#+narrow8Word# :: Word# -> Word#+narrow16Word# :: Word# -> Word#+narrow32Word# :: Word# -> Word#+(>##) :: Double# -> Double# -> Bool+(>=##) :: Double# -> Double# -> Bool+(==##) :: Double# -> Double# -> Bool+(/=##) :: Double# -> Double# -> Bool+(<##) :: Double# -> Double# -> Bool+(<=##) :: Double# -> Double# -> Bool+(+##) :: Double# -> Double# -> Double#+(-##) :: Double# -> Double# -> Double#+(*##) :: Double# -> Double# -> Double#+(/##) :: Double# -> Double# -> Double#+negateDouble# :: Double# -> Double#+double2Int# :: Double# -> Int#+double2Float# :: Double# -> Float#+expDouble# :: Double# -> Double#+logDouble# :: Double# -> Double#+sqrtDouble# :: Double# -> Double#+sinDouble# :: Double# -> Double#+cosDouble# :: Double# -> Double#+tanDouble# :: Double# -> Double#+asinDouble# :: Double# -> Double#+acosDouble# :: Double# -> Double#+atanDouble# :: Double# -> Double#+sinhDouble# :: Double# -> Double#+coshDouble# :: Double# -> Double#+tanhDouble# :: Double# -> Double#+(**##) :: Double# -> Double# -> Double#+decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #)+gtFloat# :: Float# -> Float# -> Bool+geFloat# :: Float# -> Float# -> Bool+eqFloat# :: Float# -> Float# -> Bool+neFloat# :: Float# -> Float# -> Bool+ltFloat# :: Float# -> Float# -> Bool+leFloat# :: Float# -> Float# -> Bool+plusFloat# :: Float# -> Float# -> Float#+minusFloat# :: Float# -> Float# -> Float#+timesFloat# :: Float# -> Float# -> Float#+divideFloat# :: Float# -> Float# -> Float#+negateFloat# :: Float# -> Float#+float2Int# :: Float# -> Int#+expFloat# :: Float# -> Float#+logFloat# :: Float# -> Float#+sqrtFloat# :: Float# -> Float#+sinFloat# :: Float# -> Float#+cosFloat# :: Float# -> Float#+tanFloat# :: Float# -> Float#+asinFloat# :: Float# -> Float#+acosFloat# :: Float# -> Float#+atanFloat# :: Float# -> Float#+sinhFloat# :: Float# -> Float#+coshFloat# :: Float# -> Float#+tanhFloat# :: Float# -> Float#+powerFloat# :: Float# -> Float# -> Float#+float2Double# :: Float# -> Double#+decodeFloat_Int# :: Float# -> (# Int#, Int# #)+newArray# :: Int# -> a -> State# s -> (# State# s, MutableArray# s a #)+sameMutableArray# :: MutableArray# s a -> MutableArray# s a -> Bool+readArray# :: MutableArray# s a -> Int# -> State# s -> (# State# s, a #)+writeArray# :: MutableArray# s a -> Int# -> a -> State# s -> State# s+indexArray# :: Array# a -> Int# -> (# a #)+unsafeFreezeArray# :: MutableArray# s a -> State# s -> (# State# s, Array# a #)+unsafeThawArray# :: Array# a -> State# s -> (# State# s, MutableArray# s a #)+newByteArray# :: Int# -> State# s -> (# State# s, MutableByteArray# s #)+newPinnedByteArray# :: Int# -> State# s -> (# State# s, MutableByteArray# s #)+newAlignedPinnedByteArray# :: Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)+byteArrayContents# :: ByteArray# -> Addr#+sameMutableByteArray# :: MutableByteArray# s -> MutableByteArray# s -> Bool+unsafeFreezeByteArray# :: MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)+sizeofByteArray# :: ByteArray# -> Int#+sizeofMutableByteArray# :: MutableByteArray# s -> Int#+indexCharArray# :: ByteArray# -> Int# -> Char#+indexWideCharArray# :: ByteArray# -> Int# -> Char#+indexIntArray# :: ByteArray# -> Int# -> Int#+indexWordArray# :: ByteArray# -> Int# -> Word#+indexAddrArray# :: ByteArray# -> Int# -> Addr#+indexFloatArray# :: ByteArray# -> Int# -> Float#+indexDoubleArray# :: ByteArray# -> Int# -> Double#+indexStablePtrArray# :: ByteArray# -> Int# -> StablePtr# a+indexInt8Array# :: ByteArray# -> Int# -> Int#+indexInt16Array# :: ByteArray# -> Int# -> Int#+indexInt32Array# :: ByteArray# -> Int# -> Int#+indexInt64Array# :: ByteArray# -> Int# -> Int#+indexWord8Array# :: ByteArray# -> Int# -> Word#+indexWord16Array# :: ByteArray# -> Int# -> Word#+indexWord32Array# :: ByteArray# -> Int# -> Word#+indexWord64Array# :: ByteArray# -> Int# -> Word#+readCharArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)+readWideCharArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)+readIntArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readWordArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readAddrArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)+readFloatArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)+readDoubleArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)+readStablePtrArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)+readInt8Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt16Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt32Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readInt64Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)+readWord8Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord16Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord32Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+readWord64Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)+writeCharArray# :: MutableByteArray# s -> Int# -> Char# -> State# s -> State# s+writeWideCharArray# :: MutableByteArray# s -> Int# -> Char# -> State# s -> State# s+writeIntArray# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeWordArray# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeAddrArray# :: MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s+writeFloatArray# :: MutableByteArray# s -> Int# -> Float# -> State# s -> State# s+writeDoubleArray# :: MutableByteArray# s -> Int# -> Double# -> State# s -> State# s+writeStablePtrArray# :: MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s+writeInt8Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt16Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt32Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeInt64Array# :: MutableByteArray# s -> Int# -> Int# -> State# s -> State# s+writeWord8Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord16Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord32Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+writeWord64Array# :: MutableByteArray# s -> Int# -> Word# -> State# s -> State# s+plusAddr# :: Addr# -> Int# -> Addr#+minusAddr# :: Addr# -> Addr# -> Int#+remAddr# :: Addr# -> Int# -> Int#+addr2Int# :: Addr# -> Int#+int2Addr# :: Int# -> Addr#+gtAddr# :: Addr# -> Addr# -> Bool+geAddr# :: Addr# -> Addr# -> Bool+eqAddr# :: Addr# -> Addr# -> Bool+neAddr# :: Addr# -> Addr# -> Bool+ltAddr# :: Addr# -> Addr# -> Bool+leAddr# :: Addr# -> Addr# -> Bool+indexCharOffAddr# :: Addr# -> Int# -> Char#+indexWideCharOffAddr# :: Addr# -> Int# -> Char#+indexIntOffAddr# :: Addr# -> Int# -> Int#+indexWordOffAddr# :: Addr# -> Int# -> Word#+indexAddrOffAddr# :: Addr# -> Int# -> Addr#+indexFloatOffAddr# :: Addr# -> Int# -> Float#+indexDoubleOffAddr# :: Addr# -> Int# -> Double#+indexStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a+indexInt8OffAddr# :: Addr# -> Int# -> Int#+indexInt16OffAddr# :: Addr# -> Int# -> Int#+indexInt32OffAddr# :: Addr# -> Int# -> Int#+indexInt64OffAddr# :: Addr# -> Int# -> Int#+indexWord8OffAddr# :: Addr# -> Int# -> Word#+indexWord16OffAddr# :: Addr# -> Int# -> Word#+indexWord32OffAddr# :: Addr# -> Int# -> Word#+indexWord64OffAddr# :: Addr# -> Int# -> Word#+readCharOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Char# #)+readWideCharOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Char# #)+readIntOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readWordOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readAddrOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Addr# #)+readFloatOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Float# #)+readDoubleOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Double# #)+readStablePtrOffAddr# :: Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)+readInt8OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt16OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt32OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readInt64OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Int# #)+readWord8OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord16OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord32OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+readWord64OffAddr# :: Addr# -> Int# -> State# s -> (# State# s, Word# #)+writeCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s+writeWideCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s+writeIntOffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeWordOffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeAddrOffAddr# :: Addr# -> Int# -> Addr# -> State# s -> State# s+writeFloatOffAddr# :: Addr# -> Int# -> Float# -> State# s -> State# s+writeDoubleOffAddr# :: Addr# -> Int# -> Double# -> State# s -> State# s+writeStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a -> State# s -> State# s+writeInt8OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt16OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt32OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeInt64OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s+writeWord8OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord16OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord32OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+writeWord64OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s+newMutVar# :: a -> State# s -> (# State# s, MutVar# s a #)+readMutVar# :: MutVar# s a -> State# s -> (# State# s, a #)+writeMutVar# :: MutVar# s a -> a -> State# s -> State# s+sameMutVar# :: MutVar# s a -> MutVar# s a -> Bool+atomicModifyMutVar# :: MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)+catch# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (b -> State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+raise# :: a -> b+raiseIO# :: a -> State# (RealWorld) -> (# State# (RealWorld), b #)+maskAsyncExceptions# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+maskUninterruptible# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+unmaskAsyncExceptions# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+getMaskingState# :: State# (RealWorld) -> (# State# (RealWorld), Int# #)+atomically# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+retry# :: State# (RealWorld) -> (# State# (RealWorld), a #)+catchRetry# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+catchSTM# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> (b -> State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), a #)+check# :: (State# (RealWorld) -> (# State# (RealWorld), a #)) -> State# (RealWorld) -> (# State# (RealWorld), () #)+newTVar# :: a -> State# s -> (# State# s, TVar# s a #)+readTVar# :: TVar# s a -> State# s -> (# State# s, a #)+readTVarIO# :: TVar# s a -> State# s -> (# State# s, a #)+writeTVar# :: TVar# s a -> a -> State# s -> State# s+sameTVar# :: TVar# s a -> TVar# s a -> Bool+newMVar# :: State# s -> (# State# s, MVar# s a #)+takeMVar# :: MVar# s a -> State# s -> (# State# s, a #)+tryTakeMVar# :: MVar# s a -> State# s -> (# State# s, Int#, a #)+putMVar# :: MVar# s a -> a -> State# s -> State# s+tryPutMVar# :: MVar# s a -> a -> State# s -> (# State# s, Int# #)+sameMVar# :: MVar# s a -> MVar# s a -> Bool+isEmptyMVar# :: MVar# s a -> State# s -> (# State# s, Int# #)+delay# :: Int# -> State# s -> State# s+waitRead# :: Int# -> State# s -> State# s+waitWrite# :: Int# -> State# s -> State# s+fork# :: a -> State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+forkOn# :: Int# -> a -> State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+killThread# :: ThreadId# -> a -> State# (RealWorld) -> State# (RealWorld)+yield# :: State# (RealWorld) -> State# (RealWorld)+myThreadId# :: State# (RealWorld) -> (# State# (RealWorld), ThreadId# #)+labelThread# :: ThreadId# -> Addr# -> State# (RealWorld) -> State# (RealWorld)+isCurrentThreadBound# :: State# (RealWorld) -> (# State# (RealWorld), Int# #)+noDuplicate# :: State# (RealWorld) -> State# (RealWorld)+threadStatus# :: ThreadId# -> State# (RealWorld) -> (# State# (RealWorld), Int# #)+mkWeak# :: o -> b -> c -> State# (RealWorld) -> (# State# (RealWorld), Weak# b #)+mkWeakForeignEnv# :: o -> b -> Addr# -> Addr# -> Int# -> Addr# -> State# (RealWorld) -> (# State# (RealWorld), Weak# b #)+deRefWeak# :: Weak# a -> State# (RealWorld) -> (# State# (RealWorld), Int#, a #)+finalizeWeak# :: Weak# a -> State# (RealWorld) -> (# State# (RealWorld), Int#, State# (RealWorld) -> (# State# (RealWorld), () #) #)+touch# :: o -> State# (RealWorld) -> State# (RealWorld)+makeStablePtr# :: a -> State# (RealWorld) -> (# State# (RealWorld), StablePtr# a #)+deRefStablePtr# :: StablePtr# a -> State# (RealWorld) -> (# State# (RealWorld), a #)+eqStablePtr# :: StablePtr# a -> StablePtr# a -> Int#+makeStableName# :: a -> State# (RealWorld) -> (# State# (RealWorld), StableName# a #)+eqStableName# :: StableName# a -> StableName# a -> Int#+stableNameToInt# :: StableName# a -> Int#+reallyUnsafePtrEquality# :: a -> a -> Int#+getSpark# :: State# s -> (# State# s, Int#, a #)+numSparks# :: State# s -> (# State# s, Int# #)+dataToTag# :: a -> Int#+addrToHValue# :: Addr# -> (# a #)+mkApUpd0# :: BCO# -> (# a #)+newBCO# :: ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)+unpackClosure# :: a -> (# Addr#, Array# b, ByteArray# #)+getApStackVal# :: a -> Int# -> (# Int#, b #)+traceCcs# :: a -> b -> b+traceEvent# :: Addr# -> State# s -> State# s
+ data/haskell2010.txt view
@@ -0,0 +1,4715 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Compatibility with Haskell 2010+-- +-- This package provides exactly the library modules defined by the+-- Haskell 2010 standard.+@package haskell2010+@version 1.0.0.0+++-- | The Haskell 2010 Prelude: a standard module imported by default into+-- all Haskell modules. For more documentation, see the Haskell 2010+-- Report <a>http://www.haskell.org/onlinereport/</a>.+module Prelude+data Bool :: *+False :: Bool+True :: Bool++-- | Boolean "and"+(&&) :: Bool -> Bool -> Bool++-- | Boolean "or"+(||) :: Bool -> Bool -> Bool++-- | Boolean "not"+not :: Bool -> Bool++-- | <a>otherwise</a> is defined as the value <a>True</a>. It helps to make+-- guards more readable. eg.+-- +-- <pre>+-- f x | x < 0 = ...+-- | otherwise = ...+-- </pre>+otherwise :: Bool++-- | The <a>Maybe</a> type encapsulates an optional value. A value of type+-- <tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>+-- (represented as <tt><a>Just</a> a</tt>), or it is empty (represented+-- as <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with+-- errors or exceptional cases without resorting to drastic measures such+-- as <a>error</a>.+-- +-- The <a>Maybe</a> type is also a monad. It is a simple kind of error+-- monad, where all errors are represented by <a>Nothing</a>. A richer+-- error monad can be built using the <tt>Data.Either.Either</tt> type.+data Maybe a :: * -> *+Nothing :: Maybe a+Just :: a -> Maybe a++-- | The <a>maybe</a> function takes a default value, a function, and a+-- <a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the+-- function returns the default value. Otherwise, it applies the function+-- to the value inside the <a>Just</a> and returns the result.+maybe :: b -> (a -> b) -> Maybe a -> b++-- | The <a>Either</a> type represents values with two possibilities: a+-- value of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>+-- a</tt> or <tt><a>Right</a> b</tt>.+-- +-- The <a>Either</a> type is sometimes used to represent a value which is+-- either correct or an error; by convention, the <a>Left</a> constructor+-- is used to hold an error value and the <a>Right</a> constructor is+-- used to hold a correct value (mnemonic: "right" also means "correct").+data Either a b :: * -> * -> *+Left :: a -> Either a b+Right :: b -> Either a b++-- | Case analysis for the <a>Either</a> type. If the value is+-- <tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it+-- is <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.+either :: (a -> c) -> (b -> c) -> Either a b -> c+data Ordering :: *+LT :: Ordering+EQ :: Ordering+GT :: Ordering++-- | The character type <a>Char</a> is an enumeration whose values+-- represent Unicode (or equivalently ISO/IEC 10646) characters (see+-- <a>http://www.unicode.org/</a> for details). This set extends the ISO+-- 8859-1 (Latin-1) character set (the first 256 charachers), which is+-- itself an extension of the ASCII character set (the first 128+-- characters). A character literal in Haskell has type <a>Char</a>.+-- +-- To convert a <a>Char</a> to or from the corresponding <a>Int</a> value+-- defined by Unicode, use <tt>Prelude.toEnum</tt> and+-- <tt>Prelude.fromEnum</tt> from the <tt>Prelude.Enum</tt> class+-- respectively (or equivalently <tt>ord</tt> and <tt>chr</tt>).+data Char :: *++-- | A <a>String</a> is a list of characters. String constants in Haskell+-- are values of type <a>String</a>.+type String = [Char]++-- | Extract the first component of a pair.+fst :: (a, b) -> a++-- | Extract the second component of a pair.+snd :: (a, b) -> b++-- | <a>curry</a> converts an uncurried function to a curried function.+curry :: ((a, b) -> c) -> a -> b -> c++-- | <a>uncurry</a> converts a curried function to a function on pairs.+uncurry :: (a -> b -> c) -> (a, b) -> c++-- | The <a>Eq</a> class defines equality (<a>==</a>) and inequality+-- (<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>+-- are instances of <a>Eq</a>, and <a>Eq</a> may be derived for any+-- datatype whose constituents are also instances of <a>Eq</a>.+-- +-- Minimal complete definition: either <a>==</a> or <a>/=</a>.+class Eq a+(==) :: Eq a => a -> a -> Bool+(/=) :: Eq a => a -> a -> Bool++-- | The <a>Ord</a> class is used for totally ordered datatypes.+-- +-- Instances of <a>Ord</a> can be derived for any user-defined datatype+-- whose constituent types are in <a>Ord</a>. The declared order of the+-- constructors in the data declaration determines the ordering in+-- derived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a+-- single comparison to determine the precise ordering of two objects.+-- +-- Minimal complete definition: either <a>compare</a> or <a><=</a>.+-- Using <a>compare</a> can be more efficient for complex types.+class Eq a => Ord a+compare :: Ord a => a -> a -> Ordering+(<) :: Ord a => a -> a -> Bool+(>=) :: Ord a => a -> a -> Bool+(>) :: Ord a => a -> a -> Bool+(<=) :: Ord a => a -> a -> Bool+max :: Ord a => a -> a -> a+min :: Ord a => a -> a -> a++-- | Class <a>Enum</a> defines operations on sequentially ordered types.+-- +-- The <tt>enumFrom</tt>... methods are used in Haskell's translation of+-- arithmetic sequences.+-- +-- Instances of <a>Enum</a> may be derived for any enumeration type+-- (types whose constructors have no fields). The nullary constructors+-- are assumed to be numbered left-to-right by <a>fromEnum</a> from+-- <tt>0</tt> through <tt>n-1</tt>. See Chapter 10 of the <i>Haskell+-- Report</i> for more details.+-- +-- For any type that is an instance of class <a>Bounded</a> as well as+-- <a>Enum</a>, the following should hold:+-- +-- <ul>+-- <li>The calls <tt><a>succ</a> <a>maxBound</a></tt> and <tt><a>pred</a>+-- <a>minBound</a></tt> should result in a runtime error.</li>+-- <li><a>fromEnum</a> and <a>toEnum</a> should give a runtime error if+-- the result value is not representable in the result type. For example,+-- <tt><a>toEnum</a> 7 :: <a>Bool</a></tt> is an error.</li>+-- <li><a>enumFrom</a> and <a>enumFromThen</a> should be defined with an+-- implicit bound, thus:</li>+-- </ul>+-- +-- <pre>+-- enumFrom x = enumFromTo x maxBound+-- enumFromThen x y = enumFromThenTo x y bound+-- where+-- bound | fromEnum y >= fromEnum x = maxBound+-- | otherwise = minBound+-- </pre>+class Enum a+succ :: Enum a => a -> a+pred :: Enum a => a -> a+toEnum :: Enum a => Int -> a+fromEnum :: Enum a => a -> Int+enumFrom :: Enum a => a -> [a]+enumFromThen :: Enum a => a -> a -> [a]+enumFromTo :: Enum a => a -> a -> [a]+enumFromThenTo :: Enum a => a -> a -> a -> [a]++-- | The <a>Bounded</a> class is used to name the upper and lower limits of+-- a type. <a>Ord</a> is not a superclass of <a>Bounded</a> since types+-- that are not totally ordered may also have upper and lower bounds.+-- +-- The <a>Bounded</a> class may be derived for any enumeration type;+-- <a>minBound</a> is the first constructor listed in the <tt>data</tt>+-- declaration and <a>maxBound</a> is the last. <a>Bounded</a> may also+-- be derived for single-constructor datatypes whose constituent types+-- are in <a>Bounded</a>.+class Bounded a+minBound :: Bounded a => a+maxBound :: Bounded a => a++-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..+-- 2^29-1]</tt>. The exact range for a given implementation can be+-- determined by using <tt>Prelude.minBound</tt> and+-- <tt>Prelude.maxBound</tt> from the <tt>Prelude.Bounded</tt> class.+data Int :: *++-- | Arbitrary-precision integers.+data Integer :: *++-- | Single-precision floating point numbers. It is desirable that this+-- type be at least equal in range and precision to the IEEE+-- single-precision type.+data Float :: *++-- | Double-precision floating point numbers. It is desirable that this+-- type be at least equal in range and precision to the IEEE+-- double-precision type.+data Double :: *++-- | Arbitrary-precision rational numbers, represented as a ratio of two+-- <a>Integer</a> values. A rational number may be constructed using the+-- <a>%</a> operator.+type Rational = Ratio Integer++-- | Basic numeric class.+-- +-- Minimal complete definition: all except <a>negate</a> or <tt>(-)</tt>+class (Eq a, Show a) => Num a+(+) :: Num a => a -> a -> a+(*) :: Num a => a -> a -> a+(-) :: Num a => a -> a -> a+negate :: Num a => a -> a+abs :: Num a => a -> a+signum :: Num a => a -> a+fromInteger :: Num a => Integer -> a+class (Num a, Ord a) => Real a+toRational :: Real a => a -> Rational++-- | Integral numbers, supporting integer division.+-- +-- Minimal complete definition: <a>quotRem</a> and <a>toInteger</a>+class (Real a, Enum a) => Integral a+quot :: Integral a => a -> a -> a+rem :: Integral a => a -> a -> a+div :: Integral a => a -> a -> a+mod :: Integral a => a -> a -> a+quotRem :: Integral a => a -> a -> (a, a)+divMod :: Integral a => a -> a -> (a, a)+toInteger :: Integral a => a -> Integer++-- | Fractional numbers, supporting real division.+-- +-- Minimal complete definition: <a>fromRational</a> and (<a>recip</a> or+-- <tt>(<a>/</a>)</tt>)+class Num a => Fractional a+(/) :: Fractional a => a -> a -> a+recip :: Fractional a => a -> a+fromRational :: Fractional a => Rational -> a++-- | Trigonometric and hyperbolic functions and related functions.+-- +-- Minimal complete definition: <a>pi</a>, <a>exp</a>, <a>log</a>,+-- <a>sin</a>, <a>cos</a>, <a>sinh</a>, <a>cosh</a>, <a>asin</a>,+-- <a>acos</a>, <a>atan</a>, <a>asinh</a>, <a>acosh</a> and <a>atanh</a>+class Fractional a => Floating a+pi :: Floating a => a+exp :: Floating a => a -> a+sqrt :: Floating a => a -> a+log :: Floating a => a -> a+(**) :: Floating a => a -> a -> a+logBase :: Floating a => a -> a -> a+sin :: Floating a => a -> a+tan :: Floating a => a -> a+cos :: Floating a => a -> a+asin :: Floating a => a -> a+atan :: Floating a => a -> a+acos :: Floating a => a -> a+sinh :: Floating a => a -> a+tanh :: Floating a => a -> a+cosh :: Floating a => a -> a+asinh :: Floating a => a -> a+atanh :: Floating a => a -> a+acosh :: Floating a => a -> a++-- | Extracting components of fractions.+-- +-- Minimal complete definition: <a>properFraction</a>+class (Real a, Fractional a) => RealFrac a+properFraction :: (RealFrac a, Integral b) => a -> (b, a)+truncate :: (RealFrac a, Integral b) => a -> b+round :: (RealFrac a, Integral b) => a -> b+ceiling :: (RealFrac a, Integral b) => a -> b+floor :: (RealFrac a, Integral b) => a -> b++-- | Efficient, machine-independent access to the components of a+-- floating-point number.+-- +-- Minimal complete definition: all except <a>exponent</a>,+-- <a>significand</a>, <a>scaleFloat</a> and <a>atan2</a>+class (RealFrac a, Floating a) => RealFloat a+floatRadix :: RealFloat a => a -> Integer+floatDigits :: RealFloat a => a -> Int+floatRange :: RealFloat a => a -> (Int, Int)+decodeFloat :: RealFloat a => a -> (Integer, Int)+encodeFloat :: RealFloat a => Integer -> Int -> a+exponent :: RealFloat a => a -> Int+significand :: RealFloat a => a -> a+scaleFloat :: RealFloat a => Int -> a -> a+isNaN :: RealFloat a => a -> Bool+isInfinite :: RealFloat a => a -> Bool+isDenormalized :: RealFloat a => a -> Bool+isNegativeZero :: RealFloat a => a -> Bool+isIEEE :: RealFloat a => a -> Bool+atan2 :: RealFloat a => a -> a -> a++-- | the same as <tt><a>flip</a> (<a>-</a>)</tt>.+-- +-- Because <tt>-</tt> is treated specially in the Haskell grammar,+-- <tt>(-</tt> <i>e</i><tt>)</tt> is not a section, but an application of+-- prefix negation. However, <tt>(<a>subtract</a></tt>+-- <i>exp</i><tt>)</tt> is equivalent to the disallowed section.+subtract :: Num a => a -> a -> a+even :: Integral a => a -> Bool+odd :: Integral a => a -> Bool++-- | <tt><a>gcd</a> x y</tt> is the greatest (positive) integer that+-- divides both <tt>x</tt> and <tt>y</tt>; for example <tt><a>gcd</a>+-- (-3) 6</tt> = <tt>3</tt>, <tt><a>gcd</a> (-3) (-6)</tt> = <tt>3</tt>,+-- <tt><a>gcd</a> 0 4</tt> = <tt>4</tt>. <tt><a>gcd</a> 0 0</tt> raises a+-- runtime error.+gcd :: Integral a => a -> a -> a++-- | <tt><a>lcm</a> x y</tt> is the smallest positive integer that both+-- <tt>x</tt> and <tt>y</tt> divide.+lcm :: Integral a => a -> a -> a++-- | raise a number to a non-negative integral power+(^) :: (Num a, Integral b) => a -> b -> a++-- | raise a number to an integral power+(^^) :: (Fractional a, Integral b) => a -> b -> a++-- | general coercion from integral types+fromIntegral :: (Integral a, Num b) => a -> b++-- | general coercion to fractional types+realToFrac :: (Real a, Fractional b) => a -> b++-- | The <a>Monad</a> class defines the basic operations over a+-- <i>monad</i>, a concept from a branch of mathematics known as+-- <i>category theory</i>. From the perspective of a Haskell programmer,+-- however, it is best to think of a monad as an <i>abstract datatype</i>+-- of actions. Haskell's <tt>do</tt> expressions provide a convenient+-- syntax for writing monadic expressions.+-- +-- Minimal complete definition: <a>>>=</a> and <a>return</a>.+-- +-- Instances of <a>Monad</a> should satisfy the following laws:+-- +-- <pre>+-- return a >>= k == k a+-- m >>= return == m+-- m >>= (\x -> k x >>= h) == (m >>= k) >>= h+-- </pre>+-- +-- Instances of both <a>Monad</a> and <a>Functor</a> should additionally+-- satisfy the law:+-- +-- <pre>+-- fmap f xs == xs >>= return . f+-- </pre>+-- +-- The instances of <a>Monad</a> for lists, <tt>Data.Maybe.Maybe</tt> and+-- <tt>System.IO.IO</tt> defined in the <a>Prelude</a> satisfy these+-- laws.+class Monad m :: (* -> *)+(>>=) :: Monad m => m a -> (a -> m b) -> m b+(>>) :: Monad m => m a -> m b -> m b+return :: Monad m => a -> m a+fail :: Monad m => String -> m a++-- | The <a>Functor</a> class is used for types that can be mapped over.+-- Instances of <a>Functor</a> should satisfy the following laws:+-- +-- <pre>+-- fmap id == id+-- fmap (f . g) == fmap f . fmap g+-- </pre>+-- +-- The instances of <a>Functor</a> for lists, <tt>Data.Maybe.Maybe</tt>+-- and <tt>System.IO.IO</tt> satisfy these laws.+class Functor f :: (* -> *)+fmap :: Functor f => (a -> b) -> f a -> f b++-- | <tt><a>mapM</a> f</tt> is equivalent to <tt><a>sequence</a> .+-- <a>map</a> f</tt>.+mapM :: Monad m => (a -> m b) -> [a] -> m [b]++-- | <tt><a>mapM_</a> f</tt> is equivalent to <tt><a>sequence_</a> .+-- <a>map</a> f</tt>.+mapM_ :: Monad m => (a -> m b) -> [a] -> m ()++-- | Evaluate each action in the sequence from left to right, and collect+-- the results.+sequence :: Monad m => [m a] -> m [a]++-- | Evaluate each action in the sequence from left to right, and ignore+-- the results.+sequence_ :: Monad m => [m a] -> m ()++-- | Same as <a>>>=</a>, but with the arguments interchanged.+(=<<) :: Monad m => (a -> m b) -> m a -> m b++-- | Identity function.+id :: a -> a++-- | Constant function.+const :: a -> b -> a++-- | Function composition.+(.) :: (b -> c) -> (a -> b) -> a -> c++-- | <tt><a>flip</a> f</tt> takes its (first) two arguments in the reverse+-- order of <tt>f</tt>.+flip :: (a -> b -> c) -> b -> a -> c++-- | Application operator. This operator is redundant, since ordinary+-- application <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.+-- However, <a>$</a> has low, right-associative binding precedence, so it+-- sometimes allows parentheses to be omitted; for example:+-- +-- <pre>+-- f $ g $ h x = f (g (h x))+-- </pre>+-- +-- It is also useful in higher-order situations, such as <tt><a>map</a>+-- (<a>$</a> 0) xs</tt>, or <tt><tt>Data.List.zipWith</tt> (<a>$</a>) fs+-- xs</tt>.+($) :: (a -> b) -> a -> b++-- | <tt><a>until</a> p f</tt> yields the result of applying <tt>f</tt>+-- until <tt>p</tt> holds.+until :: (a -> Bool) -> (a -> a) -> a -> a++-- | <a>asTypeOf</a> is a type-restricted version of <a>const</a>. It is+-- usually used as an infix operator, and its typing forces its first+-- argument (which is usually overloaded) to have the same type as the+-- second.+asTypeOf :: a -> a -> a++-- | <a>error</a> stops execution and displays an error message.+error :: [Char] -> a++-- | A special case of <a>error</a>. It is expected that compilers will+-- recognize this and insert error messages which are more appropriate to+-- the context in which <a>undefined</a> appears.+undefined :: a++-- | Evaluates its first argument to head normal form, and then returns its+-- second argument as the result.+seq :: a -> b -> b++-- | Strict (call-by-value) application, defined in terms of <a>seq</a>.+($!) :: (a -> b) -> a -> b++-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>+-- to each element of <tt>xs</tt>, i.e.,+-- +-- <pre>+-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]+-- map f [x1, x2, ...] == [f x1, f x2, ...]+-- </pre>+map :: (a -> b) -> [a] -> [b]++-- | Append two lists, i.e.,+-- +-- <pre>+-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]+-- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]+-- </pre>+-- +-- If the first list is not finite, the result is the first list.+(++) :: [a] -> [a] -> [a]++-- | <a>filter</a>, applied to a predicate and a list, returns the list of+-- those elements that satisfy the predicate; i.e.,+-- +-- <pre>+-- filter p xs = [ x | x <- xs, p x]+-- </pre>+filter :: (a -> Bool) -> [a] -> [a]++-- | Extract the first element of a list, which must be non-empty.+head :: [a] -> a++-- | Extract the last element of a list, which must be finite and+-- non-empty.+last :: [a] -> a++-- | Extract the elements after the head of a list, which must be+-- non-empty.+tail :: [a] -> [a]++-- | Return all the elements of a list except the last one. The list must+-- be non-empty.+init :: [a] -> [a]++-- | Test whether a list is empty.+null :: [a] -> Bool++-- | <i>O(n)</i>. <a>length</a> returns the length of a finite list as an+-- <a>Int</a>. It is an instance of the more general+-- <tt>Data.List.genericLength</tt>, the result type of which may be any+-- kind of number.+length :: [a] -> Int++-- | List index (subscript) operator, starting from 0. It is an instance of+-- the more general <tt>Data.List.genericIndex</tt>, which takes an index+-- of any integral type.+(!!) :: [a] -> Int -> a++-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in+-- reverse order. <tt>xs</tt> must be finite.+reverse :: [a] -> [a]++-- | <a>foldl</a>, applied to a binary operator, a starting value+-- (typically the left-identity of the operator), and a list, reduces the+-- list using the binary operator, from left to right:+-- +-- <pre>+-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn+-- </pre>+-- +-- The list must be finite.+foldl :: (a -> b -> a) -> a -> [b] -> a++-- | <a>foldl1</a> is a variant of <a>foldl</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldl1 :: (a -> a -> a) -> [a] -> a++-- | <a>foldr</a>, applied to a binary operator, a starting value+-- (typically the right-identity of the operator), and a list, reduces+-- the list using the binary operator, from right to left:+-- +-- <pre>+-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)+-- </pre>+foldr :: (a -> b -> b) -> b -> [a] -> b++-- | <a>foldr1</a> is a variant of <a>foldr</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldr1 :: (a -> a -> a) -> [a] -> a++-- | <a>and</a> returns the conjunction of a Boolean list. For the result+-- to be <a>True</a>, the list must be finite; <a>False</a>, however,+-- results from a <a>False</a> value at a finite index of a finite or+-- infinite list.+and :: [Bool] -> Bool++-- | <a>or</a> returns the disjunction of a Boolean list. For the result to+-- be <a>False</a>, the list must be finite; <a>True</a>, however,+-- results from a <a>True</a> value at a finite index of a finite or+-- infinite list.+or :: [Bool] -> Bool++-- | Applied to a predicate and a list, <a>any</a> determines if any+-- element of the list satisfies the predicate. For the result to be+-- <a>False</a>, the list must be finite; <a>True</a>, however, results+-- from a <a>True</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+any :: (a -> Bool) -> [a] -> Bool++-- | Applied to a predicate and a list, <a>all</a> determines if all+-- elements of the list satisfy the predicate. For the result to be+-- <a>True</a>, the list must be finite; <a>False</a>, however, results+-- from a <a>False</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+all :: (a -> Bool) -> [a] -> Bool++-- | The <a>sum</a> function computes the sum of a finite list of numbers.+sum :: Num a => [a] -> a++-- | The <a>product</a> function computes the product of a finite list of+-- numbers.+product :: Num a => [a] -> a++-- | Concatenate a list of lists.+concat :: [[a]] -> [a]++-- | Map a function over a list and concatenate the results.+concatMap :: (a -> [b]) -> [a] -> [b]++-- | <a>maximum</a> returns the maximum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>maximumBy</a>, which allows the programmer to supply their own+-- comparison function.+maximum :: Ord a => [a] -> a++-- | <a>minimum</a> returns the minimum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>minimumBy</a>, which allows the programmer to supply their own+-- comparison function.+minimum :: Ord a => [a] -> a++-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of+-- successive reduced values from the left:+-- +-- <pre>+-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]+-- </pre>+-- +-- Note that+-- +-- <pre>+-- last (scanl f z xs) == foldl f z xs.+-- </pre>+scanl :: (a -> b -> a) -> a -> [b] -> [a]++-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value+-- argument:+-- +-- <pre>+-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]+-- </pre>+scanl1 :: (a -> a -> a) -> [a] -> [a]++-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that+-- +-- <pre>+-- head (scanr f z xs) == foldr f z xs.+-- </pre>+scanr :: (a -> b -> b) -> b -> [a] -> [b]++-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value+-- argument.+scanr1 :: (a -> a -> a) -> [a] -> [a]++-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated+-- applications of <tt>f</tt> to <tt>x</tt>:+-- +-- <pre>+-- iterate f x == [x, f x, f (f x), ...]+-- </pre>+iterate :: (a -> a) -> a -> [a]++-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the+-- value of every element.+repeat :: a -> [a]++-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with+-- <tt>x</tt> the value of every element. It is an instance of the more+-- general <tt>Data.List.genericReplicate</tt>, in which <tt>n</tt> may+-- be of any integral type.+replicate :: Int -> a -> [a]++-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,+-- the infinite repetition of the original list. It is the identity on+-- infinite lists.+cycle :: [a] -> [a]++-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the+-- prefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if+-- <tt>n > <a>length</a> xs</tt>:+-- +-- <pre>+-- take 5 "Hello World!" == "Hello"+-- take 3 [1,2,3,4,5] == [1,2,3]+-- take 3 [1,2] == [1,2]+-- take 3 [] == []+-- take (-1) [1,2] == []+-- take 0 [1,2] == []+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericTake</tt>,+-- in which <tt>n</tt> may be of any integral type.+take :: Int -> [a] -> [a]++-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the+-- first <tt>n</tt> elements, or <tt>[]</tt> if <tt>n > <a>length</a>+-- xs</tt>:+-- +-- <pre>+-- drop 6 "Hello World!" == "World!"+-- drop 3 [1,2,3,4,5] == [4,5]+-- drop 3 [1,2] == []+-- drop 3 [] == []+-- drop (-1) [1,2] == [1,2]+-- drop 0 [1,2] == [1,2]+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericDrop</tt>,+-- in which <tt>n</tt> may be of any integral type.+drop :: Int -> [a] -> [a]++-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is+-- <tt>xs</tt> prefix of length <tt>n</tt> and second element is the+-- remainder of the list:+-- +-- <pre>+-- splitAt 6 "Hello World!" == ("Hello ","World!")+-- splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])+-- splitAt 1 [1,2,3] == ([1],[2,3])+-- splitAt 3 [1,2,3] == ([1,2,3],[])+-- splitAt 4 [1,2,3] == ([1,2,3],[])+-- splitAt 0 [1,2,3] == ([],[1,2,3])+-- splitAt (-1) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- It is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt>.+-- <a>splitAt</a> is an instance of the more general+-- <tt>Data.List.genericSplitAt</tt>, in which <tt>n</tt> may be of any+-- integral type.+splitAt :: Int -> [a] -> ([a], [a])++-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns the longest prefix (possibly empty) of+-- <tt>xs</tt> of elements that satisfy <tt>p</tt>:+-- +-- <pre>+-- takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]+-- takeWhile (< 9) [1,2,3] == [1,2,3]+-- takeWhile (< 0) [1,2,3] == []+-- </pre>+takeWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after+-- <a>takeWhile</a> <tt>p xs</tt>:+-- +-- <pre>+-- dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]+-- dropWhile (< 9) [1,2,3] == []+-- dropWhile (< 0) [1,2,3] == [1,2,3]+-- </pre>+dropWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,+-- returns a tuple where first element is longest prefix (possibly empty)+-- of <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element+-- is the remainder of the list:+-- +-- <pre>+-- span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])+-- span (< 9) [1,2,3] == ([1,2,3],[])+-- span (< 0) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- <a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,+-- <a>dropWhile</a> p xs)</tt>+span :: (a -> Bool) -> [a] -> ([a], [a])++-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns a tuple where first element is longest prefix+-- (possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>+-- <tt>p</tt> and second element is the remainder of the list:+-- +-- <pre>+-- break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])+-- break (< 9) [1,2,3] == ([],[1,2,3])+-- break (> 9) [1,2,3] == ([1,2,3],[])+-- </pre>+-- +-- <a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .+-- p)</tt>.+break :: (a -> Bool) -> [a] -> ([a], [a])++-- | <a>elem</a> is the list membership predicate, usually written in infix+-- form, e.g., <tt>x `elem` xs</tt>. For the result to be <a>False</a>,+-- the list must be finite; <a>True</a>, however, results from an element+-- equal to <tt>x</tt> found at a finite index of a finite or infinite+-- list.+elem :: Eq a => a -> [a] -> Bool++-- | <a>notElem</a> is the negation of <a>elem</a>.+notElem :: Eq a => a -> [a] -> Bool++-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association+-- list.+lookup :: Eq a => a -> [(a, b)] -> Maybe b++-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.+-- If one input list is short, excess elements of the longer list are+-- discarded.+zip :: [a] -> [b] -> [(a, b)]++-- | <a>zip3</a> takes three lists and returns a list of triples, analogous+-- to <a>zip</a>.+zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]++-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function+-- given as the first argument, instead of a tupling function. For+-- example, <tt><a>zipWith</a> (+)</tt> is applied to two lists to+-- produce the list of corresponding sums.+zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]++-- | The <a>zipWith3</a> function takes a function which combines three+-- elements, as well as three lists and returns a list of their+-- point-wise combination, analogous to <a>zipWith</a>.+zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]++-- | <a>unzip</a> transforms a list of pairs into a list of first+-- components and a list of second components.+unzip :: [(a, b)] -> ([a], [b])++-- | The <a>unzip3</a> function takes a list of triples and returns three+-- lists, analogous to <a>unzip</a>.+unzip3 :: [(a, b, c)] -> ([a], [b], [c])++-- | <a>lines</a> breaks a string up into a list of strings at newline+-- characters. The resulting strings do not contain newlines.+lines :: String -> [String]++-- | <a>words</a> breaks a string up into a list of words, which were+-- delimited by white space.+words :: String -> [String]++-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins+-- lines, after appending a terminating newline to each.+unlines :: [String] -> String++-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words+-- with separating spaces.+unwords :: [String] -> String++-- | The <tt>shows</tt> functions return a function that prepends the+-- output <a>String</a> to an existing <a>String</a>. This allows+-- constant-time concatenation of results using function composition.+type ShowS = String -> String++-- | Conversion of values to readable <a>String</a>s.+-- +-- Minimal complete definition: <a>showsPrec</a> or <a>show</a>.+-- +-- Derived instances of <a>Show</a> have the following properties, which+-- are compatible with derived instances of <tt>Text.Read.Read</tt>:+-- +-- <ul>+-- <li>The result of <a>show</a> is a syntactically correct Haskell+-- expression containing only constants, given the fixity declarations in+-- force at the point where the type is declared. It contains only the+-- constructor names defined in the data type, parentheses, and spaces.+-- When labelled constructor fields are used, braces, commas, field+-- names, and equal signs are also used.</li>+-- <li>If the constructor is defined to be an infix operator, then+-- <a>showsPrec</a> will produce infix applications of the+-- constructor.</li>+-- <li>the representation will be enclosed in parentheses if the+-- precedence of the top-level constructor in <tt>x</tt> is less than+-- <tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is+-- <tt>0</tt> then the result is never surrounded in parentheses; if+-- <tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,+-- unless it is an atomic expression.</li>+-- <li>If the constructor is defined using record syntax, then+-- <a>show</a> will produce the record-syntax form, with the fields given+-- in the same order as the original declaration.</li>+-- </ul>+-- +-- For example, given the declarations+-- +-- <pre>+-- infixr 5 :^:+-- data Tree a = Leaf a | Tree a :^: Tree a+-- </pre>+-- +-- the derived instance of <a>Show</a> is equivalent to+-- +-- <pre>+-- instance (Show a) => Show (Tree a) where+-- +-- showsPrec d (Leaf m) = showParen (d > app_prec) $+-- showString "Leaf " . showsPrec (app_prec+1) m+-- where app_prec = 10+-- +-- showsPrec d (u :^: v) = showParen (d > up_prec) $+-- showsPrec (up_prec+1) u . +-- showString " :^: " .+-- showsPrec (up_prec+1) v+-- where up_prec = 5+-- </pre>+-- +-- Note that right-associativity of <tt>:^:</tt> is ignored. For example,+-- +-- <ul>+-- <li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the+-- string <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>+-- </ul>+class Show a+showsPrec :: Show a => Int -> a -> ShowS+show :: Show a => a -> String+showList :: Show a => [a] -> ShowS++-- | equivalent to <a>showsPrec</a> with a precedence of 0.+shows :: Show a => a -> ShowS++-- | utility function converting a <a>Char</a> to a show function that+-- simply prepends the character unchanged.+showChar :: Char -> ShowS++-- | utility function converting a <a>String</a> to a show function that+-- simply prepends the string unchanged.+showString :: String -> ShowS++-- | utility function that surrounds the inner show function with+-- parentheses when the <a>Bool</a> parameter is <a>True</a>.+showParen :: Bool -> ShowS -> ShowS++-- | A parser for a type <tt>a</tt>, represented as a function that takes a+-- <a>String</a> and returns a list of possible parses as+-- <tt>(a,<a>String</a>)</tt> pairs.+-- +-- Note that this kind of backtracking parser is very inefficient;+-- reading a large structure may be quite slow (cf <a>ReadP</a>).+type ReadS a = String -> [(a, String)]++-- | Parsing of <a>String</a>s, producing values.+-- +-- Minimal complete definition: <a>readsPrec</a> (or, for GHC only,+-- <a>readPrec</a>)+-- +-- Derived instances of <a>Read</a> make the following assumptions, which+-- derived instances of <tt>Text.Show.Show</tt> obey:+-- +-- <ul>+-- <li>If the constructor is defined to be an infix operator, then the+-- derived <a>Read</a> instance will parse only infix applications of the+-- constructor (not the prefix form).</li>+-- <li>Associativity is not used to reduce the occurrence of parentheses,+-- although precedence may be.</li>+-- <li>If the constructor is defined using record syntax, the derived+-- <a>Read</a> will parse only the record-syntax form, and furthermore,+-- the fields must be given in the same order as the original+-- declaration.</li>+-- <li>The derived <a>Read</a> instance allows arbitrary Haskell+-- whitespace between tokens of the input string. Extra parentheses are+-- also allowed.</li>+-- </ul>+-- +-- For example, given the declarations+-- +-- <pre>+-- infixr 5 :^:+-- data Tree a = Leaf a | Tree a :^: Tree a+-- </pre>+-- +-- the derived instance of <a>Read</a> in Haskell 98 is equivalent to+-- +-- <pre>+-- instance (Read a) => Read (Tree a) where+-- +-- readsPrec d r = readParen (d > app_prec)+-- (\r -> [(Leaf m,t) |+-- ("Leaf",s) <- lex r,+-- (m,t) <- readsPrec (app_prec+1) s]) r+-- +-- ++ readParen (d > up_prec)+-- (\r -> [(u:^:v,w) |+-- (u,s) <- readsPrec (up_prec+1) r,+-- (":^:",t) <- lex s,+-- (v,w) <- readsPrec (up_prec+1) t]) r+-- +-- where app_prec = 10+-- up_prec = 5+-- </pre>+-- +-- Note that right-associativity of <tt>:^:</tt> is unused.+-- +-- The derived instance in GHC is equivalent to+-- +-- <pre>+-- instance (Read a) => Read (Tree a) where+-- +-- readPrec = parens $ (prec app_prec $ do+-- Ident "Leaf" <- lexP+-- m <- step readPrec+-- return (Leaf m))+-- +-- +++ (prec up_prec $ do+-- u <- step readPrec+-- Symbol ":^:" <- lexP+-- v <- step readPrec+-- return (u :^: v))+-- +-- where app_prec = 10+-- up_prec = 5+-- +-- readListPrec = readListPrecDefault+-- </pre>+class Read a+readsPrec :: Read a => Int -> ReadS a+readList :: Read a => ReadS [a]++-- | equivalent to <a>readsPrec</a> with a precedence of 0.+reads :: Read a => ReadS a++-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,+-- but surrounded with parentheses.+-- +-- <tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>+-- parses, but optionally surrounded with parentheses.+readParen :: Bool -> ReadS a -> ReadS a++-- | The <a>read</a> function reads input from a string, which must be+-- completely consumed by the input process.+read :: Read a => String -> a++-- | The <a>lex</a> function reads a single lexeme from the input,+-- discarding initial white space, and returning the characters that+-- constitute the lexeme. If the input string contains only white space,+-- <a>lex</a> returns a single successful `lexeme' consisting of the+-- empty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is+-- no legal lexeme at the beginning of the input string, <a>lex</a> fails+-- (i.e. returns <tt>[]</tt>).+-- +-- This lexer is not completely faithful to the Haskell lexical syntax in+-- the following respects:+-- +-- <ul>+-- <li>Qualified names are not handled properly</li>+-- <li>Octal and hexadecimal numerics are not recognized as a single+-- token</li>+-- <li>Comments are not treated properly</li>+-- </ul>+lex :: ReadS String++-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when+-- performed, does some I/O before returning a value of type <tt>a</tt>.+-- +-- There is really only one way to "perform" an I/O action: bind it to+-- <tt>Main.main</tt> in your program. When your program is run, the I/O+-- will be performed. It isn't possible to perform I/O from an arbitrary+-- function, unless that function is itself in the <a>IO</a> monad and+-- called at some point, directly or indirectly, from <tt>Main.main</tt>.+-- +-- <a>IO</a> is a monad, so <a>IO</a> actions can be combined using+-- either the do-notation or the <tt>>></tt> and <tt>>>=</tt>+-- operations from the <tt>Monad</tt> class.+data IO a :: * -> *++-- | Write a character to the standard output device (same as+-- <a>hPutChar</a> <a>stdout</a>).+putChar :: Char -> IO ()++-- | Write a string to the standard output device (same as <a>hPutStr</a>+-- <a>stdout</a>).+putStr :: String -> IO ()++-- | The same as <a>putStr</a>, but adds a newline character.+putStrLn :: String -> IO ()++-- | The <a>print</a> function outputs a value of any printable type to the+-- standard output device. Printable types are those that are instances+-- of class <a>Show</a>; <a>print</a> converts values to strings for+-- output using the <a>show</a> operation and adds a newline.+-- +-- For example, a program to print the first 20 integers and their powers+-- of 2 could be written as:+-- +-- <pre>+-- main = print ([(n, 2^n) | n <- [0..19]])+-- </pre>+print :: Show a => a -> IO ()++-- | Read a character from the standard input device (same as+-- <a>hGetChar</a> <a>stdin</a>).+getChar :: IO Char++-- | Read a line from the standard input device (same as <a>hGetLine</a>+-- <a>stdin</a>).+getLine :: IO String++-- | The <a>getContents</a> operation returns all user input as a single+-- string, which is read lazily as it is needed (same as+-- <a>hGetContents</a> <a>stdin</a>).+getContents :: IO String++-- | The <a>interact</a> function takes a function of type+-- <tt>String->String</tt> as its argument. The entire input from the+-- standard input device is passed to this function as its argument, and+-- the resulting string is output on the standard output device.+interact :: (String -> String) -> IO ()++-- | File and directory names are values of type <a>String</a>, whose+-- precise meaning is operating system dependent. Files can be opened,+-- yielding a handle which can then be used to operate on the contents of+-- that file.+type FilePath = String++-- | The <a>readFile</a> function reads a file and returns the contents of+-- the file as a string. The file is read lazily, on demand, as with+-- <a>getContents</a>.+readFile :: FilePath -> IO String++-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the+-- string <tt>str</tt>, to the file <tt>file</tt>.+writeFile :: FilePath -> String -> IO ()++-- | The computation <a>appendFile</a> <tt>file str</tt> function appends+-- the string <tt>str</tt>, to the file <tt>file</tt>.+-- +-- Note that <a>writeFile</a> and <a>appendFile</a> write a literal+-- string to a file. To write a value of any printable type, as with+-- <a>print</a>, use the <a>show</a> function to convert the value to a+-- string first.+-- +-- <pre>+-- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])+-- </pre>+appendFile :: FilePath -> String -> IO ()++-- | The <a>readIO</a> function is similar to <a>read</a> except that it+-- signals parse failure to the <a>IO</a> monad instead of terminating+-- the program.+readIO :: Read a => String -> IO a++-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.+readLn :: Read a => IO a++-- | The Haskell 98 type for exceptions in the <a>IO</a> monad. Any I/O+-- operation may raise an <a>IOError</a> instead of returning a result.+-- For a more general type of exception, including also those that arise+-- in pure code, see <a>Control.Exception.Exception</a>.+-- +-- In Haskell 98, this is an opaque type.+type IOError = IOException++-- | Raise an <a>IOError</a> in the <a>IO</a> monad.+ioError :: IOError -> IO a++-- | Construct an <a>IOError</a> value with a string describing the error.+-- The <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>+-- class raises a <a>userError</a>, thus:+-- +-- <pre>+-- instance Monad IO where +-- ...+-- fail s = ioError (userError s)+-- </pre>+userError :: String -> IOError++-- | The <a>catch</a> function establishes a handler that receives any+-- <a>IOError</a> raised in the action protected by <a>catch</a>. An+-- <a>IOError</a> is caught by the most recent handler established by+-- <a>catch</a>. These handlers are not selective: all <a>IOError</a>s+-- are caught. Exception propagation must be explicitly provided in a+-- handler by re-raising any unwanted exceptions. For example, in+-- +-- <pre>+-- f = catch g (\e -> if IO.isEOFError e then return [] else ioError e)+-- </pre>+-- +-- the function <tt>f</tt> returns <tt>[]</tt> when an end-of-file+-- exception (cf. <a>isEOFError</a>) occurs in <tt>g</tt>; otherwise, the+-- exception is propagated to the next outer handler.+-- +-- When an exception propagates outside the main program, the Haskell+-- system prints the associated <a>IOError</a> value and exits the+-- program.+-- +-- Non-I/O exceptions are not caught by this variant; to catch all+-- exceptions, use <tt>Control.Exception.catch</tt> from+-- <a>Control.Exception</a>.+catch :: IO a -> (IOError -> IO a) -> IO a++module Foreign.StablePtr++-- | A <i>stable pointer</i> is a reference to a Haskell expression that is+-- guaranteed not to be affected by garbage collection, i.e., it will+-- neither be deallocated nor will the value of the stable pointer itself+-- change during garbage collection (ordinary references may be relocated+-- during garbage collection). Consequently, stable pointers can be+-- passed to foreign code, which can treat it as an opaque reference to a+-- Haskell value.+-- +-- A value of type <tt>StablePtr a</tt> is a stable pointer to a Haskell+-- expression of type <tt>a</tt>.+data StablePtr a :: * -> *++-- | Create a stable pointer referring to the given Haskell value.+newStablePtr :: a -> IO (StablePtr a)++-- | Obtain the Haskell value referenced by a stable pointer, i.e., the+-- same value that was passed to the corresponding call to+-- <tt>makeStablePtr</tt>. If the argument to <a>deRefStablePtr</a> has+-- already been freed using <a>freeStablePtr</a>, the behaviour of+-- <a>deRefStablePtr</a> is undefined.+deRefStablePtr :: StablePtr a -> IO a++-- | Dissolve the association between the stable pointer and the Haskell+-- value. Afterwards, if the stable pointer is passed to+-- <a>deRefStablePtr</a> or <a>freeStablePtr</a>, the behaviour is+-- undefined. However, the stable pointer may still be passed to+-- <a>castStablePtrToPtr</a>, but the <tt><tt>Foreign.Ptr.Ptr</tt>+-- ()</tt> value returned by <a>castStablePtrToPtr</a>, in this case, is+-- undefined (in particular, it may be <tt>Foreign.Ptr.nullPtr</tt>).+-- Nevertheless, the call to <a>castStablePtrToPtr</a> is guaranteed not+-- to diverge.+freeStablePtr :: StablePtr a -> IO ()++-- | Coerce a stable pointer to an address. No guarantees are made about+-- the resulting value, except that the original stable pointer can be+-- recovered by <a>castPtrToStablePtr</a>. In particular, the address may+-- not refer to an accessible memory location and any attempt to pass it+-- to the member functions of the class+-- <tt>Foreign.Storable.Storable</tt> leads to undefined behaviour.+castStablePtrToPtr :: StablePtr a -> Ptr ()++-- | The inverse of <a>castStablePtrToPtr</a>, i.e., we have the identity+-- +-- <pre>+-- sp == castPtrToStablePtr (castStablePtrToPtr sp)+-- </pre>+-- +-- for any stable pointer <tt>sp</tt> on which <a>freeStablePtr</a> has+-- not been executed yet. Moreover, <a>castPtrToStablePtr</a> may only be+-- applied to pointers that have been produced by+-- <a>castStablePtrToPtr</a>.+castPtrToStablePtr :: Ptr () -> StablePtr a++module Data.Ix++-- | The <a>Ix</a> class is used to map a contiguous subrange of values in+-- a type onto integers. It is used primarily for array indexing (see the+-- array package).+-- +-- The first argument <tt>(l,u)</tt> of each of these operations is a+-- pair specifying the lower and upper bounds of a contiguous subrange of+-- values.+-- +-- An implementation is entitled to assume the following laws about these+-- operations:+-- +-- <ul>+-- <li><tt><a>inRange</a> (l,u) i == <a>elem</a> i (<a>range</a>+-- (l,u))</tt> <tt> </tt></li>+-- <li><tt><a>range</a> (l,u) <a>!!</a> <a>index</a> (l,u) i == i</tt>,+-- when <tt><a>inRange</a> (l,u) i</tt></li>+-- <li><tt><a>map</a> (<a>index</a> (l,u)) (<a>range</a> (l,u))) ==+-- [0..<a>rangeSize</a> (l,u)-1]</tt> <tt> </tt></li>+-- <li><tt><a>rangeSize</a> (l,u) == <a>length</a> (<a>range</a>+-- (l,u))</tt> <tt> </tt></li>+-- </ul>+-- +-- Minimal complete instance: <a>range</a>, <a>index</a> and+-- <a>inRange</a>.+class Ord a => Ix a+range :: Ix a => (a, a) -> [a]+index :: Ix a => (a, a) -> a -> Int+inRange :: Ix a => (a, a) -> a -> Bool+rangeSize :: Ix a => (a, a) -> Int++module Data.Char++-- | The character type <a>Char</a> is an enumeration whose values+-- represent Unicode (or equivalently ISO/IEC 10646) characters (see+-- <a>http://www.unicode.org/</a> for details). This set extends the ISO+-- 8859-1 (Latin-1) character set (the first 256 charachers), which is+-- itself an extension of the ASCII character set (the first 128+-- characters). A character literal in Haskell has type <a>Char</a>.+-- +-- To convert a <a>Char</a> to or from the corresponding <a>Int</a> value+-- defined by Unicode, use <tt>Prelude.toEnum</tt> and+-- <tt>Prelude.fromEnum</tt> from the <tt>Prelude.Enum</tt> class+-- respectively (or equivalently <tt>ord</tt> and <tt>chr</tt>).+data Char :: *++-- | A <a>String</a> is a list of characters. String constants in Haskell+-- are values of type <a>String</a>.+type String = [Char]++-- | Selects control characters, which are the non-printing characters of+-- the Latin-1 subset of Unicode.+isControl :: Char -> Bool++-- | Returns <a>True</a> for any Unicode space character, and the control+-- characters <tt>\t</tt>, <tt>\n</tt>, <tt>\r</tt>, <tt>\f</tt>,+-- <tt>\v</tt>.+isSpace :: Char -> Bool++-- | Selects lower-case alphabetic Unicode characters (letters).+isLower :: Char -> Bool++-- | Selects upper-case or title-case alphabetic Unicode characters+-- (letters). Title case is used by a small number of letter ligatures+-- like the single-character form of <i>Lj</i>.+isUpper :: Char -> Bool++-- | Selects alphabetic Unicode characters (lower-case, upper-case and+-- title-case letters, plus letters of caseless scripts and modifiers+-- letters). This function is equivalent to <tt>Data.Char.isLetter</tt>.+isAlpha :: Char -> Bool++-- | Selects alphabetic or numeric digit Unicode characters.+-- +-- Note that numeric digits outside the ASCII range are selected by this+-- function but not by <a>isDigit</a>. Such digits may be part of+-- identifiers but are not used by the printer and reader to represent+-- numbers.+isAlphaNum :: Char -> Bool++-- | Selects printable Unicode characters (letters, numbers, marks,+-- punctuation, symbols and spaces).+isPrint :: Char -> Bool++-- | Selects ASCII digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>.+isDigit :: Char -> Bool++-- | Selects ASCII octal digits, i.e. <tt>'0'</tt>..<tt>'7'</tt>.+isOctDigit :: Char -> Bool++-- | Selects ASCII hexadecimal digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>,+-- <tt>'a'</tt>..<tt>'f'</tt>, <tt>'A'</tt>..<tt>'F'</tt>.+isHexDigit :: Char -> Bool++-- | Selects alphabetic Unicode characters (lower-case, upper-case and+-- title-case letters, plus letters of caseless scripts and modifiers+-- letters). This function is equivalent to <tt>Data.Char.isAlpha</tt>.+isLetter :: Char -> Bool++-- | Selects Unicode mark characters, e.g. accents and the like, which+-- combine with preceding letters.+isMark :: Char -> Bool++-- | Selects Unicode numeric characters, including digits from various+-- scripts, Roman numerals, etc.+isNumber :: Char -> Bool++-- | Selects Unicode punctuation characters, including various kinds of+-- connectors, brackets and quotes.+isPunctuation :: Char -> Bool++-- | Selects Unicode symbol characters, including mathematical and currency+-- symbols.+isSymbol :: Char -> Bool++-- | Selects Unicode space and separator characters.+isSeparator :: Char -> Bool++-- | Selects the first 128 characters of the Unicode character set,+-- corresponding to the ASCII character set.+isAscii :: Char -> Bool++-- | Selects the first 256 characters of the Unicode character set,+-- corresponding to the ISO 8859-1 (Latin-1) character set.+isLatin1 :: Char -> Bool++-- | Selects ASCII upper-case letters, i.e. characters satisfying both+-- <a>isAscii</a> and <a>isUpper</a>.+isAsciiUpper :: Char -> Bool++-- | Selects ASCII lower-case letters, i.e. characters satisfying both+-- <a>isAscii</a> and <a>isLower</a>.+isAsciiLower :: Char -> Bool++-- | Unicode General Categories (column 2 of the UnicodeData table) in the+-- order they are listed in the Unicode standard.+data GeneralCategory :: *++-- | Lu: Letter, Uppercase+UppercaseLetter :: GeneralCategory++-- | Ll: Letter, Lowercase+LowercaseLetter :: GeneralCategory++-- | Lt: Letter, Titlecase+TitlecaseLetter :: GeneralCategory++-- | Lm: Letter, Modifier+ModifierLetter :: GeneralCategory++-- | Lo: Letter, Other+OtherLetter :: GeneralCategory++-- | Mn: Mark, Non-Spacing+NonSpacingMark :: GeneralCategory++-- | Mc: Mark, Spacing Combining+SpacingCombiningMark :: GeneralCategory++-- | Me: Mark, Enclosing+EnclosingMark :: GeneralCategory++-- | Nd: Number, Decimal+DecimalNumber :: GeneralCategory++-- | Nl: Number, Letter+LetterNumber :: GeneralCategory++-- | No: Number, Other+OtherNumber :: GeneralCategory++-- | Pc: Punctuation, Connector+ConnectorPunctuation :: GeneralCategory++-- | Pd: Punctuation, Dash+DashPunctuation :: GeneralCategory++-- | Ps: Punctuation, Open+OpenPunctuation :: GeneralCategory++-- | Pe: Punctuation, Close+ClosePunctuation :: GeneralCategory++-- | Pi: Punctuation, Initial quote+InitialQuote :: GeneralCategory++-- | Pf: Punctuation, Final quote+FinalQuote :: GeneralCategory++-- | Po: Punctuation, Other+OtherPunctuation :: GeneralCategory++-- | Sm: Symbol, Math+MathSymbol :: GeneralCategory++-- | Sc: Symbol, Currency+CurrencySymbol :: GeneralCategory++-- | Sk: Symbol, Modifier+ModifierSymbol :: GeneralCategory++-- | So: Symbol, Other+OtherSymbol :: GeneralCategory++-- | Zs: Separator, Space+Space :: GeneralCategory++-- | Zl: Separator, Line+LineSeparator :: GeneralCategory++-- | Zp: Separator, Paragraph+ParagraphSeparator :: GeneralCategory++-- | Cc: Other, Control+Control :: GeneralCategory++-- | Cf: Other, Format+Format :: GeneralCategory++-- | Cs: Other, Surrogate+Surrogate :: GeneralCategory++-- | Co: Other, Private Use+PrivateUse :: GeneralCategory++-- | Cn: Other, Not Assigned+NotAssigned :: GeneralCategory++-- | The Unicode general category of the character.+generalCategory :: Char -> GeneralCategory++-- | Convert a letter to the corresponding upper-case letter, if any. Any+-- other character is returned unchanged.+toUpper :: Char -> Char++-- | Convert a letter to the corresponding lower-case letter, if any. Any+-- other character is returned unchanged.+toLower :: Char -> Char++-- | Convert a letter to the corresponding title-case or upper-case letter,+-- if any. (Title case differs from upper case only for a small number of+-- ligature letters.) Any other character is returned unchanged.+toTitle :: Char -> Char++-- | Convert a single digit <a>Char</a> to the corresponding <a>Int</a>.+-- This function fails unless its argument satisfies <a>isHexDigit</a>,+-- but recognises both upper and lower-case hexadecimal digits (i.e.+-- <tt>'0'</tt>..<tt>'9'</tt>, <tt>'a'</tt>..<tt>'f'</tt>,+-- <tt>'A'</tt>..<tt>'F'</tt>).+digitToInt :: Char -> Int++-- | Convert an <a>Int</a> in the range <tt>0</tt>..<tt>15</tt> to the+-- corresponding single digit <a>Char</a>. This function fails on other+-- inputs, and generates lower-case hexadecimal digits.+intToDigit :: Int -> Char++-- | The <tt>Prelude.fromEnum</tt> method restricted to the type+-- <tt>Data.Char.Char</tt>.+ord :: Char -> Int++-- | The <tt>Prelude.toEnum</tt> method restricted to the type+-- <tt>Data.Char.Char</tt>.+chr :: Int -> Char++-- | Convert a character to a string using only printable characters, using+-- Haskell source-language escape conventions. For example:+-- +-- <pre>+-- showLitChar '\n' s = "\\n" ++ s+-- </pre>+showLitChar :: Char -> ShowS++-- | Read a string representation of a character, using Haskell+-- source-language escape conventions. For example:+-- +-- <pre>+-- lexLitChar "\\nHello" = [("\\n", "Hello")]+-- </pre>+lexLitChar :: ReadS String++-- | Read a string representation of a character, using Haskell+-- source-language escape conventions, and convert it to the character+-- that it encodes. For example:+-- +-- <pre>+-- readLitChar "\\nHello" = [('\n', "Hello")]+-- </pre>+readLitChar :: ReadS Char++module Data.Int++-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..+-- 2^29-1]</tt>. The exact range for a given implementation can be+-- determined by using <tt>Prelude.minBound</tt> and+-- <tt>Prelude.maxBound</tt> from the <tt>Prelude.Bounded</tt> class.+data Int :: *++-- | 8-bit signed integer type+data Int8 :: *++-- | 16-bit signed integer type+data Int16 :: *++-- | 32-bit signed integer type+data Int32 :: *++-- | 64-bit signed integer type+data Int64 :: *++module Data.Ratio++-- | Rational numbers, with numerator and denominator of some+-- <a>Integral</a> type.+data Integral a => Ratio a :: * -> *++-- | Arbitrary-precision rational numbers, represented as a ratio of two+-- <a>Integer</a> values. A rational number may be constructed using the+-- <a>%</a> operator.+type Rational = Ratio Integer++-- | Forms the ratio of two integral numbers.+(%) :: Integral a => a -> a -> Ratio a++-- | Extract the numerator of the ratio in reduced form: the numerator and+-- denominator have no common factor and the denominator is positive.+numerator :: Integral a => Ratio a -> a++-- | Extract the denominator of the ratio in reduced form: the numerator+-- and denominator have no common factor and the denominator is positive.+denominator :: Integral a => Ratio a -> a++-- | <a>approxRational</a>, applied to two real fractional numbers+-- <tt>x</tt> and <tt>epsilon</tt>, returns the simplest rational number+-- within <tt>epsilon</tt> of <tt>x</tt>. A rational number <tt>y</tt> is+-- said to be <i>simpler</i> than another <tt>y'</tt> if+-- +-- <ul>+-- <li><tt><a>abs</a> (<a>numerator</a> y) <= <a>abs</a>+-- (<a>numerator</a> y')</tt>, and</li>+-- <li><tt><a>denominator</a> y <= <a>denominator</a> y'</tt>.</li>+-- </ul>+-- +-- Any real interval contains a unique simplest rational; in particular,+-- note that <tt>0/1</tt> is the simplest rational of all.+approxRational :: RealFrac a => a -> a -> Rational++module Data.Word++-- | A <a>Word</a> is an unsigned integral type, with the same size as+-- <a>Int</a>.+data Word :: *++-- | 8-bit unsigned integer type+data Word8 :: *++-- | 16-bit unsigned integer type+data Word16 :: *++-- | 32-bit unsigned integer type+data Word32 :: *++-- | 64-bit unsigned integer type+data Word64 :: *+++-- | The module <a>Foreign.Ptr</a> provides typed pointers to foreign+-- entities. We distinguish two kinds of pointers: pointers to data and+-- pointers to functions. It is understood that these two kinds of+-- pointers may be represented differently as they may be references to+-- data and text segments, respectively.+module Foreign.Ptr++-- | A value of type <tt><a>Ptr</a> a</tt> represents a pointer to an+-- object, or an array of objects, which may be marshalled to or from+-- Haskell values of type <tt>a</tt>.+-- +-- The type <tt>a</tt> will often be an instance of class+-- <tt>Foreign.Storable.Storable</tt> which provides the marshalling+-- operations. However this is not essential, and you can provide your+-- own operations to access the pointer. For example you might write+-- small foreign functions to get or set the fields of a C+-- <tt>struct</tt>.+data Ptr a :: * -> *++-- | The constant <a>nullPtr</a> contains a distinguished value of+-- <a>Ptr</a> that is not associated with a valid memory location.+nullPtr :: Ptr a++-- | The <a>castPtr</a> function casts a pointer from one type to another.+castPtr :: Ptr a -> Ptr b++-- | Advances the given address by the given offset in bytes.+plusPtr :: Ptr a -> Int -> Ptr b++-- | Given an arbitrary address and an alignment constraint,+-- <a>alignPtr</a> yields the next higher address that fulfills the+-- alignment constraint. An alignment constraint <tt>x</tt> is fulfilled+-- by any address divisible by <tt>x</tt>. This operation is idempotent.+alignPtr :: Ptr a -> Int -> Ptr a++-- | Computes the offset required to get from the second to the first+-- argument. We have+-- +-- <pre>+-- p2 == p1 `plusPtr` (p2 `minusPtr` p1)+-- </pre>+minusPtr :: Ptr a -> Ptr b -> Int++-- | A value of type <tt><a>FunPtr</a> a</tt> is a pointer to a function+-- callable from foreign code. The type <tt>a</tt> will normally be a+-- <i>foreign type</i>, a function type with zero or more arguments where+-- +-- <ul>+-- <li>the argument types are <i>marshallable foreign types</i>, i.e.+-- <a>Char</a>, <a>Int</a>, <a>Double</a>, <a>Float</a>, <a>Bool</a>,+-- <tt>Data.Int.Int8</tt>, <tt>Data.Int.Int16</tt>,+-- <tt>Data.Int.Int32</tt>, <tt>Data.Int.Int64</tt>,+-- <tt>Data.Word.Word8</tt>, <tt>Data.Word.Word16</tt>,+-- <tt>Data.Word.Word32</tt>, <tt>Data.Word.Word64</tt>, <tt><a>Ptr</a>+-- a</tt>, <tt><a>FunPtr</a> a</tt>,+-- <tt><tt>Foreign.StablePtr.StablePtr</tt> a</tt> or a renaming of any+-- of these using <tt>newtype</tt>.</li>+-- <li>the return type is either a marshallable foreign type or has the+-- form <tt><a>IO</a> t</tt> where <tt>t</tt> is a marshallable foreign+-- type or <tt>()</tt>.</li>+-- </ul>+-- +-- A value of type <tt><a>FunPtr</a> a</tt> may be a pointer to a foreign+-- function, either returned by another foreign function or imported with+-- a a static address import like+-- +-- <pre>+-- foreign import ccall "stdlib.h &free"+-- p_free :: FunPtr (Ptr a -> IO ())+-- </pre>+-- +-- or a pointer to a Haskell function created using a <i>wrapper</i> stub+-- declared to produce a <a>FunPtr</a> of the correct type. For example:+-- +-- <pre>+-- type Compare = Int -> Int -> Bool+-- foreign import ccall "wrapper"+-- mkCompare :: Compare -> IO (FunPtr Compare)+-- </pre>+-- +-- Calls to wrapper stubs like <tt>mkCompare</tt> allocate storage, which+-- should be released with <tt>Foreign.Ptr.freeHaskellFunPtr</tt> when no+-- longer required.+-- +-- To convert <a>FunPtr</a> values to corresponding Haskell functions,+-- one can define a <i>dynamic</i> stub for the specific foreign type,+-- e.g.+-- +-- <pre>+-- type IntFunction = CInt -> IO ()+-- foreign import ccall "dynamic" +-- mkFun :: FunPtr IntFunction -> IntFunction+-- </pre>+data FunPtr a :: * -> *++-- | The constant <a>nullFunPtr</a> contains a distinguished value of+-- <a>FunPtr</a> that is not associated with a valid memory location.+nullFunPtr :: FunPtr a++-- | Casts a <a>FunPtr</a> to a <a>FunPtr</a> of a different type.+castFunPtr :: FunPtr a -> FunPtr b++-- | Casts a <a>FunPtr</a> to a <a>Ptr</a>.+-- +-- <i>Note:</i> this is valid only on architectures where data and+-- function pointers range over the same set of addresses, and should+-- only be used for bindings to external libraries whose interface+-- already relies on this assumption.+castFunPtrToPtr :: FunPtr a -> Ptr b++-- | Casts a <a>Ptr</a> to a <a>FunPtr</a>.+-- +-- <i>Note:</i> this is valid only on architectures where data and+-- function pointers range over the same set of addresses, and should+-- only be used for bindings to external libraries whose interface+-- already relies on this assumption.+castPtrToFunPtr :: Ptr a -> FunPtr b++-- | Release the storage associated with the given <a>FunPtr</a>, which+-- must have been obtained from a wrapper stub. This should be called+-- whenever the return value from a foreign import wrapper function is no+-- longer required; otherwise, the storage it uses will leak.+freeHaskellFunPtr :: FunPtr a -> IO ()++-- | A signed integral type that can be losslessly converted to and from+-- <tt>Ptr</tt>. This type is also compatible with the C99 type+-- <tt>intptr_t</tt>, and can be marshalled to and from that type safely.+data IntPtr :: *++-- | casts a <tt>Ptr</tt> to an <tt>IntPtr</tt>+ptrToIntPtr :: Ptr a -> IntPtr++-- | casts an <tt>IntPtr</tt> to a <tt>Ptr</tt>+intPtrToPtr :: IntPtr -> Ptr a++-- | An unsigned integral type that can be losslessly converted to and from+-- <tt>Ptr</tt>. This type is also compatible with the C99 type+-- <tt>uintptr_t</tt>, and can be marshalled to and from that type+-- safely.+data WordPtr :: *++-- | casts a <tt>Ptr</tt> to a <tt>WordPtr</tt>+ptrToWordPtr :: Ptr a -> WordPtr++-- | casts a <tt>WordPtr</tt> to a <tt>Ptr</tt>+wordPtrToPtr :: WordPtr -> Ptr a++module Data.Maybe++-- | The <a>Maybe</a> type encapsulates an optional value. A value of type+-- <tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>+-- (represented as <tt><a>Just</a> a</tt>), or it is empty (represented+-- as <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with+-- errors or exceptional cases without resorting to drastic measures such+-- as <a>error</a>.+-- +-- The <a>Maybe</a> type is also a monad. It is a simple kind of error+-- monad, where all errors are represented by <a>Nothing</a>. A richer+-- error monad can be built using the <tt>Data.Either.Either</tt> type.+data Maybe a :: * -> *+Nothing :: Maybe a+Just :: a -> Maybe a++-- | The <a>maybe</a> function takes a default value, a function, and a+-- <a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the+-- function returns the default value. Otherwise, it applies the function+-- to the value inside the <a>Just</a> and returns the result.+maybe :: b -> (a -> b) -> Maybe a -> b++-- | The <a>isJust</a> function returns <a>True</a> iff its argument is of+-- the form <tt>Just _</tt>.+isJust :: Maybe a -> Bool++-- | The <a>isNothing</a> function returns <a>True</a> iff its argument is+-- <a>Nothing</a>.+isNothing :: Maybe a -> Bool++-- | The <a>fromJust</a> function extracts the element out of a <a>Just</a>+-- and throws an error if its argument is <a>Nothing</a>.+fromJust :: Maybe a -> a++-- | The <a>fromMaybe</a> function takes a default value and and+-- <a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns+-- the default values; otherwise, it returns the value contained in the+-- <a>Maybe</a>.+fromMaybe :: a -> Maybe a -> a++-- | The <a>listToMaybe</a> function returns <a>Nothing</a> on an empty+-- list or <tt><a>Just</a> a</tt> where <tt>a</tt> is the first element+-- of the list.+listToMaybe :: [a] -> Maybe a++-- | The <a>maybeToList</a> function returns an empty list when given+-- <a>Nothing</a> or a singleton list when not given <a>Nothing</a>.+maybeToList :: Maybe a -> [a]++-- | The <a>catMaybes</a> function takes a list of <a>Maybe</a>s and+-- returns a list of all the <a>Just</a> values.+catMaybes :: [Maybe a] -> [a]++-- | The <a>mapMaybe</a> function is a version of <a>map</a> which can+-- throw out elements. In particular, the functional argument returns+-- something of type <tt><a>Maybe</a> b</tt>. If this is <a>Nothing</a>,+-- no element is added on to the result list. If it just <tt><a>Just</a>+-- b</tt>, then <tt>b</tt> is included in the result list.+mapMaybe :: (a -> Maybe b) -> [a] -> [b]++module Numeric++-- | Converts a possibly-negative <a>Real</a> value to a string.+showSigned :: Real a => (a -> ShowS) -> Int -> a -> ShowS++-- | Shows a <i>non-negative</i> <a>Integral</a> number using the base+-- specified by the first argument, and the character representation+-- specified by the second.+showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS++-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 10.+showInt :: Integral a => a -> ShowS++-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 16.+showHex :: Integral a => a -> ShowS++-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 8.+showOct :: Integral a => a -> ShowS++-- | Show a signed <a>RealFloat</a> value using scientific (exponential)+-- notation (e.g. <tt>2.45e2</tt>, <tt>1.5e-3</tt>).+-- +-- In the call <tt><a>showEFloat</a> digs val</tt>, if <tt>digs</tt> is+-- <a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>+-- is <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the+-- decimal point are shown.+showEFloat :: RealFloat a => Maybe Int -> a -> ShowS++-- | Show a signed <a>RealFloat</a> value using standard decimal notation+-- (e.g. <tt>245000</tt>, <tt>0.0015</tt>).+-- +-- In the call <tt><a>showFFloat</a> digs val</tt>, if <tt>digs</tt> is+-- <a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>+-- is <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the+-- decimal point are shown.+showFFloat :: RealFloat a => Maybe Int -> a -> ShowS++-- | Show a signed <a>RealFloat</a> value using standard decimal notation+-- for arguments whose absolute value lies between <tt>0.1</tt> and+-- <tt>9,999,999</tt>, and scientific notation otherwise.+-- +-- In the call <tt><a>showGFloat</a> digs val</tt>, if <tt>digs</tt> is+-- <a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>+-- is <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the+-- decimal point are shown.+showGFloat :: RealFloat a => Maybe Int -> a -> ShowS++-- | Show a signed <a>RealFloat</a> value to full precision using standard+-- decimal notation for arguments whose absolute value lies between+-- <tt>0.1</tt> and <tt>9,999,999</tt>, and scientific notation+-- otherwise.+showFloat :: RealFloat a => a -> ShowS++-- | <a>floatToDigits</a> takes a base and a non-negative <a>RealFloat</a>+-- number, and returns a list of digits and an exponent. In particular,+-- if <tt>x>=0</tt>, and+-- +-- <pre>+-- floatToDigits base x = ([d1,d2,...,dn], e)+-- </pre>+-- +-- then+-- +-- <ol>+-- <li><pre>n >= 1</pre></li>+-- <li><pre>x = 0.d1d2...dn * (base**e)</pre></li>+-- <li><pre>0 <= di <= base-1</pre></li>+-- </ol>+floatToDigits :: RealFloat a => Integer -> a -> ([Int], Int)++-- | Reads a <i>signed</i> <a>Real</a> value, given a reader for an+-- unsigned value.+readSigned :: Real a => ReadS a -> ReadS a++-- | Reads an <i>unsigned</i> <a>Integral</a> value in an arbitrary base.+readInt :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a++-- | Read an unsigned number in decimal notation.+readDec :: Num a => ReadS a++-- | Read an unsigned number in octal notation.+readOct :: Num a => ReadS a++-- | Read an unsigned number in hexadecimal notation. Both upper or lower+-- case letters are allowed.+readHex :: Num a => ReadS a++-- | Reads an <i>unsigned</i> <a>RealFrac</a> value, expressed in decimal+-- scientific notation.+readFloat :: RealFrac a => ReadS a++-- | Reads a non-empty string of decimal digits.+lexDigits :: ReadS String++-- | Converts a <a>Rational</a> value into any type in class+-- <a>RealFloat</a>.+fromRat :: RealFloat a => Rational -> a++module System.IO.Error++-- | Errors of type <a>IOError</a> are used by the <a>IO</a> monad. This is+-- an abstract type; the module <a>System.IO.Error</a> provides functions+-- to interrogate and construct values of type <a>IOError</a>.+type IOError = IOError++-- | Construct an <a>IOError</a> value with a string describing the error.+-- The <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>+-- class raises a <a>userError</a>, thus:+-- +-- <pre>+-- instance Monad IO where +-- ...+-- fail s = ioError (userError s)+-- </pre>+userError :: String -> IOError++-- | Construct an <a>IOError</a> of the given type where the second+-- argument describes the error location and the third and fourth+-- argument contain the file handle and file path of the file involved in+-- the error if applicable.+mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError++-- | Adds a location description and maybe a file path and file handle to+-- an <a>IOError</a>. If any of the file handle or file path is not given+-- the corresponding value in the <a>IOError</a> remains unaltered.+annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOError++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments already exists.+isAlreadyExistsError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments does not exist.+isDoesNotExistError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments is a single-use resource, which is already being used+-- (for example, opening the same file twice for writing might give this+-- error).+isAlreadyInUseError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- device is full.+isFullError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the end+-- of file has been reached.+isEOFError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- operation was not possible. Any computation which returns an <a>IO</a>+-- result may fail with <a>isIllegalOperation</a>. In some cases, an+-- implementation will not be able to distinguish between the possible+-- error causes. In this case it should fail with+-- <a>isIllegalOperation</a>.+isIllegalOperation :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- user does not have sufficient operating system privilege to perform+-- that operation.+isPermissionError :: IOError -> Bool++-- | A programmer-defined error value constructed using <a>userError</a>.+isUserError :: IOError -> Bool+ioeGetErrorString :: IOError -> String+ioeGetHandle :: IOError -> Maybe Handle+ioeGetFileName :: IOError -> Maybe FilePath++-- | An abstract type that contains a value for each variant of+-- <a>IOError</a>.+data IOErrorType :: *++-- | I/O error where the operation failed because one of its arguments+-- already exists.+alreadyExistsErrorType :: IOErrorType++-- | I/O error where the operation failed because one of its arguments does+-- not exist.+doesNotExistErrorType :: IOErrorType++-- | I/O error where the operation failed because one of its arguments is a+-- single-use resource, which is already being used.+alreadyInUseErrorType :: IOErrorType++-- | I/O error where the operation failed because the device is full.+fullErrorType :: IOErrorType++-- | I/O error where the operation failed because the end of file has been+-- reached.+eofErrorType :: IOErrorType++-- | I/O error where the operation is not possible.+illegalOperationErrorType :: IOErrorType++-- | I/O error where the operation failed because the user does not have+-- sufficient operating system privilege to perform that operation.+permissionErrorType :: IOErrorType++-- | I/O error that is programmer-defined.+userErrorType :: IOErrorType++-- | Raise an <a>IOError</a> in the <a>IO</a> monad.+ioError :: IOError -> IO a++-- | The <a>catch</a> function establishes a handler that receives any+-- <a>IOError</a> raised in the action protected by <a>catch</a>. An+-- <a>IOError</a> is caught by the most recent handler established by+-- <a>catch</a>. These handlers are not selective: all <a>IOError</a>s+-- are caught. Exception propagation must be explicitly provided in a+-- handler by re-raising any unwanted exceptions. For example, in+-- +-- <pre>+-- f = catch g (\e -> if IO.isEOFError e then return [] else ioError e)+-- </pre>+-- +-- the function <tt>f</tt> returns <tt>[]</tt> when an end-of-file+-- exception (cf. <a>isEOFError</a>) occurs in <tt>g</tt>; otherwise, the+-- exception is propagated to the next outer handler.+-- +-- When an exception propagates outside the main program, the Haskell+-- system prints the associated <a>IOError</a> value and exits the+-- program.+catch :: IO a -> (IOError -> IO a) -> IO a++-- | The construct <a>try</a> <tt>comp</tt> exposes IO errors which occur+-- within a computation, and which are not fully handled.+try :: IO a -> IO (Either IOError a)+++-- | This module defines bitwise operations for signed and unsigned+-- integers.+module Data.Bits++-- | The <a>Bits</a> class defines bitwise operations over integral types.+-- +-- <ul>+-- <li>Bits are numbered from 0 with bit 0 being the least significant+-- bit.</li>+-- </ul>+-- +-- Minimal complete definition: <a>.&.</a>, <a>.|.</a>, <a>xor</a>,+-- <a>complement</a>, (<a>shift</a> or (<a>shiftL</a> and+-- <a>shiftR</a>)), (<a>rotate</a> or (<a>rotateL</a> and+-- <a>rotateR</a>)), <a>bitSize</a> and <a>isSigned</a>.+class Num a => Bits a+(.&.) :: Bits a => a -> a -> a+(.|.) :: Bits a => a -> a -> a+xor :: Bits a => a -> a -> a+complement :: Bits a => a -> a+shift :: Bits a => a -> Int -> a+rotate :: Bits a => a -> Int -> a+bit :: Bits a => Int -> a+setBit :: Bits a => a -> Int -> a+clearBit :: Bits a => a -> Int -> a+complementBit :: Bits a => a -> Int -> a+testBit :: Bits a => a -> Int -> Bool+bitSize :: Bits a => a -> Int+isSigned :: Bits a => a -> Bool+shiftL :: Bits a => a -> Int -> a+shiftR :: Bits a => a -> Int -> a+rotateL :: Bits a => a -> Int -> a+rotateR :: Bits a => a -> Int -> a++module Foreign.Storable++-- | The member functions of this class facilitate writing values of+-- primitive types to raw memory (which may have been allocated with the+-- above mentioned routines) and reading values from blocks of raw+-- memory. The class, furthermore, includes support for computing the+-- storage requirements and alignment restrictions of storable types.+-- +-- Memory addresses are represented as values of type <tt><a>Ptr</a>+-- a</tt>, for some <tt>a</tt> which is an instance of class+-- <a>Storable</a>. The type argument to <a>Ptr</a> helps provide some+-- valuable type safety in FFI code (you can't mix pointers of different+-- types without an explicit cast), while helping the Haskell type system+-- figure out which marshalling method is needed for a given pointer.+-- +-- All marshalling between Haskell and a foreign language ultimately+-- boils down to translating Haskell data structures into the binary+-- representation of a corresponding data structure of the foreign+-- language and vice versa. To code this marshalling in Haskell, it is+-- necessary to manipulate primitive data types stored in unstructured+-- memory blocks. The class <a>Storable</a> facilitates this manipulation+-- on all types for which it is instantiated, which are the standard+-- basic types of Haskell, the fixed size <tt>Int</tt> types+-- (<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>), the fixed+-- size <tt>Word</tt> types (<a>Word8</a>, <a>Word16</a>, <a>Word32</a>,+-- <a>Word64</a>), <a>StablePtr</a>, all types from+-- <a>Foreign.C.Types</a>, as well as <a>Ptr</a>.+-- +-- Minimal complete definition: <a>sizeOf</a>, <a>alignment</a>, one of+-- <a>peek</a>, <a>peekElemOff</a> and <a>peekByteOff</a>, and one of+-- <a>poke</a>, <a>pokeElemOff</a> and <a>pokeByteOff</a>.+class Storable a+sizeOf :: Storable a => a -> Int+alignment :: Storable a => a -> Int+peekElemOff :: Storable a => Ptr a -> Int -> IO a+pokeElemOff :: Storable a => Ptr a -> Int -> a -> IO ()+peekByteOff :: Storable a => Ptr b -> Int -> IO a+pokeByteOff :: Storable a => Ptr b -> Int -> a -> IO ()+peek :: Storable a => Ptr a -> IO a+poke :: Storable a => Ptr a -> a -> IO ()++module Foreign.C.Types++-- | Haskell type representing the C <tt>char</tt> type.+data CChar :: *++-- | Haskell type representing the C <tt>signed char</tt> type.+data CSChar :: *++-- | Haskell type representing the C <tt>unsigned char</tt> type.+data CUChar :: *++-- | Haskell type representing the C <tt>short</tt> type.+data CShort :: *++-- | Haskell type representing the C <tt>unsigned short</tt> type.+data CUShort :: *++-- | Haskell type representing the C <tt>int</tt> type.+data CInt :: *++-- | Haskell type representing the C <tt>unsigned int</tt> type.+data CUInt :: *++-- | Haskell type representing the C <tt>long</tt> type.+data CLong :: *++-- | Haskell type representing the C <tt>unsigned long</tt> type.+data CULong :: *++-- | Haskell type representing the C <tt>ptrdiff_t</tt> type.+data CPtrdiff :: *++-- | Haskell type representing the C <tt>size_t</tt> type.+data CSize :: *++-- | Haskell type representing the C <tt>wchar_t</tt> type.+data CWchar :: *++-- | Haskell type representing the C <tt>sig_atomic_t</tt> type.+data CSigAtomic :: *++-- | Haskell type representing the C <tt>long long</tt> type.+data CLLong :: *++-- | Haskell type representing the C <tt>unsigned long long</tt> type.+data CULLong :: *+data CIntPtr :: *+data CUIntPtr :: *+data CIntMax :: *+data CUIntMax :: *++-- | Haskell type representing the C <tt>clock_t</tt> type.+data CClock :: *++-- | Haskell type representing the C <tt>time_t</tt> type.+data CTime :: *++-- | Haskell type representing the C <tt>float</tt> type.+data CFloat :: *++-- | Haskell type representing the C <tt>double</tt> type.+data CDouble :: *++-- | Haskell type representing the C <tt>FILE</tt> type.+data CFile :: *++-- | Haskell type representing the C <tt>fpos_t</tt> type.+data CFpos :: *++-- | Haskell type representing the C <tt>jmp_buf</tt> type.+data CJmpBuf :: *++module Foreign.ForeignPtr++-- | The type <a>ForeignPtr</a> represents references to objects that are+-- maintained in a foreign language, i.e., that are not part of the data+-- structures usually managed by the Haskell storage manager. The+-- essential difference between <a>ForeignPtr</a>s and vanilla memory+-- references of type <tt>Ptr a</tt> is that the former may be associated+-- with <i>finalizers</i>. A finalizer is a routine that is invoked when+-- the Haskell storage manager detects that - within the Haskell heap and+-- stack - there are no more references left that are pointing to the+-- <a>ForeignPtr</a>. Typically, the finalizer will, then, invoke+-- routines in the foreign language that free the resources bound by the+-- foreign object.+-- +-- The <a>ForeignPtr</a> is parameterised in the same way as <a>Ptr</a>.+-- The type argument of <a>ForeignPtr</a> should normally be an instance+-- of class <a>Storable</a>.+data ForeignPtr a :: * -> *++-- | A finalizer is represented as a pointer to a foreign function that, at+-- finalisation time, gets as an argument a plain pointer variant of the+-- foreign pointer that the finalizer is associated with.+type FinalizerPtr a = FunPtr (Ptr a -> IO ())+type FinalizerEnvPtr env a = FunPtr (Ptr env -> Ptr a -> IO ())++-- | Turns a plain memory reference into a foreign pointer, and associates+-- a finalizer with the reference. The finalizer will be executed after+-- the last reference to the foreign object is dropped. There is no+-- guarantee of promptness, however the finalizer will be executed before+-- the program exits.+newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)++-- | Turns a plain memory reference into a foreign pointer that may be+-- associated with finalizers by using <a>addForeignPtrFinalizer</a>.+newForeignPtr_ :: Ptr a -> IO (ForeignPtr a)++-- | This function adds a finalizer to the given foreign object. The+-- finalizer will run <i>before</i> all other finalizers for the same+-- object which have already been registered.+addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO ()++-- | This variant of <a>newForeignPtr</a> adds a finalizer that expects an+-- environment in addition to the finalized pointer. The environment that+-- will be passed to the finalizer is fixed by the second argument to+-- <a>newForeignPtrEnv</a>.+newForeignPtrEnv :: FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)++-- | Like <a>addForeignPtrFinalizerEnv</a> but allows the finalizer to be+-- passed an additional environment parameter to be passed to the+-- finalizer. The environment passed to the finalizer is fixed by the+-- second argument to <a>addForeignPtrFinalizerEnv</a>+addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()++-- | This is a way to look at the pointer living inside a foreign object.+-- This function takes a function which is applied to that pointer. The+-- resulting <a>IO</a> action is then executed. The foreign object is+-- kept alive at least during the whole action, even if it is not used+-- directly inside. Note that it is not safe to return the pointer from+-- the action and use it after the action completes. All uses of the+-- pointer should be inside the <a>withForeignPtr</a> bracket. The reason+-- for this unsafeness is the same as for <a>unsafeForeignPtrToPtr</a>+-- below: the finalizer may run earlier than expected, because the+-- compiler can only track usage of the <a>ForeignPtr</a> object, not a+-- <a>Ptr</a> object made from it.+-- +-- This function is normally used for marshalling data to or from the+-- object pointed to by the <a>ForeignPtr</a>, using the operations from+-- the <a>Storable</a> class.+withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b++-- | Causes the finalizers associated with a foreign pointer to be run+-- immediately.+finalizeForeignPtr :: ForeignPtr a -> IO ()++-- | This function extracts the pointer component of a foreign pointer.+-- This is a potentially dangerous operations, as if the argument to+-- <a>unsafeForeignPtrToPtr</a> is the last usage occurrence of the given+-- foreign pointer, then its finalizer(s) will be run, which potentially+-- invalidates the plain pointer just obtained. Hence,+-- <a>touchForeignPtr</a> must be used wherever it has to be guaranteed+-- that the pointer lives on - i.e., has another usage occurrence.+-- +-- To avoid subtle coding errors, hand written marshalling code should+-- preferably use <tt>Foreign.ForeignPtr.withForeignPtr</tt> rather than+-- combinations of <a>unsafeForeignPtrToPtr</a> and+-- <a>touchForeignPtr</a>. However, the latter routines are occasionally+-- preferred in tool generated marshalling code.+unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a++-- | This function ensures that the foreign object in question is alive at+-- the given place in the sequence of IO actions. In particular+-- <a>withForeignPtr</a> does a <a>touchForeignPtr</a> after it executes+-- the user action.+-- +-- Note that this function should not be used to express dependencies+-- between finalizers on <a>ForeignPtr</a>s. For example, if the+-- finalizer for a <a>ForeignPtr</a> <tt>F1</tt> calls+-- <a>touchForeignPtr</a> on a second <a>ForeignPtr</a> <tt>F2</tt>, then+-- the only guarantee is that the finalizer for <tt>F2</tt> is never+-- started before the finalizer for <tt>F1</tt>. They might be started+-- together if for example both <tt>F1</tt> and <tt>F2</tt> are otherwise+-- unreachable.+-- +-- In general, it is not recommended to use finalizers on separate+-- objects with ordering constraints between them. To express the+-- ordering robustly requires explicit synchronisation between+-- finalizers.+touchForeignPtr :: ForeignPtr a -> IO ()++-- | This function casts a <a>ForeignPtr</a> parameterised by one type into+-- another type.+castForeignPtr :: ForeignPtr a -> ForeignPtr b++-- | Allocate some memory and return a <a>ForeignPtr</a> to it. The memory+-- will be released automatically when the <a>ForeignPtr</a> is+-- discarded.+-- +-- <a>mallocForeignPtr</a> is equivalent to+-- +-- <pre>+-- do { p <- malloc; newForeignPtr finalizerFree p }+-- </pre>+-- +-- although it may be implemented differently internally: you may not+-- assume that the memory returned by <a>mallocForeignPtr</a> has been+-- allocated with <tt>Foreign.Marshal.Alloc.malloc</tt>.+mallocForeignPtr :: Storable a => IO (ForeignPtr a)++-- | This function is similar to <a>mallocForeignPtr</a>, except that the+-- size of the memory required is given explicitly as a number of bytes.+mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)++-- | This function is similar to+-- <tt>Foreign.Marshal.Array.mallocArray</tt>, but yields a memory area+-- that has a finalizer attached that releases the memory area. As with+-- <a>mallocForeignPtr</a>, it is not guaranteed that the block of memory+-- was allocated by <tt>Foreign.Marshal.Alloc.malloc</tt>.+mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a)++-- | This function is similar to+-- <tt>Foreign.Marshal.Array.mallocArray0</tt>, but yields a memory area+-- that has a finalizer attached that releases the memory area. As with+-- <a>mallocForeignPtr</a>, it is not guaranteed that the block of memory+-- was allocated by <tt>Foreign.Marshal.Alloc.malloc</tt>.+mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)++module System.Exit++-- | Defines the exit codes that a program can return.+data ExitCode :: *++-- | indicates successful termination;+ExitSuccess :: ExitCode++-- | indicates program failure with an exit code. The exact interpretation+-- of the code is operating-system dependent. In particular, some values+-- may be prohibited (e.g. 0 on a POSIX-compliant system).+ExitFailure :: Int -> ExitCode++-- | Computation <tt><a>exitWith</a> code</tt> terminates the program,+-- returning <tt>code</tt> to the program's caller. The caller may+-- interpret the return code as it wishes, but the program should return+-- <a>ExitSuccess</a> to mean normal completion, and+-- <tt><a>ExitFailure</a> n</tt> to mean that the program encountered a+-- problem from which it could not recover. The value <a>exitFailure</a>+-- is equal to <tt><a>exitWith</a> (<a>ExitFailure</a> exitfail)</tt>,+-- where <tt>exitfail</tt> is implementation-dependent. <a>exitWith</a>+-- bypasses the error handling in the I/O monad and cannot be intercepted+-- by <a>catch</a> from the <tt>Prelude</tt>.+exitWith :: ExitCode -> IO a++-- | The computation <a>exitFailure</a> is equivalent to <a>exitWith</a>+-- <tt>(</tt><a>ExitFailure</a> <i>exitfail</i><tt>)</tt>, where+-- <i>exitfail</i> is implementation-dependent.+exitFailure :: IO a++-- | The computation <a>exitSuccess</a> is equivalent to <a>exitWith</a>+-- <a>ExitSuccess</a>, It terminates the program successfully.+exitSuccess :: IO a++module Foreign.Marshal.Error++-- | Execute an <a>IO</a> action, throwing a <a>userError</a> if the+-- predicate yields <a>True</a> when applied to the result returned by+-- the <a>IO</a> action. If no exception is raised, return the result of+-- the computation.+throwIf :: (a -> Bool) -> (a -> String) -> IO a -> IO a++-- | Like <a>throwIf</a>, but discarding the result+throwIf_ :: (a -> Bool) -> (a -> String) -> IO a -> IO ()++-- | Guards against negative result values+throwIfNeg :: (Ord a, Num a) => (a -> String) -> IO a -> IO a++-- | Like <a>throwIfNeg</a>, but discarding the result+throwIfNeg_ :: (Ord a, Num a) => (a -> String) -> IO a -> IO ()++-- | Guards against null pointers+throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a)++-- | Discard the return value of an <a>IO</a> action+void :: IO a -> IO ()+++-- | The module <a>Foreign.Marshal.Alloc</a> provides operations to+-- allocate and deallocate blocks of raw memory (i.e., unstructured+-- chunks of memory outside of the area maintained by the Haskell storage+-- manager). These memory blocks are commonly used to pass compound data+-- structures to foreign functions or to provide space in which compound+-- result values are obtained from foreign functions.+-- +-- If any of the allocation functions fails, a value of <tt>nullPtr</tt>+-- is produced. If <a>free</a> or <a>reallocBytes</a> is applied to a+-- memory area that has been allocated with <a>alloca</a> or+-- <a>allocaBytes</a>, the behaviour is undefined. Any further access to+-- memory areas allocated with <a>alloca</a> or <a>allocaBytes</a>, after+-- the computation that was passed to the allocation function has+-- terminated, leads to undefined behaviour. Any further access to the+-- memory area referenced by a pointer passed to <a>realloc</a>,+-- <a>reallocBytes</a>, or <a>free</a> entails undefined behaviour.+-- +-- All storage allocated by functions that allocate based on a <i>size in+-- bytes</i> must be sufficiently aligned for any of the basic foreign+-- types that fits into the newly allocated storage. All storage+-- allocated by functions that allocate based on a specific type must be+-- sufficiently aligned for that type. Array allocation routines need to+-- obey the same alignment constraints for each array element.+module Foreign.Marshal.Alloc++-- | <tt><a>alloca</a> f</tt> executes the computation <tt>f</tt>, passing+-- as argument a pointer to a temporarily allocated block of memory+-- sufficient to hold values of type <tt>a</tt>.+-- +-- The memory is freed when <tt>f</tt> terminates (either normally or via+-- an exception), so the pointer passed to <tt>f</tt> must <i>not</i> be+-- used after this.+alloca :: Storable a => (Ptr a -> IO b) -> IO b++-- | <tt><a>allocaBytes</a> n f</tt> executes the computation <tt>f</tt>,+-- passing as argument a pointer to a temporarily allocated block of+-- memory of <tt>n</tt> bytes. The block of memory is sufficiently+-- aligned for any of the basic foreign types that fits into a memory+-- block of the allocated size.+-- +-- The memory is freed when <tt>f</tt> terminates (either normally or via+-- an exception), so the pointer passed to <tt>f</tt> must <i>not</i> be+-- used after this.+allocaBytes :: Int -> (Ptr a -> IO b) -> IO b++-- | Allocate a block of memory that is sufficient to hold values of type+-- <tt>a</tt>. The size of the area allocated is determined by the+-- <a>sizeOf</a> method from the instance of <a>Storable</a> for the+-- appropriate type.+-- +-- The memory may be deallocated using <a>free</a> or+-- <a>finalizerFree</a> when no longer required.+malloc :: Storable a => IO (Ptr a)++-- | Allocate a block of memory of the given number of bytes. The block of+-- memory is sufficiently aligned for any of the basic foreign types that+-- fits into a memory block of the allocated size.+-- +-- The memory may be deallocated using <a>free</a> or+-- <a>finalizerFree</a> when no longer required.+mallocBytes :: Int -> IO (Ptr a)++-- | Resize a memory area that was allocated with <a>malloc</a> or+-- <a>mallocBytes</a> to the size needed to store values of type+-- <tt>b</tt>. The returned pointer may refer to an entirely different+-- memory area, but will be suitably aligned to hold values of type+-- <tt>b</tt>. The contents of the referenced memory area will be the+-- same as of the original pointer up to the minimum of the original size+-- and the size of values of type <tt>b</tt>.+-- +-- If the argument to <a>realloc</a> is <a>nullPtr</a>, <a>realloc</a>+-- behaves like <a>malloc</a>.+realloc :: Storable b => Ptr a -> IO (Ptr b)++-- | Resize a memory area that was allocated with <a>malloc</a> or+-- <a>mallocBytes</a> to the given size. The returned pointer may refer+-- to an entirely different memory area, but will be sufficiently aligned+-- for any of the basic foreign types that fits into a memory block of+-- the given size. The contents of the referenced memory area will be the+-- same as of the original pointer up to the minimum of the original size+-- and the given size.+-- +-- If the pointer argument to <a>reallocBytes</a> is <a>nullPtr</a>,+-- <a>reallocBytes</a> behaves like <a>malloc</a>. If the requested size+-- is 0, <a>reallocBytes</a> behaves like <a>free</a>.+reallocBytes :: Ptr a -> Int -> IO (Ptr a)++-- | Free a block of memory that was allocated with <a>malloc</a>,+-- <a>mallocBytes</a>, <a>realloc</a>, <a>reallocBytes</a>,+-- <tt>Foreign.Marshal.Utils.new</tt> or any of the <tt>new</tt><i>X</i>+-- functions in <a>Foreign.Marshal.Array</a> or <a>Foreign.C.String</a>.+free :: Ptr a -> IO ()++-- | A pointer to a foreign function equivalent to <a>free</a>, which may+-- be used as a finalizer (cf <tt>Foreign.ForeignPtr.ForeignPtr</tt>) for+-- storage allocated with <a>malloc</a>, <a>mallocBytes</a>,+-- <a>realloc</a> or <a>reallocBytes</a>.+finalizerFree :: FinalizerPtr a++module Foreign.Marshal.Utils++-- | <tt><a>with</a> val f</tt> executes the computation <tt>f</tt>,+-- passing as argument a pointer to a temporarily allocated block of+-- memory into which <tt>val</tt> has been marshalled (the combination of+-- <a>alloca</a> and <a>poke</a>).+-- +-- The memory is freed when <tt>f</tt> terminates (either normally or via+-- an exception), so the pointer passed to <tt>f</tt> must <i>not</i> be+-- used after this.+with :: Storable a => a -> (Ptr a -> IO b) -> IO b++-- | Allocate a block of memory and marshal a value into it (the+-- combination of <a>malloc</a> and <a>poke</a>). The size of the area+-- allocated is determined by the <tt>Foreign.Storable.sizeOf</tt> method+-- from the instance of <a>Storable</a> for the appropriate type.+-- +-- The memory may be deallocated using+-- <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt> when no longer required.+new :: Storable a => a -> IO (Ptr a)++-- | Convert a Haskell <a>Bool</a> to its numeric representation+fromBool :: Num a => Bool -> a++-- | Convert a Boolean in numeric representation to a Haskell value+toBool :: Num a => a -> Bool++-- | Allocate storage and marshal a storable value wrapped into a+-- <a>Maybe</a>+-- +-- <ul>+-- <li>the <a>nullPtr</a> is used to represent <a>Nothing</a></li>+-- </ul>+maybeNew :: (a -> IO (Ptr a)) -> Maybe a -> IO (Ptr a)++-- | Converts a <tt>withXXX</tt> combinator into one marshalling a value+-- wrapped into a <a>Maybe</a>, using <a>nullPtr</a> to represent+-- <a>Nothing</a>.+maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c++-- | Convert a peek combinator into a one returning <a>Nothing</a> if+-- applied to a <a>nullPtr</a>+maybePeek :: (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)++-- | Replicates a <tt>withXXX</tt> combinator over a list of objects,+-- yielding a list of marshalled objects+withMany :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res++-- | Copies the given number of bytes from the second area (source) into+-- the first (destination); the copied areas may <i>not</i> overlap+copyBytes :: Ptr a -> Ptr a -> Int -> IO ()++-- | Copies the given number of bytes from the second area (source) into+-- the first (destination); the copied areas <i>may</i> overlap+moveBytes :: Ptr a -> Ptr a -> Int -> IO ()+++-- | The module <a>Foreign.Marshal.Array</a> provides operations for+-- marshalling Haskell lists into monolithic arrays and vice versa. Most+-- functions come in two flavours: one for arrays terminated by a special+-- termination element and one where an explicit length parameter is used+-- to determine the extent of an array. The typical example for the+-- former case are C's NUL terminated strings. However, please note that+-- C strings should usually be marshalled using the functions provided by+-- <a>Foreign.C.String</a> as the Unicode encoding has to be taken into+-- account. All functions specifically operating on arrays that are+-- terminated by a special termination element have a name ending on+-- <tt>0</tt>---e.g., <a>mallocArray</a> allocates space for an array of+-- the given size, whereas <a>mallocArray0</a> allocates space for one+-- more element to ensure that there is room for the terminator.+module Foreign.Marshal.Array++-- | Allocate storage for the given number of elements of a storable type+-- (like <tt>Foreign.Marshal.Alloc.malloc</tt>, but for multiple+-- elements).+mallocArray :: Storable a => Int -> IO (Ptr a)++-- | Like <a>mallocArray</a>, but add an extra position to hold a special+-- termination element.+mallocArray0 :: Storable a => Int -> IO (Ptr a)++-- | Temporarily allocate space for the given number of elements (like+-- <tt>Foreign.Marshal.Alloc.alloca</tt>, but for multiple elements).+allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b++-- | Like <a>allocaArray</a>, but add an extra position to hold a special+-- termination element.+allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b++-- | Adjust the size of an array+reallocArray :: Storable a => Ptr a -> Int -> IO (Ptr a)++-- | Adjust the size of an array including an extra position for the end+-- marker.+reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a)++-- | Convert an array of given length into a Haskell list.+peekArray :: Storable a => Int -> Ptr a -> IO [a]++-- | Convert an array terminated by the given end marker into a Haskell+-- list+peekArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO [a]++-- | Write the list elements consecutive into memory+pokeArray :: Storable a => Ptr a -> [a] -> IO ()++-- | Write the list elements consecutive into memory and terminate them+-- with the given marker element+pokeArray0 :: Storable a => a -> Ptr a -> [a] -> IO ()++-- | Write a list of storable elements into a newly allocated, consecutive+-- sequence of storable values (like <tt>Foreign.Marshal.Utils.new</tt>,+-- but for multiple elements).+newArray :: Storable a => [a] -> IO (Ptr a)++-- | Write a list of storable elements into a newly allocated, consecutive+-- sequence of storable values, where the end is fixed by the given end+-- marker+newArray0 :: Storable a => a -> [a] -> IO (Ptr a)++-- | Temporarily store a list of storable values in memory (like+-- <tt>Foreign.Marshal.Utils.with</tt>, but for multiple elements).+withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b++-- | Like <a>withArray</a>, but a terminator indicates where the array ends+withArray0 :: Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b++-- | Like <a>withArray</a>, but the action gets the number of values as an+-- additional parameter+withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b++-- | Like <a>withArrayLen</a>, but a terminator indicates where the array+-- ends+withArrayLen0 :: Storable a => a -> [a] -> (Int -> Ptr a -> IO b) -> IO b++-- | Copy the given number of elements from the second array (source) into+-- the first array (destination); the copied areas may <i>not</i> overlap+copyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()++-- | Copy the given number of elements from the second array (source) into+-- the first array (destination); the copied areas <i>may</i> overlap+moveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()++-- | Return the number of elements in an array, excluding the terminator+lengthArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO Int++-- | Advance a pointer into an array by the given number of elements+advancePtr :: Storable a => Ptr a -> Int -> Ptr a+++-- | Utilities for primitive marshalling of C strings.+-- +-- The marshalling converts each Haskell character, representing a+-- Unicode code point, to one or more bytes in a manner that, by default,+-- is determined by the current locale. As a consequence, no guarantees+-- can be made about the relative length of a Haskell string and its+-- corresponding C string, and therefore all the marshalling routines+-- include memory allocation. The translation between Unicode and the+-- encoding of the current locale may be lossy.+module Foreign.C.String++-- | A C string is a reference to an array of C characters terminated by+-- NUL.+type CString = Ptr CChar++-- | A string with explicit length information in bytes instead of a+-- terminating NUL (allowing NUL characters in the middle of the string).+type CStringLen = (Ptr CChar, Int)++-- | Marshal a NUL terminated C string into a Haskell string.+peekCString :: CString -> IO String++-- | Marshal a C string with explicit length into a Haskell string.+peekCStringLen :: CStringLen -> IO String++-- | Marshal a Haskell string into a NUL terminated C string.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>new storage is allocated for the C string and must be explicitly+-- freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCString :: String -> IO CString++-- | Marshal a Haskell string into a C string (ie, character array) with+-- explicit length information.+-- +-- <ul>+-- <li>new storage is allocated for the C string and must be explicitly+-- freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCStringLen :: String -> IO CStringLen++-- | Marshal a Haskell string into a NUL terminated C string using+-- temporary storage.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCString :: String -> (CString -> IO a) -> IO a++-- | Marshal a Haskell string into a C string (ie, character array) in+-- temporary storage, with explicit length information.+-- +-- <ul>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCStringLen :: String -> (CStringLen -> IO a) -> IO a++-- | Determines whether a character can be accurately encoded in a+-- <a>CString</a>. Unrepresentable characters are converted to+-- <tt>'?'</tt>.+-- +-- Currently only Latin-1 characters are representable.+charIsRepresentable :: Char -> IO Bool++-- | Convert a Haskell character to a C character. This function is only+-- safe on the first 256 characters.+castCharToCChar :: Char -> CChar++-- | Convert a C byte, representing a Latin-1 character, to the+-- corresponding Haskell character.+castCCharToChar :: CChar -> Char++-- | Convert a Haskell character to a C <tt>unsigned char</tt>. This+-- function is only safe on the first 256 characters.+castCharToCUChar :: Char -> CUChar++-- | Convert a C <tt>unsigned char</tt>, representing a Latin-1 character,+-- to the corresponding Haskell character.+castCUCharToChar :: CUChar -> Char++-- | Convert a Haskell character to a C <tt>signed char</tt>. This function+-- is only safe on the first 256 characters.+castCharToCSChar :: Char -> CSChar++-- | Convert a C <tt>signed char</tt>, representing a Latin-1 character, to+-- the corresponding Haskell character.+castCSCharToChar :: CSChar -> Char++-- | Marshal a NUL terminated C string into a Haskell string.+peekCAString :: CString -> IO String++-- | Marshal a C string with explicit length into a Haskell string.+peekCAStringLen :: CStringLen -> IO String++-- | Marshal a Haskell string into a NUL terminated C string.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>new storage is allocated for the C string and must be explicitly+-- freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCAString :: String -> IO CString++-- | Marshal a Haskell string into a C string (ie, character array) with+-- explicit length information.+-- +-- <ul>+-- <li>new storage is allocated for the C string and must be explicitly+-- freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCAStringLen :: String -> IO CStringLen++-- | Marshal a Haskell string into a NUL terminated C string using+-- temporary storage.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCAString :: String -> (CString -> IO a) -> IO a++-- | Marshal a Haskell string into a C string (ie, character array) in+-- temporary storage, with explicit length information.+-- +-- <ul>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCAStringLen :: String -> (CStringLen -> IO a) -> IO a++-- | A C wide string is a reference to an array of C wide characters+-- terminated by NUL.+type CWString = Ptr CWchar++-- | A wide character string with explicit length information in+-- <a>CWchar</a>s instead of a terminating NUL (allowing NUL characters+-- in the middle of the string).+type CWStringLen = (Ptr CWchar, Int)++-- | Marshal a NUL terminated C wide string into a Haskell string.+peekCWString :: CWString -> IO String++-- | Marshal a C wide string with explicit length into a Haskell string.+peekCWStringLen :: CWStringLen -> IO String++-- | Marshal a Haskell string into a NUL terminated C wide string.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>new storage is allocated for the C wide string and must be+-- explicitly freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCWString :: String -> IO CWString++-- | Marshal a Haskell string into a C wide string (ie, wide character+-- array) with explicit length information.+-- +-- <ul>+-- <li>new storage is allocated for the C wide string and must be+-- explicitly freed using <tt>Foreign.Marshal.Alloc.free</tt> or+-- <tt>Foreign.Marshal.Alloc.finalizerFree</tt>.</li>+-- </ul>+newCWStringLen :: String -> IO CWStringLen++-- | Marshal a Haskell string into a NUL terminated C wide string using+-- temporary storage.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCWString :: String -> (CWString -> IO a) -> IO a++-- | Marshal a Haskell string into a NUL terminated C wide string using+-- temporary storage.+-- +-- <ul>+-- <li>the Haskell string may <i>not</i> contain any NUL characters</li>+-- <li>the memory is freed when the subcomputation terminates (either+-- normally or via an exception), so the pointer to the temporary storage+-- must <i>not</i> be used after this.</li>+-- </ul>+withCWStringLen :: String -> (CWStringLen -> IO a) -> IO a+++-- | The module <a>Foreign.C.Error</a> facilitates C-specific error+-- handling of <tt>errno</tt>.+module Foreign.C.Error++-- | Haskell representation for <tt>errno</tt> values. The implementation+-- is deliberately exposed, to allow users to add their own definitions+-- of <a>Errno</a> values.+newtype Errno :: *+Errno :: CInt -> Errno+eOK :: Errno+e2BIG :: Errno+eACCES :: Errno+eADDRINUSE :: Errno+eADDRNOTAVAIL :: Errno+eADV :: Errno+eAFNOSUPPORT :: Errno+eAGAIN :: Errno+eALREADY :: Errno+eBADF :: Errno+eBADMSG :: Errno+eBADRPC :: Errno+eBUSY :: Errno+eCHILD :: Errno+eCOMM :: Errno+eCONNABORTED :: Errno+eCONNREFUSED :: Errno+eCONNRESET :: Errno+eDEADLK :: Errno+eDESTADDRREQ :: Errno+eDIRTY :: Errno+eDOM :: Errno+eDQUOT :: Errno+eEXIST :: Errno+eFAULT :: Errno+eFBIG :: Errno+eFTYPE :: Errno+eHOSTDOWN :: Errno+eHOSTUNREACH :: Errno+eIDRM :: Errno+eILSEQ :: Errno+eINPROGRESS :: Errno+eINTR :: Errno+eINVAL :: Errno+eIO :: Errno+eISCONN :: Errno+eISDIR :: Errno+eLOOP :: Errno+eMFILE :: Errno+eMLINK :: Errno+eMSGSIZE :: Errno+eMULTIHOP :: Errno+eNAMETOOLONG :: Errno+eNETDOWN :: Errno+eNETRESET :: Errno+eNETUNREACH :: Errno+eNFILE :: Errno+eNOBUFS :: Errno+eNODATA :: Errno+eNODEV :: Errno+eNOENT :: Errno+eNOEXEC :: Errno+eNOLCK :: Errno+eNOLINK :: Errno+eNOMEM :: Errno+eNOMSG :: Errno+eNONET :: Errno+eNOPROTOOPT :: Errno+eNOSPC :: Errno+eNOSR :: Errno+eNOSTR :: Errno+eNOSYS :: Errno+eNOTBLK :: Errno+eNOTCONN :: Errno+eNOTDIR :: Errno+eNOTEMPTY :: Errno+eNOTSOCK :: Errno+eNOTTY :: Errno+eNXIO :: Errno+eOPNOTSUPP :: Errno+ePERM :: Errno+ePFNOSUPPORT :: Errno+ePIPE :: Errno+ePROCLIM :: Errno+ePROCUNAVAIL :: Errno+ePROGMISMATCH :: Errno+ePROGUNAVAIL :: Errno+ePROTO :: Errno+ePROTONOSUPPORT :: Errno+ePROTOTYPE :: Errno+eRANGE :: Errno+eREMCHG :: Errno+eREMOTE :: Errno+eROFS :: Errno+eRPCMISMATCH :: Errno+eRREMOTE :: Errno+eSHUTDOWN :: Errno+eSOCKTNOSUPPORT :: Errno+eSPIPE :: Errno+eSRCH :: Errno+eSRMNT :: Errno+eSTALE :: Errno+eTIME :: Errno+eTIMEDOUT :: Errno+eTOOMANYREFS :: Errno+eTXTBSY :: Errno+eUSERS :: Errno+eWOULDBLOCK :: Errno+eXDEV :: Errno++-- | Yield <a>True</a> if the given <a>Errno</a> value is valid on the+-- system. This implies that the <a>Eq</a> instance of <a>Errno</a> is+-- also system dependent as it is only defined for valid values of+-- <a>Errno</a>.+isValidErrno :: Errno -> Bool++-- | Get the current value of <tt>errno</tt> in the current thread.+getErrno :: IO Errno++-- | Reset the current thread's <tt>errno</tt> value to <a>eOK</a>.+resetErrno :: IO ()++-- | Construct an <a>IOError</a> based on the given <a>Errno</a> value. The+-- optional information can be used to improve the accuracy of error+-- messages.+errnoToIOError :: String -> Errno -> Maybe Handle -> Maybe String -> IOError++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a>.+throwErrno :: String -> IO a++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a> if the result value of the <a>IO</a> action meets the+-- given predicate.+throwErrnoIf :: (a -> Bool) -> String -> IO a -> IO a++-- | as <a>throwErrnoIf</a>, but discards the result of the <a>IO</a>+-- action after error handling.+throwErrnoIf_ :: (a -> Bool) -> String -> IO a -> IO ()++-- | as <a>throwErrnoIf</a>, but retry the <a>IO</a> action when it yields+-- the error code <a>eINTR</a> - this amounts to the standard retry loop+-- for interrupted POSIX system calls.+throwErrnoIfRetry :: (a -> Bool) -> String -> IO a -> IO a++-- | as <a>throwErrnoIfRetry</a>, but discards the result.+throwErrnoIfRetry_ :: (a -> Bool) -> String -> IO a -> IO ()++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a> if the <a>IO</a> action returns a result of+-- <tt>-1</tt>.+throwErrnoIfMinus1 :: Num a => String -> IO a -> IO a++-- | as <a>throwErrnoIfMinus1</a>, but discards the result.+throwErrnoIfMinus1_ :: Num a => String -> IO a -> IO ()++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a> if the <a>IO</a> action returns a result of+-- <tt>-1</tt>, but retries in case of an interrupted operation.+throwErrnoIfMinus1Retry :: Num a => String -> IO a -> IO a++-- | as <a>throwErrnoIfMinus1</a>, but discards the result.+throwErrnoIfMinus1Retry_ :: Num a => String -> IO a -> IO ()++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a> if the <a>IO</a> action returns <a>nullPtr</a>.+throwErrnoIfNull :: String -> IO (Ptr a) -> IO (Ptr a)++-- | Throw an <a>IOError</a> corresponding to the current value of+-- <a>getErrno</a> if the <a>IO</a> action returns <a>nullPtr</a>, but+-- retry in case of an interrupted operation.+throwErrnoIfNullRetry :: String -> IO (Ptr a) -> IO (Ptr a)++-- | as <a>throwErrnoIfRetry</a>, but additionally if the operation yields+-- the error code <a>eAGAIN</a> or <a>eWOULDBLOCK</a>, an alternative+-- action is executed before retrying.+throwErrnoIfRetryMayBlock :: (a -> Bool) -> String -> IO a -> IO b -> IO a++-- | as <a>throwErrnoIfRetryMayBlock</a>, but discards the result.+throwErrnoIfRetryMayBlock_ :: (a -> Bool) -> String -> IO a -> IO b -> IO ()++-- | as <a>throwErrnoIfMinus1Retry</a>, but checks for operations that+-- would block.+throwErrnoIfMinus1RetryMayBlock :: Num a => String -> IO a -> IO b -> IO a++-- | as <a>throwErrnoIfMinus1RetryMayBlock</a>, but discards the result.+throwErrnoIfMinus1RetryMayBlock_ :: Num a => String -> IO a -> IO b -> IO ()++-- | as <a>throwErrnoIfNullRetry</a>, but checks for operations that would+-- block.+throwErrnoIfNullRetryMayBlock :: String -> IO (Ptr a) -> IO b -> IO (Ptr a)++-- | as <a>throwErrno</a>, but exceptions include the given path when+-- appropriate.+throwErrnoPath :: String -> FilePath -> IO a++-- | as <a>throwErrnoIf</a>, but exceptions include the given path when+-- appropriate.+throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> IO a -> IO a++-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when+-- appropriate.+throwErrnoPathIf_ :: (a -> Bool) -> String -> FilePath -> IO a -> IO ()++-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when+-- appropriate.+throwErrnoPathIfNull :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)++-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path+-- when appropriate.+throwErrnoPathIfMinus1 :: Num a => String -> FilePath -> IO a -> IO a++-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path+-- when appropriate.+throwErrnoPathIfMinus1_ :: Num a => String -> FilePath -> IO a -> IO ()++module Foreign.Marshal++-- | Sometimes an external entity is a pure function, except that it passes+-- arguments and/or results via pointers. The function+-- <tt>unsafeLocalState</tt> permits the packaging of such entities as+-- pure functions.+-- +-- The only IO operations allowed in the IO action passed to+-- <tt>unsafeLocalState</tt> are (a) local allocation (<tt>alloca</tt>,+-- <tt>allocaBytes</tt> and derived operations such as <tt>withArray</tt>+-- and <tt>withCString</tt>), and (b) pointer operations+-- (<tt>Foreign.Storable</tt> and <tt>Foreign.Ptr</tt>) on the pointers+-- to local storage, and (c) foreign functions whose only observable+-- effect is to read and/or write the locally allocated memory. Passing+-- an IO operation that does not obey these rules results in undefined+-- behaviour.+-- +-- It is expected that this operation will be replaced in a future+-- revision of Haskell.+unsafeLocalState :: IO a -> a++module Data.Complex++-- | Complex numbers are an algebraic type.+-- +-- For a complex number <tt>z</tt>, <tt><a>abs</a> z</tt> is a number+-- with the magnitude of <tt>z</tt>, but oriented in the positive real+-- direction, whereas <tt><a>signum</a> z</tt> has the phase of+-- <tt>z</tt>, but unit magnitude.+data RealFloat a => Complex a :: * -> *++-- | forms a complex number from its real and imaginary rectangular+-- components.+(:+) :: !a -> !a -> Complex a++-- | Extracts the real part of a complex number.+realPart :: RealFloat a => Complex a -> a++-- | Extracts the imaginary part of a complex number.+imagPart :: RealFloat a => Complex a -> a++-- | Form a complex number from polar components of magnitude and phase.+mkPolar :: RealFloat a => a -> a -> Complex a++-- | <tt><a>cis</a> t</tt> is a complex value with magnitude <tt>1</tt> and+-- phase <tt>t</tt> (modulo <tt>2*<a>pi</a></tt>).+cis :: RealFloat a => a -> Complex a++-- | The function <a>polar</a> takes a complex number and returns a+-- (magnitude, phase) pair in canonical form: the magnitude is+-- nonnegative, and the phase in the range <tt>(-<a>pi</a>,+-- <a>pi</a>]</tt>; if the magnitude is zero, then so is the phase.+polar :: RealFloat a => Complex a -> (a, a)++-- | The nonnegative magnitude of a complex number.+magnitude :: RealFloat a => Complex a -> a++-- | The phase of a complex number, in the range <tt>(-<a>pi</a>,+-- <a>pi</a>]</tt>. If the magnitude is zero, then so is the phase.+phase :: RealFloat a => Complex a -> a++-- | The conjugate of a complex number.+conjugate :: RealFloat a => Complex a -> Complex a++module System.Environment++-- | Computation <a>getArgs</a> returns a list of the program's command+-- line arguments (not including the program name).+getArgs :: IO [String]++-- | Computation <a>getProgName</a> returns the name of the program as it+-- was invoked.+-- +-- However, this is hard-to-impossible to implement on some non-Unix+-- OSes, so instead, for maximum portability, we just return the leafname+-- of the program as invoked. Even then there are some differences+-- between platforms: on Windows, for example, a program invoked as foo+-- is probably really <tt>FOO.EXE</tt>, and that is what+-- <a>getProgName</a> will return.+getProgName :: IO String++-- | Computation <a>getEnv</a> <tt>var</tt> returns the value of the+-- environment variable <tt>var</tt>.+-- +-- This computation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isDoesNotExistError</tt> if the environment+-- variable does not exist.</li>+-- </ul>+getEnv :: String -> IO String++module Foreign.C++module Foreign++module Data.List++-- | Append two lists, i.e.,+-- +-- <pre>+-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]+-- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]+-- </pre>+-- +-- If the first list is not finite, the result is the first list.+(++) :: [a] -> [a] -> [a]++-- | Extract the first element of a list, which must be non-empty.+head :: [a] -> a++-- | Extract the last element of a list, which must be finite and+-- non-empty.+last :: [a] -> a++-- | Extract the elements after the head of a list, which must be+-- non-empty.+tail :: [a] -> [a]++-- | Return all the elements of a list except the last one. The list must+-- be non-empty.+init :: [a] -> [a]++-- | Test whether a list is empty.+null :: [a] -> Bool++-- | <i>O(n)</i>. <a>length</a> returns the length of a finite list as an+-- <a>Int</a>. It is an instance of the more general+-- <tt>Data.List.genericLength</tt>, the result type of which may be any+-- kind of number.+length :: [a] -> Int++-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>+-- to each element of <tt>xs</tt>, i.e.,+-- +-- <pre>+-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]+-- map f [x1, x2, ...] == [f x1, f x2, ...]+-- </pre>+map :: (a -> b) -> [a] -> [b]++-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in+-- reverse order. <tt>xs</tt> must be finite.+reverse :: [a] -> [a]++-- | The <a>intersperse</a> function takes an element and a list and+-- `intersperses' that element between the elements of the list. For+-- example,+-- +-- <pre>+-- intersperse ',' "abcde" == "a,b,c,d,e"+-- </pre>+intersperse :: a -> [a] -> [a]++-- | <a>intercalate</a> <tt>xs xss</tt> is equivalent to <tt>(<a>concat</a>+-- (<a>intersperse</a> xs xss))</tt>. It inserts the list <tt>xs</tt> in+-- between the lists in <tt>xss</tt> and concatenates the result.+intercalate :: [a] -> [[a]] -> [a]++-- | The <a>transpose</a> function transposes the rows and columns of its+-- argument. For example,+-- +-- <pre>+-- transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]+-- </pre>+transpose :: [[a]] -> [[a]]++-- | The <a>subsequences</a> function returns the list of all subsequences+-- of the argument.+-- +-- <pre>+-- subsequences "abc" == ["","a","b","ab","c","ac","bc","abc"]+-- </pre>+subsequences :: [a] -> [[a]]++-- | The <a>permutations</a> function returns the list of all permutations+-- of the argument.+-- +-- <pre>+-- permutations "abc" == ["abc","bac","cba","bca","cab","acb"]+-- </pre>+permutations :: [a] -> [[a]]++-- | <a>foldl</a>, applied to a binary operator, a starting value+-- (typically the left-identity of the operator), and a list, reduces the+-- list using the binary operator, from left to right:+-- +-- <pre>+-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn+-- </pre>+-- +-- The list must be finite.+foldl :: (a -> b -> a) -> a -> [b] -> a++-- | A strict version of <a>foldl</a>.+foldl' :: (a -> b -> a) -> a -> [b] -> a++-- | <a>foldl1</a> is a variant of <a>foldl</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldl1 :: (a -> a -> a) -> [a] -> a++-- | A strict version of <a>foldl1</a>+foldl1' :: (a -> a -> a) -> [a] -> a++-- | <a>foldr</a>, applied to a binary operator, a starting value+-- (typically the right-identity of the operator), and a list, reduces+-- the list using the binary operator, from right to left:+-- +-- <pre>+-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)+-- </pre>+foldr :: (a -> b -> b) -> b -> [a] -> b++-- | <a>foldr1</a> is a variant of <a>foldr</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldr1 :: (a -> a -> a) -> [a] -> a++-- | Concatenate a list of lists.+concat :: [[a]] -> [a]++-- | Map a function over a list and concatenate the results.+concatMap :: (a -> [b]) -> [a] -> [b]++-- | <a>and</a> returns the conjunction of a Boolean list. For the result+-- to be <a>True</a>, the list must be finite; <a>False</a>, however,+-- results from a <a>False</a> value at a finite index of a finite or+-- infinite list.+and :: [Bool] -> Bool++-- | <a>or</a> returns the disjunction of a Boolean list. For the result to+-- be <a>False</a>, the list must be finite; <a>True</a>, however,+-- results from a <a>True</a> value at a finite index of a finite or+-- infinite list.+or :: [Bool] -> Bool++-- | Applied to a predicate and a list, <a>any</a> determines if any+-- element of the list satisfies the predicate. For the result to be+-- <a>False</a>, the list must be finite; <a>True</a>, however, results+-- from a <a>True</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+any :: (a -> Bool) -> [a] -> Bool++-- | Applied to a predicate and a list, <a>all</a> determines if all+-- elements of the list satisfy the predicate. For the result to be+-- <a>True</a>, the list must be finite; <a>False</a>, however, results+-- from a <a>False</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+all :: (a -> Bool) -> [a] -> Bool++-- | The <a>sum</a> function computes the sum of a finite list of numbers.+sum :: Num a => [a] -> a++-- | The <a>product</a> function computes the product of a finite list of+-- numbers.+product :: Num a => [a] -> a++-- | <a>maximum</a> returns the maximum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>maximumBy</a>, which allows the programmer to supply their own+-- comparison function.+maximum :: Ord a => [a] -> a++-- | <a>minimum</a> returns the minimum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>minimumBy</a>, which allows the programmer to supply their own+-- comparison function.+minimum :: Ord a => [a] -> a++-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of+-- successive reduced values from the left:+-- +-- <pre>+-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]+-- </pre>+-- +-- Note that+-- +-- <pre>+-- last (scanl f z xs) == foldl f z xs.+-- </pre>+scanl :: (a -> b -> a) -> a -> [b] -> [a]++-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value+-- argument:+-- +-- <pre>+-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]+-- </pre>+scanl1 :: (a -> a -> a) -> [a] -> [a]++-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that+-- +-- <pre>+-- head (scanr f z xs) == foldr f z xs.+-- </pre>+scanr :: (a -> b -> b) -> b -> [a] -> [b]++-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value+-- argument.+scanr1 :: (a -> a -> a) -> [a] -> [a]++-- | The <a>mapAccumL</a> function behaves like a combination of <a>map</a>+-- and <a>foldl</a>; it applies a function to each element of a list,+-- passing an accumulating parameter from left to right, and returning a+-- final value of this accumulator together with the new list.+mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])++-- | The <a>mapAccumR</a> function behaves like a combination of <a>map</a>+-- and <a>foldr</a>; it applies a function to each element of a list,+-- passing an accumulating parameter from right to left, and returning a+-- final value of this accumulator together with the new list.+mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])++-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated+-- applications of <tt>f</tt> to <tt>x</tt>:+-- +-- <pre>+-- iterate f x == [x, f x, f (f x), ...]+-- </pre>+iterate :: (a -> a) -> a -> [a]++-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the+-- value of every element.+repeat :: a -> [a]++-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with+-- <tt>x</tt> the value of every element. It is an instance of the more+-- general <tt>Data.List.genericReplicate</tt>, in which <tt>n</tt> may+-- be of any integral type.+replicate :: Int -> a -> [a]++-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,+-- the infinite repetition of the original list. It is the identity on+-- infinite lists.+cycle :: [a] -> [a]++-- | The <a>unfoldr</a> function is a `dual' to <a>foldr</a>: while+-- <a>foldr</a> reduces a list to a summary value, <a>unfoldr</a> builds+-- a list from a seed value. The function takes the element and returns+-- <a>Nothing</a> if it is done producing the list or returns <a>Just</a>+-- <tt>(a,b)</tt>, in which case, <tt>a</tt> is a prepended to the list+-- and <tt>b</tt> is used as the next element in a recursive call. For+-- example,+-- +-- <pre>+-- iterate f == unfoldr (\x -> Just (x, f x))+-- </pre>+-- +-- In some cases, <a>unfoldr</a> can undo a <a>foldr</a> operation:+-- +-- <pre>+-- unfoldr f' (foldr f z xs) == xs+-- </pre>+-- +-- if the following holds:+-- +-- <pre>+-- f' (f x y) = Just (x,y)+-- f' z = Nothing+-- </pre>+-- +-- A simple use of unfoldr:+-- +-- <pre>+-- unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10+-- [10,9,8,7,6,5,4,3,2,1]+-- </pre>+unfoldr :: (b -> Maybe (a, b)) -> b -> [a]++-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the+-- prefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if+-- <tt>n > <a>length</a> xs</tt>:+-- +-- <pre>+-- take 5 "Hello World!" == "Hello"+-- take 3 [1,2,3,4,5] == [1,2,3]+-- take 3 [1,2] == [1,2]+-- take 3 [] == []+-- take (-1) [1,2] == []+-- take 0 [1,2] == []+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericTake</tt>,+-- in which <tt>n</tt> may be of any integral type.+take :: Int -> [a] -> [a]++-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the+-- first <tt>n</tt> elements, or <tt>[]</tt> if <tt>n > <a>length</a>+-- xs</tt>:+-- +-- <pre>+-- drop 6 "Hello World!" == "World!"+-- drop 3 [1,2,3,4,5] == [4,5]+-- drop 3 [1,2] == []+-- drop 3 [] == []+-- drop (-1) [1,2] == [1,2]+-- drop 0 [1,2] == [1,2]+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericDrop</tt>,+-- in which <tt>n</tt> may be of any integral type.+drop :: Int -> [a] -> [a]++-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is+-- <tt>xs</tt> prefix of length <tt>n</tt> and second element is the+-- remainder of the list:+-- +-- <pre>+-- splitAt 6 "Hello World!" == ("Hello ","World!")+-- splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])+-- splitAt 1 [1,2,3] == ([1],[2,3])+-- splitAt 3 [1,2,3] == ([1,2,3],[])+-- splitAt 4 [1,2,3] == ([1,2,3],[])+-- splitAt 0 [1,2,3] == ([],[1,2,3])+-- splitAt (-1) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- It is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt>.+-- <a>splitAt</a> is an instance of the more general+-- <tt>Data.List.genericSplitAt</tt>, in which <tt>n</tt> may be of any+-- integral type.+splitAt :: Int -> [a] -> ([a], [a])++-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns the longest prefix (possibly empty) of+-- <tt>xs</tt> of elements that satisfy <tt>p</tt>:+-- +-- <pre>+-- takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]+-- takeWhile (< 9) [1,2,3] == [1,2,3]+-- takeWhile (< 0) [1,2,3] == []+-- </pre>+takeWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after+-- <a>takeWhile</a> <tt>p xs</tt>:+-- +-- <pre>+-- dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]+-- dropWhile (< 9) [1,2,3] == []+-- dropWhile (< 0) [1,2,3] == [1,2,3]+-- </pre>+dropWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,+-- returns a tuple where first element is longest prefix (possibly empty)+-- of <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element+-- is the remainder of the list:+-- +-- <pre>+-- span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])+-- span (< 9) [1,2,3] == ([1,2,3],[])+-- span (< 0) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- <a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,+-- <a>dropWhile</a> p xs)</tt>+span :: (a -> Bool) -> [a] -> ([a], [a])++-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns a tuple where first element is longest prefix+-- (possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>+-- <tt>p</tt> and second element is the remainder of the list:+-- +-- <pre>+-- break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])+-- break (< 9) [1,2,3] == ([],[1,2,3])+-- break (> 9) [1,2,3] == ([1,2,3],[])+-- </pre>+-- +-- <a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .+-- p)</tt>.+break :: (a -> Bool) -> [a] -> ([a], [a])++-- | The <a>stripPrefix</a> function drops the given prefix from a list. It+-- returns <a>Nothing</a> if the list did not start with the prefix+-- given, or <a>Just</a> the list after the prefix, if it does.+-- +-- <pre>+-- stripPrefix "foo" "foobar" == Just "bar"+-- stripPrefix "foo" "foo" == Just ""+-- stripPrefix "foo" "barfoo" == Nothing+-- stripPrefix "foo" "barfoobaz" == Nothing+-- </pre>+stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]++-- | The <a>group</a> function takes a list and returns a list of lists+-- such that the concatenation of the result is equal to the argument.+-- Moreover, each sublist in the result contains only equal elements. For+-- example,+-- +-- <pre>+-- group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]+-- </pre>+-- +-- It is a special case of <a>groupBy</a>, which allows the programmer to+-- supply their own equality test.+group :: Eq a => [a] -> [[a]]++-- | The <a>inits</a> function returns all initial segments of the+-- argument, shortest first. For example,+-- +-- <pre>+-- inits "abc" == ["","a","ab","abc"]+-- </pre>+inits :: [a] -> [[a]]++-- | The <a>tails</a> function returns all final segments of the argument,+-- longest first. For example,+-- +-- <pre>+-- tails "abc" == ["abc", "bc", "c",""]+-- </pre>+tails :: [a] -> [[a]]++-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>+-- iff the first list is a prefix of the second.+isPrefixOf :: Eq a => [a] -> [a] -> Bool++-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>+-- iff the first list is a suffix of the second. Both lists must be+-- finite.+isSuffixOf :: Eq a => [a] -> [a] -> Bool++-- | The <a>isInfixOf</a> function takes two lists and returns <a>True</a>+-- iff the first list is contained, wholly and intact, anywhere within+-- the second.+-- +-- Example:+-- +-- <pre>+-- isInfixOf "Haskell" "I really like Haskell." == True+-- isInfixOf "Ial" "I really like Haskell." == False+-- </pre>+isInfixOf :: Eq a => [a] -> [a] -> Bool++-- | <a>elem</a> is the list membership predicate, usually written in infix+-- form, e.g., <tt>x `elem` xs</tt>. For the result to be <a>False</a>,+-- the list must be finite; <a>True</a>, however, results from an element+-- equal to <tt>x</tt> found at a finite index of a finite or infinite+-- list.+elem :: Eq a => a -> [a] -> Bool++-- | <a>notElem</a> is the negation of <a>elem</a>.+notElem :: Eq a => a -> [a] -> Bool++-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association+-- list.+lookup :: Eq a => a -> [(a, b)] -> Maybe b++-- | The <a>find</a> function takes a predicate and a list and returns the+-- first element in the list matching the predicate, or <a>Nothing</a> if+-- there is no such element.+find :: (a -> Bool) -> [a] -> Maybe a++-- | <a>filter</a>, applied to a predicate and a list, returns the list of+-- those elements that satisfy the predicate; i.e.,+-- +-- <pre>+-- filter p xs = [ x | x <- xs, p x]+-- </pre>+filter :: (a -> Bool) -> [a] -> [a]++-- | The <a>partition</a> function takes a predicate a list and returns the+-- pair of lists of elements which do and do not satisfy the predicate,+-- respectively; i.e.,+-- +-- <pre>+-- partition p xs == (filter p xs, filter (not . p) xs)+-- </pre>+partition :: (a -> Bool) -> [a] -> ([a], [a])++-- | List index (subscript) operator, starting from 0. It is an instance of+-- the more general <tt>Data.List.genericIndex</tt>, which takes an index+-- of any integral type.+(!!) :: [a] -> Int -> a++-- | The <a>elemIndex</a> function returns the index of the first element+-- in the given list which is equal (by <a>==</a>) to the query element,+-- or <a>Nothing</a> if there is no such element.+elemIndex :: Eq a => a -> [a] -> Maybe Int++-- | The <a>elemIndices</a> function extends <a>elemIndex</a>, by returning+-- the indices of all elements equal to the query element, in ascending+-- order.+elemIndices :: Eq a => a -> [a] -> [Int]++-- | The <a>findIndex</a> function takes a predicate and a list and returns+-- the index of the first element in the list satisfying the predicate,+-- or <a>Nothing</a> if there is no such element.+findIndex :: (a -> Bool) -> [a] -> Maybe Int++-- | The <a>findIndices</a> function extends <a>findIndex</a>, by returning+-- the indices of all elements satisfying the predicate, in ascending+-- order.+findIndices :: (a -> Bool) -> [a] -> [Int]++-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.+-- If one input list is short, excess elements of the longer list are+-- discarded.+zip :: [a] -> [b] -> [(a, b)]++-- | <a>zip3</a> takes three lists and returns a list of triples, analogous+-- to <a>zip</a>.+zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]++-- | The <a>zip4</a> function takes four lists and returns a list of+-- quadruples, analogous to <a>zip</a>.+zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]++-- | The <a>zip5</a> function takes five lists and returns a list of+-- five-tuples, analogous to <a>zip</a>.+zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]++-- | The <a>zip6</a> function takes six lists and returns a list of+-- six-tuples, analogous to <a>zip</a>.+zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]++-- | The <a>zip7</a> function takes seven lists and returns a list of+-- seven-tuples, analogous to <a>zip</a>.+zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]++-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function+-- given as the first argument, instead of a tupling function. For+-- example, <tt><a>zipWith</a> (+)</tt> is applied to two lists to+-- produce the list of corresponding sums.+zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]++-- | The <a>zipWith3</a> function takes a function which combines three+-- elements, as well as three lists and returns a list of their+-- point-wise combination, analogous to <a>zipWith</a>.+zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]++-- | The <a>zipWith4</a> function takes a function which combines four+-- elements, as well as four lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]++-- | The <a>zipWith5</a> function takes a function which combines five+-- elements, as well as five lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]++-- | The <a>zipWith6</a> function takes a function which combines six+-- elements, as well as six lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]++-- | The <a>zipWith7</a> function takes a function which combines seven+-- elements, as well as seven lists and returns a list of their+-- point-wise combination, analogous to <a>zipWith</a>.+zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]++-- | <a>unzip</a> transforms a list of pairs into a list of first+-- components and a list of second components.+unzip :: [(a, b)] -> ([a], [b])++-- | The <a>unzip3</a> function takes a list of triples and returns three+-- lists, analogous to <a>unzip</a>.+unzip3 :: [(a, b, c)] -> ([a], [b], [c])++-- | The <a>unzip4</a> function takes a list of quadruples and returns four+-- lists, analogous to <a>unzip</a>.+unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])++-- | The <a>unzip5</a> function takes a list of five-tuples and returns+-- five lists, analogous to <a>unzip</a>.+unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])++-- | The <a>unzip6</a> function takes a list of six-tuples and returns six+-- lists, analogous to <a>unzip</a>.+unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])++-- | The <a>unzip7</a> function takes a list of seven-tuples and returns+-- seven lists, analogous to <a>unzip</a>.+unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])++-- | <a>lines</a> breaks a string up into a list of strings at newline+-- characters. The resulting strings do not contain newlines.+lines :: String -> [String]++-- | <a>words</a> breaks a string up into a list of words, which were+-- delimited by white space.+words :: String -> [String]++-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins+-- lines, after appending a terminating newline to each.+unlines :: [String] -> String++-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words+-- with separating spaces.+unwords :: [String] -> String++-- | <i>O(n^2)</i>. The <a>nub</a> function removes duplicate elements from+-- a list. In particular, it keeps only the first occurrence of each+-- element. (The name <a>nub</a> means `essence'.) It is a special case+-- of <a>nubBy</a>, which allows the programmer to supply their own+-- equality test.+nub :: Eq a => [a] -> [a]++-- | <a>delete</a> <tt>x</tt> removes the first occurrence of <tt>x</tt>+-- from its list argument. For example,+-- +-- <pre>+-- delete 'a' "banana" == "bnana"+-- </pre>+-- +-- It is a special case of <a>deleteBy</a>, which allows the programmer+-- to supply their own equality test.+delete :: Eq a => a -> [a] -> [a]++-- | The <a>\\</a> function is list difference ((non-associative). In the+-- result of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of+-- each element of <tt>ys</tt> in turn (if any) has been removed from+-- <tt>xs</tt>. Thus+-- +-- <pre>+-- (xs ++ ys) \\ xs == ys.+-- </pre>+-- +-- It is a special case of <a>deleteFirstsBy</a>, which allows the+-- programmer to supply their own equality test.+(\\) :: Eq a => [a] -> [a] -> [a]++-- | The <a>union</a> function returns the list union of the two lists. For+-- example,+-- +-- <pre>+-- "dog" `union` "cow" == "dogcw"+-- </pre>+-- +-- Duplicates, and elements of the first list, are removed from the the+-- second list, but if the first list contains duplicates, so will the+-- result. It is a special case of <a>unionBy</a>, which allows the+-- programmer to supply their own equality test.+union :: Eq a => [a] -> [a] -> [a]++-- | The <a>intersect</a> function takes the list intersection of two+-- lists. For example,+-- +-- <pre>+-- [1,2,3,4] `intersect` [2,4,6,8] == [2,4]+-- </pre>+-- +-- If the first list contains duplicates, so will the result.+-- +-- <pre>+-- [1,2,2,3,4] `intersect` [6,4,4,2] == [2,2,4]+-- </pre>+-- +-- It is a special case of <a>intersectBy</a>, which allows the+-- programmer to supply their own equality test.+intersect :: Eq a => [a] -> [a] -> [a]++-- | The <a>sort</a> function implements a stable sorting algorithm. It is+-- a special case of <a>sortBy</a>, which allows the programmer to supply+-- their own comparison function.+sort :: Ord a => [a] -> [a]++-- | The <a>insert</a> function takes an element and a list and inserts the+-- element into the list at the last position where it is still less than+-- or equal to the next element. In particular, if the list is sorted+-- before the call, the result will also be sorted. It is a special case+-- of <a>insertBy</a>, which allows the programmer to supply their own+-- comparison function.+insert :: Ord a => a -> [a] -> [a]++-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses+-- a user-supplied equality predicate instead of the overloaded <a>==</a>+-- function.+nubBy :: (a -> a -> Bool) -> [a] -> [a]++-- | The <a>deleteBy</a> function behaves like <a>delete</a>, but takes a+-- user-supplied equality predicate.+deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]++-- | The <a>deleteFirstsBy</a> function takes a predicate and two lists and+-- returns the first list with the first occurrence of each element of+-- the second list removed.+deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>unionBy</a> function is the non-overloaded version of+-- <a>union</a>.+unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>intersectBy</a> function is the non-overloaded version of+-- <a>intersect</a>.+intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>groupBy</a> function is the non-overloaded version of+-- <a>group</a>.+groupBy :: (a -> a -> Bool) -> [a] -> [[a]]++-- | The <a>sortBy</a> function is the non-overloaded version of+-- <a>sort</a>.+sortBy :: (a -> a -> Ordering) -> [a] -> [a]++-- | The non-overloaded version of <a>insert</a>.+insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]++-- | The <a>maximumBy</a> function takes a comparison function and a list+-- and returns the greatest element of the list by the comparison+-- function. The list must be finite and non-empty.+maximumBy :: (a -> a -> Ordering) -> [a] -> a++-- | The <a>minimumBy</a> function takes a comparison function and a list+-- and returns the least element of the list by the comparison function.+-- The list must be finite and non-empty.+minimumBy :: (a -> a -> Ordering) -> [a] -> a++-- | The <a>genericLength</a> function is an overloaded version of+-- <a>length</a>. In particular, instead of returning an <a>Int</a>, it+-- returns any type which is an instance of <a>Num</a>. It is, however,+-- less efficient than <a>length</a>.+genericLength :: Num i => [b] -> i++-- | The <a>genericTake</a> function is an overloaded version of+-- <a>take</a>, which accepts any <a>Integral</a> value as the number of+-- elements to take.+genericTake :: Integral i => i -> [a] -> [a]++-- | The <a>genericDrop</a> function is an overloaded version of+-- <a>drop</a>, which accepts any <a>Integral</a> value as the number of+-- elements to drop.+genericDrop :: Integral i => i -> [a] -> [a]++-- | The <a>genericSplitAt</a> function is an overloaded version of+-- <a>splitAt</a>, which accepts any <a>Integral</a> value as the+-- position at which to split.+genericSplitAt :: Integral i => i -> [b] -> ([b], [b])++-- | The <a>genericIndex</a> function is an overloaded version of+-- <a>!!</a>, which accepts any <a>Integral</a> value as the index.+genericIndex :: Integral a => [b] -> a -> b++-- | The <a>genericReplicate</a> function is an overloaded version of+-- <a>replicate</a>, which accepts any <a>Integral</a> value as the+-- number of repetitions to make.+genericReplicate :: Integral i => i -> a -> [a]+++-- | The <a>Control.Monad</a> module provides the <a>Functor</a>,+-- <a>Monad</a> and <a>MonadPlus</a> classes, together with some useful+-- operations on monads.+module Control.Monad++-- | The <a>Functor</a> class is used for types that can be mapped over.+-- Instances of <a>Functor</a> should satisfy the following laws:+-- +-- <pre>+-- fmap id == id+-- fmap (f . g) == fmap f . fmap g+-- </pre>+-- +-- The instances of <a>Functor</a> for lists, <tt>Data.Maybe.Maybe</tt>+-- and <tt>System.IO.IO</tt> satisfy these laws.+class Functor f :: (* -> *)+fmap :: Functor f => (a -> b) -> f a -> f b++-- | The <a>Monad</a> class defines the basic operations over a+-- <i>monad</i>, a concept from a branch of mathematics known as+-- <i>category theory</i>. From the perspective of a Haskell programmer,+-- however, it is best to think of a monad as an <i>abstract datatype</i>+-- of actions. Haskell's <tt>do</tt> expressions provide a convenient+-- syntax for writing monadic expressions.+-- +-- Minimal complete definition: <a>>>=</a> and <a>return</a>.+-- +-- Instances of <a>Monad</a> should satisfy the following laws:+-- +-- <pre>+-- return a >>= k == k a+-- m >>= return == m+-- m >>= (\x -> k x >>= h) == (m >>= k) >>= h+-- </pre>+-- +-- Instances of both <a>Monad</a> and <a>Functor</a> should additionally+-- satisfy the law:+-- +-- <pre>+-- fmap f xs == xs >>= return . f+-- </pre>+-- +-- The instances of <a>Monad</a> for lists, <tt>Data.Maybe.Maybe</tt> and+-- <tt>System.IO.IO</tt> defined in the <a>Prelude</a> satisfy these+-- laws.+class Monad m :: (* -> *)+(>>=) :: Monad m => m a -> (a -> m b) -> m b+(>>) :: Monad m => m a -> m b -> m b+return :: Monad m => a -> m a+fail :: Monad m => String -> m a++-- | Monads that also support choice and failure.+class Monad m => MonadPlus m :: (* -> *)+mzero :: MonadPlus m => m a+mplus :: MonadPlus m => m a -> m a -> m a++-- | <tt><a>mapM</a> f</tt> is equivalent to <tt><a>sequence</a> .+-- <a>map</a> f</tt>.+mapM :: Monad m => (a -> m b) -> [a] -> m [b]++-- | <tt><a>mapM_</a> f</tt> is equivalent to <tt><a>sequence_</a> .+-- <a>map</a> f</tt>.+mapM_ :: Monad m => (a -> m b) -> [a] -> m ()++-- | <a>forM</a> is <a>mapM</a> with its arguments flipped+forM :: Monad m => [a] -> (a -> m b) -> m [b]++-- | <a>forM_</a> is <a>mapM_</a> with its arguments flipped+forM_ :: Monad m => [a] -> (a -> m b) -> m ()++-- | Evaluate each action in the sequence from left to right, and collect+-- the results.+sequence :: Monad m => [m a] -> m [a]++-- | Evaluate each action in the sequence from left to right, and ignore+-- the results.+sequence_ :: Monad m => [m a] -> m ()++-- | Same as <a>>>=</a>, but with the arguments interchanged.+(=<<) :: Monad m => (a -> m b) -> m a -> m b++-- | Left-to-right Kleisli composition of monads.+(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c++-- | Right-to-left Kleisli composition of monads.+-- <tt>(<a>>=></a>)</tt>, with the arguments flipped+(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c++-- | <tt><a>forever</a> act</tt> repeats the action infinitely.+forever :: Monad m => m a -> m b++-- | <tt><a>void</a> value</tt> discards or ignores the result of+-- evaluation, such as the return value of an <a>IO</a> action.+void :: Functor f => f a -> f ()++-- | The <a>join</a> function is the conventional monad join operator. It+-- is used to remove one level of monadic structure, projecting its bound+-- argument into the outer level.+join :: Monad m => m (m a) -> m a++-- | This generalizes the list-based <a>concat</a> function.+msum :: MonadPlus m => [m a] -> m a++-- | This generalizes the list-based <a>filter</a> function.+filterM :: Monad m => (a -> m Bool) -> [a] -> m [a]++-- | The <a>mapAndUnzipM</a> function maps its first argument over a list,+-- returning the result as a pair of lists. This function is mainly used+-- with complicated data structures or a state-transforming monad.+mapAndUnzipM :: Monad m => (a -> m (b, c)) -> [a] -> m ([b], [c])++-- | The <a>zipWithM</a> function generalizes <a>zipWith</a> to arbitrary+-- monads.+zipWithM :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]++-- | <a>zipWithM_</a> is the extension of <a>zipWithM</a> which ignores the+-- final result.+zipWithM_ :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m ()++-- | The <a>foldM</a> function is analogous to <a>foldl</a>, except that+-- its result is encapsulated in a monad. Note that <a>foldM</a> works+-- from left-to-right over the list arguments. This could be an issue+-- where <tt>(<a>>></a>)</tt> and the `folded function' are not+-- commutative.+-- +-- <pre>+-- foldM f a1 [x1, x2, ..., xm]+-- </pre>+-- +-- ==+-- +-- <pre>+-- do+-- a2 <- f a1 x1+-- a3 <- f a2 x2+-- ...+-- f am xm+-- </pre>+-- +-- If right-to-left evaluation is required, the input list should be+-- reversed.+foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a++-- | Like <a>foldM</a>, but discards the result.+foldM_ :: Monad m => (a -> b -> m a) -> a -> [b] -> m ()++-- | <tt><a>replicateM</a> n act</tt> performs the action <tt>n</tt> times,+-- gathering the results.+replicateM :: Monad m => Int -> m a -> m [a]++-- | Like <a>replicateM</a>, but discards the result.+replicateM_ :: Monad m => Int -> m a -> m ()++-- | <tt><a>guard</a> b</tt> is <tt><a>return</a> ()</tt> if <tt>b</tt> is+-- <a>True</a>, and <a>mzero</a> if <tt>b</tt> is <a>False</a>.+guard :: MonadPlus m => Bool -> m ()++-- | Conditional execution of monadic expressions. For example,+-- +-- <pre>+-- when debug (putStr "Debugging\n")+-- </pre>+-- +-- will output the string <tt>Debugging\n</tt> if the Boolean value+-- <tt>debug</tt> is <a>True</a>, and otherwise do nothing.+when :: Monad m => Bool -> m () -> m ()++-- | The reverse of <a>when</a>.+unless :: Monad m => Bool -> m () -> m ()++-- | Promote a function to a monad.+liftM :: Monad m => (a1 -> r) -> m a1 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right. For example,+-- +-- <pre>+-- liftM2 (+) [0,1] [0,2] = [0,2,1,3]+-- liftM2 (+) (Just 1) Nothing = Nothing+-- </pre>+liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r++-- | In many situations, the <a>liftM</a> operations can be replaced by+-- uses of <a>ap</a>, which promotes function application.+-- +-- <pre>+-- return f `ap` x1 `ap` ... `ap` xn+-- </pre>+-- +-- is equivalent to+-- +-- <pre>+-- liftMn f x1 x2 ... xn+-- </pre>+ap :: Monad m => m (a -> b) -> m a -> m b++module System.IO++-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when+-- performed, does some I/O before returning a value of type <tt>a</tt>.+-- +-- There is really only one way to "perform" an I/O action: bind it to+-- <tt>Main.main</tt> in your program. When your program is run, the I/O+-- will be performed. It isn't possible to perform I/O from an arbitrary+-- function, unless that function is itself in the <a>IO</a> monad and+-- called at some point, directly or indirectly, from <tt>Main.main</tt>.+-- +-- <a>IO</a> is a monad, so <a>IO</a> actions can be combined using+-- either the do-notation or the <tt>>></tt> and <tt>>>=</tt>+-- operations from the <tt>Monad</tt> class.+data IO a :: * -> *+fixIO :: (a -> IO a) -> IO a++-- | File and directory names are values of type <a>String</a>, whose+-- precise meaning is operating system dependent. Files can be opened,+-- yielding a handle which can then be used to operate on the contents of+-- that file.+type FilePath = String++-- | Haskell defines operations to read and write characters from and to+-- files, represented by values of type <tt>Handle</tt>. Each value of+-- this type is a <i>handle</i>: a record used by the Haskell run-time+-- system to <i>manage</i> I/O with file system objects. A handle has at+-- least the following properties:+-- +-- <ul>+-- <li>whether it manages input or output or both;</li>+-- <li>whether it is <i>open</i>, <i>closed</i> or+-- <i>semi-closed</i>;</li>+-- <li>whether the object is seekable;</li>+-- <li>whether buffering is disabled, or enabled on a line or block+-- basis;</li>+-- <li>a buffer (whose length may be zero).</li>+-- </ul>+-- +-- Most handles will also have a current I/O position indicating where+-- the next input or output operation will occur. A handle is+-- <i>readable</i> if it manages only input or both input and output;+-- likewise, it is <i>writable</i> if it manages only output or both+-- input and output. A handle is <i>open</i> when first allocated. Once+-- it is closed it can no longer be used for either input or output,+-- though an implementation cannot re-use its storage while references+-- remain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.+-- The string produced by showing a handle is system dependent; it should+-- include enough information to identify the handle for debugging. A+-- handle is equal according to <a>==</a> only to itself; no attempt is+-- made to compare the internal state of different handles for equality.+data Handle :: *++-- | A handle managing input from the Haskell program's standard input+-- channel.+stdin :: Handle++-- | A handle managing output to the Haskell program's standard output+-- channel.+stdout :: Handle++-- | A handle managing output to the Haskell program's standard error+-- channel.+stderr :: Handle++-- | <tt><a>withFile</a> name mode act</tt> opens a file using+-- <a>openFile</a> and passes the resulting handle to the computation+-- <tt>act</tt>. The handle will be closed on exit from <a>withFile</a>,+-- whether by normal termination or by raising an exception. If closing+-- the handle raises an exception, then this exception will be raised by+-- <a>withFile</a> rather than any exception raised by <tt>act</tt>.+withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r++-- | Computation <a>openFile</a> <tt>file mode</tt> allocates and returns a+-- new, open handle to manage the file <tt>file</tt>. It manages input if+-- <tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is+-- <a>WriteMode</a> or <a>AppendMode</a>, and both input and output if+-- mode is <a>ReadWriteMode</a>.+-- +-- If the file does not exist and it is opened for output, it should be+-- created as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the+-- file already exists, then it should be truncated to zero length. Some+-- operating systems delete empty files, so there is no guarantee that+-- the file will exist following an <a>openFile</a> with <tt>mode</tt>+-- <a>WriteMode</a> unless it is subsequently written to successfully.+-- The handle is positioned at the end of the file if <tt>mode</tt> is+-- <a>AppendMode</a>, and otherwise at the beginning (in which case its+-- internal position is 0). The initial buffer mode is+-- implementation-dependent.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isAlreadyInUseError</tt> if the file is already open and+-- cannot be reopened;</li>+-- <li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>+-- <li><tt>isPermissionError</tt> if the user does not have permission to+-- open the file.</li>+-- </ul>+openFile :: FilePath -> IOMode -> IO Handle++-- | See <tt>System.IO.openFile</tt>+data IOMode :: *+ReadMode :: IOMode+WriteMode :: IOMode+AppendMode :: IOMode+ReadWriteMode :: IOMode++-- | Computation <a>hClose</a> <tt>hdl</tt> makes handle <tt>hdl</tt>+-- closed. Before the computation finishes, if <tt>hdl</tt> is writable+-- its buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>+-- on a handle that has already been closed has no effect; doing so is+-- not an error. All other operations on a closed handle will fail. If+-- <a>hClose</a> fails for any reason, any further operations (apart from+-- <a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had+-- been successfully closed.+hClose :: Handle -> IO ()++-- | The <a>readFile</a> function reads a file and returns the contents of+-- the file as a string. The file is read lazily, on demand, as with+-- <a>getContents</a>.+readFile :: FilePath -> IO String++-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the+-- string <tt>str</tt>, to the file <tt>file</tt>.+writeFile :: FilePath -> String -> IO ()++-- | The computation <a>appendFile</a> <tt>file str</tt> function appends+-- the string <tt>str</tt>, to the file <tt>file</tt>.+-- +-- Note that <a>writeFile</a> and <a>appendFile</a> write a literal+-- string to a file. To write a value of any printable type, as with+-- <a>print</a>, use the <a>show</a> function to convert the value to a+-- string first.+-- +-- <pre>+-- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])+-- </pre>+appendFile :: FilePath -> String -> IO ()++-- | For a handle <tt>hdl</tt> which attached to a physical file,+-- <a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit+-- bytes.+hFileSize :: Handle -> IO Integer++-- | <a>hSetFileSize</a> <tt>hdl</tt> <tt>size</tt> truncates the physical+-- file with handle <tt>hdl</tt> to <tt>size</tt> bytes.+hSetFileSize :: Handle -> Integer -> IO ()++-- | For a readable handle <tt>hdl</tt>, <a>hIsEOF</a> <tt>hdl</tt> returns+-- <a>True</a> if no further input can be taken from <tt>hdl</tt> or for+-- a physical file, if the current I/O position is equal to the length of+-- the file. Otherwise, it returns <a>False</a>.+-- +-- NOTE: <a>hIsEOF</a> may block, because it has to attempt to read from+-- the stream to determine whether there is any more data to be read.+hIsEOF :: Handle -> IO Bool++-- | The computation <a>isEOF</a> is identical to <a>hIsEOF</a>, except+-- that it works only on <a>stdin</a>.+isEOF :: IO Bool++-- | Three kinds of buffering are supported: line-buffering,+-- block-buffering or no-buffering. These modes have the following+-- effects. For output, items are written out, or <i>flushed</i>, from+-- the internal buffer according to the buffer mode:+-- +-- <ul>+-- <li><i>line-buffering</i>: the entire output buffer is flushed+-- whenever a newline is output, the buffer overflows, a+-- <tt>System.IO.hFlush</tt> is issued, or the handle is closed.</li>+-- <li><i>block-buffering</i>: the entire buffer is written out whenever+-- it overflows, a <tt>System.IO.hFlush</tt> is issued, or the handle is+-- closed.</li>+-- <li><i>no-buffering</i>: output is written immediately, and never+-- stored in the buffer.</li>+-- </ul>+-- +-- An implementation is free to flush the buffer more frequently, but not+-- less frequently, than specified above. The output buffer is emptied as+-- soon as it has been written out.+-- +-- Similarly, input occurs according to the buffer mode for the handle:+-- +-- <ul>+-- <li><i>line-buffering</i>: when the buffer for the handle is not+-- empty, the next item is obtained from the buffer; otherwise, when the+-- buffer is empty, characters up to and including the next newline+-- character are read into the buffer. No characters are available until+-- the newline character is available or the buffer is full.</li>+-- <li><i>block-buffering</i>: when the buffer for the handle becomes+-- empty, the next block of data is read into the buffer.</li>+-- <li><i>no-buffering</i>: the next input item is read and returned. The+-- <tt>System.IO.hLookAhead</tt> operation implies that even a+-- no-buffered handle may require a one-character buffer.</li>+-- </ul>+-- +-- The default buffering mode when a handle is opened is+-- implementation-dependent and may depend on the file system object+-- which is attached to that handle. For most implementations, physical+-- files will normally be block-buffered and terminals will normally be+-- line-buffered.+data BufferMode :: *++-- | buffering is disabled if possible.+NoBuffering :: BufferMode++-- | line-buffering should be enabled if possible.+LineBuffering :: BufferMode++-- | block-buffering should be enabled if possible. The size of the buffer+-- is <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is+-- otherwise implementation-dependent.+BlockBuffering :: Maybe Int -> BufferMode++-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of+-- buffering for handle <tt>hdl</tt> on subsequent reads and writes.+-- +-- If the buffer mode is changed from <a>BlockBuffering</a> or+-- <a>LineBuffering</a> to <a>NoBuffering</a>, then+-- +-- <ul>+-- <li>if <tt>hdl</tt> is writable, the buffer is flushed as for+-- <a>hFlush</a>;</li>+-- <li>if <tt>hdl</tt> is not writable, the contents of the buffer is+-- discarded.</li>+-- </ul>+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isPermissionError</tt> if the handle has already been used for+-- reading or writing and the implementation does not allow the buffering+-- mode to be changed.</li>+-- </ul>+hSetBuffering :: Handle -> BufferMode -> IO ()++-- | Computation <a>hGetBuffering</a> <tt>hdl</tt> returns the current+-- buffering mode for <tt>hdl</tt>.+hGetBuffering :: Handle -> IO BufferMode++-- | The action <a>hFlush</a> <tt>hdl</tt> causes any items buffered for+-- output in handle <tt>hdl</tt> to be sent immediately to the operating+-- system.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isFullError</tt> if the device is full;</li>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded. It is unspecified whether the characters in the buffer are+-- discarded or retained under these circumstances.</li>+-- </ul>+hFlush :: Handle -> IO ()++-- | Computation <a>hGetPosn</a> <tt>hdl</tt> returns the current I/O+-- position of <tt>hdl</tt> as a value of the abstract type+-- <a>HandlePosn</a>.+hGetPosn :: Handle -> IO HandlePosn++-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position+-- <tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the+-- position of <tt>hdl</tt> to the position it held at the time of the+-- call to <a>hGetPosn</a>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded.</li>+-- </ul>+hSetPosn :: HandlePosn -> IO ()+data HandlePosn :: *++-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of+-- handle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>+-- is given in terms of 8-bit bytes.+-- +-- If <tt>hdl</tt> is block- or line-buffered, then seeking to a position+-- which is not in the current buffer will first cause any items in the+-- output buffer to be written to the device, and then cause the input+-- buffer to be discarded. Some handles may not be seekable (see+-- <a>hIsSeekable</a>), or only support a subset of the possible+-- positioning operations (for instance, it may only be possible to seek+-- to the end of a tape, or to a positive offset from the beginning or+-- current position). It is not possible to set a negative I/O position,+-- or for a physical file, an I/O position beyond the current+-- end-of-file.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or+-- does not support the requested seek mode.</li>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded.</li>+-- </ul>+hSeek :: Handle -> SeekMode -> Integer -> IO ()++-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode+-- i</tt>.+data SeekMode :: *++-- | the position of <tt>hdl</tt> is set to <tt>i</tt>.+AbsoluteSeek :: SeekMode++-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the+-- current position.+RelativeSeek :: SeekMode++-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end+-- of the file.+SeekFromEnd :: SeekMode++-- | Computation <a>hTell</a> <tt>hdl</tt> returns the current position of+-- the handle <tt>hdl</tt>, as the number of bytes from the beginning of+-- the file. The value returned may be subsequently passed to+-- <a>hSeek</a> to reposition the handle to the current position.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isIllegalOperationError</tt> if the Handle is not+-- seekable.</li>+-- </ul>+hTell :: Handle -> IO Integer+hIsOpen :: Handle -> IO Bool+hIsClosed :: Handle -> IO Bool+hIsReadable :: Handle -> IO Bool+hIsWritable :: Handle -> IO Bool+hIsSeekable :: Handle -> IO Bool++-- | Is the handle connected to a terminal?+hIsTerminalDevice :: Handle -> IO Bool++-- | Set the echoing status of a handle connected to a terminal.+hSetEcho :: Handle -> Bool -> IO ()++-- | Get the echoing status of a handle connected to a terminal.+hGetEcho :: Handle -> IO Bool++-- | <a>hShow</a> is in the <a>IO</a> monad, and gives more comprehensive+-- output than the (pure) instance of <a>Show</a> for <a>Handle</a>.+hShow :: Handle -> IO String++-- | Computation <a>hWaitForInput</a> <tt>hdl t</tt> waits until input is+-- available on handle <tt>hdl</tt>. It returns <a>True</a> as soon as+-- input is available on <tt>hdl</tt>, or <a>False</a> if no input is+-- available within <tt>t</tt> milliseconds. Note that+-- <a>hWaitForInput</a> waits until one or more full <i>characters</i>+-- are available, which means that it needs to do decoding, and hence may+-- fail with a decoding error.+-- +-- If <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits+-- indefinitely.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isEOFError</tt> if the end of file has been reached.</li>+-- <li>a decoding error, if the input begins with an invalid byte+-- sequence in this Handle's encoding.</li>+-- </ul>+hWaitForInput :: Handle -> Int -> IO Bool++-- | Computation <a>hReady</a> <tt>hdl</tt> indicates whether at least one+-- item is available for input from handle <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isEOFError</tt> if the end of file has been+-- reached.</li>+-- </ul>+hReady :: Handle -> IO Bool++-- | Computation <a>hGetChar</a> <tt>hdl</tt> reads a character from the+-- file or channel managed by <tt>hdl</tt>, blocking until a character is+-- available.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file has been reached.</li>+-- </ul>+hGetChar :: Handle -> IO Char++-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or+-- channel managed by <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file is encountered when reading+-- the <i>first</i> character of the line.</li>+-- </ul>+-- +-- If <a>hGetLine</a> encounters end-of-file at any other point while+-- reading in a line, it is treated as a line terminator and the+-- (partial) line is returned.+hGetLine :: Handle -> IO String++-- | Computation <a>hLookAhead</a> returns the next character from the+-- handle without removing it from the input buffer, blocking until a+-- character is available.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isEOFError</tt> if the end of file has been reached.</li>+-- </ul>+hLookAhead :: Handle -> IO Char++-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of+-- characters corresponding to the unread portion of the channel or file+-- managed by <tt>hdl</tt>, which is put into an intermediate state,+-- <i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,+-- but items are read from <tt>hdl</tt> on demand and accumulated in a+-- special list returned by <a>hGetContents</a> <tt>hdl</tt>.+-- +-- Any operation that fails because a handle is closed, also fails if a+-- handle is semi-closed. The only exception is <tt>hClose</tt>. A+-- semi-closed handle becomes closed:+-- +-- <ul>+-- <li>if <tt>hClose</tt> is applied to it;</li>+-- <li>if an I/O error occurs when reading an item from the handle;</li>+-- <li>or once the entire contents of the handle has been read.</li>+-- </ul>+-- +-- Once a semi-closed handle becomes closed, the contents of the+-- associated list becomes fixed. The contents of this final list is only+-- partially specified: it will contain at least all the items of the+-- stream that were evaluated prior to the handle becoming closed.+-- +-- Any I/O errors encountered while a handle is semi-closed are simply+-- discarded.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file has been reached.</li>+-- </ul>+hGetContents :: Handle -> IO String++-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character+-- <tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters+-- may be buffered if buffering is enabled for <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isFullError</a> if the device is full; or</li>+-- <li><a>isPermissionError</a> if another system resource limit would be+-- exceeded.</li>+-- </ul>+hPutChar :: Handle -> Char -> IO ()++-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>+-- to the file or channel managed by <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isFullError</a> if the device is full; or</li>+-- <li><a>isPermissionError</a> if another system resource limit would be+-- exceeded.</li>+-- </ul>+hPutStr :: Handle -> String -> IO ()++-- | The same as <a>hPutStr</a>, but adds a newline character.+hPutStrLn :: Handle -> String -> IO ()++-- | Computation <a>hPrint</a> <tt>hdl t</tt> writes the string+-- representation of <tt>t</tt> given by the <a>shows</a> function to the+-- file or channel managed by <tt>hdl</tt> and appends a newline.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isFullError</tt> if the device is full;+-- or</li>+-- <li><tt>System.IO.Error.isPermissionError</tt> if another system+-- resource limit would be exceeded.</li>+-- </ul>+hPrint :: Show a => Handle -> a -> IO ()++-- | The <a>interact</a> function takes a function of type+-- <tt>String->String</tt> as its argument. The entire input from the+-- standard input device is passed to this function as its argument, and+-- the resulting string is output on the standard output device.+interact :: (String -> String) -> IO ()++-- | Write a character to the standard output device (same as+-- <a>hPutChar</a> <a>stdout</a>).+putChar :: Char -> IO ()++-- | Write a string to the standard output device (same as <a>hPutStr</a>+-- <a>stdout</a>).+putStr :: String -> IO ()++-- | The same as <a>putStr</a>, but adds a newline character.+putStrLn :: String -> IO ()++-- | The <a>print</a> function outputs a value of any printable type to the+-- standard output device. Printable types are those that are instances+-- of class <a>Show</a>; <a>print</a> converts values to strings for+-- output using the <a>show</a> operation and adds a newline.+-- +-- For example, a program to print the first 20 integers and their powers+-- of 2 could be written as:+-- +-- <pre>+-- main = print ([(n, 2^n) | n <- [0..19]])+-- </pre>+print :: Show a => a -> IO ()++-- | Read a character from the standard input device (same as+-- <a>hGetChar</a> <a>stdin</a>).+getChar :: IO Char++-- | Read a line from the standard input device (same as <a>hGetLine</a>+-- <a>stdin</a>).+getLine :: IO String++-- | The <a>getContents</a> operation returns all user input as a single+-- string, which is read lazily as it is needed (same as+-- <a>hGetContents</a> <a>stdin</a>).+getContents :: IO String++-- | The <a>readIO</a> function is similar to <a>read</a> except that it+-- signals parse failure to the <a>IO</a> monad instead of terminating+-- the program.+readIO :: Read a => String -> IO a++-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.+readLn :: Read a => IO a++module Data.Array++-- | The type of immutable non-strict (boxed) arrays with indices in+-- <tt>i</tt> and elements in <tt>e</tt>.+data Ix i => Array i e :: * -> * -> *++-- | Construct an array with the specified bounds and containing values for+-- given indices within these bounds.+-- +-- The array is undefined (i.e. bottom) if any index in the list is out+-- of bounds. If any two associations in the list have the same index,+-- the value at that index is undefined (i.e. bottom).+-- +-- Because the indices must be checked for these errors, <a>array</a> is+-- strict in the bounds argument and in the indices of the association+-- list, but non-strict in the values. Thus, recurrences such as the+-- following are possible:+-- +-- <pre>+-- a = array (1,100) ((1,1) : [(i, i * a!(i-1)) | i <- [2..100]])+-- </pre>+-- +-- Not every index within the bounds of the array need appear in the+-- association list, but the values associated with indices that do not+-- appear will be undefined (i.e. bottom).+-- +-- If, in any dimension, the lower bound is greater than the upper bound,+-- then the array is legal, but empty. Indexing an empty array always+-- gives an array-bounds error, but <a>bounds</a> still yields the bounds+-- with which the array was constructed.+array :: Ix i => (i, i) -> [(i, e)] -> Array i e++-- | Construct an array from a pair of bounds and a list of values in index+-- order.+listArray :: Ix i => (i, i) -> [e] -> Array i e++-- | The <a>accumArray</a> function deals with repeated indices in the+-- association list using an <i>accumulating function</i> which combines+-- the values of associations with the same index. For example, given a+-- list of values of some index type, <tt>hist</tt> produces a histogram+-- of the number of occurrences of each index within a specified range:+-- +-- <pre>+-- hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b+-- hist bnds is = accumArray (+) 0 bnds [(i, 1) | i<-is, inRange bnds i]+-- </pre>+-- +-- If the accumulating function is strict, then <a>accumArray</a> is+-- strict in the values, as well as the indices, in the association list.+-- Thus, unlike ordinary arrays built with <a>array</a>, accumulated+-- arrays should not in general be recursive.+accumArray :: Ix i => (e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e++-- | The value at the given index in an array.+(!) :: Ix i => Array i e -> i -> e++-- | The bounds with which an array was constructed.+bounds :: Ix i => Array i e -> (i, i)++-- | The list of indices of an array in ascending order.+indices :: Ix i => Array i e -> [i]++-- | The list of elements of an array in index order.+elems :: Ix i => Array i e -> [e]++-- | The list of associations of an array in index order.+assocs :: Ix i => Array i e -> [(i, e)]++-- | Constructs an array identical to the first argument except that it has+-- been updated by the associations in the right argument. For example,+-- if <tt>m</tt> is a 1-origin, <tt>n</tt> by <tt>n</tt> matrix, then+-- +-- <pre>+-- m//[((i,i), 0) | i <- [1..n]]+-- </pre>+-- +-- is the same matrix, except with the diagonal zeroed.+-- +-- Repeated indices in the association list are handled as for+-- <a>array</a>: the resulting array is undefined (i.e. bottom),+(//) :: Ix i => Array i e -> [(i, e)] -> Array i e++-- | <tt><a>accum</a> f</tt> takes an array and an association list and+-- accumulates pairs from the list into the array with the accumulating+-- function <tt>f</tt>. Thus <a>accumArray</a> can be defined using+-- <a>accum</a>:+-- +-- <pre>+-- accumArray f z b = accum f (array b [(i, z) | i <- range b])+-- </pre>+accum :: Ix i => (e -> a -> e) -> Array i e -> [(i, a)] -> Array i e++-- | <a>ixmap</a> allows for transformations on array indices. It may be+-- thought of as providing function composition on the right with the+-- mapping that the original array embodies.+-- +-- A similar transformation of array values may be achieved using+-- <a>fmap</a> from the <a>Array</a> instance of the <a>Functor</a>+-- class.+ixmap :: (Ix i, Ix j) => (i, i) -> (i -> j) -> Array j e -> Array i e
+ data/haskell98.txt view
@@ -0,0 +1,2532 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Compatibility with Haskell 98+-- +-- This package provides compatibility with the modules of Haskell 98 and+-- the FFI addendum, by means of wrappers around modules from the base+-- package (which in many cases have additional features). However+-- Prelude, Numeric and Foreign are provided directly by the base+-- package.+@package haskell98+@version 1.1.0.1++module MarshalUtils++module MarshalError++-- | An abstract type that contains a value for each variant of+-- <a>IOError</a>.+data IOErrorType :: *++-- | Construct an <a>IOError</a> of the given type where the second+-- argument describes the error location and the third and fourth+-- argument contain the file handle and file path of the file involved in+-- the error if applicable.+mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError++-- | I/O error where the operation failed because one of its arguments+-- already exists.+alreadyExistsErrorType :: IOErrorType++-- | I/O error where the operation failed because one of its arguments does+-- not exist.+doesNotExistErrorType :: IOErrorType++-- | I/O error where the operation failed because one of its arguments is a+-- single-use resource, which is already being used.+alreadyInUseErrorType :: IOErrorType++-- | I/O error where the operation failed because the device is full.+fullErrorType :: IOErrorType++-- | I/O error where the operation failed because the end of file has been+-- reached.+eofErrorType :: IOErrorType++-- | I/O error where the operation is not possible.+illegalOperationErrorType :: IOErrorType++-- | I/O error where the operation failed because the user does not have+-- sufficient operating system privilege to perform that operation.+permissionErrorType :: IOErrorType++-- | I/O error that is programmer-defined.+userErrorType :: IOErrorType++-- | Adds a location description and maybe a file path and file handle to+-- an <a>IOError</a>. If any of the file handle or file path is not given+-- the corresponding value in the <a>IOError</a> remains unaltered.+annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOError++module MarshalArray++module MarshalAlloc++module CTypes++module CForeign++module CError++module Time++-- | A representation of the internal clock time. Clock times may be+-- compared, converted to strings, or converted to an external calendar+-- time <a>CalendarTime</a> for I/O or other manipulations.+data ClockTime :: *++-- | A month of the year.+data Month :: *+January :: Month+February :: Month+March :: Month+April :: Month+May :: Month+June :: Month+July :: Month+August :: Month+September :: Month+October :: Month+November :: Month+December :: Month++-- | A day of the week.+data Day :: *+Sunday :: Day+Monday :: Day+Tuesday :: Day+Wednesday :: Day+Thursday :: Day+Friday :: Day+Saturday :: Day++-- | <a>CalendarTime</a> is a user-readable and manipulable representation+-- of the internal <a>ClockTime</a> type.+data CalendarTime :: *+CalendarTime :: Int -> Month -> Int -> Int -> Int -> Int -> Integer -> Day -> Int -> String -> Int -> Bool -> CalendarTime++-- | Year (pre-Gregorian dates are inaccurate)+ctYear :: CalendarTime -> Int++-- | Month of the year+ctMonth :: CalendarTime -> Month++-- | Day of the month (1 to 31)+ctDay :: CalendarTime -> Int++-- | Hour of the day (0 to 23)+ctHour :: CalendarTime -> Int++-- | Minutes (0 to 59)+ctMin :: CalendarTime -> Int++-- | Seconds (0 to 61, allowing for up to two leap seconds)+ctSec :: CalendarTime -> Int++-- | Picoseconds+ctPicosec :: CalendarTime -> Integer++-- | Day of the week+ctWDay :: CalendarTime -> Day++-- | Day of the year (0 to 364, or 365 in leap years)+ctYDay :: CalendarTime -> Int++-- | Name of the time zone+ctTZName :: CalendarTime -> String++-- | Variation from UTC in seconds+ctTZ :: CalendarTime -> Int++-- | <a>True</a> if Daylight Savings Time would be in effect, and+-- <a>False</a> otherwise+ctIsDST :: CalendarTime -> Bool++-- | records the difference between two clock times in a user-readable way.+data TimeDiff :: *+TimeDiff :: Int -> Int -> Int -> Int -> Int -> Int -> Integer -> TimeDiff+tdYear :: TimeDiff -> Int+tdMonth :: TimeDiff -> Int+tdDay :: TimeDiff -> Int+tdHour :: TimeDiff -> Int+tdMin :: TimeDiff -> Int+tdSec :: TimeDiff -> Int+tdPicosec :: TimeDiff -> Integer+getClockTime :: IO ClockTime++-- | <tt><a>addToClockTime</a> d t</tt> adds a time difference <tt>d</tt>+-- and a clock time <tt>t</tt> to yield a new clock time. The difference+-- <tt>d</tt> may be either positive or negative.+addToClockTime :: TimeDiff -> ClockTime -> ClockTime++-- | <tt><a>diffClockTimes</a> t1 t2</tt> returns the difference between+-- two clock times <tt>t1</tt> and <tt>t2</tt> as a <a>TimeDiff</a>.+diffClockTimes :: ClockTime -> ClockTime -> TimeDiff++-- | converts an internal clock time to a local time, modified by the+-- timezone and daylight savings time settings in force at the time of+-- conversion. Because of this dependence on the local environment,+-- <a>toCalendarTime</a> is in the <a>IO</a> monad.+toCalendarTime :: ClockTime -> IO CalendarTime++-- | converts an internal clock time into a <a>CalendarTime</a> in standard+-- UTC format.+toUTCTime :: ClockTime -> CalendarTime++-- | converts a <a>CalendarTime</a> into the corresponding internal+-- <a>ClockTime</a>, ignoring the contents of the <a>ctWDay</a>,+-- <a>ctYDay</a>, <a>ctTZName</a> and <a>ctIsDST</a> fields.+toClockTime :: CalendarTime -> ClockTime++-- | formats calendar times using local conventions.+calendarTimeToString :: CalendarTime -> String++-- | formats calendar times using local conventions and a formatting+-- string. The formatting string is that understood by the ISO C+-- <tt>strftime()</tt> function.+formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String++module Locale+data TimeLocale :: *+TimeLocale :: [(String, String)] -> [(String, String)] -> [(String, String)] -> (String, String) -> String -> String -> String -> String -> TimeLocale+defaultTimeLocale :: TimeLocale++module List++-- | The <a>elemIndex</a> function returns the index of the first element+-- in the given list which is equal (by <a>==</a>) to the query element,+-- or <a>Nothing</a> if there is no such element.+elemIndex :: Eq a => a -> [a] -> Maybe Int++-- | The <a>elemIndices</a> function extends <a>elemIndex</a>, by returning+-- the indices of all elements equal to the query element, in ascending+-- order.+elemIndices :: Eq a => a -> [a] -> [Int]++-- | The <a>find</a> function takes a predicate and a list and returns the+-- first element in the list matching the predicate, or <a>Nothing</a> if+-- there is no such element.+find :: (a -> Bool) -> [a] -> Maybe a++-- | The <a>findIndex</a> function takes a predicate and a list and returns+-- the index of the first element in the list satisfying the predicate,+-- or <a>Nothing</a> if there is no such element.+findIndex :: (a -> Bool) -> [a] -> Maybe Int++-- | The <a>findIndices</a> function extends <a>findIndex</a>, by returning+-- the indices of all elements satisfying the predicate, in ascending+-- order.+findIndices :: (a -> Bool) -> [a] -> [Int]++-- | <i>O(n^2)</i>. The <a>nub</a> function removes duplicate elements from+-- a list. In particular, it keeps only the first occurrence of each+-- element. (The name <a>nub</a> means `essence'.) It is a special case+-- of <a>nubBy</a>, which allows the programmer to supply their own+-- equality test.+nub :: Eq a => [a] -> [a]++-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses+-- a user-supplied equality predicate instead of the overloaded <a>==</a>+-- function.+nubBy :: (a -> a -> Bool) -> [a] -> [a]++-- | <a>delete</a> <tt>x</tt> removes the first occurrence of <tt>x</tt>+-- from its list argument. For example,+-- +-- <pre>+-- delete 'a' "banana" == "bnana"+-- </pre>+-- +-- It is a special case of <a>deleteBy</a>, which allows the programmer+-- to supply their own equality test.+delete :: Eq a => a -> [a] -> [a]++-- | The <a>deleteBy</a> function behaves like <a>delete</a>, but takes a+-- user-supplied equality predicate.+deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]++-- | The <a>\\</a> function is list difference ((non-associative). In the+-- result of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of+-- each element of <tt>ys</tt> in turn (if any) has been removed from+-- <tt>xs</tt>. Thus+-- +-- <pre>+-- (xs ++ ys) \\ xs == ys.+-- </pre>+-- +-- It is a special case of <a>deleteFirstsBy</a>, which allows the+-- programmer to supply their own equality test.+(\\) :: Eq a => [a] -> [a] -> [a]++-- | The <a>deleteFirstsBy</a> function takes a predicate and two lists and+-- returns the first list with the first occurrence of each element of+-- the second list removed.+deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>union</a> function returns the list union of the two lists. For+-- example,+-- +-- <pre>+-- "dog" `union` "cow" == "dogcw"+-- </pre>+-- +-- Duplicates, and elements of the first list, are removed from the the+-- second list, but if the first list contains duplicates, so will the+-- result. It is a special case of <a>unionBy</a>, which allows the+-- programmer to supply their own equality test.+union :: Eq a => [a] -> [a] -> [a]++-- | The <a>unionBy</a> function is the non-overloaded version of+-- <a>union</a>.+unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>intersect</a> function takes the list intersection of two+-- lists. For example,+-- +-- <pre>+-- [1,2,3,4] `intersect` [2,4,6,8] == [2,4]+-- </pre>+-- +-- If the first list contains duplicates, so will the result.+-- +-- <pre>+-- [1,2,2,3,4] `intersect` [6,4,4,2] == [2,2,4]+-- </pre>+-- +-- It is a special case of <a>intersectBy</a>, which allows the+-- programmer to supply their own equality test.+intersect :: Eq a => [a] -> [a] -> [a]++-- | The <a>intersectBy</a> function is the non-overloaded version of+-- <a>intersect</a>.+intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]++-- | The <a>intersperse</a> function takes an element and a list and+-- `intersperses' that element between the elements of the list. For+-- example,+-- +-- <pre>+-- intersperse ',' "abcde" == "a,b,c,d,e"+-- </pre>+intersperse :: a -> [a] -> [a]++-- | The <a>transpose</a> function transposes the rows and columns of its+-- argument. For example,+-- +-- <pre>+-- transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]+-- </pre>+transpose :: [[a]] -> [[a]]++-- | The <a>partition</a> function takes a predicate a list and returns the+-- pair of lists of elements which do and do not satisfy the predicate,+-- respectively; i.e.,+-- +-- <pre>+-- partition p xs == (filter p xs, filter (not . p) xs)+-- </pre>+partition :: (a -> Bool) -> [a] -> ([a], [a])++-- | The <a>group</a> function takes a list and returns a list of lists+-- such that the concatenation of the result is equal to the argument.+-- Moreover, each sublist in the result contains only equal elements. For+-- example,+-- +-- <pre>+-- group "Mississippi" = ["M","i","ss","i","ss","i","pp","i"]+-- </pre>+-- +-- It is a special case of <a>groupBy</a>, which allows the programmer to+-- supply their own equality test.+group :: Eq a => [a] -> [[a]]++-- | The <a>groupBy</a> function is the non-overloaded version of+-- <a>group</a>.+groupBy :: (a -> a -> Bool) -> [a] -> [[a]]++-- | The <a>inits</a> function returns all initial segments of the+-- argument, shortest first. For example,+-- +-- <pre>+-- inits "abc" == ["","a","ab","abc"]+-- </pre>+-- +-- Note that <a>inits</a> has the following strictness property:+-- <tt>inits _|_ = [] : _|_</tt>+inits :: [a] -> [[a]]++-- | The <a>tails</a> function returns all final segments of the argument,+-- longest first. For example,+-- +-- <pre>+-- tails "abc" == ["abc", "bc", "c",""]+-- </pre>+-- +-- Note that <a>tails</a> has the following strictness property:+-- <tt>tails _|_ = _|_ : _|_</tt>+tails :: [a] -> [[a]]++-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>+-- iff the first list is a prefix of the second.+isPrefixOf :: Eq a => [a] -> [a] -> Bool++-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>+-- iff the first list is a suffix of the second. Both lists must be+-- finite.+isSuffixOf :: Eq a => [a] -> [a] -> Bool++-- | The <a>mapAccumL</a> function behaves like a combination of <a>map</a>+-- and <a>foldl</a>; it applies a function to each element of a list,+-- passing an accumulating parameter from left to right, and returning a+-- final value of this accumulator together with the new list.+mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])++-- | The <a>mapAccumR</a> function behaves like a combination of <a>map</a>+-- and <a>foldr</a>; it applies a function to each element of a list,+-- passing an accumulating parameter from right to left, and returning a+-- final value of this accumulator together with the new list.+mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])++-- | The <a>sort</a> function implements a stable sorting algorithm. It is+-- a special case of <a>sortBy</a>, which allows the programmer to supply+-- their own comparison function.+sort :: Ord a => [a] -> [a]++-- | The <a>sortBy</a> function is the non-overloaded version of+-- <a>sort</a>.+sortBy :: (a -> a -> Ordering) -> [a] -> [a]++-- | The <a>insert</a> function takes an element and a list and inserts the+-- element into the list at the last position where it is still less than+-- or equal to the next element. In particular, if the list is sorted+-- before the call, the result will also be sorted. It is a special case+-- of <a>insertBy</a>, which allows the programmer to supply their own+-- comparison function.+insert :: Ord a => a -> [a] -> [a]++-- | The non-overloaded version of <a>insert</a>.+insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]++-- | The <a>maximumBy</a> function takes a comparison function and a list+-- and returns the greatest element of the list by the comparison+-- function. The list must be finite and non-empty.+maximumBy :: (a -> a -> Ordering) -> [a] -> a++-- | The <a>minimumBy</a> function takes a comparison function and a list+-- and returns the least element of the list by the comparison function.+-- The list must be finite and non-empty.+minimumBy :: (a -> a -> Ordering) -> [a] -> a++-- | The <a>genericLength</a> function is an overloaded version of+-- <a>length</a>. In particular, instead of returning an <a>Int</a>, it+-- returns any type which is an instance of <a>Num</a>. It is, however,+-- less efficient than <a>length</a>.+genericLength :: Num i => [b] -> i++-- | The <a>genericTake</a> function is an overloaded version of+-- <a>take</a>, which accepts any <a>Integral</a> value as the number of+-- elements to take.+genericTake :: Integral i => i -> [a] -> [a]++-- | The <a>genericDrop</a> function is an overloaded version of+-- <a>drop</a>, which accepts any <a>Integral</a> value as the number of+-- elements to drop.+genericDrop :: Integral i => i -> [a] -> [a]++-- | The <a>genericSplitAt</a> function is an overloaded version of+-- <a>splitAt</a>, which accepts any <a>Integral</a> value as the+-- position at which to split.+genericSplitAt :: Integral i => i -> [b] -> ([b], [b])++-- | The <a>genericIndex</a> function is an overloaded version of+-- <a>!!</a>, which accepts any <a>Integral</a> value as the index.+genericIndex :: Integral a => [b] -> a -> b++-- | The <a>genericReplicate</a> function is an overloaded version of+-- <a>replicate</a>, which accepts any <a>Integral</a> value as the+-- number of repetitions to make.+genericReplicate :: Integral i => i -> a -> [a]++-- | The <a>zip4</a> function takes four lists and returns a list of+-- quadruples, analogous to <a>zip</a>.+zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]++-- | The <a>zip5</a> function takes five lists and returns a list of+-- five-tuples, analogous to <a>zip</a>.+zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]++-- | The <a>zip6</a> function takes six lists and returns a list of+-- six-tuples, analogous to <a>zip</a>.+zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]++-- | The <a>zip7</a> function takes seven lists and returns a list of+-- seven-tuples, analogous to <a>zip</a>.+zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]++-- | The <a>zipWith4</a> function takes a function which combines four+-- elements, as well as four lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]++-- | The <a>zipWith5</a> function takes a function which combines five+-- elements, as well as five lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]++-- | The <a>zipWith6</a> function takes a function which combines six+-- elements, as well as six lists and returns a list of their point-wise+-- combination, analogous to <a>zipWith</a>.+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]++-- | The <a>zipWith7</a> function takes a function which combines seven+-- elements, as well as seven lists and returns a list of their+-- point-wise combination, analogous to <a>zipWith</a>.+zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]++-- | The <a>unzip4</a> function takes a list of quadruples and returns four+-- lists, analogous to <a>unzip</a>.+unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])++-- | The <a>unzip5</a> function takes a list of five-tuples and returns+-- five lists, analogous to <a>unzip</a>.+unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])++-- | The <a>unzip6</a> function takes a list of six-tuples and returns six+-- lists, analogous to <a>unzip</a>.+unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])++-- | The <a>unzip7</a> function takes a list of seven-tuples and returns+-- seven lists, analogous to <a>unzip</a>.+unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])++-- | The <a>unfoldr</a> function is a `dual' to <a>foldr</a>: while+-- <a>foldr</a> reduces a list to a summary value, <a>unfoldr</a> builds+-- a list from a seed value. The function takes the element and returns+-- <a>Nothing</a> if it is done producing the list or returns <a>Just</a>+-- <tt>(a,b)</tt>, in which case, <tt>a</tt> is a prepended to the list+-- and <tt>b</tt> is used as the next element in a recursive call. For+-- example,+-- +-- <pre>+-- iterate f == unfoldr (\x -> Just (x, f x))+-- </pre>+-- +-- In some cases, <a>unfoldr</a> can undo a <a>foldr</a> operation:+-- +-- <pre>+-- unfoldr f' (foldr f z xs) == xs+-- </pre>+-- +-- if the following holds:+-- +-- <pre>+-- f' (f x y) = Just (x,y)+-- f' z = Nothing+-- </pre>+-- +-- A simple use of unfoldr:+-- +-- <pre>+-- unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10+-- [10,9,8,7,6,5,4,3,2,1]+-- </pre>+unfoldr :: (b -> Maybe (a, b)) -> b -> [a]++-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>+-- to each element of <tt>xs</tt>, i.e.,+-- +-- <pre>+-- map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]+-- map f [x1, x2, ...] == [f x1, f x2, ...]+-- </pre>+map :: (a -> b) -> [a] -> [b]++-- | Append two lists, i.e.,+-- +-- <pre>+-- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]+-- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]+-- </pre>+-- +-- If the first list is not finite, the result is the first list.+(++) :: [a] -> [a] -> [a]++-- | Concatenate a list of lists.+concat :: [[a]] -> [a]++-- | <a>filter</a>, applied to a predicate and a list, returns the list of+-- those elements that satisfy the predicate; i.e.,+-- +-- <pre>+-- filter p xs = [ x | x <- xs, p x]+-- </pre>+filter :: (a -> Bool) -> [a] -> [a]++-- | Extract the first element of a list, which must be non-empty.+head :: [a] -> a++-- | Extract the last element of a list, which must be finite and+-- non-empty.+last :: [a] -> a++-- | Extract the elements after the head of a list, which must be+-- non-empty.+tail :: [a] -> [a]++-- | Return all the elements of a list except the last one. The list must+-- be non-empty.+init :: [a] -> [a]++-- | Test whether a list is empty.+null :: [a] -> Bool++-- | <i>O(n)</i>. <a>length</a> returns the length of a finite list as an+-- <a>Int</a>. It is an instance of the more general+-- <tt>Data.List.genericLength</tt>, the result type of which may be any+-- kind of number.+length :: [a] -> Int++-- | List index (subscript) operator, starting from 0. It is an instance of+-- the more general <tt>Data.List.genericIndex</tt>, which takes an index+-- of any integral type.+(!!) :: [a] -> Int -> a++-- | <a>foldl</a>, applied to a binary operator, a starting value+-- (typically the left-identity of the operator), and a list, reduces the+-- list using the binary operator, from left to right:+-- +-- <pre>+-- foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn+-- </pre>+-- +-- The list must be finite.+foldl :: (a -> b -> a) -> a -> [b] -> a++-- | <a>foldl1</a> is a variant of <a>foldl</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldl1 :: (a -> a -> a) -> [a] -> a++-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of+-- successive reduced values from the left:+-- +-- <pre>+-- scanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]+-- </pre>+-- +-- Note that+-- +-- <pre>+-- last (scanl f z xs) == foldl f z xs.+-- </pre>+scanl :: (a -> b -> a) -> a -> [b] -> [a]++-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value+-- argument:+-- +-- <pre>+-- scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]+-- </pre>+scanl1 :: (a -> a -> a) -> [a] -> [a]++-- | <a>foldr</a>, applied to a binary operator, a starting value+-- (typically the right-identity of the operator), and a list, reduces+-- the list using the binary operator, from right to left:+-- +-- <pre>+-- foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)+-- </pre>+foldr :: (a -> b -> b) -> b -> [a] -> b++-- | <a>foldr1</a> is a variant of <a>foldr</a> that has no starting value+-- argument, and thus must be applied to non-empty lists.+foldr1 :: (a -> a -> a) -> [a] -> a++-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that+-- +-- <pre>+-- head (scanr f z xs) == foldr f z xs.+-- </pre>+scanr :: (a -> b -> b) -> b -> [a] -> [b]++-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value+-- argument.+scanr1 :: (a -> a -> a) -> [a] -> [a]++-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated+-- applications of <tt>f</tt> to <tt>x</tt>:+-- +-- <pre>+-- iterate f x == [x, f x, f (f x), ...]+-- </pre>+iterate :: (a -> a) -> a -> [a]++-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the+-- value of every element.+repeat :: a -> [a]++-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with+-- <tt>x</tt> the value of every element. It is an instance of the more+-- general <tt>Data.List.genericReplicate</tt>, in which <tt>n</tt> may+-- be of any integral type.+replicate :: Int -> a -> [a]++-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,+-- the infinite repetition of the original list. It is the identity on+-- infinite lists.+cycle :: [a] -> [a]++-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the+-- prefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if+-- <tt>n > <a>length</a> xs</tt>:+-- +-- <pre>+-- take 5 "Hello World!" == "Hello"+-- take 3 [1,2,3,4,5] == [1,2,3]+-- take 3 [1,2] == [1,2]+-- take 3 [] == []+-- take (-1) [1,2] == []+-- take 0 [1,2] == []+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericTake</tt>,+-- in which <tt>n</tt> may be of any integral type.+take :: Int -> [a] -> [a]++-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the+-- first <tt>n</tt> elements, or <tt>[]</tt> if <tt>n > <a>length</a>+-- xs</tt>:+-- +-- <pre>+-- drop 6 "Hello World!" == "World!"+-- drop 3 [1,2,3,4,5] == [4,5]+-- drop 3 [1,2] == []+-- drop 3 [] == []+-- drop (-1) [1,2] == [1,2]+-- drop 0 [1,2] == [1,2]+-- </pre>+-- +-- It is an instance of the more general <tt>Data.List.genericDrop</tt>,+-- in which <tt>n</tt> may be of any integral type.+drop :: Int -> [a] -> [a]++-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is+-- <tt>xs</tt> prefix of length <tt>n</tt> and second element is the+-- remainder of the list:+-- +-- <pre>+-- splitAt 6 "Hello World!" == ("Hello ","World!")+-- splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])+-- splitAt 1 [1,2,3] == ([1],[2,3])+-- splitAt 3 [1,2,3] == ([1,2,3],[])+-- splitAt 4 [1,2,3] == ([1,2,3],[])+-- splitAt 0 [1,2,3] == ([],[1,2,3])+-- splitAt (-1) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- It is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when+-- <tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).+-- <a>splitAt</a> is an instance of the more general+-- <tt>Data.List.genericSplitAt</tt>, in which <tt>n</tt> may be of any+-- integral type.+splitAt :: Int -> [a] -> ([a], [a])++-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns the longest prefix (possibly empty) of+-- <tt>xs</tt> of elements that satisfy <tt>p</tt>:+-- +-- <pre>+-- takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]+-- takeWhile (< 9) [1,2,3] == [1,2,3]+-- takeWhile (< 0) [1,2,3] == []+-- </pre>+takeWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after+-- <a>takeWhile</a> <tt>p xs</tt>:+-- +-- <pre>+-- dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]+-- dropWhile (< 9) [1,2,3] == []+-- dropWhile (< 0) [1,2,3] == [1,2,3]+-- </pre>+dropWhile :: (a -> Bool) -> [a] -> [a]++-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,+-- returns a tuple where first element is longest prefix (possibly empty)+-- of <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element+-- is the remainder of the list:+-- +-- <pre>+-- span (< 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])+-- span (< 9) [1,2,3] == ([1,2,3],[])+-- span (< 0) [1,2,3] == ([],[1,2,3])+-- </pre>+-- +-- <a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,+-- <a>dropWhile</a> p xs)</tt>+span :: (a -> Bool) -> [a] -> ([a], [a])++-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list+-- <tt>xs</tt>, returns a tuple where first element is longest prefix+-- (possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>+-- <tt>p</tt> and second element is the remainder of the list:+-- +-- <pre>+-- break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])+-- break (< 9) [1,2,3] == ([],[1,2,3])+-- break (> 9) [1,2,3] == ([1,2,3],[])+-- </pre>+-- +-- <a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .+-- p)</tt>.+break :: (a -> Bool) -> [a] -> ([a], [a])++-- | <a>lines</a> breaks a string up into a list of strings at newline+-- characters. The resulting strings do not contain newlines.+lines :: String -> [String]++-- | <a>words</a> breaks a string up into a list of words, which were+-- delimited by white space.+words :: String -> [String]++-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins+-- lines, after appending a terminating newline to each.+unlines :: [String] -> String++-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words+-- with separating spaces.+unwords :: [String] -> String++-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in+-- reverse order. <tt>xs</tt> must be finite.+reverse :: [a] -> [a]++-- | <a>and</a> returns the conjunction of a Boolean list. For the result+-- to be <a>True</a>, the list must be finite; <a>False</a>, however,+-- results from a <a>False</a> value at a finite index of a finite or+-- infinite list.+and :: [Bool] -> Bool++-- | <a>or</a> returns the disjunction of a Boolean list. For the result to+-- be <a>False</a>, the list must be finite; <a>True</a>, however,+-- results from a <a>True</a> value at a finite index of a finite or+-- infinite list.+or :: [Bool] -> Bool++-- | Applied to a predicate and a list, <a>any</a> determines if any+-- element of the list satisfies the predicate. For the result to be+-- <a>False</a>, the list must be finite; <a>True</a>, however, results+-- from a <a>True</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+any :: (a -> Bool) -> [a] -> Bool++-- | Applied to a predicate and a list, <a>all</a> determines if all+-- elements of the list satisfy the predicate. For the result to be+-- <a>True</a>, the list must be finite; <a>False</a>, however, results+-- from a <a>False</a> value for the predicate applied to an element at a+-- finite index of a finite or infinite list.+all :: (a -> Bool) -> [a] -> Bool++-- | <a>elem</a> is the list membership predicate, usually written in infix+-- form, e.g., <tt>x `elem` xs</tt>. For the result to be <a>False</a>,+-- the list must be finite; <a>True</a>, however, results from an element+-- equal to <tt>x</tt> found at a finite index of a finite or infinite+-- list.+elem :: Eq a => a -> [a] -> Bool++-- | <a>notElem</a> is the negation of <a>elem</a>.+notElem :: Eq a => a -> [a] -> Bool++-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association+-- list.+lookup :: Eq a => a -> [(a, b)] -> Maybe b++-- | The <a>sum</a> function computes the sum of a finite list of numbers.+sum :: Num a => [a] -> a++-- | The <a>product</a> function computes the product of a finite list of+-- numbers.+product :: Num a => [a] -> a++-- | <a>maximum</a> returns the maximum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>maximumBy</a>, which allows the programmer to supply their own+-- comparison function.+maximum :: Ord a => [a] -> a++-- | <a>minimum</a> returns the minimum value from a list, which must be+-- non-empty, finite, and of an ordered type. It is a special case of+-- <a>minimumBy</a>, which allows the programmer to supply their own+-- comparison function.+minimum :: Ord a => [a] -> a++-- | Map a function over a list and concatenate the results.+concatMap :: (a -> [b]) -> [a] -> [b]++-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.+-- If one input list is short, excess elements of the longer list are+-- discarded.+zip :: [a] -> [b] -> [(a, b)]++-- | <a>zip3</a> takes three lists and returns a list of triples, analogous+-- to <a>zip</a>.+zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]++-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function+-- given as the first argument, instead of a tupling function. For+-- example, <tt><a>zipWith</a> (+)</tt> is applied to two lists to+-- produce the list of corresponding sums.+zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]++-- | The <a>zipWith3</a> function takes a function which combines three+-- elements, as well as three lists and returns a list of their+-- point-wise combination, analogous to <a>zipWith</a>.+zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]++-- | <a>unzip</a> transforms a list of pairs into a list of first+-- components and a list of second components.+unzip :: [(a, b)] -> ([a], [b])++-- | The <a>unzip3</a> function takes a list of triples and returns three+-- lists, analogous to <a>unzip</a>.+unzip3 :: [(a, b, c)] -> ([a], [b], [c])++module System++-- | Defines the exit codes that a program can return.+data ExitCode :: *++-- | indicates successful termination;+ExitSuccess :: ExitCode++-- | indicates program failure with an exit code. The exact interpretation+-- of the code is operating-system dependent. In particular, some values+-- may be prohibited (e.g. 0 on a POSIX-compliant system).+ExitFailure :: Int -> ExitCode++-- | Computation <a>getArgs</a> returns a list of the program's command+-- line arguments (not including the program name).+getArgs :: IO [String]++-- | Computation <a>getProgName</a> returns the name of the program as it+-- was invoked.+-- +-- However, this is hard-to-impossible to implement on some non-Unix+-- OSes, so instead, for maximum portability, we just return the leafname+-- of the program as invoked. Even then there are some differences+-- between platforms: on Windows, for example, a program invoked as foo+-- is probably really <tt>FOO.EXE</tt>, and that is what+-- <a>getProgName</a> will return.+getProgName :: IO String++-- | Computation <a>getEnv</a> <tt>var</tt> returns the value of the+-- environment variable <tt>var</tt>.+-- +-- This computation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isDoesNotExistError</tt> if the environment+-- variable does not exist.</li>+-- </ul>+getEnv :: String -> IO String++-- | Computation <tt>system cmd</tt> returns the exit code produced when+-- the operating system runs the shell command <tt>cmd</tt>.+-- +-- This computation may fail with+-- +-- <ul>+-- <li><tt>PermissionDenied</tt>: The process has insufficient privileges+-- to perform the operation.</li>+-- <li><tt>ResourceExhausted</tt>: Insufficient resources are available+-- to perform the operation.</li>+-- <li><tt>UnsupportedOperation</tt>: The implementation does not support+-- system calls.</li>+-- </ul>+-- +-- On Windows, <a>system</a> passes the command to the Windows command+-- interpreter (<tt>CMD.EXE</tt> or <tt>COMMAND.COM</tt>), hence Unixy+-- shell tricks will not work.+system :: String -> IO ExitCode++-- | Computation <a>exitWith</a> <tt>code</tt> throws <a>ExitCode</a>+-- <tt>code</tt>. Normally this terminates the program, returning+-- <tt>code</tt> to the program's caller.+-- +-- On program termination, the standard <tt>Handle</tt>s <tt>stdout</tt>+-- and <tt>stderr</tt> are flushed automatically; any other buffered+-- <tt>Handle</tt>s need to be flushed manually, otherwise the buffered+-- data will be discarded.+-- +-- A program that fails in any other way is treated as if it had called+-- <a>exitFailure</a>. A program that terminates successfully without+-- calling <a>exitWith</a> explicitly is treated as it it had called+-- <a>exitWith</a> <a>ExitSuccess</a>.+-- +-- As an <a>ExitCode</a> is not an <a>IOError</a>, <a>exitWith</a>+-- bypasses the error handling in the <a>IO</a> monad and cannot be+-- intercepted by <a>catch</a> from the <a>Prelude</a>. However it is a+-- <tt>SomeException</tt>, and can be caught using the functions of+-- <a>Control.Exception</a>. This means that cleanup computations added+-- with <tt>Control.Exception.bracket</tt> (from+-- <a>Control.Exception</a>) are also executed properly on+-- <a>exitWith</a>.+-- +-- Note: in GHC, <a>exitWith</a> should be called from the main program+-- thread in order to exit the process. When called from another thread,+-- <a>exitWith</a> will throw an <tt>ExitException</tt> as normal, but+-- the exception will not cause the process itself to exit.+exitWith :: ExitCode -> IO a++-- | The computation <a>exitFailure</a> is equivalent to <a>exitWith</a>+-- <tt>(</tt><a>ExitFailure</a> <i>exitfail</i><tt>)</tt>, where+-- <i>exitfail</i> is implementation-dependent.+exitFailure :: IO a++module CPUTime++-- | Computation <a>getCPUTime</a> returns the number of picoseconds CPU+-- time used by the current program. The precision of this result is+-- implementation-dependent.+getCPUTime :: IO Integer++-- | The <a>cpuTimePrecision</a> constant is the smallest measurable+-- difference in CPU time that the implementation can record, and is+-- given as an integral number of picoseconds.+cpuTimePrecision :: Integer++module Complex++-- | Complex numbers are an algebraic type.+-- +-- For a complex number <tt>z</tt>, <tt><a>abs</a> z</tt> is a number+-- with the magnitude of <tt>z</tt>, but oriented in the positive real+-- direction, whereas <tt><a>signum</a> z</tt> has the phase of+-- <tt>z</tt>, but unit magnitude.+data Complex a :: * -> *++-- | forms a complex number from its real and imaginary rectangular+-- components.+(:+) :: !a -> !a -> Complex a++-- | Extracts the real part of a complex number.+realPart :: RealFloat a => Complex a -> a++-- | Extracts the imaginary part of a complex number.+imagPart :: RealFloat a => Complex a -> a++-- | The conjugate of a complex number.+conjugate :: RealFloat a => Complex a -> Complex a++-- | Form a complex number from polar components of magnitude and phase.+mkPolar :: RealFloat a => a -> a -> Complex a++-- | <tt><a>cis</a> t</tt> is a complex value with magnitude <tt>1</tt> and+-- phase <tt>t</tt> (modulo <tt>2*<a>pi</a></tt>).+cis :: RealFloat a => a -> Complex a++-- | The function <a>polar</a> takes a complex number and returns a+-- (magnitude, phase) pair in canonical form: the magnitude is+-- nonnegative, and the phase in the range <tt>(-<a>pi</a>,+-- <a>pi</a>]</tt>; if the magnitude is zero, then so is the phase.+polar :: RealFloat a => Complex a -> (a, a)++-- | The nonnegative magnitude of a complex number.+magnitude :: RealFloat a => Complex a -> a++-- | The phase of a complex number, in the range <tt>(-<a>pi</a>,+-- <a>pi</a>]</tt>. If the magnitude is zero, then so is the phase.+phase :: RealFloat a => Complex a -> a++module CString++module Storable++module Directory+data Permissions+Permissions :: Bool -> Bool -> Bool -> Bool -> Permissions+readable :: Permissions -> Bool+writable :: Permissions -> Bool+executable :: Permissions -> Bool+searchable :: Permissions -> Bool++-- | <tt><a>createDirectory</a> dir</tt> creates a new directory+-- <tt>dir</tt> which is initially empty, or as near to empty as the+-- operating system allows.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation. <tt>[EROFS,+-- EACCES]</tt></li>+-- <li><a>isAlreadyExistsError</a> / <a>AlreadyExists</a> The operand+-- refers to a directory that already exists. <tt> [EEXIST]</tt></li>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> The operand is not a valid directory name.+-- <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>NoSuchThing</a> There is no path to the directory. <tt>[ENOENT,+-- ENOTDIR]</tt></li>+-- <li><a>ResourceExhausted</a> Insufficient resources (virtual memory,+-- process file descriptors, physical disk space, etc.) are available to+-- perform the operation. <tt>[EDQUOT, ENOSPC, ENOMEM, EMLINK]</tt></li>+-- <li><a>InappropriateType</a> The path refers to an existing+-- non-directory object. <tt>[EEXIST]</tt></li>+-- </ul>+createDirectory :: FilePath -> IO ()++-- | <tt><a>removeDirectory</a> dir</tt> removes an existing directory+-- <i>dir</i>. The implementation may specify additional constraints+-- which must be satisfied before a directory can be removed (e.g. the+-- directory has to be empty, or may not be in use by other processes).+-- It is not legal for an implementation to partially remove a directory+-- unless the entire directory is removed. A conformant implementation+-- need not support directory removal in all situations (e.g. removal of+-- the root directory).+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred. EIO</li>+-- <li><a>InvalidArgument</a> The operand is not a valid directory name.+-- [ENAMETOOLONG, ELOOP]</li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The directory does+-- not exist. <tt>[ENOENT, ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation. <tt>[EROFS, EACCES,+-- EPERM]</tt></li>+-- <li><a>UnsatisfiedConstraints</a> Implementation-dependent constraints+-- are not satisfied. <tt>[EBUSY, ENOTEMPTY, EEXIST]</tt></li>+-- <li><a>UnsupportedOperation</a> The implementation does not support+-- removal in this situation. <tt>[EINVAL]</tt></li>+-- <li><a>InappropriateType</a> The operand refers to an existing+-- non-directory object. <tt>[ENOTDIR]</tt></li>+-- </ul>+removeDirectory :: FilePath -> IO ()++-- | <a>removeFile</a> <i>file</i> removes the directory entry for an+-- existing file <i>file</i>, where <i>file</i> is not itself a+-- directory. The implementation may specify additional constraints which+-- must be satisfied before a file can be removed (e.g. the file may not+-- be in use by other processes).+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> The operand is not a valid file name.+-- <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The file does not+-- exist. <tt>[ENOENT, ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation. <tt>[EROFS, EACCES,+-- EPERM]</tt></li>+-- <li><a>UnsatisfiedConstraints</a> Implementation-dependent constraints+-- are not satisfied. <tt>[EBUSY]</tt></li>+-- <li><a>InappropriateType</a> The operand refers to an existing+-- directory. <tt>[EPERM, EINVAL]</tt></li>+-- </ul>+removeFile :: FilePath -> IO ()++-- | <tt><a>renameDirectory</a> old new</tt> changes the name of an+-- existing directory from <i>old</i> to <i>new</i>. If the <i>new</i>+-- directory already exists, it is atomically replaced by the <i>old</i>+-- directory. If the <i>new</i> directory is neither the <i>old</i>+-- directory nor an alias of the <i>old</i> directory, it is removed as+-- if by <a>removeDirectory</a>. A conformant implementation need not+-- support renaming directories in all situations (e.g. renaming to an+-- existing directory, or across different physical devices), but the+-- constraints must be documented.+-- +-- On Win32 platforms, <tt>renameDirectory</tt> fails if the <i>new</i>+-- directory already exists.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> Either operand is not a valid directory+-- name. <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The original+-- directory does not exist, or there is no path to the target.+-- <tt>[ENOENT, ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation. <tt>[EROFS, EACCES,+-- EPERM]</tt></li>+-- <li><a>ResourceExhausted</a> Insufficient resources are available to+-- perform the operation. <tt>[EDQUOT, ENOSPC, ENOMEM, EMLINK]</tt></li>+-- <li><a>UnsatisfiedConstraints</a> Implementation-dependent constraints+-- are not satisfied. <tt>[EBUSY, ENOTEMPTY, EEXIST]</tt></li>+-- <li><a>UnsupportedOperation</a> The implementation does not support+-- renaming in this situation. <tt>[EINVAL, EXDEV]</tt></li>+-- <li><a>InappropriateType</a> Either path refers to an existing+-- non-directory object. <tt>[ENOTDIR, EISDIR]</tt></li>+-- </ul>+renameDirectory :: FilePath -> FilePath -> IO ()++-- | <tt><a>renameFile</a> old new</tt> changes the name of an existing+-- file system object from <i>old</i> to <i>new</i>. If the <i>new</i>+-- object already exists, it is atomically replaced by the <i>old</i>+-- object. Neither path may refer to an existing directory. A conformant+-- implementation need not support renaming files in all situations (e.g.+-- renaming across different physical devices), but the constraints must+-- be documented.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> Either operand is not a valid file name.+-- <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The original file+-- does not exist, or there is no path to the target. <tt>[ENOENT,+-- ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation. <tt>[EROFS, EACCES,+-- EPERM]</tt></li>+-- <li><a>ResourceExhausted</a> Insufficient resources are available to+-- perform the operation. <tt>[EDQUOT, ENOSPC, ENOMEM, EMLINK]</tt></li>+-- <li><a>UnsatisfiedConstraints</a> Implementation-dependent constraints+-- are not satisfied. <tt>[EBUSY]</tt></li>+-- <li><a>UnsupportedOperation</a> The implementation does not support+-- renaming in this situation. <tt>[EXDEV]</tt></li>+-- <li><a>InappropriateType</a> Either path refers to an existing+-- directory. <tt>[ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]</tt></li>+-- </ul>+renameFile :: FilePath -> FilePath -> IO ()++-- | <tt><a>getDirectoryContents</a> dir</tt> returns a list of <i>all</i>+-- entries in <i>dir</i>.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> The operand is not a valid directory name.+-- <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The directory does+-- not exist. <tt>[ENOENT, ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation.+-- <tt>[EACCES]</tt></li>+-- <li><a>ResourceExhausted</a> Insufficient resources are available to+-- perform the operation. <tt>[EMFILE, ENFILE]</tt></li>+-- <li><a>InappropriateType</a> The path refers to an existing+-- non-directory object. <tt>[ENOTDIR]</tt></li>+-- </ul>+getDirectoryContents :: FilePath -> IO [FilePath]++-- | If the operating system has a notion of current directories,+-- <a>getCurrentDirectory</a> returns an absolute path to the current+-- directory of the calling process.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> There is no path+-- referring to the current directory. <tt>[EPERM, ENOENT,+-- ESTALE...]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation.+-- <tt>[EACCES]</tt></li>+-- <li><a>ResourceExhausted</a> Insufficient resources are available to+-- perform the operation.</li>+-- <li><a>UnsupportedOperation</a> The operating system has no notion of+-- current directory.</li>+-- </ul>+-- +-- Note that in a concurrent program, the current directory is global+-- state shared between all threads of the process. When using filesystem+-- operations from multiple threads, it is therefore highly recommended+-- to use absolute rather than relative <a>FilePath</a>s.+getCurrentDirectory :: IO FilePath++-- | If the operating system has a notion of current directories,+-- <tt><a>setCurrentDirectory</a> dir</tt> changes the current directory+-- of the calling process to <i>dir</i>.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>HardwareFault</a> A physical I/O error has occurred.+-- <tt>[EIO]</tt></li>+-- <li><a>InvalidArgument</a> The operand is not a valid directory name.+-- <tt>[ENAMETOOLONG, ELOOP]</tt></li>+-- <li><a>isDoesNotExistError</a> / <a>NoSuchThing</a> The directory does+-- not exist. <tt>[ENOENT, ENOTDIR]</tt></li>+-- <li><a>isPermissionError</a> / <a>PermissionDenied</a> The process has+-- insufficient privileges to perform the operation.+-- <tt>[EACCES]</tt></li>+-- <li><a>UnsupportedOperation</a> The operating system has no notion of+-- current directory, or the current directory cannot be dynamically+-- changed.</li>+-- <li><a>InappropriateType</a> The path refers to an existing+-- non-directory object. <tt>[ENOTDIR]</tt></li>+-- </ul>+-- +-- Note that in a concurrent program, the current directory is global+-- state shared between all threads of the process. When using filesystem+-- operations from multiple threads, it is therefore highly recommended+-- to use absolute rather than relative <a>FilePath</a>s.+setCurrentDirectory :: FilePath -> IO ()++-- | The operation <a>doesFileExist</a> returns <a>True</a> if the argument+-- file exists and is not a directory, and <a>False</a> otherwise.+doesFileExist :: FilePath -> IO Bool++-- | The operation <a>doesDirectoryExist</a> returns <a>True</a> if the+-- argument file exists and is a directory, and <a>False</a> otherwise.+doesDirectoryExist :: FilePath -> IO Bool+getPermissions :: FilePath -> IO Permissions+setPermissions :: FilePath -> Permissions -> IO ()++-- | The <a>getModificationTime</a> operation returns the clock time at+-- which the file or directory was last modified.+-- +-- The operation may fail with:+-- +-- <ul>+-- <li><a>isPermissionError</a> if the user is not permitted to access+-- the modification time; or</li>+-- <li><a>isDoesNotExistError</a> if the file or directory does not+-- exist.</li>+-- </ul>+getModificationTime :: FilePath -> IO ClockTime+instance Eq Permissions+instance Ord Permissions+instance Read Permissions+instance Show Permissions++module Bits++module Maybe++-- | The <a>isJust</a> function returns <a>True</a> iff its argument is of+-- the form <tt>Just _</tt>.+isJust :: Maybe a -> Bool++-- | The <a>isNothing</a> function returns <a>True</a> iff its argument is+-- <a>Nothing</a>.+isNothing :: Maybe a -> Bool++-- | The <a>fromJust</a> function extracts the element out of a <a>Just</a>+-- and throws an error if its argument is <a>Nothing</a>.+fromJust :: Maybe a -> a++-- | The <a>fromMaybe</a> function takes a default value and and+-- <a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns+-- the default values; otherwise, it returns the value contained in the+-- <a>Maybe</a>.+fromMaybe :: a -> Maybe a -> a++-- | The <a>listToMaybe</a> function returns <a>Nothing</a> on an empty+-- list or <tt><a>Just</a> a</tt> where <tt>a</tt> is the first element+-- of the list.+listToMaybe :: [a] -> Maybe a++-- | The <a>maybeToList</a> function returns an empty list when given+-- <a>Nothing</a> or a singleton list when not given <a>Nothing</a>.+maybeToList :: Maybe a -> [a]++-- | The <a>catMaybes</a> function takes a list of <a>Maybe</a>s and+-- returns a list of all the <a>Just</a> values.+catMaybes :: [Maybe a] -> [a]++-- | The <a>mapMaybe</a> function is a version of <a>map</a> which can+-- throw out elements. In particular, the functional argument returns+-- something of type <tt><a>Maybe</a> b</tt>. If this is <a>Nothing</a>,+-- no element is added on to the result list. If it just <tt><a>Just</a>+-- b</tt>, then <tt>b</tt> is included in the result list.+mapMaybe :: (a -> Maybe b) -> [a] -> [b]++-- | The <a>Maybe</a> type encapsulates an optional value. A value of type+-- <tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>+-- (represented as <tt><a>Just</a> a</tt>), or it is empty (represented+-- as <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with+-- errors or exceptional cases without resorting to drastic measures such+-- as <a>error</a>.+-- +-- The <a>Maybe</a> type is also a monad. It is a simple kind of error+-- monad, where all errors are represented by <a>Nothing</a>. A richer+-- error monad can be built using the <tt>Data.Either.Either</tt> type.+data Maybe a :: * -> *+Nothing :: Maybe a+Just :: a -> Maybe a++-- | The <a>maybe</a> function takes a default value, a function, and a+-- <a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the+-- function returns the default value. Otherwise, it applies the function+-- to the value inside the <a>Just</a> and returns the result.+maybe :: b -> (a -> b) -> Maybe a -> b++module Random++-- | The class <a>RandomGen</a> provides a common interface to random+-- number generators.+-- +-- Minimal complete definition: <a>next</a> and <a>split</a>.+class RandomGen g+next :: RandomGen g => g -> (Int, g)+split :: RandomGen g => g -> (g, g)+genRange :: RandomGen g => g -> (Int, Int)++-- | The <a>StdGen</a> instance of <a>RandomGen</a> has a <a>genRange</a>+-- of at least 30 bits.+-- +-- The result of repeatedly using <a>next</a> should be at least as+-- statistically robust as the <i>Minimal Standard Random Number+-- Generator</i> described by [<a>System.Random#Park</a>,+-- <a>System.Random#Carta</a>]. Until more is known about implementations+-- of <a>split</a>, all we require is that <a>split</a> deliver+-- generators that are (a) not identical and (b) independently robust in+-- the sense just given.+-- +-- The <a>Show</a> and <a>Read</a> instances of <a>StdGen</a> provide a+-- primitive way to save the state of a random number generator. It is+-- required that <tt><a>read</a> (<a>show</a> g) == g</tt>.+-- +-- In addition, <a>reads</a> may be used to map an arbitrary string (not+-- necessarily one produced by <a>show</a>) onto a value of type+-- <a>StdGen</a>. In general, the <a>Read</a> instance of <a>StdGen</a>+-- has the following properties:+-- +-- <ul>+-- <li>It guarantees to succeed on any string.</li>+-- <li>It guarantees to consume only a finite portion of the string.</li>+-- <li>Different argument strings are likely to result in different+-- results.</li>+-- </ul>+data StdGen :: *++-- | The function <a>mkStdGen</a> provides an alternative way of producing+-- an initial generator, by mapping an <a>Int</a> into a generator.+-- Again, distinct arguments should be likely to produce distinct+-- generators.+mkStdGen :: Int -> StdGen++-- | With a source of random number supply in hand, the <a>Random</a> class+-- allows the programmer to extract random values of a variety of types.+-- +-- Minimal complete definition: <a>randomR</a> and <a>random</a>.+class Random a+randomR :: (Random a, RandomGen g) => (a, a) -> g -> (a, g)+random :: (Random a, RandomGen g) => g -> (a, g)+randomRs :: (Random a, RandomGen g) => (a, a) -> g -> [a]+randoms :: (Random a, RandomGen g) => g -> [a]+randomRIO :: Random a => (a, a) -> IO a+randomIO :: Random a => IO a++-- | Uses the supplied function to get a value from the current global+-- random generator, and updates the global generator with the new+-- generator returned by the function. For example, <tt>rollDice</tt>+-- gets a random integer between 1 and 6:+-- +-- <pre>+-- rollDice :: IO Int+-- rollDice = getStdRandom (randomR (1,6))+-- </pre>+getStdRandom :: (StdGen -> (a, StdGen)) -> IO a++-- | Gets the global random number generator.+getStdGen :: IO StdGen++-- | Sets the global random number generator.+setStdGen :: StdGen -> IO ()++-- | Applies <a>split</a> to the current global random generator, updates+-- it with one of the results, and returns the other.+newStdGen :: IO StdGen++module Word++module Ptr++module StablePtr++module Monad++-- | Monads that also support choice and failure.+class Monad m => MonadPlus m :: (* -> *)+mzero :: MonadPlus m => m a+mplus :: MonadPlus m => m a -> m a -> m a++-- | The <a>join</a> function is the conventional monad join operator. It+-- is used to remove one level of monadic structure, projecting its bound+-- argument into the outer level.+join :: Monad m => m (m a) -> m a++-- | <tt><a>guard</a> b</tt> is <tt><a>return</a> ()</tt> if <tt>b</tt> is+-- <a>True</a>, and <a>mzero</a> if <tt>b</tt> is <a>False</a>.+guard :: MonadPlus m => Bool -> m ()++-- | Conditional execution of monadic expressions. For example,+-- +-- <pre>+-- when debug (putStr "Debugging\n")+-- </pre>+-- +-- will output the string <tt>Debugging\n</tt> if the Boolean value+-- <tt>debug</tt> is <a>True</a>, and otherwise do nothing.+when :: Monad m => Bool -> m () -> m ()++-- | The reverse of <a>when</a>.+unless :: Monad m => Bool -> m () -> m ()++-- | In many situations, the <a>liftM</a> operations can be replaced by+-- uses of <a>ap</a>, which promotes function application.+-- +-- <pre>+-- return f `ap` x1 `ap` ... `ap` xn+-- </pre>+-- +-- is equivalent to+-- +-- <pre>+-- liftMn f x1 x2 ... xn+-- </pre>+ap :: Monad m => m (a -> b) -> m a -> m b++-- | This generalizes the list-based <a>concat</a> function.+msum :: MonadPlus m => [m a] -> m a++-- | This generalizes the list-based <a>filter</a> function.+filterM :: Monad m => (a -> m Bool) -> [a] -> m [a]++-- | The <a>mapAndUnzipM</a> function maps its first argument over a list,+-- returning the result as a pair of lists. This function is mainly used+-- with complicated data structures or a state-transforming monad.+mapAndUnzipM :: Monad m => (a -> m (b, c)) -> [a] -> m ([b], [c])++-- | The <a>zipWithM</a> function generalizes <a>zipWith</a> to arbitrary+-- monads.+zipWithM :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]++-- | <a>zipWithM_</a> is the extension of <a>zipWithM</a> which ignores the+-- final result.+zipWithM_ :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m ()++-- | The <a>foldM</a> function is analogous to <a>foldl</a>, except that+-- its result is encapsulated in a monad. Note that <a>foldM</a> works+-- from left-to-right over the list arguments. This could be an issue+-- where <tt>(<a>>></a>)</tt> and the `folded function' are not+-- commutative.+-- +-- <pre>+-- foldM f a1 [x1, x2, ..., xm]+-- </pre>+-- +-- ==+-- +-- <pre>+-- do+-- a2 <- f a1 x1+-- a3 <- f a2 x2+-- ...+-- f am xm+-- </pre>+-- +-- If right-to-left evaluation is required, the input list should be+-- reversed.+foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a++-- | Promote a function to a monad.+liftM :: Monad m => (a1 -> r) -> m a1 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right. For example,+-- +-- <pre>+-- liftM2 (+) [0,1] [0,2] = [0,2,1,3]+-- liftM2 (+) (Just 1) Nothing = Nothing+-- </pre>+liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r++-- | Promote a function to a monad, scanning the monadic arguments from+-- left to right (cf. <a>liftM2</a>).+liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r++-- | The <a>Monad</a> class defines the basic operations over a+-- <i>monad</i>, a concept from a branch of mathematics known as+-- <i>category theory</i>. From the perspective of a Haskell programmer,+-- however, it is best to think of a monad as an <i>abstract datatype</i>+-- of actions. Haskell's <tt>do</tt> expressions provide a convenient+-- syntax for writing monadic expressions.+-- +-- Minimal complete definition: <a>>>=</a> and <a>return</a>.+-- +-- Instances of <a>Monad</a> should satisfy the following laws:+-- +-- <pre>+-- return a >>= k == k a+-- m >>= return == m+-- m >>= (\x -> k x >>= h) == (m >>= k) >>= h+-- </pre>+-- +-- Instances of both <a>Monad</a> and <a>Functor</a> should additionally+-- satisfy the law:+-- +-- <pre>+-- fmap f xs == xs >>= return . f+-- </pre>+-- +-- The instances of <a>Monad</a> for lists, <tt>Data.Maybe.Maybe</tt> and+-- <tt>System.IO.IO</tt> defined in the <a>Prelude</a> satisfy these+-- laws.+class Monad m :: (* -> *)+(>>=) :: Monad m => m a -> (a -> m b) -> m b+(>>) :: Monad m => m a -> m b -> m b+return :: Monad m => a -> m a+fail :: Monad m => String -> m a++-- | The <a>Functor</a> class is used for types that can be mapped over.+-- Instances of <a>Functor</a> should satisfy the following laws:+-- +-- <pre>+-- fmap id == id+-- fmap (f . g) == fmap f . fmap g+-- </pre>+-- +-- The instances of <a>Functor</a> for lists, <tt>Data.Maybe.Maybe</tt>+-- and <tt>System.IO.IO</tt> satisfy these laws.+class Functor f :: (* -> *)+fmap :: Functor f => (a -> b) -> f a -> f b++-- | <tt><a>mapM</a> f</tt> is equivalent to <tt><a>sequence</a> .+-- <a>map</a> f</tt>.+mapM :: Monad m => (a -> m b) -> [a] -> m [b]++-- | <tt><a>mapM_</a> f</tt> is equivalent to <tt><a>sequence_</a> .+-- <a>map</a> f</tt>.+mapM_ :: Monad m => (a -> m b) -> [a] -> m ()++-- | Evaluate each action in the sequence from left to right, and collect+-- the results.+sequence :: Monad m => [m a] -> m [a]++-- | Evaluate each action in the sequence from left to right, and ignore+-- the results.+sequence_ :: Monad m => [m a] -> m ()++-- | Same as <a>>>=</a>, but with the arguments interchanged.+(=<<) :: Monad m => (a -> m b) -> m a -> m b++module Ratio++-- | Rational numbers, with numerator and denominator of some+-- <a>Integral</a> type.+data Ratio a :: * -> *++-- | Arbitrary-precision rational numbers, represented as a ratio of two+-- <a>Integer</a> values. A rational number may be constructed using the+-- <a>%</a> operator.+type Rational = Ratio Integer++-- | Forms the ratio of two integral numbers.+(%) :: Integral a => a -> a -> Ratio a++-- | Extract the numerator of the ratio in reduced form: the numerator and+-- denominator have no common factor and the denominator is positive.+numerator :: Integral a => Ratio a -> a++-- | Extract the denominator of the ratio in reduced form: the numerator+-- and denominator have no common factor and the denominator is positive.+denominator :: Integral a => Ratio a -> a++-- | <a>approxRational</a>, applied to two real fractional numbers+-- <tt>x</tt> and <tt>epsilon</tt>, returns the simplest rational number+-- within <tt>epsilon</tt> of <tt>x</tt>. A rational number <tt>y</tt> is+-- said to be <i>simpler</i> than another <tt>y'</tt> if+-- +-- <ul>+-- <li><tt><a>abs</a> (<a>numerator</a> y) <= <a>abs</a>+-- (<a>numerator</a> y')</tt>, and</li>+-- <li><tt><a>denominator</a> y <= <a>denominator</a> y'</tt>.</li>+-- </ul>+-- +-- Any real interval contains a unique simplest rational; in particular,+-- note that <tt>0/1</tt> is the simplest rational of all.+approxRational :: RealFrac a => a -> a -> Rational++module ForeignPtr++module IO++-- | Haskell defines operations to read and write characters from and to+-- files, represented by values of type <tt>Handle</tt>. Each value of+-- this type is a <i>handle</i>: a record used by the Haskell run-time+-- system to <i>manage</i> I/O with file system objects. A handle has at+-- least the following properties:+-- +-- <ul>+-- <li>whether it manages input or output or both;</li>+-- <li>whether it is <i>open</i>, <i>closed</i> or+-- <i>semi-closed</i>;</li>+-- <li>whether the object is seekable;</li>+-- <li>whether buffering is disabled, or enabled on a line or block+-- basis;</li>+-- <li>a buffer (whose length may be zero).</li>+-- </ul>+-- +-- Most handles will also have a current I/O position indicating where+-- the next input or output operation will occur. A handle is+-- <i>readable</i> if it manages only input or both input and output;+-- likewise, it is <i>writable</i> if it manages only output or both+-- input and output. A handle is <i>open</i> when first allocated. Once+-- it is closed it can no longer be used for either input or output,+-- though an implementation cannot re-use its storage while references+-- remain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.+-- The string produced by showing a handle is system dependent; it should+-- include enough information to identify the handle for debugging. A+-- handle is equal according to <a>==</a> only to itself; no attempt is+-- made to compare the internal state of different handles for equality.+data Handle :: *+data HandlePosn :: *++-- | See <tt>System.IO.openFile</tt>+data IOMode :: *+ReadMode :: IOMode+WriteMode :: IOMode+AppendMode :: IOMode+ReadWriteMode :: IOMode++-- | Three kinds of buffering are supported: line-buffering,+-- block-buffering or no-buffering. These modes have the following+-- effects. For output, items are written out, or <i>flushed</i>, from+-- the internal buffer according to the buffer mode:+-- +-- <ul>+-- <li><i>line-buffering</i>: the entire output buffer is flushed+-- whenever a newline is output, the buffer overflows, a+-- <tt>System.IO.hFlush</tt> is issued, or the handle is closed.</li>+-- <li><i>block-buffering</i>: the entire buffer is written out whenever+-- it overflows, a <tt>System.IO.hFlush</tt> is issued, or the handle is+-- closed.</li>+-- <li><i>no-buffering</i>: output is written immediately, and never+-- stored in the buffer.</li>+-- </ul>+-- +-- An implementation is free to flush the buffer more frequently, but not+-- less frequently, than specified above. The output buffer is emptied as+-- soon as it has been written out.+-- +-- Similarly, input occurs according to the buffer mode for the handle:+-- +-- <ul>+-- <li><i>line-buffering</i>: when the buffer for the handle is not+-- empty, the next item is obtained from the buffer; otherwise, when the+-- buffer is empty, characters up to and including the next newline+-- character are read into the buffer. No characters are available until+-- the newline character is available or the buffer is full.</li>+-- <li><i>block-buffering</i>: when the buffer for the handle becomes+-- empty, the next block of data is read into the buffer.</li>+-- <li><i>no-buffering</i>: the next input item is read and returned. The+-- <tt>System.IO.hLookAhead</tt> operation implies that even a+-- no-buffered handle may require a one-character buffer.</li>+-- </ul>+-- +-- The default buffering mode when a handle is opened is+-- implementation-dependent and may depend on the file system object+-- which is attached to that handle. For most implementations, physical+-- files will normally be block-buffered and terminals will normally be+-- line-buffered.+data BufferMode :: *++-- | buffering is disabled if possible.+NoBuffering :: BufferMode++-- | line-buffering should be enabled if possible.+LineBuffering :: BufferMode++-- | block-buffering should be enabled if possible. The size of the buffer+-- is <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is+-- otherwise implementation-dependent.+BlockBuffering :: Maybe Int -> BufferMode++-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode+-- i</tt>.+data SeekMode :: *++-- | the position of <tt>hdl</tt> is set to <tt>i</tt>.+AbsoluteSeek :: SeekMode++-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the+-- current position.+RelativeSeek :: SeekMode++-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end+-- of the file.+SeekFromEnd :: SeekMode++-- | A handle managing input from the Haskell program's standard input+-- channel.+stdin :: Handle++-- | A handle managing output to the Haskell program's standard output+-- channel.+stdout :: Handle++-- | A handle managing output to the Haskell program's standard error+-- channel.+stderr :: Handle++-- | Computation <a>openFile</a> <tt>file mode</tt> allocates and returns a+-- new, open handle to manage the file <tt>file</tt>. It manages input if+-- <tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is+-- <a>WriteMode</a> or <a>AppendMode</a>, and both input and output if+-- mode is <a>ReadWriteMode</a>.+-- +-- If the file does not exist and it is opened for output, it should be+-- created as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the+-- file already exists, then it should be truncated to zero length. Some+-- operating systems delete empty files, so there is no guarantee that+-- the file will exist following an <a>openFile</a> with <tt>mode</tt>+-- <a>WriteMode</a> unless it is subsequently written to successfully.+-- The handle is positioned at the end of the file if <tt>mode</tt> is+-- <a>AppendMode</a>, and otherwise at the beginning (in which case its+-- internal position is 0). The initial buffer mode is+-- implementation-dependent.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isAlreadyInUseError</tt> if the file is already open and+-- cannot be reopened;</li>+-- <li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>+-- <li><tt>isPermissionError</tt> if the user does not have permission to+-- open the file.</li>+-- </ul>+-- +-- Note: if you will be working with files containing binary data, you'll+-- want to be using <a>openBinaryFile</a>.+openFile :: FilePath -> IOMode -> IO Handle++-- | Computation <a>hClose</a> <tt>hdl</tt> makes handle <tt>hdl</tt>+-- closed. Before the computation finishes, if <tt>hdl</tt> is writable+-- its buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>+-- on a handle that has already been closed has no effect; doing so is+-- not an error. All other operations on a closed handle will fail. If+-- <a>hClose</a> fails for any reason, any further operations (apart from+-- <a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had+-- been successfully closed.+hClose :: Handle -> IO ()++-- | For a handle <tt>hdl</tt> which attached to a physical file,+-- <a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit+-- bytes.+hFileSize :: Handle -> IO Integer++-- | For a readable handle <tt>hdl</tt>, <a>hIsEOF</a> <tt>hdl</tt> returns+-- <a>True</a> if no further input can be taken from <tt>hdl</tt> or for+-- a physical file, if the current I/O position is equal to the length of+-- the file. Otherwise, it returns <a>False</a>.+-- +-- NOTE: <a>hIsEOF</a> may block, because it has to attempt to read from+-- the stream to determine whether there is any more data to be read.+hIsEOF :: Handle -> IO Bool++-- | The computation <a>isEOF</a> is identical to <a>hIsEOF</a>, except+-- that it works only on <a>stdin</a>.+isEOF :: IO Bool++-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of+-- buffering for handle <tt>hdl</tt> on subsequent reads and writes.+-- +-- If the buffer mode is changed from <a>BlockBuffering</a> or+-- <a>LineBuffering</a> to <a>NoBuffering</a>, then+-- +-- <ul>+-- <li>if <tt>hdl</tt> is writable, the buffer is flushed as for+-- <a>hFlush</a>;</li>+-- <li>if <tt>hdl</tt> is not writable, the contents of the buffer is+-- discarded.</li>+-- </ul>+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isPermissionError</tt> if the handle has already been used for+-- reading or writing and the implementation does not allow the buffering+-- mode to be changed.</li>+-- </ul>+hSetBuffering :: Handle -> BufferMode -> IO ()++-- | Computation <a>hGetBuffering</a> <tt>hdl</tt> returns the current+-- buffering mode for <tt>hdl</tt>.+hGetBuffering :: Handle -> IO BufferMode++-- | The action <a>hFlush</a> <tt>hdl</tt> causes any items buffered for+-- output in handle <tt>hdl</tt> to be sent immediately to the operating+-- system.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isFullError</tt> if the device is full;</li>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded. It is unspecified whether the characters in the buffer are+-- discarded or retained under these circumstances.</li>+-- </ul>+hFlush :: Handle -> IO ()++-- | Computation <a>hGetPosn</a> <tt>hdl</tt> returns the current I/O+-- position of <tt>hdl</tt> as a value of the abstract type+-- <a>HandlePosn</a>.+hGetPosn :: Handle -> IO HandlePosn++-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position+-- <tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the+-- position of <tt>hdl</tt> to the position it held at the time of the+-- call to <a>hGetPosn</a>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded.</li>+-- </ul>+hSetPosn :: HandlePosn -> IO ()++-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of+-- handle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>+-- is given in terms of 8-bit bytes.+-- +-- If <tt>hdl</tt> is block- or line-buffered, then seeking to a position+-- which is not in the current buffer will first cause any items in the+-- output buffer to be written to the device, and then cause the input+-- buffer to be discarded. Some handles may not be seekable (see+-- <a>hIsSeekable</a>), or only support a subset of the possible+-- positioning operations (for instance, it may only be possible to seek+-- to the end of a tape, or to a positive offset from the beginning or+-- current position). It is not possible to set a negative I/O position,+-- or for a physical file, an I/O position beyond the current+-- end-of-file.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or+-- does not support the requested seek mode.</li>+-- <li><tt>isPermissionError</tt> if a system resource limit would be+-- exceeded.</li>+-- </ul>+hSeek :: Handle -> SeekMode -> Integer -> IO ()++-- | Computation <a>hWaitForInput</a> <tt>hdl t</tt> waits until input is+-- available on handle <tt>hdl</tt>. It returns <a>True</a> as soon as+-- input is available on <tt>hdl</tt>, or <a>False</a> if no input is+-- available within <tt>t</tt> milliseconds. Note that+-- <a>hWaitForInput</a> waits until one or more full <i>characters</i>+-- are available, which means that it needs to do decoding, and hence may+-- fail with a decoding error.+-- +-- If <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits+-- indefinitely.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file has been reached.</li>+-- <li>a decoding error, if the input begins with an invalid byte+-- sequence in this Handle's encoding.</li>+-- </ul>+-- +-- NOTE for GHC users: unless you use the <tt>-threaded</tt> flag,+-- <tt>hWaitForInput t</tt> where <tt>t >= 0</tt> will block all other+-- Haskell threads for the duration of the call. It behaves like a+-- <tt>safe</tt> foreign call in this respect.+hWaitForInput :: Handle -> Int -> IO Bool++-- | Computation <a>hReady</a> <tt>hdl</tt> indicates whether at least one+-- item is available for input from handle <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isEOFError</tt> if the end of file has been+-- reached.</li>+-- </ul>+hReady :: Handle -> IO Bool++-- | Computation <a>hGetChar</a> <tt>hdl</tt> reads a character from the+-- file or channel managed by <tt>hdl</tt>, blocking until a character is+-- available.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file has been reached.</li>+-- </ul>+hGetChar :: Handle -> IO Char++-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or+-- channel managed by <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file is encountered when reading+-- the <i>first</i> character of the line.</li>+-- </ul>+-- +-- If <a>hGetLine</a> encounters end-of-file at any other point while+-- reading in a line, it is treated as a line terminator and the+-- (partial) line is returned.+hGetLine :: Handle -> IO String++-- | Computation <a>hLookAhead</a> returns the next character from the+-- handle without removing it from the input buffer, blocking until a+-- character is available.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>isEOFError</tt> if the end of file has been reached.</li>+-- </ul>+hLookAhead :: Handle -> IO Char++-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of+-- characters corresponding to the unread portion of the channel or file+-- managed by <tt>hdl</tt>, which is put into an intermediate state,+-- <i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,+-- but items are read from <tt>hdl</tt> on demand and accumulated in a+-- special list returned by <a>hGetContents</a> <tt>hdl</tt>.+-- +-- Any operation that fails because a handle is closed, also fails if a+-- handle is semi-closed. The only exception is <tt>hClose</tt>. A+-- semi-closed handle becomes closed:+-- +-- <ul>+-- <li>if <tt>hClose</tt> is applied to it;</li>+-- <li>if an I/O error occurs when reading an item from the handle;</li>+-- <li>or once the entire contents of the handle has been read.</li>+-- </ul>+-- +-- Once a semi-closed handle becomes closed, the contents of the+-- associated list becomes fixed. The contents of this final list is only+-- partially specified: it will contain at least all the items of the+-- stream that were evaluated prior to the handle becoming closed.+-- +-- Any I/O errors encountered while a handle is semi-closed are simply+-- discarded.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isEOFError</a> if the end of file has been reached.</li>+-- </ul>+hGetContents :: Handle -> IO String++-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character+-- <tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters+-- may be buffered if buffering is enabled for <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isFullError</a> if the device is full; or</li>+-- <li><a>isPermissionError</a> if another system resource limit would be+-- exceeded.</li>+-- </ul>+hPutChar :: Handle -> Char -> IO ()++-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>+-- to the file or channel managed by <tt>hdl</tt>.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><a>isFullError</a> if the device is full; or</li>+-- <li><a>isPermissionError</a> if another system resource limit would be+-- exceeded.</li>+-- </ul>+hPutStr :: Handle -> String -> IO ()++-- | The same as <a>hPutStr</a>, but adds a newline character.+hPutStrLn :: Handle -> String -> IO ()++-- | Computation <a>hPrint</a> <tt>hdl t</tt> writes the string+-- representation of <tt>t</tt> given by the <a>shows</a> function to the+-- file or channel managed by <tt>hdl</tt> and appends a newline.+-- +-- This operation may fail with:+-- +-- <ul>+-- <li><tt>System.IO.Error.isFullError</tt> if the device is full;+-- or</li>+-- <li><tt>System.IO.Error.isPermissionError</tt> if another system+-- resource limit would be exceeded.</li>+-- </ul>+hPrint :: Show a => Handle -> a -> IO ()+hIsOpen :: Handle -> IO Bool+hIsClosed :: Handle -> IO Bool+hIsReadable :: Handle -> IO Bool+hIsWritable :: Handle -> IO Bool+hIsSeekable :: Handle -> IO Bool++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments already exists.+isAlreadyExistsError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments does not exist.+isDoesNotExistError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because one of+-- its arguments is a single-use resource, which is already being used+-- (for example, opening the same file twice for writing might give this+-- error).+isAlreadyInUseError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- device is full.+isFullError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the end+-- of file has been reached.+isEOFError :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- operation was not possible. Any computation which returns an <a>IO</a>+-- result may fail with <a>isIllegalOperation</a>. In some cases, an+-- implementation will not be able to distinguish between the possible+-- error causes. In this case it should fail with+-- <a>isIllegalOperation</a>.+isIllegalOperation :: IOError -> Bool++-- | An error indicating that an <a>IO</a> operation failed because the+-- user does not have sufficient operating system privilege to perform+-- that operation.+isPermissionError :: IOError -> Bool++-- | A programmer-defined error value constructed using <a>userError</a>.+isUserError :: IOError -> Bool+ioeGetErrorString :: IOError -> String+ioeGetHandle :: IOError -> Maybe Handle+ioeGetFileName :: IOError -> Maybe FilePath++-- | The <a>try</a> function is deprecated. Please use the new exceptions+-- variant, <tt>Control.Exception.try</tt> from <a>Control.Exception</a>,+-- instead.+try :: IO a -> IO (Either IOError a)++-- | The <a>bracket</a> function captures a common allocate, compute,+-- deallocate idiom in which the deallocation step must occur even in the+-- case of an error during computation. This is similar to+-- try-catch-finally in Java.+-- +-- This version handles only IO errors, as defined by Haskell 98. The+-- version of <tt>bracket</tt> in <a>Control.Exception</a> handles all+-- exceptions, and should be used instead.+bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c++-- | A variant of <a>bracket</a> where the middle computation doesn't want+-- <tt>x</tt>.+-- +-- This version handles only IO errors, as defined by Haskell 98. The+-- version of <tt>bracket_</tt> in <a>Control.Exception</a> handles all+-- exceptions, and should be used instead.+bracket_ :: IO a -> (a -> IO b) -> IO c -> IO c++-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when+-- performed, does some I/O before returning a value of type <tt>a</tt>.+-- +-- There is really only one way to "perform" an I/O action: bind it to+-- <tt>Main.main</tt> in your program. When your program is run, the I/O+-- will be performed. It isn't possible to perform I/O from an arbitrary+-- function, unless that function is itself in the <a>IO</a> monad and+-- called at some point, directly or indirectly, from <tt>Main.main</tt>.+-- +-- <a>IO</a> is a monad, so <a>IO</a> actions can be combined using+-- either the do-notation or the <tt>>></tt> and <tt>>>=</tt>+-- operations from the <tt>Monad</tt> class.+data IO a :: * -> *++-- | File and directory names are values of type <a>String</a>, whose+-- precise meaning is operating system dependent. Files can be opened,+-- yielding a handle which can then be used to operate on the contents of+-- that file.+type FilePath = String++-- | The Haskell 98 type for exceptions in the <a>IO</a> monad. Any I/O+-- operation may raise an <a>IOError</a> instead of returning a result.+-- For a more general type of exception, including also those that arise+-- in pure code, see <a>Control.Exception.Exception</a>.+-- +-- In Haskell 98, this is an opaque type.+type IOError = IOException++-- | Raise an <a>IOError</a> in the <a>IO</a> monad.+ioError :: IOError -> IO a++-- | Construct an <a>IOError</a> value with a string describing the error.+-- The <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>+-- class raises a <a>userError</a>, thus:+-- +-- <pre>+-- instance Monad IO where +-- ...+-- fail s = ioError (userError s)+-- </pre>+userError :: String -> IOError++-- | The <a>catch</a> function is deprecated. Please use the new exceptions+-- variant, <tt>Control.Exception.catch</tt> from+-- <a>Control.Exception</a>, instead.+catch :: IO a -> (IOError -> IO a) -> IO a++-- | The <a>interact</a> function takes a function of type+-- <tt>String->String</tt> as its argument. The entire input from the+-- standard input device is passed to this function as its argument, and+-- the resulting string is output on the standard output device.+interact :: (String -> String) -> IO ()++-- | Write a character to the standard output device (same as+-- <a>hPutChar</a> <a>stdout</a>).+putChar :: Char -> IO ()++-- | Write a string to the standard output device (same as <a>hPutStr</a>+-- <a>stdout</a>).+putStr :: String -> IO ()++-- | The same as <a>putStr</a>, but adds a newline character.+putStrLn :: String -> IO ()++-- | The <a>print</a> function outputs a value of any printable type to the+-- standard output device. Printable types are those that are instances+-- of class <a>Show</a>; <a>print</a> converts values to strings for+-- output using the <a>show</a> operation and adds a newline.+-- +-- For example, a program to print the first 20 integers and their powers+-- of 2 could be written as:+-- +-- <pre>+-- main = print ([(n, 2^n) | n <- [0..19]])+-- </pre>+print :: Show a => a -> IO ()++-- | Read a character from the standard input device (same as+-- <a>hGetChar</a> <a>stdin</a>).+getChar :: IO Char++-- | Read a line from the standard input device (same as <a>hGetLine</a>+-- <a>stdin</a>).+getLine :: IO String++-- | The <a>getContents</a> operation returns all user input as a single+-- string, which is read lazily as it is needed (same as+-- <a>hGetContents</a> <a>stdin</a>).+getContents :: IO String++-- | The <a>readFile</a> function reads a file and returns the contents of+-- the file as a string. The file is read lazily, on demand, as with+-- <a>getContents</a>.+readFile :: FilePath -> IO String++-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the+-- string <tt>str</tt>, to the file <tt>file</tt>.+writeFile :: FilePath -> String -> IO ()++-- | The computation <a>appendFile</a> <tt>file str</tt> function appends+-- the string <tt>str</tt>, to the file <tt>file</tt>.+-- +-- Note that <a>writeFile</a> and <a>appendFile</a> write a literal+-- string to a file. To write a value of any printable type, as with+-- <a>print</a>, use the <a>show</a> function to convert the value to a+-- string first.+-- +-- <pre>+-- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])+-- </pre>+appendFile :: FilePath -> String -> IO ()++-- | The <a>readIO</a> function is similar to <a>read</a> except that it+-- signals parse failure to the <a>IO</a> monad instead of terminating+-- the program.+readIO :: Read a => String -> IO a++-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.+readLn :: Read a => IO a++module Char++-- | Selects the first 128 characters of the Unicode character set,+-- corresponding to the ASCII character set.+isAscii :: Char -> Bool++-- | Selects the first 256 characters of the Unicode character set,+-- corresponding to the ISO 8859-1 (Latin-1) character set.+isLatin1 :: Char -> Bool++-- | Selects control characters, which are the non-printing characters of+-- the Latin-1 subset of Unicode.+isControl :: Char -> Bool++-- | Selects printable Unicode characters (letters, numbers, marks,+-- punctuation, symbols and spaces).+isPrint :: Char -> Bool++-- | Returns <a>True</a> for any Unicode space character, and the control+-- characters <tt>\t</tt>, <tt>\n</tt>, <tt>\r</tt>, <tt>\f</tt>,+-- <tt>\v</tt>.+isSpace :: Char -> Bool++-- | Selects upper-case or title-case alphabetic Unicode characters+-- (letters). Title case is used by a small number of letter ligatures+-- like the single-character form of <i>Lj</i>.+isUpper :: Char -> Bool++-- | Selects lower-case alphabetic Unicode characters (letters).+isLower :: Char -> Bool++-- | Selects alphabetic Unicode characters (lower-case, upper-case and+-- title-case letters, plus letters of caseless scripts and modifiers+-- letters). This function is equivalent to <tt>Data.Char.isLetter</tt>.+isAlpha :: Char -> Bool++-- | Selects ASCII digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>.+isDigit :: Char -> Bool++-- | Selects ASCII octal digits, i.e. <tt>'0'</tt>..<tt>'7'</tt>.+isOctDigit :: Char -> Bool++-- | Selects ASCII hexadecimal digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>,+-- <tt>'a'</tt>..<tt>'f'</tt>, <tt>'A'</tt>..<tt>'F'</tt>.+isHexDigit :: Char -> Bool++-- | Selects alphabetic or numeric digit Unicode characters.+-- +-- Note that numeric digits outside the ASCII range are selected by this+-- function but not by <a>isDigit</a>. Such digits may be part of+-- identifiers but are not used by the printer and reader to represent+-- numbers.+isAlphaNum :: Char -> Bool++-- | Convert a single digit <a>Char</a> to the corresponding <a>Int</a>.+-- This function fails unless its argument satisfies <a>isHexDigit</a>,+-- but recognises both upper and lower-case hexadecimal digits (i.e.+-- <tt>'0'</tt>..<tt>'9'</tt>, <tt>'a'</tt>..<tt>'f'</tt>,+-- <tt>'A'</tt>..<tt>'F'</tt>).+digitToInt :: Char -> Int++-- | Convert an <a>Int</a> in the range <tt>0</tt>..<tt>15</tt> to the+-- corresponding single digit <a>Char</a>. This function fails on other+-- inputs, and generates lower-case hexadecimal digits.+intToDigit :: Int -> Char++-- | Convert a letter to the corresponding upper-case letter, if any. Any+-- other character is returned unchanged.+toUpper :: Char -> Char++-- | Convert a letter to the corresponding lower-case letter, if any. Any+-- other character is returned unchanged.+toLower :: Char -> Char++-- | The <tt>Prelude.fromEnum</tt> method restricted to the type+-- <tt>Data.Char.Char</tt>.+ord :: Char -> Int++-- | The <tt>Prelude.toEnum</tt> method restricted to the type+-- <tt>Data.Char.Char</tt>.+chr :: Int -> Char++-- | Read a string representation of a character, using Haskell+-- source-language escape conventions, and convert it to the character+-- that it encodes. For example:+-- +-- <pre>+-- readLitChar "\\nHello" = [('\n', "Hello")]+-- </pre>+readLitChar :: ReadS Char++-- | Convert a character to a string using only printable characters, using+-- Haskell source-language escape conventions. For example:+-- +-- <pre>+-- showLitChar '\n' s = "\\n" ++ s+-- </pre>+showLitChar :: Char -> ShowS++-- | Read a string representation of a character, using Haskell+-- source-language escape conventions. For example:+-- +-- <pre>+-- lexLitChar "\\nHello" = [("\\n", "Hello")]+-- </pre>+lexLitChar :: ReadS String++-- | The character type <a>Char</a> is an enumeration whose values+-- represent Unicode (or equivalently ISO/IEC 10646) characters (see+-- <a>http://www.unicode.org/</a> for details). This set extends the ISO+-- 8859-1 (Latin-1) character set (the first 256 charachers), which is+-- itself an extension of the ASCII character set (the first 128+-- characters). A character literal in Haskell has type <a>Char</a>.+-- +-- To convert a <a>Char</a> to or from the corresponding <a>Int</a> value+-- defined by Unicode, use <tt>Prelude.toEnum</tt> and+-- <tt>Prelude.fromEnum</tt> from the <tt>Prelude.Enum</tt> class+-- respectively (or equivalently <tt>ord</tt> and <tt>chr</tt>).+data Char :: *++-- | A <a>String</a> is a list of characters. String constants in Haskell+-- are values of type <a>String</a>.+type String = [Char]++module Int++module Ix++-- | The <a>Ix</a> class is used to map a contiguous subrange of values in+-- a type onto integers. It is used primarily for array indexing (see the+-- array package).+-- +-- The first argument <tt>(l,u)</tt> of each of these operations is a+-- pair specifying the lower and upper bounds of a contiguous subrange of+-- values.+-- +-- An implementation is entitled to assume the following laws about these+-- operations:+-- +-- <ul>+-- <li><tt><a>inRange</a> (l,u) i == <a>elem</a> i (<a>range</a>+-- (l,u))</tt> <tt> </tt></li>+-- <li><tt><a>range</a> (l,u) <a>!!</a> <a>index</a> (l,u) i == i</tt>,+-- when <tt><a>inRange</a> (l,u) i</tt></li>+-- <li><tt><a>map</a> (<a>index</a> (l,u)) (<a>range</a> (l,u))) ==+-- [0..<a>rangeSize</a> (l,u)-1]</tt> <tt> </tt></li>+-- <li><tt><a>rangeSize</a> (l,u) == <a>length</a> (<a>range</a>+-- (l,u))</tt> <tt> </tt></li>+-- </ul>+-- +-- Minimal complete instance: <a>range</a>, <a>index</a> and+-- <a>inRange</a>.+class Ord a => Ix a+range :: Ix a => (a, a) -> [a]+index :: Ix a => (a, a) -> a -> Int+inRange :: Ix a => (a, a) -> a -> Bool+rangeSize :: Ix a => (a, a) -> Int++-- | The size of the subrange defined by a bounding pair.+rangeSize :: Ix a => (a, a) -> Int++module Array++-- | The type of immutable non-strict (boxed) arrays with indices in+-- <tt>i</tt> and elements in <tt>e</tt>.+data Array i e :: * -> * -> *++-- | Construct an array with the specified bounds and containing values for+-- given indices within these bounds.+-- +-- The array is undefined (i.e. bottom) if any index in the list is out+-- of bounds. The Haskell 98 Report further specifies that if any two+-- associations in the list have the same index, the value at that index+-- is undefined (i.e. bottom). However in GHC's implementation, the value+-- at such an index is the value part of the last association with that+-- index in the list.+-- +-- Because the indices must be checked for these errors, <a>array</a> is+-- strict in the bounds argument and in the indices of the association+-- list, but non-strict in the values. Thus, recurrences such as the+-- following are possible:+-- +-- <pre>+-- a = array (1,100) ((1,1) : [(i, i * a!(i-1)) | i <- [2..100]])+-- </pre>+-- +-- Not every index within the bounds of the array need appear in the+-- association list, but the values associated with indices that do not+-- appear will be undefined (i.e. bottom).+-- +-- If, in any dimension, the lower bound is greater than the upper bound,+-- then the array is legal, but empty. Indexing an empty array always+-- gives an array-bounds error, but <a>bounds</a> still yields the bounds+-- with which the array was constructed.+array :: Ix i => (i, i) -> [(i, e)] -> Array i e++-- | Construct an array from a pair of bounds and a list of values in index+-- order.+listArray :: Ix i => (i, i) -> [e] -> Array i e++-- | The value at the given index in an array.+(!) :: Ix i => Array i e -> i -> e++-- | The bounds with which an array was constructed.+bounds :: Ix i => Array i e -> (i, i)++-- | The list of indices of an array in ascending order.+indices :: Ix i => Array i e -> [i]++-- | The list of elements of an array in index order.+elems :: Ix i => Array i e -> [e]++-- | The list of associations of an array in index order.+assocs :: Ix i => Array i e -> [(i, e)]++-- | The <a>accumArray</a> function deals with repeated indices in the+-- association list using an <i>accumulating function</i> which combines+-- the values of associations with the same index. For example, given a+-- list of values of some index type, <tt>hist</tt> produces a histogram+-- of the number of occurrences of each index within a specified range:+-- +-- <pre>+-- hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b+-- hist bnds is = accumArray (+) 0 bnds [(i, 1) | i<-is, inRange bnds i]+-- </pre>+-- +-- If the accumulating function is strict, then <a>accumArray</a> is+-- strict in the values, as well as the indices, in the association list.+-- Thus, unlike ordinary arrays built with <a>array</a>, accumulated+-- arrays should not in general be recursive.+accumArray :: Ix i => (e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e++-- | Constructs an array identical to the first argument except that it has+-- been updated by the associations in the right argument. For example,+-- if <tt>m</tt> is a 1-origin, <tt>n</tt> by <tt>n</tt> matrix, then+-- +-- <pre>+-- m//[((i,i), 0) | i <- [1..n]]+-- </pre>+-- +-- is the same matrix, except with the diagonal zeroed.+-- +-- Repeated indices in the association list are handled as for+-- <a>array</a>: Haskell 98 specifies that the resulting array is+-- undefined (i.e. bottom), but GHC's implementation uses the last+-- association for each index.+(//) :: Ix i => Array i e -> [(i, e)] -> Array i e++-- | <tt><a>accum</a> f</tt> takes an array and an association list and+-- accumulates pairs from the list into the array with the accumulating+-- function <tt>f</tt>. Thus <a>accumArray</a> can be defined using+-- <a>accum</a>:+-- +-- <pre>+-- accumArray f z b = accum f (array b [(i, z) | i <- range b])+-- </pre>+accum :: Ix i => (e -> a -> e) -> Array i e -> [(i, a)] -> Array i e++-- | <a>ixmap</a> allows for transformations on array indices. It may be+-- thought of as providing function composition on the right with the+-- mapping that the original array embodies.+-- +-- A similar transformation of array values may be achieved using+-- <a>fmap</a> from the <a>Array</a> instance of the <a>Functor</a>+-- class.+ixmap :: (Ix i, Ix j) => (i, i) -> (i -> j) -> Array j e -> Array i e
+ data/html.txt view
@@ -0,0 +1,272 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | HTML combinator library+-- +-- This package contains a combinator library for constructing HTML+-- documents.+@package html+@version 1.0.1.2+++-- | An Html combinator library+module Text.Html.BlockTable+data BlockTable a+single :: a -> BlockTable a+empty :: BlockTable a+above :: BlockTable a -> BlockTable a -> BlockTable a+beside :: BlockTable a -> BlockTable a -> BlockTable a+getMatrix :: BlockTable a -> [[(a, (Int, Int))]]+showsTable :: Show a => BlockTable a -> ShowS+showTable :: Show a => BlockTable a -> String+instance Show a => Show (BlockTable a)+++-- | An Html combinator library+module Text.Html+data HtmlElement+HtmlString :: String -> HtmlElement+HtmlTag :: String -> [HtmlAttr] -> Html -> HtmlElement+markupTag :: HtmlElement -> String+markupAttrs :: HtmlElement -> [HtmlAttr]+markupContent :: HtmlElement -> Html+data HtmlAttr+HtmlAttr :: String -> String -> HtmlAttr+newtype Html+Html :: [HtmlElement] -> Html+getHtmlElements :: Html -> [HtmlElement]+class HTML a+toHtml :: HTML a => a -> Html+toHtmlFromList :: HTML a => [a] -> Html+class ADDATTRS a+(!) :: ADDATTRS a => a -> [HtmlAttr] -> a+(<<) :: HTML a => (Html -> b) -> a -> b+concatHtml :: HTML a => [a] -> Html+(+++) :: (HTML a, HTML b) => a -> b -> Html+noHtml :: Html+tag :: String -> Html -> Html+itag :: String -> Html+emptyAttr :: String -> HtmlAttr+intAttr :: String -> Int -> HtmlAttr+strAttr :: String -> String -> HtmlAttr+stringToHtmlString :: String -> String+type URL = String+primHtml :: String -> Html+stringToHtml :: String -> Html+lineToHtml :: String -> Html+address :: Html -> Html+anchor :: Html -> Html+applet :: Html -> Html+area :: Html+basefont :: Html+big :: Html -> Html+blockquote :: Html -> Html+body :: Html -> Html+bold :: Html -> Html+br :: Html+caption :: Html -> Html+center :: Html -> Html+cite :: Html -> Html+ddef :: Html -> Html+define :: Html -> Html+dlist :: Html -> Html+dterm :: Html -> Html+emphasize :: Html -> Html+fieldset :: Html -> Html+font :: Html -> Html+form :: Html -> Html+frame :: Html -> Html+frameset :: Html -> Html+h1 :: Html -> Html+h2 :: Html -> Html+h3 :: Html -> Html+h4 :: Html -> Html+h5 :: Html -> Html+h6 :: Html -> Html+header :: Html -> Html+hr :: Html+image :: Html+input :: Html+italics :: Html -> Html+keyboard :: Html -> Html+legend :: Html -> Html+li :: Html -> Html+meta :: Html+noframes :: Html -> Html+olist :: Html -> Html+option :: Html -> Html+paragraph :: Html -> Html+param :: Html+pre :: Html -> Html+sample :: Html -> Html+select :: Html -> Html+small :: Html -> Html+strong :: Html -> Html+style :: Html -> Html+sub :: Html -> Html+sup :: Html -> Html+table :: Html -> Html+td :: Html -> Html+textarea :: Html -> Html+th :: Html -> Html+thebase :: Html+thecode :: Html -> Html+thediv :: Html -> Html+thehtml :: Html -> Html+thelink :: Html -> Html+themap :: Html -> Html+thespan :: Html -> Html+thetitle :: Html -> Html+tr :: Html -> Html+tt :: Html -> Html+ulist :: Html -> Html+underline :: Html -> Html+variable :: Html -> Html+action :: String -> HtmlAttr+align :: String -> HtmlAttr+alink :: String -> HtmlAttr+alt :: String -> HtmlAttr+altcode :: String -> HtmlAttr+archive :: String -> HtmlAttr+background :: String -> HtmlAttr+base :: String -> HtmlAttr+bgcolor :: String -> HtmlAttr+border :: Int -> HtmlAttr+bordercolor :: String -> HtmlAttr+cellpadding :: Int -> HtmlAttr+cellspacing :: Int -> HtmlAttr+checked :: HtmlAttr+clear :: String -> HtmlAttr+code :: String -> HtmlAttr+codebase :: String -> HtmlAttr+color :: String -> HtmlAttr+cols :: String -> HtmlAttr+colspan :: Int -> HtmlAttr+compact :: HtmlAttr+content :: String -> HtmlAttr+coords :: String -> HtmlAttr+enctype :: String -> HtmlAttr+face :: String -> HtmlAttr+frameborder :: Int -> HtmlAttr+height :: Int -> HtmlAttr+href :: String -> HtmlAttr+hspace :: Int -> HtmlAttr+httpequiv :: String -> HtmlAttr+identifier :: String -> HtmlAttr+ismap :: HtmlAttr+lang :: String -> HtmlAttr+link :: String -> HtmlAttr+marginheight :: Int -> HtmlAttr+marginwidth :: Int -> HtmlAttr+maxlength :: Int -> HtmlAttr+method :: String -> HtmlAttr+multiple :: HtmlAttr+name :: String -> HtmlAttr+nohref :: HtmlAttr+noresize :: HtmlAttr+noshade :: HtmlAttr+nowrap :: HtmlAttr+rel :: String -> HtmlAttr+rev :: String -> HtmlAttr+rows :: String -> HtmlAttr+rowspan :: Int -> HtmlAttr+rules :: String -> HtmlAttr+scrolling :: String -> HtmlAttr+selected :: HtmlAttr+shape :: String -> HtmlAttr+size :: String -> HtmlAttr+src :: String -> HtmlAttr+start :: Int -> HtmlAttr+target :: String -> HtmlAttr+text :: String -> HtmlAttr+theclass :: String -> HtmlAttr+thestyle :: String -> HtmlAttr+thetype :: String -> HtmlAttr+title :: String -> HtmlAttr+usemap :: String -> HtmlAttr+valign :: String -> HtmlAttr+value :: String -> HtmlAttr+version :: String -> HtmlAttr+vlink :: String -> HtmlAttr+vspace :: Int -> HtmlAttr+width :: String -> HtmlAttr+validHtmlTags :: [String]+validHtmlITags :: [String]+validHtmlAttrs :: [String]+aqua :: String+black :: String+blue :: String+fuchsia :: String+gray :: String+green :: String+lime :: String+maroon :: String+navy :: String+olive :: String+purple :: String+red :: String+silver :: String+teal :: String+yellow :: String+white :: String+linesToHtml :: [String] -> Html+primHtmlChar :: String -> Html+copyright :: Html+spaceHtml :: Html+bullet :: Html+p :: Html -> Html+class HTMLTABLE ht+cell :: HTMLTABLE ht => ht -> HtmlTable+newtype HtmlTable+HtmlTable :: (BlockTable (Int -> Int -> Html)) -> HtmlTable+(</>, beside, <->, above) :: (HTMLTABLE ht1, HTMLTABLE ht2) => ht1 -> ht2 -> HtmlTable+aboves, besides :: HTMLTABLE ht => [ht] -> HtmlTable+simpleTable :: [HtmlAttr] -> [HtmlAttr] -> [[Html]] -> Html+mkHtmlTable :: BlockTable (Int -> Int -> Html) -> HtmlTable+renderTable :: BlockTable (Int -> Int -> Html) -> Html+data HtmlTree+HtmlLeaf :: Html -> HtmlTree+HtmlNode :: Html -> [HtmlTree] -> Html -> HtmlTree+treeHtml :: [String] -> HtmlTree -> Html+debugHtml :: HTML a => a -> Html+data HotLink+HotLink :: URL -> [Html] -> [HtmlAttr] -> HotLink+hotLinkURL :: HotLink -> URL+hotLinkContents :: HotLink -> [Html]+hotLinkAttributes :: HotLink -> [HtmlAttr]+hotlink :: URL -> [Html] -> HotLink+ordList :: HTML a => [a] -> Html+unordList :: HTML a => [a] -> Html+defList :: (HTML a, HTML b) => [(a, b)] -> Html+widget :: String -> String -> [HtmlAttr] -> Html+checkbox :: String -> String -> Html+hidden :: String -> String -> Html+radio :: String -> String -> Html+reset :: String -> String -> Html+submit :: String -> String -> Html+password :: String -> Html+textfield :: String -> Html+afile :: String -> Html+clickmap :: String -> Html+menu :: String -> [Html] -> Html+gui :: String -> Html -> Html+renderHtml :: HTML html => html -> String+prettyHtml :: HTML html => html -> String+renderHtml' :: Int -> HtmlElement -> ShowS+prettyHtml' :: HtmlElement -> [String]+renderTag :: Bool -> String -> [HtmlAttr] -> Int -> ShowS+instance Show HotLink+instance HTML HotLink+instance HTML HtmlTree+instance Show HtmlTable+instance HTML HtmlTable+instance HTMLTABLE Html+instance HTMLTABLE HtmlTable+instance Show HtmlAttr+instance Show Html+instance ADDATTRS Html+instance ADDATTRS b => ADDATTRS (a -> b)+instance HTML a => HTML [a]+instance HTML Char+instance HTML Html
+ data/vector.txt view
@@ -0,0 +1,8948 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Efficient Arrays+-- +-- An efficient implementation of Int-indexed arrays (both mutable and+-- immutable), with a powerful loop optimisation framework .+-- +-- It is structured as follows:+-- +-- <ul>+-- <li><i><a>Data.Vector</a></i> Boxed vectors of arbitrary types.</li>+-- <li><i><a>Data.Vector.Unboxed</a></i> Unboxed vectors with an adaptive+-- representation based on data type families.</li>+-- <li><i><a>Data.Vector.Storable</a></i> Unboxed vectors of+-- <a>Storable</a> types.</li>+-- <li><i><a>Data.Vector.Primitive</a></i> Unboxed vectors of primitive+-- types as defined by the <tt>primitive</tt> package.+-- <a>Data.Vector.Unboxed</a> is more flexible at no performance+-- cost.</li>+-- <li><i><a>Data.Vector.Generic</a></i> Generic interface to the vector+-- types.</li>+-- </ul>+-- +-- Each module has a <tt>Safe</tt> version with is marked as+-- <tt>Trustworthy</tt> (see+-- <a>http://hackage.haskell.org/trac/ghc/wiki/SafeHaskell</a>).+-- +-- There is also a (draft) tutorial on common uses of vector.+-- +-- <ul>+-- +-- <li><a>http://haskell.org/haskellwiki/Numeric_Haskell:_A_Vector_Tutorial</a></li>+-- </ul>+-- +-- Please use the project trac to submit bug reports and feature+-- requests.+-- +-- <ul>+-- <li><a>http://trac.haskell.org/vector</a></li>+-- </ul>+-- +-- Changes in version 0.9+-- +-- <ul>+-- <li><a>MonadPlus</a> instance for boxed vectors</li>+-- <li>Export more <tt>construct</tt> and <tt>constructN</tt> from+-- <tt>Safe</tt> modules</li>+-- <li>Require <tt>primitive-0.4.0.1</tt></li>+-- </ul>+-- +-- Changes in version 0.8+-- +-- <ul>+-- <li>New functions: <tt>constructN</tt>, <tt>constructrN</tt></li>+-- <li>Support for GHC 7.2 array copying primitives</li>+-- <li>New fixity for <tt>(!)</tt></li>+-- <li>Safe Haskell support (contributed by David Terei)</li>+-- <li><a>Functor</a>, <a>Monad</a>, <a>Applicative</a>,+-- <a>Alternative</a>, <a>Foldable</a> and <a>Traversable</a> instances+-- for boxed vectors (<i>WARNING: they tend to be slow and are only+-- provided for completeness</i>)</li>+-- <li><a>Show</a> instances for immutable vectors follow containers+-- conventions</li>+-- <li><a>Read</a> instances for all immutable vector types</li>+-- <li>Performance improvements</li>+-- </ul>+@package vector+@version 0.9+++-- | Ugly internal utility functions for implementing <a>Storable</a>-based+-- vectors.+module Data.Vector.Storable.Internal+getPtr :: ForeignPtr a -> Ptr a+setPtr :: ForeignPtr a -> Ptr a -> ForeignPtr a+updPtr :: (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a+++-- | Fusion-related utility types+module Data.Vector.Fusion.Util++-- | Identity monad+newtype Id a+Id :: a -> Id a+unId :: Id a -> a++-- | Box monad+data Box a+Box :: a -> Box a+unBox :: Box a -> a++-- | Delay inlining a function until late in the game (simplifier phase 0).+delay_inline :: (a -> b) -> a -> b++-- | <a>min</a> inlined in phase 0+delayed_min :: Int -> Int -> Int+instance Monad Box+instance Functor Box+instance Monad Id+instance Functor Id+++-- | Size hints for streams.+module Data.Vector.Fusion.Stream.Size++-- | Size hint+data Size++-- | Exact size+Exact :: Int -> Size++-- | Upper bound on the size+Max :: Int -> Size++-- | Unknown size+Unknown :: Size++-- | Minimum of two size hints+smaller :: Size -> Size -> Size++-- | Maximum of two size hints+larger :: Size -> Size -> Size++-- | Convert a size hint to an upper bound+toMax :: Size -> Size++-- | Compute the maximum size from a size hint if possible+upperBound :: Size -> Maybe Int+instance Eq Size+instance Show Size+instance Num Size+++-- | Bounds checking infrastructure+module Data.Vector.Internal.Check+data Checks+Bounds :: Checks+Unsafe :: Checks+Internal :: Checks+doChecks :: Checks -> Bool+error :: String -> Int -> Checks -> String -> String -> a+emptyStream :: String -> Int -> Checks -> String -> a+check :: String -> Int -> Checks -> String -> String -> Bool -> a -> a+assert :: String -> Int -> Checks -> String -> Bool -> a -> a+checkIndex :: String -> Int -> Checks -> String -> Int -> Int -> a -> a+checkLength :: String -> Int -> Checks -> String -> Int -> a -> a+checkSlice :: String -> Int -> Checks -> String -> Int -> Int -> Int -> a -> a+instance Eq Checks+++-- | Monadic stream combinators.+module Data.Vector.Fusion.Stream.Monadic++-- | Monadic streams+data Stream m a+Stream :: (s -> m (Step s a)) -> s -> Size -> Stream m a++-- | Result of taking a single step in a stream+data Step s a++-- | a new element and a new seed+Yield :: a -> s -> Step s a++-- | just a new seed+Skip :: s -> Step s a++-- | end of stream+Done :: Step s a++-- | <a>Size</a> hint of a <a>Stream</a>+size :: Stream m a -> Size++-- | Attach a <a>Size</a> hint to a <a>Stream</a>+sized :: Stream m a -> Size -> Stream m a++-- | Length of a <a>Stream</a>+length :: Monad m => Stream m a -> m Int++-- | Check if a <a>Stream</a> is empty+null :: Monad m => Stream m a -> m Bool++-- | Empty <a>Stream</a>+empty :: Monad m => Stream m a++-- | Singleton <a>Stream</a>+singleton :: Monad m => a -> Stream m a++-- | Prepend an element+cons :: Monad m => a -> Stream m a -> Stream m a++-- | Append an element+snoc :: Monad m => Stream m a -> a -> Stream m a++-- | Replicate a value to a given length+replicate :: Monad m => Int -> a -> Stream m a++-- | Yield a <a>Stream</a> of values obtained by performing the monadic+-- action the given number of times+replicateM :: Monad m => Int -> m a -> Stream m a+generate :: Monad m => Int -> (Int -> a) -> Stream m a++-- | Generate a stream from its indices+generateM :: Monad m => Int -> (Int -> m a) -> Stream m a++-- | Concatenate two <a>Stream</a>s+(++) :: Monad m => Stream m a -> Stream m a -> Stream m a++-- | First element of the <a>Stream</a> or error if empty+head :: Monad m => Stream m a -> m a++-- | Last element of the <a>Stream</a> or error if empty+last :: Monad m => Stream m a -> m a++-- | Element at the given position+(!!) :: Monad m => Stream m a -> Int -> m a++-- | Element at the given position or <a>Nothing</a> if out of bounds+(!?) :: Monad m => Stream m a -> Int -> m (Maybe a)++-- | Extract a substream of the given length starting at the given+-- position.+slice :: Monad m => Int -> Int -> Stream m a -> Stream m a++-- | All but the last element+init :: Monad m => Stream m a -> Stream m a++-- | All but the first element+tail :: Monad m => Stream m a -> Stream m a++-- | The first <tt>n</tt> elements+take :: Monad m => Int -> Stream m a -> Stream m a++-- | All but the first <tt>n</tt> elements+drop :: Monad m => Int -> Stream m a -> Stream m a++-- | Map a function over a <a>Stream</a>+map :: Monad m => (a -> b) -> Stream m a -> Stream m b++-- | Map a monadic function over a <a>Stream</a>+mapM :: Monad m => (a -> m b) -> Stream m a -> Stream m b++-- | Execute a monadic action for each element of the <a>Stream</a>+mapM_ :: Monad m => (a -> m b) -> Stream m a -> m ()++-- | Transform a <a>Stream</a> to use a different monad+trans :: (Monad m, Monad m') => (forall a. m a -> m' a) -> Stream m a -> Stream m' a+unbox :: Monad m => Stream m (Box a) -> Stream m a+concatMap :: Monad m => (a -> Stream m b) -> Stream m a -> Stream m b++-- | Create a <a>Stream</a> of values from a <a>Stream</a> of streamable+-- things+flatten :: Monad m => (a -> m s) -> (s -> m (Step s b)) -> Size -> Stream m a -> Stream m b++-- | Pair each element in a <a>Stream</a> with its index+indexed :: Monad m => Stream m a -> Stream m (Int, a)++-- | Pair each element in a <a>Stream</a> with its index, starting from the+-- right and counting down+indexedR :: Monad m => Int -> Stream m a -> Stream m (Int, a)+zipWithM_ :: Monad m => (a -> b -> m c) -> Stream m a -> Stream m b -> m ()++-- | Zip two <a>Stream</a>s with the given monadic function+zipWithM :: Monad m => (a -> b -> m c) -> Stream m a -> Stream m b -> Stream m c+zipWith3M :: Monad m => (a -> b -> c -> m d) -> Stream m a -> Stream m b -> Stream m c -> Stream m d+zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e+zipWith5M :: Monad m => (a -> b -> c -> d -> e -> m f) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f+zipWith6M :: Monad m => (a -> b -> c -> d -> e -> f -> m g) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g+zipWith :: Monad m => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c+zipWith3 :: Monad m => (a -> b -> c -> d) -> Stream m a -> Stream m b -> Stream m c -> Stream m d+zipWith4 :: Monad m => (a -> b -> c -> d -> e) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e+zipWith5 :: Monad m => (a -> b -> c -> d -> e -> f) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f+zipWith6 :: Monad m => (a -> b -> c -> d -> e -> f -> g) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g+zip :: Monad m => Stream m a -> Stream m b -> Stream m (a, b)+zip3 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m (a, b, c)+zip4 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m (a, b, c, d)+zip5 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m (a, b, c, d, e)+zip6 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m (a, b, c, d, e, f)++-- | Drop elements which do not satisfy the predicate+filter :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Drop elements which do not satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Longest prefix of elements that satisfy the predicate+takeWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Longest prefix of elements that satisfy the monadic predicate+takeWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Drop the longest prefix of elements that satisfy the predicate+dropWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Drop the longest prefix of elements that satisfy the monadic predicate+dropWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Check whether the <a>Stream</a> contains an element+elem :: (Monad m, Eq a) => a -> Stream m a -> m Bool++-- | Inverse of <a>elem</a>+notElem :: (Monad m, Eq a) => a -> Stream m a -> m Bool++-- | Yield <a>Just</a> the first element that satisfies the predicate or+-- <a>Nothing</a> if no such element exists.+find :: Monad m => (a -> Bool) -> Stream m a -> m (Maybe a)++-- | Yield <a>Just</a> the first element that satisfies the monadic+-- predicate or <a>Nothing</a> if no such element exists.+findM :: Monad m => (a -> m Bool) -> Stream m a -> m (Maybe a)++-- | Yield <a>Just</a> the index of the first element that satisfies the+-- predicate or <a>Nothing</a> if no such element exists.+findIndex :: Monad m => (a -> Bool) -> Stream m a -> m (Maybe Int)++-- | Yield <a>Just</a> the index of the first element that satisfies the+-- monadic predicate or <a>Nothing</a> if no such element exists.+findIndexM :: Monad m => (a -> m Bool) -> Stream m a -> m (Maybe Int)++-- | Left fold+foldl :: Monad m => (a -> b -> a) -> a -> Stream m b -> m a++-- | Left fold with a monadic operator+foldlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Left fold over a non-empty <a>Stream</a>+foldl1 :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Left fold over a non-empty <a>Stream</a> with a monadic operator+foldl1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Same as <a>foldlM</a>+foldM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Same as <a>foldl1M</a>+fold1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Left fold with a strict accumulator+foldl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> m a++-- | Left fold with a strict accumulator and a monadic operator+foldlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Left fold over a non-empty <a>Stream</a> with a strict accumulator+foldl1' :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Left fold over a non-empty <a>Stream</a> with a strict accumulator and+-- a monadic operator+foldl1M' :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Same as <a>foldlM'</a>+foldM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Same as <a>foldl1M'</a>+fold1M' :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Right fold+foldr :: Monad m => (a -> b -> b) -> b -> Stream m a -> m b++-- | Right fold with a monadic operator+foldrM :: Monad m => (a -> b -> m b) -> b -> Stream m a -> m b++-- | Right fold over a non-empty stream+foldr1 :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Right fold over a non-empty stream with a monadic operator+foldr1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a+and :: Monad m => Stream m Bool -> m Bool+or :: Monad m => Stream m Bool -> m Bool+concatMapM :: Monad m => (a -> m (Stream m b)) -> Stream m a -> Stream m b++-- | Unfold+unfoldr :: Monad m => (s -> Maybe (a, s)) -> s -> Stream m a++-- | Unfold with a monadic function+unfoldrM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Stream m a++-- | Unfold at most <tt>n</tt> elements+unfoldrN :: Monad m => Int -> (s -> Maybe (a, s)) -> s -> Stream m a++-- | Unfold at most <tt>n</tt> elements with a monadic functions+unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Stream m a++-- | Apply function n times to value. Zeroth element is original value.+iterateN :: Monad m => Int -> (a -> a) -> a -> Stream m a++-- | Apply monadic function n times to value. Zeroth element is original+-- value.+iterateNM :: Monad m => Int -> (a -> m a) -> a -> Stream m a++-- | Prefix scan+prescanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with a monadic operator+prescanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with strict accumulator+prescanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with strict accumulator and a monadic operator+prescanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Suffix scan+postscanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with a monadic operator+postscanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with strict accumulator+postscanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with strict acccumulator and a monadic operator+postscanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan+scanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with a monadic operator+scanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with strict accumulator+scanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with strict accumulator and a monadic operator+scanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Scan over a non-empty <a>Stream</a>+scanl1 :: Monad m => (a -> a -> a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a monadic operator+scanl1M :: Monad m => (a -> a -> m a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator+scanl1' :: Monad m => (a -> a -> a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator and a+-- monadic operator+scanl1M' :: Monad m => (a -> a -> m a) -> Stream m a -> Stream m a++-- | Yield a <a>Stream</a> of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc.+enumFromStepN :: (Num a, Monad m) => a -> a -> Int -> Stream m a++-- | Enumerate values+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromTo :: (Enum a, Monad m) => a -> a -> Stream m a++-- | Enumerate values with a given step.+-- +-- <i>WARNING:</i> This operation is very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Enum a, Monad m) => a -> a -> a -> Stream m a++-- | Convert a <a>Stream</a> to a list+toList :: Monad m => Stream m a -> m [a]++-- | Convert a list to a <a>Stream</a>+fromList :: Monad m => [a] -> Stream m a++-- | Convert the first <tt>n</tt> elements of a list to a <a>Stream</a>+fromListN :: Monad m => Int -> [a] -> Stream m a++-- | Convert a list to a <a>Stream</a> with the given <a>Size</a> hint.+unsafeFromList :: Monad m => Size -> [a] -> Stream m a+instance Monad m => Functor (Stream m)+++-- | Streams for stream fusion+module Data.Vector.Fusion.Stream++-- | Result of taking a single step in a stream+data Step s a++-- | a new element and a new seed+Yield :: a -> s -> Step s a++-- | just a new seed+Skip :: s -> Step s a++-- | end of stream+Done :: Step s a++-- | The type of pure streams+type Stream = Stream Id++-- | Alternative name for monadic streams+type MStream = Stream+inplace :: (forall m. Monad m => Stream m a -> Stream m b) -> Stream a -> Stream b++-- | <a>Size</a> hint of a <a>Stream</a>+size :: Stream a -> Size++-- | Attach a <a>Size</a> hint to a <a>Stream</a>+sized :: Stream a -> Size -> Stream a++-- | Length of a <a>Stream</a>+length :: Stream a -> Int++-- | Check if a <a>Stream</a> is empty+null :: Stream a -> Bool++-- | Empty <a>Stream</a>+empty :: Stream a++-- | Singleton <a>Stream</a>+singleton :: a -> Stream a++-- | Prepend an element+cons :: a -> Stream a -> Stream a++-- | Append an element+snoc :: Stream a -> a -> Stream a++-- | Replicate a value to a given length+replicate :: Int -> a -> Stream a++-- | Generate a stream from its indices+generate :: Int -> (Int -> a) -> Stream a++-- | Concatenate two <a>Stream</a>s+(++) :: Stream a -> Stream a -> Stream a++-- | First element of the <a>Stream</a> or error if empty+head :: Stream a -> a++-- | Last element of the <a>Stream</a> or error if empty+last :: Stream a -> a++-- | Element at the given position+(!!) :: Stream a -> Int -> a++-- | Element at the given position or <a>Nothing</a> if out of bounds+(!?) :: Stream a -> Int -> Maybe a++-- | Extract a substream of the given length starting at the given+-- position.+slice :: Int -> Int -> Stream a -> Stream a++-- | All but the last element+init :: Stream a -> Stream a++-- | All but the first element+tail :: Stream a -> Stream a++-- | The first <tt>n</tt> elements+take :: Int -> Stream a -> Stream a++-- | All but the first <tt>n</tt> elements+drop :: Int -> Stream a -> Stream a++-- | Map a function over a <a>Stream</a>+map :: (a -> b) -> Stream a -> Stream b+concatMap :: (a -> Stream b) -> Stream a -> Stream b++-- | Create a <a>Stream</a> of values from a <a>Stream</a> of streamable+-- things+flatten :: (a -> s) -> (s -> Step s b) -> Size -> Stream a -> Stream b+unbox :: Stream (Box a) -> Stream a++-- | Pair each element in a <a>Stream</a> with its index+indexed :: Stream a -> Stream (Int, a)++-- | Pair each element in a <a>Stream</a> with its index, starting from the+-- right and counting down+indexedR :: Int -> Stream a -> Stream (Int, a)++-- | Zip two <a>Stream</a>s with the given function+zipWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c++-- | Zip three <a>Stream</a>s with the given function+zipWith3 :: (a -> b -> c -> d) -> Stream a -> Stream b -> Stream c -> Stream d+zipWith4 :: (a -> b -> c -> d -> e) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e+zipWith5 :: (a -> b -> c -> d -> e -> f) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f -> Stream g+zip :: Stream a -> Stream b -> Stream (a, b)+zip3 :: Stream a -> Stream b -> Stream c -> Stream (a, b, c)+zip4 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream (a, b, c, d)+zip5 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream (a, b, c, d, e)+zip6 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f -> Stream (a, b, c, d, e, f)++-- | Drop elements which do not satisfy the predicate+filter :: (a -> Bool) -> Stream a -> Stream a++-- | Longest prefix of elements that satisfy the predicate+takeWhile :: (a -> Bool) -> Stream a -> Stream a++-- | Drop the longest prefix of elements that satisfy the predicate+dropWhile :: (a -> Bool) -> Stream a -> Stream a++-- | Check whether the <a>Stream</a> contains an element+elem :: Eq a => a -> Stream a -> Bool++-- | Inverse of <a>elem</a>+notElem :: Eq a => a -> Stream a -> Bool++-- | Yield <a>Just</a> the first element matching the predicate or+-- <a>Nothing</a> if no such element exists.+find :: (a -> Bool) -> Stream a -> Maybe a++-- | Yield <a>Just</a> the index of the first element matching the+-- predicate or <a>Nothing</a> if no such element exists.+findIndex :: (a -> Bool) -> Stream a -> Maybe Int++-- | Left fold+foldl :: (a -> b -> a) -> a -> Stream b -> a++-- | Left fold on non-empty <a>Stream</a>s+foldl1 :: (a -> a -> a) -> Stream a -> a++-- | Left fold with strict accumulator+foldl' :: (a -> b -> a) -> a -> Stream b -> a++-- | Left fold on non-empty <a>Stream</a>s with strict accumulator+foldl1' :: (a -> a -> a) -> Stream a -> a++-- | Right fold+foldr :: (a -> b -> b) -> b -> Stream a -> b++-- | Right fold on non-empty <a>Stream</a>s+foldr1 :: (a -> a -> a) -> Stream a -> a+and :: Stream Bool -> Bool+or :: Stream Bool -> Bool++-- | Unfold+unfoldr :: (s -> Maybe (a, s)) -> s -> Stream a++-- | Unfold at most <tt>n</tt> elements+unfoldrN :: Int -> (s -> Maybe (a, s)) -> s -> Stream a++-- | Apply function n-1 times to value. Zeroth element is original value.+iterateN :: Int -> (a -> a) -> a -> Stream a++-- | Prefix scan+prescanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Prefix scan with strict accumulator+prescanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Suffix scan+postscanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Suffix scan with strict accumulator+postscanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Haskell-style scan+scanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Haskell-style scan with strict accumulator+scanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Scan over a non-empty <a>Stream</a>+scanl1 :: (a -> a -> a) -> Stream a -> Stream a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator+scanl1' :: (a -> a -> a) -> Stream a -> Stream a++-- | Yield a <a>Stream</a> of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc.+enumFromStepN :: Num a => a -> a -> Int -> Stream a++-- | Enumerate values+-- +-- <i>WARNING:</i> This operations can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromTo :: Enum a => a -> a -> Stream a++-- | Enumerate values with a given step.+-- +-- <i>WARNING:</i> This operations is very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: Enum a => a -> a -> a -> Stream a++-- | Convert a <a>Stream</a> to a list+toList :: Stream a -> [a]++-- | Create a <a>Stream</a> from a list+fromList :: [a] -> Stream a++-- | Create a <a>Stream</a> from the first <tt>n</tt> elements of a list+-- +-- <pre>+-- fromListN n xs = fromList (take n xs)+-- </pre>+fromListN :: Int -> [a] -> Stream a+unsafeFromList :: Size -> [a] -> Stream a++-- | Convert a pure stream to a monadic stream+liftStream :: Monad m => Stream a -> Stream m a++-- | Apply a monadic action to each element of the stream, producing a+-- monadic stream of results+mapM :: Monad m => (a -> m b) -> Stream a -> Stream m b++-- | Apply a monadic action to each element of the stream+mapM_ :: Monad m => (a -> m b) -> Stream a -> m ()+zipWithM :: Monad m => (a -> b -> m c) -> Stream a -> Stream b -> Stream m c+zipWithM_ :: Monad m => (a -> b -> m c) -> Stream a -> Stream b -> m ()++-- | Yield a monadic stream of elements that satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Stream a -> Stream m a++-- | Monadic fold+foldM :: Monad m => (a -> b -> m a) -> a -> Stream b -> m a++-- | Monadic fold over non-empty stream+fold1M :: Monad m => (a -> a -> m a) -> Stream a -> m a++-- | Monadic fold with strict accumulator+foldM' :: Monad m => (a -> b -> m a) -> a -> Stream b -> m a++-- | Monad fold over non-empty stream with strict accumulator+fold1M' :: Monad m => (a -> a -> m a) -> Stream a -> m a++-- | Check if two <a>Stream</a>s are equal+eq :: Eq a => Stream a -> Stream a -> Bool++-- | Lexicographically compare two <a>Stream</a>s+cmp :: Ord a => Stream a -> Stream a -> Ordering+instance Ord a => Ord (Stream Id a)+instance Eq a => Eq (Stream Id a)+++-- | Safe interface to <a>Data.Vector.Fusion.Stream</a>+module Data.Vector.Fusion.Stream.Safe++-- | Result of taking a single step in a stream+data Step s a++-- | a new element and a new seed+Yield :: a -> s -> Step s a++-- | just a new seed+Skip :: s -> Step s a++-- | end of stream+Done :: Step s a++-- | The type of pure streams+type Stream = Stream Id++-- | Alternative name for monadic streams+type MStream = Stream+inplace :: (forall m. Monad m => Stream m a -> Stream m b) -> Stream a -> Stream b++-- | <a>Size</a> hint of a <a>Stream</a>+size :: Stream a -> Size++-- | Attach a <a>Size</a> hint to a <a>Stream</a>+sized :: Stream a -> Size -> Stream a++-- | Length of a <a>Stream</a>+length :: Stream a -> Int++-- | Check if a <a>Stream</a> is empty+null :: Stream a -> Bool++-- | Empty <a>Stream</a>+empty :: Stream a++-- | Singleton <a>Stream</a>+singleton :: a -> Stream a++-- | Prepend an element+cons :: a -> Stream a -> Stream a++-- | Append an element+snoc :: Stream a -> a -> Stream a++-- | Replicate a value to a given length+replicate :: Int -> a -> Stream a++-- | Generate a stream from its indices+generate :: Int -> (Int -> a) -> Stream a++-- | Concatenate two <a>Stream</a>s+(++) :: Stream a -> Stream a -> Stream a++-- | First element of the <a>Stream</a> or error if empty+head :: Stream a -> a++-- | Last element of the <a>Stream</a> or error if empty+last :: Stream a -> a++-- | Element at the given position+(!!) :: Stream a -> Int -> a++-- | Extract a substream of the given length starting at the given+-- position.+slice :: Int -> Int -> Stream a -> Stream a++-- | All but the last element+init :: Stream a -> Stream a++-- | All but the first element+tail :: Stream a -> Stream a++-- | The first <tt>n</tt> elements+take :: Int -> Stream a -> Stream a++-- | All but the first <tt>n</tt> elements+drop :: Int -> Stream a -> Stream a++-- | Map a function over a <a>Stream</a>+map :: (a -> b) -> Stream a -> Stream b+concatMap :: (a -> Stream b) -> Stream a -> Stream b++-- | Create a <a>Stream</a> of values from a <a>Stream</a> of streamable+-- things+flatten :: (a -> s) -> (s -> Step s b) -> Size -> Stream a -> Stream b+unbox :: Stream (Box a) -> Stream a++-- | Pair each element in a <a>Stream</a> with its index+indexed :: Stream a -> Stream (Int, a)++-- | Pair each element in a <a>Stream</a> with its index, starting from the+-- right and counting down+indexedR :: Int -> Stream a -> Stream (Int, a)++-- | Zip two <a>Stream</a>s with the given function+zipWith :: (a -> b -> c) -> Stream a -> Stream b -> Stream c++-- | Zip three <a>Stream</a>s with the given function+zipWith3 :: (a -> b -> c -> d) -> Stream a -> Stream b -> Stream c -> Stream d+zipWith4 :: (a -> b -> c -> d -> e) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e+zipWith5 :: (a -> b -> c -> d -> e -> f) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f -> Stream g+zip :: Stream a -> Stream b -> Stream (a, b)+zip3 :: Stream a -> Stream b -> Stream c -> Stream (a, b, c)+zip4 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream (a, b, c, d)+zip5 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream (a, b, c, d, e)+zip6 :: Stream a -> Stream b -> Stream c -> Stream d -> Stream e -> Stream f -> Stream (a, b, c, d, e, f)++-- | Drop elements which do not satisfy the predicate+filter :: (a -> Bool) -> Stream a -> Stream a++-- | Longest prefix of elements that satisfy the predicate+takeWhile :: (a -> Bool) -> Stream a -> Stream a++-- | Drop the longest prefix of elements that satisfy the predicate+dropWhile :: (a -> Bool) -> Stream a -> Stream a++-- | Check whether the <a>Stream</a> contains an element+elem :: Eq a => a -> Stream a -> Bool++-- | Inverse of <a>elem</a>+notElem :: Eq a => a -> Stream a -> Bool++-- | Yield <a>Just</a> the first element matching the predicate or+-- <a>Nothing</a> if no such element exists.+find :: (a -> Bool) -> Stream a -> Maybe a++-- | Yield <a>Just</a> the index of the first element matching the+-- predicate or <a>Nothing</a> if no such element exists.+findIndex :: (a -> Bool) -> Stream a -> Maybe Int++-- | Left fold+foldl :: (a -> b -> a) -> a -> Stream b -> a++-- | Left fold on non-empty <a>Stream</a>s+foldl1 :: (a -> a -> a) -> Stream a -> a++-- | Left fold with strict accumulator+foldl' :: (a -> b -> a) -> a -> Stream b -> a++-- | Left fold on non-empty <a>Stream</a>s with strict accumulator+foldl1' :: (a -> a -> a) -> Stream a -> a++-- | Right fold+foldr :: (a -> b -> b) -> b -> Stream a -> b++-- | Right fold on non-empty <a>Stream</a>s+foldr1 :: (a -> a -> a) -> Stream a -> a+and :: Stream Bool -> Bool+or :: Stream Bool -> Bool++-- | Unfold+unfoldr :: (s -> Maybe (a, s)) -> s -> Stream a++-- | Unfold at most <tt>n</tt> elements+unfoldrN :: Int -> (s -> Maybe (a, s)) -> s -> Stream a++-- | Apply function n-1 times to value. Zeroth element is original value.+iterateN :: Int -> (a -> a) -> a -> Stream a++-- | Prefix scan+prescanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Prefix scan with strict accumulator+prescanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Suffix scan+postscanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Suffix scan with strict accumulator+postscanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Haskell-style scan+scanl :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Haskell-style scan with strict accumulator+scanl' :: (a -> b -> a) -> a -> Stream b -> Stream a++-- | Scan over a non-empty <a>Stream</a>+scanl1 :: (a -> a -> a) -> Stream a -> Stream a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator+scanl1' :: (a -> a -> a) -> Stream a -> Stream a++-- | Yield a <a>Stream</a> of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc.+enumFromStepN :: Num a => a -> a -> Int -> Stream a++-- | Enumerate values+-- +-- <i>WARNING:</i> This operations can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromTo :: Enum a => a -> a -> Stream a++-- | Enumerate values with a given step.+-- +-- <i>WARNING:</i> This operations is very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: Enum a => a -> a -> a -> Stream a++-- | Convert a <a>Stream</a> to a list+toList :: Stream a -> [a]++-- | Create a <a>Stream</a> from a list+fromList :: [a] -> Stream a++-- | Create a <a>Stream</a> from the first <tt>n</tt> elements of a list+-- +-- <pre>+-- fromListN n xs = fromList (take n xs)+-- </pre>+fromListN :: Int -> [a] -> Stream a++-- | Convert a pure stream to a monadic stream+liftStream :: Monad m => Stream a -> Stream m a++-- | Apply a monadic action to each element of the stream, producing a+-- monadic stream of results+mapM :: Monad m => (a -> m b) -> Stream a -> Stream m b++-- | Apply a monadic action to each element of the stream+mapM_ :: Monad m => (a -> m b) -> Stream a -> m ()+zipWithM :: Monad m => (a -> b -> m c) -> Stream a -> Stream b -> Stream m c+zipWithM_ :: Monad m => (a -> b -> m c) -> Stream a -> Stream b -> m ()++-- | Yield a monadic stream of elements that satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Stream a -> Stream m a++-- | Monadic fold+foldM :: Monad m => (a -> b -> m a) -> a -> Stream b -> m a++-- | Monadic fold over non-empty stream+fold1M :: Monad m => (a -> a -> m a) -> Stream a -> m a++-- | Monadic fold with strict accumulator+foldM' :: Monad m => (a -> b -> m a) -> a -> Stream b -> m a++-- | Monad fold over non-empty stream with strict accumulator+fold1M' :: Monad m => (a -> a -> m a) -> Stream a -> m a++-- | Check if two <a>Stream</a>s are equal+eq :: Eq a => Stream a -> Stream a -> Bool++-- | Lexicographically compare two <a>Stream</a>s+cmp :: Ord a => Stream a -> Stream a -> Ordering+++-- | Safe interface to <a>Data.Vector.Fusion.Stream.Monadic</a>+module Data.Vector.Fusion.Stream.Monadic.Safe++-- | Monadic streams+data Stream m a+Stream :: (s -> m (Step s a)) -> s -> Size -> Stream m a++-- | Result of taking a single step in a stream+data Step s a++-- | a new element and a new seed+Yield :: a -> s -> Step s a++-- | just a new seed+Skip :: s -> Step s a++-- | end of stream+Done :: Step s a++-- | <a>Size</a> hint of a <a>Stream</a>+size :: Stream m a -> Size++-- | Attach a <a>Size</a> hint to a <a>Stream</a>+sized :: Stream m a -> Size -> Stream m a++-- | Length of a <a>Stream</a>+length :: Monad m => Stream m a -> m Int++-- | Check if a <a>Stream</a> is empty+null :: Monad m => Stream m a -> m Bool++-- | Empty <a>Stream</a>+empty :: Monad m => Stream m a++-- | Singleton <a>Stream</a>+singleton :: Monad m => a -> Stream m a++-- | Prepend an element+cons :: Monad m => a -> Stream m a -> Stream m a++-- | Append an element+snoc :: Monad m => Stream m a -> a -> Stream m a++-- | Replicate a value to a given length+replicate :: Monad m => Int -> a -> Stream m a++-- | Yield a <a>Stream</a> of values obtained by performing the monadic+-- action the given number of times+replicateM :: Monad m => Int -> m a -> Stream m a+generate :: Monad m => Int -> (Int -> a) -> Stream m a++-- | Generate a stream from its indices+generateM :: Monad m => Int -> (Int -> m a) -> Stream m a++-- | Concatenate two <a>Stream</a>s+(++) :: Monad m => Stream m a -> Stream m a -> Stream m a++-- | First element of the <a>Stream</a> or error if empty+head :: Monad m => Stream m a -> m a++-- | Last element of the <a>Stream</a> or error if empty+last :: Monad m => Stream m a -> m a++-- | Element at the given position+(!!) :: Monad m => Stream m a -> Int -> m a++-- | Extract a substream of the given length starting at the given+-- position.+slice :: Monad m => Int -> Int -> Stream m a -> Stream m a++-- | All but the last element+init :: Monad m => Stream m a -> Stream m a++-- | All but the first element+tail :: Monad m => Stream m a -> Stream m a++-- | The first <tt>n</tt> elements+take :: Monad m => Int -> Stream m a -> Stream m a++-- | All but the first <tt>n</tt> elements+drop :: Monad m => Int -> Stream m a -> Stream m a++-- | Map a function over a <a>Stream</a>+map :: Monad m => (a -> b) -> Stream m a -> Stream m b++-- | Map a monadic function over a <a>Stream</a>+mapM :: Monad m => (a -> m b) -> Stream m a -> Stream m b++-- | Execute a monadic action for each element of the <a>Stream</a>+mapM_ :: Monad m => (a -> m b) -> Stream m a -> m ()++-- | Transform a <a>Stream</a> to use a different monad+trans :: (Monad m, Monad m') => (forall a. m a -> m' a) -> Stream m a -> Stream m' a+unbox :: Monad m => Stream m (Box a) -> Stream m a+concatMap :: Monad m => (a -> Stream m b) -> Stream m a -> Stream m b++-- | Create a <a>Stream</a> of values from a <a>Stream</a> of streamable+-- things+flatten :: Monad m => (a -> m s) -> (s -> m (Step s b)) -> Size -> Stream m a -> Stream m b++-- | Pair each element in a <a>Stream</a> with its index+indexed :: Monad m => Stream m a -> Stream m (Int, a)++-- | Pair each element in a <a>Stream</a> with its index, starting from the+-- right and counting down+indexedR :: Monad m => Int -> Stream m a -> Stream m (Int, a)+zipWithM_ :: Monad m => (a -> b -> m c) -> Stream m a -> Stream m b -> m ()++-- | Zip two <a>Stream</a>s with the given monadic function+zipWithM :: Monad m => (a -> b -> m c) -> Stream m a -> Stream m b -> Stream m c+zipWith3M :: Monad m => (a -> b -> c -> m d) -> Stream m a -> Stream m b -> Stream m c -> Stream m d+zipWith4M :: Monad m => (a -> b -> c -> d -> m e) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e+zipWith5M :: Monad m => (a -> b -> c -> d -> e -> m f) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f+zipWith6M :: Monad m => (a -> b -> c -> d -> e -> f -> m g) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g+zipWith :: Monad m => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c+zipWith3 :: Monad m => (a -> b -> c -> d) -> Stream m a -> Stream m b -> Stream m c -> Stream m d+zipWith4 :: Monad m => (a -> b -> c -> d -> e) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e+zipWith5 :: Monad m => (a -> b -> c -> d -> e -> f) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f+zipWith6 :: Monad m => (a -> b -> c -> d -> e -> f -> g) -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g+zip :: Monad m => Stream m a -> Stream m b -> Stream m (a, b)+zip3 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m (a, b, c)+zip4 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m (a, b, c, d)+zip5 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m (a, b, c, d, e)+zip6 :: Monad m => Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m (a, b, c, d, e, f)++-- | Drop elements which do not satisfy the predicate+filter :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Drop elements which do not satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Longest prefix of elements that satisfy the predicate+takeWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Longest prefix of elements that satisfy the monadic predicate+takeWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Drop the longest prefix of elements that satisfy the predicate+dropWhile :: Monad m => (a -> Bool) -> Stream m a -> Stream m a++-- | Drop the longest prefix of elements that satisfy the monadic predicate+dropWhileM :: Monad m => (a -> m Bool) -> Stream m a -> Stream m a++-- | Check whether the <a>Stream</a> contains an element+elem :: (Monad m, Eq a) => a -> Stream m a -> m Bool++-- | Inverse of <a>elem</a>+notElem :: (Monad m, Eq a) => a -> Stream m a -> m Bool++-- | Yield <a>Just</a> the first element that satisfies the predicate or+-- <a>Nothing</a> if no such element exists.+find :: Monad m => (a -> Bool) -> Stream m a -> m (Maybe a)++-- | Yield <a>Just</a> the first element that satisfies the monadic+-- predicate or <a>Nothing</a> if no such element exists.+findM :: Monad m => (a -> m Bool) -> Stream m a -> m (Maybe a)++-- | Yield <a>Just</a> the index of the first element that satisfies the+-- predicate or <a>Nothing</a> if no such element exists.+findIndex :: Monad m => (a -> Bool) -> Stream m a -> m (Maybe Int)++-- | Yield <a>Just</a> the index of the first element that satisfies the+-- monadic predicate or <a>Nothing</a> if no such element exists.+findIndexM :: Monad m => (a -> m Bool) -> Stream m a -> m (Maybe Int)++-- | Left fold+foldl :: Monad m => (a -> b -> a) -> a -> Stream m b -> m a++-- | Left fold with a monadic operator+foldlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Left fold over a non-empty <a>Stream</a>+foldl1 :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Left fold over a non-empty <a>Stream</a> with a monadic operator+foldl1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Same as <a>foldlM</a>+foldM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Same as <a>foldl1M</a>+fold1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Left fold with a strict accumulator+foldl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> m a++-- | Left fold with a strict accumulator and a monadic operator+foldlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Left fold over a non-empty <a>Stream</a> with a strict accumulator+foldl1' :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Left fold over a non-empty <a>Stream</a> with a strict accumulator and+-- a monadic operator+foldl1M' :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Same as <a>foldlM'</a>+foldM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a++-- | Same as <a>foldl1M'</a>+fold1M' :: Monad m => (a -> a -> m a) -> Stream m a -> m a++-- | Right fold+foldr :: Monad m => (a -> b -> b) -> b -> Stream m a -> m b++-- | Right fold with a monadic operator+foldrM :: Monad m => (a -> b -> m b) -> b -> Stream m a -> m b++-- | Right fold over a non-empty stream+foldr1 :: Monad m => (a -> a -> a) -> Stream m a -> m a++-- | Right fold over a non-empty stream with a monadic operator+foldr1M :: Monad m => (a -> a -> m a) -> Stream m a -> m a+and :: Monad m => Stream m Bool -> m Bool+or :: Monad m => Stream m Bool -> m Bool+concatMapM :: Monad m => (a -> m (Stream m b)) -> Stream m a -> Stream m b++-- | Unfold+unfoldr :: Monad m => (s -> Maybe (a, s)) -> s -> Stream m a++-- | Unfold with a monadic function+unfoldrM :: Monad m => (s -> m (Maybe (a, s))) -> s -> Stream m a++-- | Unfold at most <tt>n</tt> elements+unfoldrN :: Monad m => Int -> (s -> Maybe (a, s)) -> s -> Stream m a++-- | Unfold at most <tt>n</tt> elements with a monadic functions+unfoldrNM :: Monad m => Int -> (s -> m (Maybe (a, s))) -> s -> Stream m a++-- | Apply function n times to value. Zeroth element is original value.+iterateN :: Monad m => Int -> (a -> a) -> a -> Stream m a++-- | Apply monadic function n times to value. Zeroth element is original+-- value.+iterateNM :: Monad m => Int -> (a -> m a) -> a -> Stream m a++-- | Prefix scan+prescanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with a monadic operator+prescanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with strict accumulator+prescanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Prefix scan with strict accumulator and a monadic operator+prescanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Suffix scan+postscanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with a monadic operator+postscanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with strict accumulator+postscanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Suffix scan with strict acccumulator and a monadic operator+postscanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan+scanl :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with a monadic operator+scanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with strict accumulator+scanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a++-- | Haskell-style scan with strict accumulator and a monadic operator+scanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a++-- | Scan over a non-empty <a>Stream</a>+scanl1 :: Monad m => (a -> a -> a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a monadic operator+scanl1M :: Monad m => (a -> a -> m a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator+scanl1' :: Monad m => (a -> a -> a) -> Stream m a -> Stream m a++-- | Scan over a non-empty <a>Stream</a> with a strict accumulator and a+-- monadic operator+scanl1M' :: Monad m => (a -> a -> m a) -> Stream m a -> Stream m a++-- | Yield a <a>Stream</a> of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc.+enumFromStepN :: (Num a, Monad m) => a -> a -> Int -> Stream m a++-- | Enumerate values+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromTo :: (Enum a, Monad m) => a -> a -> Stream m a++-- | Enumerate values with a given step.+-- +-- <i>WARNING:</i> This operation is very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Enum a, Monad m) => a -> a -> a -> Stream m a++-- | Convert a <a>Stream</a> to a list+toList :: Monad m => Stream m a -> m [a]++-- | Convert a list to a <a>Stream</a>+fromList :: Monad m => [a] -> Stream m a++-- | Convert the first <tt>n</tt> elements of a list to a <a>Stream</a>+fromListN :: Monad m => Int -> [a] -> Stream m a+++-- | Generic interface to mutable vectors+module Data.Vector.Generic.Mutable++-- | Class of mutable vectors parametrised with a primitive state token.+class MVector v a+basicLength :: MVector v a => v s a -> Int+basicUnsafeSlice :: MVector v a => Int -> Int -> v s a -> v s a+basicOverlaps :: MVector v a => v s a -> v s a -> Bool+basicUnsafeNew :: (MVector v a, PrimMonad m) => Int -> m (v (PrimState m) a)+basicUnsafeReplicate :: (MVector v a, PrimMonad m) => Int -> a -> m (v (PrimState m) a)+basicUnsafeRead :: (MVector v a, PrimMonad m) => v (PrimState m) a -> Int -> m a+basicUnsafeWrite :: (MVector v a, PrimMonad m) => v (PrimState m) a -> Int -> a -> m ()+basicClear :: (MVector v a, PrimMonad m) => v (PrimState m) a -> m ()+basicSet :: (MVector v a, PrimMonad m) => v (PrimState m) a -> a -> m ()+basicUnsafeCopy :: (MVector v a, PrimMonad m) => v (PrimState m) a -> v (PrimState m) a -> m ()+basicUnsafeMove :: (MVector v a, PrimMonad m) => v (PrimState m) a -> v (PrimState m) a -> m ()+basicUnsafeGrow :: (MVector v a, PrimMonad m) => v (PrimState m) a -> Int -> m (v (PrimState m) a)++-- | Length of the mutable vector.+length :: MVector v a => v s a -> Int++-- | Check whether the vector is empty+null :: MVector v a => v s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: MVector v a => Int -> Int -> v s a -> v s a+init :: MVector v a => v s a -> v s a+tail :: MVector v a => v s a -> v s a+take :: MVector v a => Int -> v s a -> v s a+drop :: MVector v a => Int -> v s a -> v s a+splitAt :: MVector v a => Int -> v s a -> (v s a, v s a)++-- | Yield a part of the mutable vector without copying it. No bounds+-- checks are performed.+unsafeSlice :: MVector v a => Int -> Int -> v s a -> v s a+unsafeInit :: MVector v a => v s a -> v s a+unsafeTail :: MVector v a => v s a -> v s a+unsafeTake :: MVector v a => Int -> v s a -> v s a+unsafeDrop :: MVector v a => Int -> v s a -> v s a+overlaps :: MVector v a => v s a -> v s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, MVector v a) => Int -> m (v (PrimState m) a)++-- | Create a mutable vector of the given length. The length is not+-- checked.+unsafeNew :: (PrimMonad m, MVector v a) => Int -> m (v (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, MVector v a) => Int -> a -> m (v (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, MVector v a) => Int -> m a -> m (v (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (v (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m (v (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive but this is not checked.+unsafeGrow :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m (v (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> Int -> m ()++-- | Yield the element at the given position. No bounds checks are+-- performed.+unsafeRead :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m a++-- | Replace the element at the given position. No bounds checks are+-- performed.+unsafeWrite :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions. No bounds checks are+-- performed.+unsafeSwap :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, MVector v a) => v (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap. This is not checked.+unsafeCopy :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length, but this is not checked.+-- +-- If the vectors do not overlap, then this is equivalent to+-- <a>unsafeCopy</a>. Otherwise, the copying is performed as if the+-- source vector were copied to a temporary vector and then the temporary+-- vector was copied to the target vector.+unsafeMove :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()+mstream :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a+mstreamR :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a++-- | Create a new mutable vector and fill it with elements from the+-- <a>Stream</a>. The vector will grow exponentially if the maximum size+-- of the <a>Stream</a> is unknown.+unstream :: (PrimMonad m, MVector v a) => Stream a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the+-- <a>Stream</a> from right to left. The vector will grow exponentially+-- if the maximum size of the <a>Stream</a> is unknown.+unstreamR :: (PrimMonad m, MVector v a) => Stream a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the monadic+-- stream. The vector will grow exponentially if the maximum size of the+-- stream is unknown.+munstream :: (PrimMonad m, MVector v a) => MStream m a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the monadic+-- stream from right to left. The vector will grow exponentially if the+-- maximum size of the stream is unknown.+munstreamR :: (PrimMonad m, MVector v a) => MStream m a -> m (v (PrimState m) a)+transform :: (PrimMonad m, MVector v a) => (MStream m a -> MStream m a) -> v (PrimState m) a -> m (v (PrimState m) a)+transformR :: (PrimMonad m, MVector v a) => (MStream m a -> MStream m a) -> v (PrimState m) a -> m (v (PrimState m) a)+fill :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a -> m (v (PrimState m) a)+fillR :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a -> m (v (PrimState m) a)+unsafeAccum :: (PrimMonad m, MVector v a) => (a -> b -> a) -> v (PrimState m) a -> Stream (Int, b) -> m ()+accum :: (PrimMonad m, MVector v a) => (a -> b -> a) -> v (PrimState m) a -> Stream (Int, b) -> m ()+unsafeUpdate :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Stream (Int, a) -> m ()+update :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Stream (Int, a) -> m ()+reverse :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m ()+unstablePartition :: (PrimMonad m, MVector v a) => (a -> Bool) -> v (PrimState m) a -> m Int+unstablePartitionStream :: (PrimMonad m, MVector v a) => (a -> Bool) -> Stream a -> m (v (PrimState m) a, v (PrimState m) a)+partitionStream :: (PrimMonad m, MVector v a) => (a -> Bool) -> Stream a -> m (v (PrimState m) a, v (PrimState m) a)+++-- | Safe interface to <a>Data.Vector.Generic.Mutable</a>+module Data.Vector.Generic.Mutable.Safe++-- | Class of mutable vectors parametrised with a primitive state token.+class MVector v a++-- | Length of the mutable vector.+length :: MVector v a => v s a -> Int++-- | Check whether the vector is empty+null :: MVector v a => v s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: MVector v a => Int -> Int -> v s a -> v s a+init :: MVector v a => v s a -> v s a+tail :: MVector v a => v s a -> v s a+take :: MVector v a => Int -> v s a -> v s a+drop :: MVector v a => Int -> v s a -> v s a+splitAt :: MVector v a => Int -> v s a -> (v s a, v s a)+overlaps :: MVector v a => v s a -> v s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, MVector v a) => Int -> m (v (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, MVector v a) => Int -> a -> m (v (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, MVector v a) => Int -> m a -> m (v (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m (v (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m (v (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, MVector v a) => v (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, MVector v a) => v (PrimState m) a -> v (PrimState m) a -> m ()++-- | Create a new mutable vector and fill it with elements from the+-- <a>Stream</a>. The vector will grow exponentially if the maximum size+-- of the <a>Stream</a> is unknown.+unstream :: (PrimMonad m, MVector v a) => Stream a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the+-- <a>Stream</a> from right to left. The vector will grow exponentially+-- if the maximum size of the <a>Stream</a> is unknown.+unstreamR :: (PrimMonad m, MVector v a) => Stream a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the monadic+-- stream. The vector will grow exponentially if the maximum size of the+-- stream is unknown.+munstream :: (PrimMonad m, MVector v a) => MStream m a -> m (v (PrimState m) a)++-- | Create a new mutable vector and fill it with elements from the monadic+-- stream from right to left. The vector will grow exponentially if the+-- maximum size of the stream is unknown.+munstreamR :: (PrimMonad m, MVector v a) => MStream m a -> m (v (PrimState m) a)+transform :: (PrimMonad m, MVector v a) => (MStream m a -> MStream m a) -> v (PrimState m) a -> m (v (PrimState m) a)+transformR :: (PrimMonad m, MVector v a) => (MStream m a -> MStream m a) -> v (PrimState m) a -> m (v (PrimState m) a)+fill :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a -> m (v (PrimState m) a)+fillR :: (PrimMonad m, MVector v a) => v (PrimState m) a -> MStream m a -> m (v (PrimState m) a)+accum :: (PrimMonad m, MVector v a) => (a -> b -> a) -> v (PrimState m) a -> Stream (Int, b) -> m ()+update :: (PrimMonad m, MVector v a) => v (PrimState m) a -> Stream (Int, a) -> m ()+reverse :: (PrimMonad m, MVector v a) => v (PrimState m) a -> m ()+unstablePartition :: (PrimMonad m, MVector v a) => (a -> Bool) -> v (PrimState m) a -> m Int+unstablePartitionStream :: (PrimMonad m, MVector v a) => (a -> Bool) -> Stream a -> m (v (PrimState m) a, v (PrimState m) a)+partitionStream :: (PrimMonad m, MVector v a) => (a -> Bool) -> Stream a -> m (v (PrimState m) a, v (PrimState m) a)+++-- | Purely functional interface to initialisation of mutable vectors+module Data.Vector.Generic.New+data New v a+New :: (forall s. ST s (Mutable v s a)) -> New v a+create :: (forall s. ST s (Mutable v s a)) -> New v a+run :: New v a -> ST s (Mutable v s a)+runPrim :: PrimMonad m => New v a -> m (Mutable v (PrimState m) a)+apply :: (forall s. Mutable v s a -> Mutable v s a) -> New v a -> New v a+modify :: (forall s. Mutable v s a -> ST s ()) -> New v a -> New v a+modifyWithStream :: (forall s. Mutable v s a -> Stream b -> ST s ()) -> New v a -> Stream b -> New v a+unstream :: Vector v a => Stream a -> New v a+transform :: Vector v a => (forall m. Monad m => MStream m a -> MStream m a) -> New v a -> New v a+unstreamR :: Vector v a => Stream a -> New v a+transformR :: Vector v a => (forall m. Monad m => MStream m a -> MStream m a) -> New v a -> New v a+slice :: Vector v a => Int -> Int -> New v a -> New v a+init :: Vector v a => New v a -> New v a+tail :: Vector v a => New v a -> New v a+take :: Vector v a => Int -> New v a -> New v a+drop :: Vector v a => Int -> New v a -> New v a+unsafeSlice :: Vector v a => Int -> Int -> New v a -> New v a+unsafeInit :: Vector v a => New v a -> New v a+unsafeTail :: Vector v a => New v a -> New v a+++-- | Generic interface to pure vectors.+module Data.Vector.Generic++-- | Class of immutable vectors. Every immutable vector is associated with+-- its mutable version through the <a>Mutable</a> type family. Methods of+-- this class should not be used directly. Instead,+-- <a>Data.Vector.Generic</a> and other Data.Vector modules provide safe+-- and fusible wrappers.+-- +-- Minimum complete implementation:+-- +-- <ul>+-- <li><a>basicUnsafeFreeze</a></li>+-- <li><a>basicUnsafeThaw</a></li>+-- <li><a>basicLength</a></li>+-- <li><a>basicUnsafeSlice</a></li>+-- <li><a>basicUnsafeIndexM</a></li>+-- </ul>+class MVector (Mutable v) a => Vector v a+basicUnsafeFreeze :: (Vector v a, PrimMonad m) => Mutable v (PrimState m) a -> m (v a)+basicUnsafeThaw :: (Vector v a, PrimMonad m) => v a -> m (Mutable v (PrimState m) a)+basicLength :: Vector v a => v a -> Int+basicUnsafeSlice :: Vector v a => Int -> Int -> v a -> v a+basicUnsafeIndexM :: (Vector v a, Monad m) => v a -> Int -> m a+basicUnsafeCopy :: (Vector v a, PrimMonad m) => Mutable v (PrimState m) a -> v a -> m ()+elemseq :: Vector v a => v a -> a -> b -> b++-- | <tt>Mutable v s a</tt> is the mutable version of the pure vector type+-- <tt>v a</tt> with the state token <tt>s</tt>++-- | <i>O(1)</i> Yield the length of the vector.+length :: Vector v a => v a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Vector v a => v a -> Bool++-- | O(1) Indexing+(!) :: Vector v a => v a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Vector v a => v a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Vector v a => v a -> a++-- | <i>O(1)</i> Last element+last :: Vector v a => v a -> a++-- | <i>O(1)</i> Unsafe indexing without bounds checking+unsafeIndex :: Vector v a => v a -> Int -> a++-- | <i>O(1)</i> First element without checking if the vector is empty+unsafeHead :: Vector v a => v a -> a++-- | <i>O(1)</i> Last element without checking if the vector is empty+unsafeLast :: Vector v a => v a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Vector v a, Monad m) => v a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Indexing in a monad without bounds checks. See+-- <a>indexM</a> for an explanation of why this is useful.+unsafeIndexM :: (Vector v a, Monad m) => v a -> Int -> m a++-- | <i>O(1)</i> First element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeHeadM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Last element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeLastM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Vector v a => Int -> Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector may contain less than <tt>n</tt> elements in which case it is+-- returned unchanged.+take :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Vector v a => Int -> v a -> (v a, v a)++-- | <i>O(1)</i> Yield a slice of the vector without copying. The vector+-- must contain at least <tt>i+n</tt> elements but this is not checked.+unsafeSlice :: Vector v a => Int -> Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty but this is not checked.+unsafeInit :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty but this is not checked.+unsafeTail :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector must contain at least <tt>n</tt> elements but this is not+-- checked.+unsafeTake :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector must contain at least <tt>n</tt> elements but this+-- is not checked.+unsafeDrop :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Empty vector+empty :: Vector v a => v a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Vector v a => a -> v a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Vector v a => Int -> a -> v a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Vector v a => Int -> (Int -> a) -> v a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Vector v a => Int -> (a -> a) -> a -> v a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Vector v a) => Int -> m a -> m (v a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Vector v a) => Int -> (Int -> m a) -> m (v a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- <a>new</a> 2; <a>write</a> v 0 'a'; <a>write</a> v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Vector v a => (forall s. ST s (Mutable v s a)) -> v a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Vector v a => (b -> Maybe (a, b)) -> b -> v a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Vector v a => Int -> (b -> Maybe (a, b)) -> b -> v a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Vector v a => Int -> (v a -> a) -> v a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Vector v a => Int -> (v a -> a) -> v a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Vector v a, Num a) => a -> Int -> v a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Vector v a, Num a) => a -> a -> Int -> v a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Vector v a, Enum a) => a -> a -> v a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Vector v a, Enum a) => a -> a -> a -> v a++-- | <i>O(n)</i> Prepend an element+cons :: Vector v a => a -> v a -> v a++-- | <i>O(n)</i> Append an element+snoc :: Vector v a => v a -> a -> v a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Vector v a => v a -> v a -> v a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Vector v a => [v a] -> v a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Vector v a => v a -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Vector v a => v a -> [(Int, a)] -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- This function is useful for instances of <a>Vector</a> that cannot+-- store pairs. Otherwise, <a>update</a> is probably more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a++-- | Same as (<a>//</a>) but without bounds checking.+unsafeUpd :: Vector v a => v a -> [(Int, a)] -> v a++-- | Same as <a>update</a> but without bounds checking.+unsafeUpdate :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a++-- | Same as <a>update_</a> but without bounds checking.+unsafeUpdate_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- This function is useful for instances of <a>Vector</a> that cannot+-- store pairs. Otherwise, <a>accumulate</a> is probably more convenient:+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a++-- | Same as <a>accum</a> but without bounds checking.+unsafeAccum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a++-- | Same as <a>accumulate</a> but without bounds checking.+unsafeAccumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a++-- | Same as <a>accumulate_</a> but without bounds checking.+unsafeAccumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a++-- | <i>O(n)</i> Reverse a vector+reverse :: Vector v a => v a -> v a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a++-- | Same as <a>backpermute</a> but without bounds checking.+unsafeBackpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> <a>write</a> v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Vector v a => (forall s. Mutable v s a -> ST s ()) -> v a -> v a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (Vector v a, Vector v b) => (a -> b) -> v a -> v b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Vector v a, Vector v b) => (a -> v b) -> v a -> v b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Vector v a, Vector v b) => (a -> m b) -> v a -> m (v b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Vector v a) => (a -> m b) -> v a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Vector v a, Vector v b) => v a -> (a -> m b) -> m (v b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Vector v a) => v a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> v a -> v b -> v c++-- | Zip three vectors with the given function.+zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> v a -> v b -> v c -> v d+zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e+zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f+zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> c) -> v a -> v b -> v c+izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d+izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e+izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (Int -> a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f+izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g++-- | <i>O(min(m,n))</i> Zip two vectors+zip :: (Vector v a, Vector v b, Vector v (a, b)) => v a -> v b -> v (a, b)+zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v a -> v b -> v c -> v (a, b, c)+zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v a -> v b -> v c -> v d -> v (a, b, c, d)+zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v a -> v b -> v c -> v d -> v e -> v (a, b, c, d, e)+zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v a -> v b -> v c -> v d -> v e -> v f -> v (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> v a -> v b -> m (v c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> v a -> v b -> m ()++-- | <i>O(min(m,n))</i> Unzip a vector of pairs.+unzip :: (Vector v a, Vector v b, Vector v (a, b)) => v (a, b) -> (v a, v b)+unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v (a, b, c) -> (v a, v b, v c)+unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v (a, b, c, d) -> (v a, v b, v c, v d)+unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v (a, b, c, d, e) -> (v a, v b, v c, v d, v e)+unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v (a, b, c, d, e, f) -> (v a, v b, v c, v d, v e, v f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Vector v a => (Int -> a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Vector v a) => (a -> m Bool) -> v a -> m (v a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Vector v a, Eq a) => a -> v a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Vector v a, Eq a) => a -> v a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Vector v a => (a -> Bool) -> v a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Vector v a => (a -> Bool) -> v a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: (Vector v a, Vector v Int) => (a -> Bool) -> v a -> v Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Vector v a, Eq a) => a -> v a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Vector v a, Vector v Int, Eq a) => a -> v a -> v Int++-- | <i>O(n)</i> Left fold+foldl :: Vector v b => (a -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Vector v b => (a -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Right fold+foldr :: Vector v a => (a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Vector v a => (a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Vector v a => (a -> Bool) -> v a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Vector v a => (a -> Bool) -> v a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector v Bool => v Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector v Bool => v Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Vector v a, Num a) => v a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Vector v a, Num a) => v a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Vector v a, Ord a) => v a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Vector v a, Ord a) => v a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Vector v a, Ord a) => v a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Vector v a, Ord a) => v a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()++-- | <i>O(n)</i> Monad fold over non-empty vectors with strict accumulator+-- that discards the result+fold1M'_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()++-- | Evaluate each action and collect the results+sequence :: (Monad m, Vector v a, Vector v (m a)) => v (m a) -> m (v a)++-- | Evaluate each action and discard the results+sequence_ :: (Monad m, Vector v (m a)) => v (m a) -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Vector v a => v a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Vector v a => [a] -> v a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Vector v a => Int -> [a] -> v a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()++-- | <i>O(1)</i> Unsafe convert a mutable vector to an immutable one+-- without copying. The mutable vector may not be used after this+-- operation.+unsafeFreeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)++-- | <i>O(1)</i> Unsafely convert an immutable vector to a mutable one+-- without copying. The immutable vector may not be used after this+-- operation.+unsafeThaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length. This is not checked.+unsafeCopy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()++-- | <i>O(1)</i> Convert a vector to a <a>Stream</a>+stream :: Vector v a => v a -> Stream a++-- | <i>O(n)</i> Construct a vector from a <a>Stream</a>+unstream :: Vector v a => Stream a -> v a++-- | <i>O(1)</i> Convert a vector to a <a>Stream</a>, proceeding from right+-- to left+streamR :: Vector v a => v a -> Stream a++-- | <i>O(n)</i> Construct a vector from a <a>Stream</a>, proceeding from+-- right to left+unstreamR :: Vector v a => Stream a -> v a++-- | Construct a vector from a monadic initialiser.+new :: Vector v a => New v a -> v a++-- | Convert a vector to an initialiser which, when run, produces a copy of+-- the vector.+clone :: Vector v a => v a -> New v a++-- | <i>O(n)</i> Check if two vectors are equal. All <a>Vector</a>+-- instances are also instances of <a>Eq</a> and it is usually more+-- appropriate to use those. This function is primarily intended for+-- implementing <a>Eq</a> instances for new vector types.+eq :: (Vector v a, Eq a) => v a -> v a -> Bool++-- | <i>O(n)</i> Compare two vectors lexicographically. All <a>Vector</a>+-- instances are also instances of <a>Ord</a> and it is usually more+-- appropriate to use those. This function is primarily intended for+-- implementing <a>Ord</a> instances for new vector types.+cmp :: (Vector v a, Ord a) => v a -> v a -> Ordering++-- | Generic definition of <tt>Prelude.showsPrec</tt>+showsPrec :: (Vector v a, Show a) => Int -> v a -> ShowS++-- | Generic definition of <tt>Text.Read.readPrec</tt>+readPrec :: (Vector v a, Read a) => ReadPrec (v a)++-- | Generic definion of <tt>Data.Data.gfoldl</tt> that views a+-- <a>Vector</a> as a list.+gfoldl :: (Vector v a, Data a) => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> v a -> c (v a)+dataCast :: (Vector v a, Data a, Typeable1 v, Typeable1 t) => (forall d. Data d => c (t d)) -> Maybe (c (v a))+mkType :: String -> DataType+++-- | Safe interface to <a>Data.Vector.Generic</a>+module Data.Vector.Generic.Safe++-- | Class of immutable vectors. Every immutable vector is associated with+-- its mutable version through the <a>Mutable</a> type family. Methods of+-- this class should not be used directly. Instead,+-- <a>Data.Vector.Generic</a> and other Data.Vector modules provide safe+-- and fusible wrappers.+-- +-- Minimum complete implementation:+-- +-- <ul>+-- <li><a>basicUnsafeFreeze</a></li>+-- <li><a>basicUnsafeThaw</a></li>+-- <li><a>basicLength</a></li>+-- <li><a>basicUnsafeSlice</a></li>+-- <li><a>basicUnsafeIndexM</a></li>+-- </ul>+class MVector (Mutable v) a => Vector v a++-- | <tt>Mutable v s a</tt> is the mutable version of the pure vector type+-- <tt>v a</tt> with the state token <tt>s</tt>++-- | <i>O(1)</i> Yield the length of the vector.+length :: Vector v a => v a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Vector v a => v a -> Bool++-- | O(1) Indexing+(!) :: Vector v a => v a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Vector v a => v a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Vector v a => v a -> a++-- | <i>O(1)</i> Last element+last :: Vector v a => v a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Vector v a, Monad m) => v a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Vector v a, Monad m) => v a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Vector v a => Int -> Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Vector v a => v a -> v a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector may contain less than <tt>n</tt> elements in which case it is+-- returned unchanged.+take :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Vector v a => Int -> v a -> v a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Vector v a => Int -> v a -> (v a, v a)++-- | <i>O(1)</i> Empty vector+empty :: Vector v a => v a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Vector v a => a -> v a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Vector v a => Int -> a -> v a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Vector v a => Int -> (Int -> a) -> v a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Vector v a => Int -> (a -> a) -> a -> v a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Vector v a) => Int -> m a -> m (v a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Vector v a) => Int -> (Int -> m a) -> m (v a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- <a>new</a> 2; <a>write</a> v 0 'a'; <a>write</a> v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Vector v a => (forall s. ST s (Mutable v s a)) -> v a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Vector v a => (b -> Maybe (a, b)) -> b -> v a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Vector v a => Int -> (b -> Maybe (a, b)) -> b -> v a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Vector v a, Num a) => a -> Int -> v a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Vector v a, Num a) => a -> a -> Int -> v a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Vector v a, Enum a) => a -> a -> v a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Vector v a, Enum a) => a -> a -> a -> v a++-- | <i>O(n)</i> Prepend an element+cons :: Vector v a => a -> v a -> v a++-- | <i>O(n)</i> Append an element+snoc :: Vector v a => v a -> a -> v a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Vector v a => v a -> v a -> v a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Vector v a => [v a] -> v a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Vector v a => v a -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Vector v a => v a -> [(Int, a)] -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a) -> v a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- This function is useful for instances of <a>Vector</a> that cannot+-- store pairs. Otherwise, <a>update</a> is probably more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: (Vector v a, Vector v Int) => v a -> v Int -> v a -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Vector v a => (a -> b -> a) -> v a -> [(Int, b)] -> v a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (Vector v a, Vector v (Int, b)) => (a -> b -> a) -> v a -> v (Int, b) -> v a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- This function is useful for instances of <a>Vector</a> that cannot+-- store pairs. Otherwise, <a>accumulate</a> is probably more convenient:+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (Vector v a, Vector v Int, Vector v b) => (a -> b -> a) -> v a -> v Int -> v b -> v a++-- | <i>O(n)</i> Reverse a vector+reverse :: Vector v a => v a -> v a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: (Vector v a, Vector v Int) => v a -> v Int -> v a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> <a>write</a> v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Vector v a => (forall s. Mutable v s a -> ST s ()) -> v a -> v a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: (Vector v a, Vector v (Int, a)) => v a -> v (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (Vector v a, Vector v b) => (a -> b) -> v a -> v b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Vector v a, Vector v b) => (a -> v b) -> v a -> v b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Vector v a, Vector v b) => (a -> m b) -> v a -> m (v b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Vector v a) => (a -> m b) -> v a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Vector v a, Vector v b) => v a -> (a -> m b) -> m (v b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Vector v a) => v a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> v a -> v b -> v c++-- | Zip three vectors with the given function.+zipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (a -> b -> c -> d) -> v a -> v b -> v c -> v d+zipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e+zipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f+zipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Vector v a, Vector v b, Vector v c) => (Int -> a -> b -> c) -> v a -> v b -> v c+izipWith3 :: (Vector v a, Vector v b, Vector v c, Vector v d) => (Int -> a -> b -> c -> d) -> v a -> v b -> v c -> v d+izipWith4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e) => (Int -> a -> b -> c -> d -> e) -> v a -> v b -> v c -> v d -> v e+izipWith5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f) => (Int -> a -> b -> c -> d -> e -> f) -> v a -> v b -> v c -> v d -> v e -> v f+izipWith6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> v a -> v b -> v c -> v d -> v e -> v f -> v g++-- | <i>O(min(m,n))</i> Zip two vectors+zip :: (Vector v a, Vector v b, Vector v (a, b)) => v a -> v b -> v (a, b)+zip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v a -> v b -> v c -> v (a, b, c)+zip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v a -> v b -> v c -> v d -> v (a, b, c, d)+zip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v a -> v b -> v c -> v d -> v e -> v (a, b, c, d, e)+zip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v a -> v b -> v c -> v d -> v e -> v f -> v (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Vector v a, Vector v b, Vector v c) => (a -> b -> m c) -> v a -> v b -> m (v c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Vector v a, Vector v b) => (a -> b -> m c) -> v a -> v b -> m ()++-- | <i>O(min(m,n))</i> Unzip a vector of pairs.+unzip :: (Vector v a, Vector v b, Vector v (a, b)) => v (a, b) -> (v a, v b)+unzip3 :: (Vector v a, Vector v b, Vector v c, Vector v (a, b, c)) => v (a, b, c) -> (v a, v b, v c)+unzip4 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v (a, b, c, d)) => v (a, b, c, d) -> (v a, v b, v c, v d)+unzip5 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v (a, b, c, d, e)) => v (a, b, c, d, e) -> (v a, v b, v c, v d, v e)+unzip6 :: (Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v (a, b, c, d, e, f)) => v (a, b, c, d, e, f) -> (v a, v b, v c, v d, v e, v f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Vector v a => (Int -> a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Vector v a) => (a -> m Bool) -> v a -> m (v a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Vector v a => (a -> Bool) -> v a -> v a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Vector v a => (a -> Bool) -> v a -> (v a, v a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Vector v a, Eq a) => a -> v a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Vector v a, Eq a) => a -> v a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Vector v a => (a -> Bool) -> v a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Vector v a => (a -> Bool) -> v a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: (Vector v a, Vector v Int) => (a -> Bool) -> v a -> v Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Vector v a, Eq a) => a -> v a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Vector v a, Vector v Int, Eq a) => a -> v a -> v Int++-- | <i>O(n)</i> Left fold+foldl :: Vector v b => (a -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Vector v b => (a -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Right fold+foldr :: Vector v a => (a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Vector v a => (a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Vector v a => (a -> a -> a) -> v a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Vector v b => (a -> Int -> b -> a) -> a -> v b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Vector v a => (Int -> a -> b -> b) -> b -> v a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Vector v a => (a -> Bool) -> v a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Vector v a => (a -> Bool) -> v a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector v Bool => v Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector v Bool => v Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Vector v a, Num a) => v a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Vector v a, Num a) => v a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Vector v a, Ord a) => v a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Vector v a, Ord a) => v a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Vector v a => (a -> a -> Ordering) -> v a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Vector v a, Ord a) => v a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Vector v a, Ord a) => v a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Vector v a => (a -> a -> Ordering) -> v a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Vector v b) => (a -> b -> m a) -> a -> v b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()++-- | <i>O(n)</i> Monad fold over non-empty vectors with strict accumulator+-- that discards the result+fold1M'_ :: (Monad m, Vector v a) => (a -> a -> m a) -> v a -> m ()++-- | Evaluate each action and collect the results+sequence :: (Monad m, Vector v a, Vector v (m a)) => v (m a) -> m (v a)++-- | Evaluate each action and discard the results+sequence_ :: (Monad m, Vector v (m a)) => v (m a) -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Vector v a, Vector v b) => (a -> b -> a) -> a -> v b -> v a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Vector v a, Vector v b) => (a -> b -> b) -> b -> v a -> v b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Vector v a => (a -> a -> a) -> v a -> v a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Vector v a => v a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Vector v a => [a] -> v a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Vector v a => Int -> [a] -> v a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> m (v a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (PrimMonad m, Vector v a) => v a -> m (Mutable v (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (PrimMonad m, Vector v a) => Mutable v (PrimState m) a -> v a -> m ()++-- | <i>O(1)</i> Convert a vector to a <a>Stream</a>+stream :: Vector v a => v a -> Stream a++-- | <i>O(n)</i> Construct a vector from a <a>Stream</a>+unstream :: Vector v a => Stream a -> v a++-- | <i>O(1)</i> Convert a vector to a <a>Stream</a>, proceeding from right+-- to left+streamR :: Vector v a => v a -> Stream a++-- | <i>O(n)</i> Construct a vector from a <a>Stream</a>, proceeding from+-- right to left+unstreamR :: Vector v a => Stream a -> v a++-- | Construct a vector from a monadic initialiser.+new :: Vector v a => New v a -> v a++-- | Convert a vector to an initialiser which, when run, produces a copy of+-- the vector.+clone :: Vector v a => v a -> New v a++-- | <i>O(n)</i> Check if two vectors are equal. All <a>Vector</a>+-- instances are also instances of <a>Eq</a> and it is usually more+-- appropriate to use those. This function is primarily intended for+-- implementing <a>Eq</a> instances for new vector types.+eq :: (Vector v a, Eq a) => v a -> v a -> Bool++-- | <i>O(n)</i> Compare two vectors lexicographically. All <a>Vector</a>+-- instances are also instances of <a>Ord</a> and it is usually more+-- appropriate to use those. This function is primarily intended for+-- implementing <a>Ord</a> instances for new vector types.+cmp :: (Vector v a, Ord a) => v a -> v a -> Ordering++-- | Generic definion of <tt>Data.Data.gfoldl</tt> that views a+-- <a>Vector</a> as a list.+gfoldl :: (Vector v a, Data a) => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> v a -> c (v a)+dataCast :: (Vector v a, Data a, Typeable1 v, Typeable1 t) => (forall d. Data d => c (t d)) -> Maybe (c (v a))+mkType :: String -> DataType+++-- | Safe interface to <a>Data.Vector.Generic.New</a>+module Data.Vector.Generic.New.Safe+data New v a+New :: (forall s. ST s (Mutable v s a)) -> New v a+create :: (forall s. ST s (Mutable v s a)) -> New v a+run :: New v a -> ST s (Mutable v s a)+apply :: (forall s. Mutable v s a -> Mutable v s a) -> New v a -> New v a+modify :: (forall s. Mutable v s a -> ST s ()) -> New v a -> New v a+modifyWithStream :: (forall s. Mutable v s a -> Stream b -> ST s ()) -> New v a -> Stream b -> New v a+unstream :: Vector v a => Stream a -> New v a+transform :: Vector v a => (forall m. Monad m => MStream m a -> MStream m a) -> New v a -> New v a+unstreamR :: Vector v a => Stream a -> New v a+transformR :: Vector v a => (forall m. Monad m => MStream m a -> MStream m a) -> New v a -> New v a+slice :: Vector v a => Int -> Int -> New v a -> New v a+init :: Vector v a => New v a -> New v a+tail :: Vector v a => New v a -> New v a+take :: Vector v a => Int -> New v a -> New v a+drop :: Vector v a => Int -> New v a -> New v a+++-- | Mutable primitive vectors.+module Data.Vector.Primitive.Mutable++-- | Mutable vectors of primitive types.+data MVector s a+MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !MutableByteArray s -> MVector s a+type IOVector = MVector RealWorld+type STVector s = MVector s++-- | Class of types supporting primitive array operations+class Prim a++-- | Length of the mutable vector.+length :: Prim a => MVector s a -> Int++-- | Check whether the vector is empty+null :: Prim a => MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Prim a => Int -> Int -> MVector s a -> MVector s a+init :: Prim a => MVector s a -> MVector s a+tail :: Prim a => MVector s a -> MVector s a+take :: Prim a => Int -> MVector s a -> MVector s a+drop :: Prim a => Int -> MVector s a -> MVector s a+splitAt :: Prim a => Int -> MVector s a -> (MVector s a, MVector s a)++-- | Yield a part of the mutable vector without copying it. No bounds+-- checks are performed.+unsafeSlice :: Prim a => Int -> Int -> MVector s a -> MVector s a+unsafeInit :: Prim a => MVector s a -> MVector s a+unsafeTail :: Prim a => MVector s a -> MVector s a+unsafeTake :: Prim a => Int -> MVector s a -> MVector s a+unsafeDrop :: Prim a => Int -> MVector s a -> MVector s a+overlaps :: Prim a => MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, Prim a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length. The length is not+-- checked.+unsafeNew :: (PrimMonad m, Prim a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, Prim a) => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, Prim a) => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive but this is not checked.+unsafeGrow :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Yield the element at the given position. No bounds checks are+-- performed.+unsafeRead :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position. No bounds checks are+-- performed.+unsafeWrite :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions. No bounds checks are+-- performed.+unsafeSwap :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap. This is not checked.+unsafeCopy :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length, but this is not checked.+-- +-- If the vectors do not overlap, then this is equivalent to+-- <a>unsafeCopy</a>. Otherwise, the copying is performed as if the+-- source vector were copied to a temporary vector and then the temporary+-- vector was copied to the target vector.+unsafeMove :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()+instance Typeable2 MVector+instance Prim a => MVector MVector a+++-- | Unboxed vectors of primitive types. The use of this module is not+-- recommended except in very special cases. Adaptive unboxed vectors+-- defined in <a>Data.Vector.Unboxed</a> are significantly more flexible+-- at no performance cost.+module Data.Vector.Primitive++-- | Unboxed vectors of primitive types+data Vector a++-- | Mutable vectors of primitive types.+data MVector s a+MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !MutableByteArray s -> MVector s a++-- | Class of types supporting primitive array operations+class Prim a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Prim a => Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Prim a => Vector a -> Bool++-- | O(1) Indexing+(!) :: Prim a => Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Prim a => Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Prim a => Vector a -> a++-- | <i>O(1)</i> Last element+last :: Prim a => Vector a -> a++-- | <i>O(1)</i> Unsafe indexing without bounds checking+unsafeIndex :: Prim a => Vector a -> Int -> a++-- | <i>O(1)</i> First element without checking if the vector is empty+unsafeHead :: Prim a => Vector a -> a++-- | <i>O(1)</i> Last element without checking if the vector is empty+unsafeLast :: Prim a => Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Prim a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Indexing in a monad without bounds checks. See+-- <a>indexM</a> for an explanation of why this is useful.+unsafeIndexM :: (Prim a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeHeadM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeLastM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Prim a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Prim a => Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Yield a slice of the vector without copying. The vector+-- must contain at least <tt>i+n</tt> elements but this is not checked.+unsafeSlice :: Prim a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty but this is not checked.+unsafeInit :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty but this is not checked.+unsafeTail :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector must contain at least <tt>n</tt> elements but this is not+-- checked.+unsafeTake :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector must contain at least <tt>n</tt> elements but this+-- is not checked.+unsafeDrop :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Empty vector+empty :: Prim a => Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Prim a => a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Prim a => Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Prim a => Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Prim a => Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Prim a) => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Prim a) => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Prim a => (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Prim a => (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Prim a => Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Prim a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Prim a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Prim a, Num a) => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Prim a, Num a) => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Prim a, Enum a) => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Prim a, Enum a) => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: Prim a => a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Prim a => Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Prim a => Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Prim a => [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Prim a => Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Prim a => Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+update_ :: Prim a => Vector a -> Vector Int -> Vector a -> Vector a++-- | Same as (<a>//</a>) but without bounds checking.+unsafeUpd :: Prim a => Vector a -> [(Int, a)] -> Vector a++-- | Same as <a>update_</a> but without bounds checking.+unsafeUpdate_ :: Prim a => Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Prim a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate_ :: (Prim a, Prim b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | Same as <a>accum</a> but without bounds checking.+unsafeAccum :: Prim a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | Same as <a>accumulate_</a> but without bounds checking.+unsafeAccumulate_ :: (Prim a, Prim b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Prim a => Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Prim a => Vector a -> Vector Int -> Vector a++-- | Same as <a>backpermute</a> but without bounds checking.+unsafeBackpermute :: Prim a => Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Prim a => (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Map a function over a vector+map :: (Prim a, Prim b) => (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Prim a, Prim b) => (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Prim a, Prim b) => (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Prim a, Prim b) => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Prim a) => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Prim a, Prim b) => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Prim a) => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Prim a, Prim b, Prim c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (Prim a, Prim b, Prim c, Prim d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (Prim a, Prim b, Prim c, Prim d, Prim e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f, Prim g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Prim a, Prim b, Prim c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Prim a, Prim b, Prim c, Prim d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Prim a, Prim b, Prim c, Prim d, Prim e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f, Prim g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Prim a, Prim b, Prim c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Prim a, Prim b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Prim a => (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Prim a) => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Prim a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Prim a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Prim a => (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Prim a => (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: Prim a => (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Prim a, Eq a) => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Prim a, Eq a) => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: Prim b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Prim b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: Prim a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Prim a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Prim b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Prim b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Prim a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Prim a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Prim a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Prim a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Prim a, Num a) => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Prim a, Num a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Prim a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Prim a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Prim a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Prim a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Prim a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Prim a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Prim a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Prim a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Prim a => Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Prim a => [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Prim a => Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (Prim a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()++-- | <i>O(1)</i> Unsafe convert a mutable vector to an immutable one+-- without copying. The mutable vector may not be used after this+-- operation.+unsafeFreeze :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(1)</i> Unsafely convert an immutable vector to a mutable one+-- without copying. The immutable vector may not be used after this+-- operation.+unsafeThaw :: (Prim a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length. This is not checked.+unsafeCopy :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()+instance Typeable1 Vector+instance Prim a => Monoid (Vector a)+instance (Prim a, Ord a) => Ord (Vector a)+instance (Prim a, Eq a) => Eq (Vector a)+instance Prim a => Vector Vector a+instance (Data a, Prim a) => Data (Vector a)+instance (Read a, Prim a) => Read (Vector a)+instance (Show a, Prim a) => Show (Vector a)+++-- | Safe interface to <a>Data.Vector.Primitive</a>+module Data.Vector.Primitive.Safe++-- | Unboxed vectors of primitive types+data Vector a++-- | Mutable vectors of primitive types.+data MVector s a++-- | Class of types supporting primitive array operations+class Prim a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Prim a => Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Prim a => Vector a -> Bool++-- | O(1) Indexing+(!) :: Prim a => Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Prim a => Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Prim a => Vector a -> a++-- | <i>O(1)</i> Last element+last :: Prim a => Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Prim a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Prim a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Prim a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Prim a => Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Prim a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Prim a => Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Empty vector+empty :: Prim a => Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Prim a => a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Prim a => Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Prim a => Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Prim a => Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Prim a) => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Prim a) => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Prim a => (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Prim a => (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Prim a => Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Prim a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Prim a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Prim a, Num a) => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Prim a, Num a) => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Prim a, Enum a) => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Prim a, Enum a) => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: Prim a => a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Prim a => Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Prim a => Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Prim a => [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Prim a => Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Prim a => Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+update_ :: Prim a => Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Prim a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate_ :: (Prim a, Prim b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Prim a => Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Prim a => Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Prim a => (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Map a function over a vector+map :: (Prim a, Prim b) => (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Prim a, Prim b) => (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Prim a, Prim b) => (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Prim a, Prim b) => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Prim a) => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Prim a, Prim b) => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Prim a) => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Prim a, Prim b, Prim c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (Prim a, Prim b, Prim c, Prim d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (Prim a, Prim b, Prim c, Prim d, Prim e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f, Prim g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Prim a, Prim b, Prim c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Prim a, Prim b, Prim c, Prim d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Prim a, Prim b, Prim c, Prim d, Prim e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Prim a, Prim b, Prim c, Prim d, Prim e, Prim f, Prim g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Prim a, Prim b, Prim c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Prim a, Prim b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Prim a => (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Prim a) => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Prim a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Prim a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Prim a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Prim a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Prim a => (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Prim a => (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: Prim a => (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Prim a, Eq a) => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Prim a, Eq a) => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: Prim b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Prim b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: Prim a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Prim a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Prim a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Prim b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Prim b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Prim a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Prim a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Prim a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Prim a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Prim a, Num a) => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Prim a, Num a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Prim a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Prim a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Prim a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Prim a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Prim a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Prim a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Prim a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Prim a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Prim b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: (Monad m, Prim a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Prim a, Prim b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Prim a, Prim b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Prim a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Prim a => Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Prim a => [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Prim a => Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (Prim a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (Prim a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()+++-- | Safe interface to <a>Data.Vector.Primitive.Mutable</a>+module Data.Vector.Primitive.Mutable.Safe++-- | Mutable vectors of primitive types.+data MVector s a+type IOVector = MVector RealWorld+type STVector s = MVector s++-- | Class of types supporting primitive array operations+class Prim a++-- | Length of the mutable vector.+length :: Prim a => MVector s a -> Int++-- | Check whether the vector is empty+null :: Prim a => MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Prim a => Int -> Int -> MVector s a -> MVector s a+init :: Prim a => MVector s a -> MVector s a+tail :: Prim a => MVector s a -> MVector s a+take :: Prim a => Int -> MVector s a -> MVector s a+drop :: Prim a => Int -> MVector s a -> MVector s a+splitAt :: Prim a => Int -> MVector s a -> (MVector s a, MVector s a)+overlaps :: Prim a => MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, Prim a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, Prim a) => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, Prim a) => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, Prim a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()+++-- | Mutable vectors based on Storable.+module Data.Vector.Storable.Mutable++-- | Mutable <a>Storable</a>-based vectors+data MVector s a+MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !ForeignPtr a -> MVector s a+type IOVector = MVector RealWorld+type STVector s = MVector s++-- | The member functions of this class facilitate writing values of+-- primitive types to raw memory (which may have been allocated with the+-- above mentioned routines) and reading values from blocks of raw+-- memory. The class, furthermore, includes support for computing the+-- storage requirements and alignment restrictions of storable types.+-- +-- Memory addresses are represented as values of type <tt><a>Ptr</a>+-- a</tt>, for some <tt>a</tt> which is an instance of class+-- <a>Storable</a>. The type argument to <a>Ptr</a> helps provide some+-- valuable type safety in FFI code (you can't mix pointers of different+-- types without an explicit cast), while helping the Haskell type system+-- figure out which marshalling method is needed for a given pointer.+-- +-- All marshalling between Haskell and a foreign language ultimately+-- boils down to translating Haskell data structures into the binary+-- representation of a corresponding data structure of the foreign+-- language and vice versa. To code this marshalling in Haskell, it is+-- necessary to manipulate primitive data types stored in unstructured+-- memory blocks. The class <a>Storable</a> facilitates this manipulation+-- on all types for which it is instantiated, which are the standard+-- basic types of Haskell, the fixed size <tt>Int</tt> types+-- (<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>), the fixed+-- size <tt>Word</tt> types (<a>Word8</a>, <a>Word16</a>, <a>Word32</a>,+-- <a>Word64</a>), <a>StablePtr</a>, all types from+-- <a>Foreign.C.Types</a>, as well as <a>Ptr</a>.+-- +-- Minimal complete definition: <a>sizeOf</a>, <a>alignment</a>, one of+-- <a>peek</a>, <a>peekElemOff</a> and <a>peekByteOff</a>, and one of+-- <a>poke</a>, <a>pokeElemOff</a> and <a>pokeByteOff</a>.+class Storable a++-- | Length of the mutable vector.+length :: Storable a => MVector s a -> Int++-- | Check whether the vector is empty+null :: Storable a => MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Storable a => Int -> Int -> MVector s a -> MVector s a+init :: Storable a => MVector s a -> MVector s a+tail :: Storable a => MVector s a -> MVector s a+take :: Storable a => Int -> MVector s a -> MVector s a+drop :: Storable a => Int -> MVector s a -> MVector s a+splitAt :: Storable a => Int -> MVector s a -> (MVector s a, MVector s a)++-- | Yield a part of the mutable vector without copying it. No bounds+-- checks are performed.+unsafeSlice :: Storable a => Int -> Int -> MVector s a -> MVector s a+unsafeInit :: Storable a => MVector s a -> MVector s a+unsafeTail :: Storable a => MVector s a -> MVector s a+unsafeTake :: Storable a => Int -> MVector s a -> MVector s a+unsafeDrop :: Storable a => Int -> MVector s a -> MVector s a+overlaps :: Storable a => MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, Storable a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length. The length is not+-- checked.+unsafeNew :: (PrimMonad m, Storable a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, Storable a) => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, Storable a) => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive but this is not checked.+unsafeGrow :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Yield the element at the given position. No bounds checks are+-- performed.+unsafeRead :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position. No bounds checks are+-- performed.+unsafeWrite :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions. No bounds checks are+-- performed.+unsafeSwap :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap. This is not checked.+unsafeCopy :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length, but this is not checked.+-- +-- If the vectors do not overlap, then this is equivalent to+-- <a>unsafeCopy</a>. Otherwise, the copying is performed as if the+-- source vector were copied to a temporary vector and then the temporary+-- vector was copied to the target vector.+unsafeMove :: (PrimMonad m, Storable a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | <i>O(1)</i> Unsafely cast a mutable vector from one element type to+-- another. The operation just changes the type of the underlying pointer+-- and does not modify the elements.+-- +-- The resulting vector contains as many elements as can fit into the+-- underlying memory block.+unsafeCast :: (Storable a, Storable b) => MVector s a -> MVector s b++-- | Create a mutable vector from a <a>ForeignPtr</a> with an offset and a+-- length. Modifying data through the <a>ForeignPtr</a> afterwards is+-- unsafe if the vector could have been frozen before the modification.+unsafeFromForeignPtr :: Storable a => ForeignPtr a -> Int -> Int -> MVector s a++-- | Yield the underlying <a>ForeignPtr</a> together with the offset to the+-- data and its length. Modifying the data through the <a>ForeignPtr</a>+-- is unsafe if the vector could have frozen before the modification.+unsafeToForeignPtr :: Storable a => MVector s a -> (ForeignPtr a, Int, Int)++-- | Pass a pointer to the vector's data to the IO action. Modifying data+-- through the pointer is unsafe if the vector could have been frozen+-- before the modification.+unsafeWith :: Storable a => IOVector a -> (Ptr a -> IO b) -> IO b+instance Typeable2 MVector+instance Storable a => MVector MVector a+++-- | <a>Storable</a>-based vectors.+module Data.Vector.Storable++-- | <a>Storable</a>-based vectors+data Vector a++-- | Mutable <a>Storable</a>-based vectors+data MVector s a+MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !ForeignPtr a -> MVector s a++-- | The member functions of this class facilitate writing values of+-- primitive types to raw memory (which may have been allocated with the+-- above mentioned routines) and reading values from blocks of raw+-- memory. The class, furthermore, includes support for computing the+-- storage requirements and alignment restrictions of storable types.+-- +-- Memory addresses are represented as values of type <tt><a>Ptr</a>+-- a</tt>, for some <tt>a</tt> which is an instance of class+-- <a>Storable</a>. The type argument to <a>Ptr</a> helps provide some+-- valuable type safety in FFI code (you can't mix pointers of different+-- types without an explicit cast), while helping the Haskell type system+-- figure out which marshalling method is needed for a given pointer.+-- +-- All marshalling between Haskell and a foreign language ultimately+-- boils down to translating Haskell data structures into the binary+-- representation of a corresponding data structure of the foreign+-- language and vice versa. To code this marshalling in Haskell, it is+-- necessary to manipulate primitive data types stored in unstructured+-- memory blocks. The class <a>Storable</a> facilitates this manipulation+-- on all types for which it is instantiated, which are the standard+-- basic types of Haskell, the fixed size <tt>Int</tt> types+-- (<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>), the fixed+-- size <tt>Word</tt> types (<a>Word8</a>, <a>Word16</a>, <a>Word32</a>,+-- <a>Word64</a>), <a>StablePtr</a>, all types from+-- <a>Foreign.C.Types</a>, as well as <a>Ptr</a>.+-- +-- Minimal complete definition: <a>sizeOf</a>, <a>alignment</a>, one of+-- <a>peek</a>, <a>peekElemOff</a> and <a>peekByteOff</a>, and one of+-- <a>poke</a>, <a>pokeElemOff</a> and <a>pokeByteOff</a>.+class Storable a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Storable a => Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Storable a => Vector a -> Bool++-- | O(1) Indexing+(!) :: Storable a => Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Storable a => Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Storable a => Vector a -> a++-- | <i>O(1)</i> Last element+last :: Storable a => Vector a -> a++-- | <i>O(1)</i> Unsafe indexing without bounds checking+unsafeIndex :: Storable a => Vector a -> Int -> a++-- | <i>O(1)</i> First element without checking if the vector is empty+unsafeHead :: Storable a => Vector a -> a++-- | <i>O(1)</i> Last element without checking if the vector is empty+unsafeLast :: Storable a => Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Storable a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Storable a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Storable a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Indexing in a monad without bounds checks. See+-- <a>indexM</a> for an explanation of why this is useful.+unsafeIndexM :: (Storable a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeHeadM :: (Storable a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeLastM :: (Storable a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Storable a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Storable a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Storable a => Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Storable a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Storable a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Storable a => Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Yield a slice of the vector without copying. The vector+-- must contain at least <tt>i+n</tt> elements but this is not checked.+unsafeSlice :: Storable a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty but this is not checked.+unsafeInit :: Storable a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty but this is not checked.+unsafeTail :: Storable a => Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector must contain at least <tt>n</tt> elements but this is not+-- checked.+unsafeTake :: Storable a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector must contain at least <tt>n</tt> elements but this+-- is not checked.+unsafeDrop :: Storable a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Empty vector+empty :: Storable a => Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Storable a => a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Storable a => Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Storable a => Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Storable a => Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Storable a) => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Storable a) => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Storable a => (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Storable a => (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Storable a => Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Storable a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Storable a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Storable a, Num a) => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Storable a, Num a) => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Storable a, Enum a) => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Storable a, Enum a) => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: Storable a => a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Storable a => Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Storable a => Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Storable a => [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Storable a => Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Storable a => Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+update_ :: Storable a => Vector a -> Vector Int -> Vector a -> Vector a++-- | Same as (<a>//</a>) but without bounds checking.+unsafeUpd :: Storable a => Vector a -> [(Int, a)] -> Vector a++-- | Same as <a>update_</a> but without bounds checking.+unsafeUpdate_ :: Storable a => Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Storable a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | Same as <a>accum</a> but without bounds checking.+unsafeAccum :: Storable a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | Same as <a>accumulate_</a> but without bounds checking.+unsafeAccumulate_ :: (Storable a, Storable b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Storable a => Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Storable a => Vector a -> Vector Int -> Vector a++-- | Same as <a>backpermute</a> but without bounds checking.+unsafeBackpermute :: Storable a => Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Storable a => (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Map a function over a vector+map :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Storable a, Storable b) => (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Storable a, Storable b) => (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Storable a, Storable b) => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Storable a) => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Storable a, Storable b) => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Storable a) => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Storable a, Storable b, Storable c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Storable a, Storable b, Storable c, Storable d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Storable a, Storable b, Storable c, Storable d, Storable e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Storable a, Storable b, Storable c, Storable d, Storable e, Storable f, Storable g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Storable a, Storable b, Storable c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Storable a, Storable b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Storable a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Storable a => (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Storable a) => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Storable a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Storable a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Storable a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Storable a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Storable a => (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Storable a => (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: Storable a => (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Storable a, Eq a) => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Storable a, Eq a) => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: Storable b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Storable a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Storable b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Storable a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: Storable a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Storable a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Storable a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Storable a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Storable b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Storable a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Storable a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Storable a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Storable a, Num a) => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Storable a, Num a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Storable a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Storable a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Storable a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Storable a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Storable a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Storable a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Storable b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: (Monad m, Storable a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Storable a, Storable b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Storable a, Storable b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Storable a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Storable a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Storable a => Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Storable a => [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Storable a => Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(1)</i> Unsafely cast a vector from one element type to another.+-- The operation just changes the type of the underlying pointer and does+-- not modify the elements.+-- +-- The resulting vector contains as many elements as can fit into the+-- underlying memory block.+unsafeCast :: (Storable a, Storable b) => Vector a -> Vector b++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (Storable a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()++-- | <i>O(1)</i> Unsafe convert a mutable vector to an immutable one+-- without copying. The mutable vector may not be used after this+-- operation.+unsafeFreeze :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(1)</i> Unsafely convert an immutable vector to a mutable one+-- without copying. The immutable vector may not be used after this+-- operation.+unsafeThaw :: (Storable a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length. This is not checked.+unsafeCopy :: (Storable a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()++-- | <i>O(1)</i> Create a vector from a <a>ForeignPtr</a> with an offset+-- and a length. The data may not be modified through the+-- <a>ForeignPtr</a> afterwards.+unsafeFromForeignPtr :: Storable a => ForeignPtr a -> Int -> Int -> Vector a++-- | <i>O(1)</i> Yield the underlying <a>ForeignPtr</a> together with the+-- offset to the data and its length. The data may not be modified+-- through the <a>ForeignPtr</a>.+unsafeToForeignPtr :: Storable a => Vector a -> (ForeignPtr a, Int, Int)++-- | Pass a pointer to the vector's data to the IO action. The data may not+-- be modified through the 'Ptr.+unsafeWith :: Storable a => Vector a -> (Ptr a -> IO b) -> IO b+instance Typeable1 Vector+instance Storable a => Monoid (Vector a)+instance (Storable a, Ord a) => Ord (Vector a)+instance (Storable a, Eq a) => Eq (Vector a)+instance Storable a => Vector Vector a+instance (Data a, Storable a) => Data (Vector a)+instance (Read a, Storable a) => Read (Vector a)+instance (Show a, Storable a) => Show (Vector a)+++-- | Adaptive unboxed vectors. The implementation is based on type families+-- and picks an efficient, specialised representation for every element+-- type. In particular, unboxed vectors of pairs are represented as pairs+-- of unboxed vectors.+-- +-- Implementing unboxed vectors for new data types can be very easy. Here+-- is how the library does this for <tt>Complex</tt> by simply wrapping+-- vectors of pairs.+-- +-- <pre>+-- newtype instance <a>MVector</a> s (<tt>Complex</tt> a) = MV_Complex (<a>MVector</a> s (a,a))+-- newtype instance <a>Vector</a> (<tt>Complex</tt> a) = V_Complex (<a>Vector</a> (a,a))+-- +-- instance (<a>RealFloat</a> a, <a>Unbox</a> a) => <tt>Data.Vector.Generic.Mutable.MVector</tt> <a>MVector</a> (<tt>Complex</tt> a) where+-- {-# INLINE basicLength #-}+-- basicLength (MV_Complex v) = <tt>Data.Vector.Generic.Mutable.basicLength</tt> v+-- ...+-- +-- instance (<a>RealFloat</a> a, <a>Unbox</a> a) => Data.Vector.Generic.Vector <a>Vector</a> (<tt>Complex</tt> a) where+-- {-# INLINE basicLength #-}+-- basicLength (V_Complex v) = Data.Vector.Generic.basicLength v+-- ...+-- +-- instance (<a>RealFloat</a> a, <a>Unbox</a> a) => <a>Unbox</a> (<tt>Complex</tt> a)+-- </pre>+module Data.Vector.Unboxed+class (Vector Vector a, MVector MVector a) => Unbox a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Unbox a => Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Unbox a => Vector a -> Bool++-- | O(1) Indexing+(!) :: Unbox a => Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Unbox a => Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Last element+last :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Unsafe indexing without bounds checking+unsafeIndex :: Unbox a => Vector a -> Int -> a++-- | <i>O(1)</i> First element without checking if the vector is empty+unsafeHead :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Last element without checking if the vector is empty+unsafeLast :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Unbox a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Indexing in a monad without bounds checks. See+-- <a>indexM</a> for an explanation of why this is useful.+unsafeIndexM :: (Unbox a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeHeadM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeLastM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Unbox a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Unbox a => Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Yield a slice of the vector without copying. The vector+-- must contain at least <tt>i+n</tt> elements but this is not checked.+unsafeSlice :: Unbox a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty but this is not checked.+unsafeInit :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty but this is not checked.+unsafeTail :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector must contain at least <tt>n</tt> elements but this is not+-- checked.+unsafeTake :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector must contain at least <tt>n</tt> elements but this+-- is not checked.+unsafeDrop :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Empty vector+empty :: Unbox a => Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Unbox a => a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Unbox a => Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Unbox a => Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Unbox a => Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Unbox a) => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Unbox a) => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Unbox a => (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Unbox a => (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Unbox a => Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Unbox a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Unbox a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Unbox a, Num a) => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Unbox a, Num a) => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Unbox a, Enum a) => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Unbox a, Enum a) => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: Unbox a => a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Unbox a => Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Unbox a => Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Unbox a => [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Unbox a => Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Unbox a => Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: Unbox a => Vector a -> Vector (Int, a) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- The function <a>update</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Vector a++-- | Same as (<a>//</a>) but without bounds checking.+unsafeUpd :: Unbox a => Vector a -> [(Int, a)] -> Vector a++-- | Same as <a>update</a> but without bounds checking.+unsafeUpdate :: Unbox a => Vector a -> Vector (Int, a) -> Vector a++-- | Same as <a>update_</a> but without bounds checking.+unsafeUpdate_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- The function <a>accumulate</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | Same as <a>accum</a> but without bounds checking.+unsafeAccum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | Same as <a>accumulate</a> but without bounds checking.+unsafeAccumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | Same as <a>accumulate_</a> but without bounds checking.+unsafeAccumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Unbox a => Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Unbox a => Vector a -> Vector Int -> Vector a++-- | Same as <a>backpermute</a> but without bounds checking.+unsafeBackpermute :: Unbox a => Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Unbox a => (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: Unbox a => Vector a -> Vector (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Unbox a, Unbox b) => (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Unbox a, Unbox b) => (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Unbox a, Unbox b) => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Unbox a) => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Unbox a, Unbox b) => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Unbox a) => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(1)</i> Zip 2 vectors+zip :: (Unbox a, Unbox b) => Vector a -> Vector b -> Vector (a, b)++-- | <i>O(1)</i> Zip 3 vectors+zip3 :: (Unbox a, Unbox b, Unbox c) => Vector a -> Vector b -> Vector c -> Vector (a, b, c)++-- | <i>O(1)</i> Zip 4 vectors+zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)++-- | <i>O(1)</i> Zip 5 vectors+zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)++-- | <i>O(1)</i> Zip 6 vectors+zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Unbox a, Unbox b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(1)</i> Unzip 2 vectors+unzip :: (Unbox a, Unbox b) => Vector (a, b) -> (Vector a, Vector b)++-- | <i>O(1)</i> Unzip 3 vectors+unzip3 :: (Unbox a, Unbox b, Unbox c) => Vector (a, b, c) -> (Vector a, Vector b, Vector c)++-- | <i>O(1)</i> Unzip 4 vectors+unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)++-- | <i>O(1)</i> Unzip 5 vectors+unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)++-- | <i>O(1)</i> Unzip 6 vectors+unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Unbox a => (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Unbox a) => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Unbox a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Unbox a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Unbox a => (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: Unbox a => (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Unbox a, Eq a) => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Unbox a, Eq a) => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: Unbox b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Unbox b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: Unbox a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Unbox a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Unbox a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Unbox a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Unbox a, Num a) => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Unbox a, Num a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Unbox a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Unbox a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Unbox a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Unbox a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Unbox a => Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Unbox a => [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Unbox a => Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()++-- | <i>O(1)</i> Unsafe convert a mutable vector to an immutable one+-- without copying. The mutable vector may not be used after this+-- operation.+unsafeFreeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(1)</i> Unsafely convert an immutable vector to a mutable one+-- without copying. The immutable vector may not be used after this+-- operation.+unsafeThaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length. This is not checked.+unsafeCopy :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()+instance (Read a, Unbox a) => Read (Vector a)+instance (Show a, Unbox a) => Show (Vector a)+instance Unbox a => Monoid (Vector a)+instance (Unbox a, Ord a) => Ord (Vector a)+instance (Unbox a, Eq a) => Eq (Vector a)+++-- | Safe interface to <a>Data.Vector.Unboxed</a>+module Data.Vector.Unboxed.Safe+class (Vector Vector a, MVector MVector a) => Unbox a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Unbox a => Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Unbox a => Vector a -> Bool++-- | O(1) Indexing+(!) :: Unbox a => Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Unbox a => Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Last element+last :: Unbox a => Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: (Unbox a, Monad m) => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: (Unbox a, Monad m) => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Unbox a => Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Unbox a => Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Unbox a => Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Unbox a => Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Empty vector+empty :: Unbox a => Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: Unbox a => a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Unbox a => Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Unbox a => Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Unbox a => Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: (Monad m, Unbox a) => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: (Monad m, Unbox a) => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: Unbox a => (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: Unbox a => (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Unbox a => Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Unbox a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Unbox a => Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: (Unbox a, Num a) => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: (Unbox a, Num a) => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: (Unbox a, Enum a) => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: (Unbox a, Enum a) => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: Unbox a => a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Unbox a => Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Unbox a => Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: Unbox a => [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Unbox a => Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Unbox a => Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: Unbox a => Vector a -> Vector (Int, a) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- The function <a>update</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: Unbox a => Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: Unbox a => (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- The function <a>accumulate</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (Unbox a, Unbox b) => (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Unbox a => Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Unbox a => Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: Unbox a => (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: Unbox a => Vector a -> Vector (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Unbox a, Unbox b) => (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (Unbox a, Unbox b) => (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: (Monad m, Unbox a, Unbox b) => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: (Monad m, Unbox a) => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: (Monad m, Unbox a, Unbox b) => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: (Monad m, Unbox a) => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Unbox a, Unbox b, Unbox c) => (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Unbox a, Unbox b, Unbox c, Unbox d) => (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f, Unbox g) => (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(1)</i> Zip 2 vectors+zip :: (Unbox a, Unbox b) => Vector a -> Vector b -> Vector (a, b)++-- | <i>O(1)</i> Zip 3 vectors+zip3 :: (Unbox a, Unbox b, Unbox c) => Vector a -> Vector b -> Vector c -> Vector (a, b, c)++-- | <i>O(1)</i> Zip 4 vectors+zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)++-- | <i>O(1)</i> Zip 5 vectors+zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)++-- | <i>O(1)</i> Zip 6 vectors+zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: (Monad m, Unbox a, Unbox b, Unbox c) => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: (Monad m, Unbox a, Unbox b) => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(1)</i> Unzip 2 vectors+unzip :: (Unbox a, Unbox b) => Vector (a, b) -> (Vector a, Vector b)++-- | <i>O(1)</i> Unzip 3 vectors+unzip3 :: (Unbox a, Unbox b, Unbox c) => Vector (a, b, c) -> (Vector a, Vector b, Vector c)++-- | <i>O(1)</i> Unzip 4 vectors+unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)++-- | <i>O(1)</i> Unzip 5 vectors+unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)++-- | <i>O(1)</i> Unzip 6 vectors+unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: Unbox a => (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: (Monad m, Unbox a) => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: Unbox a => (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: Unbox a => (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: (Unbox a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: (Unbox a, Eq a) => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: Unbox a => (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: Unbox a => (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: (Unbox a, Eq a) => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: (Unbox a, Eq a) => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: Unbox b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: Unbox b => (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: Unbox a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: Unbox a => (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: Unbox a => (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: Unbox a => (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: Unbox a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: Unbox a => (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: (Unbox a, Num a) => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: (Unbox a, Num a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: (Unbox a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: (Unbox a, Ord a) => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: (Unbox a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: (Unbox a, Ord a) => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: Unbox a => (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: (Monad m, Unbox b) => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: (Monad m, Unbox a) => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (Unbox a, Unbox b) => (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (Unbox a, Unbox b) => (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: Unbox a => (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Unbox a => Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: Unbox a => [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Unbox a => Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: (Unbox a, PrimMonad m) => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> Vector a -> m ()+++-- | Mutable adaptive unboxed vectors+module Data.Vector.Unboxed.Mutable+type IOVector = MVector RealWorld+type STVector s = MVector s+class (Vector Vector a, MVector MVector a) => Unbox a++-- | Length of the mutable vector.+length :: Unbox a => MVector s a -> Int++-- | Check whether the vector is empty+null :: Unbox a => MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Unbox a => Int -> Int -> MVector s a -> MVector s a+init :: Unbox a => MVector s a -> MVector s a+tail :: Unbox a => MVector s a -> MVector s a+take :: Unbox a => Int -> MVector s a -> MVector s a+drop :: Unbox a => Int -> MVector s a -> MVector s a+splitAt :: Unbox a => Int -> MVector s a -> (MVector s a, MVector s a)++-- | Yield a part of the mutable vector without copying it. No bounds+-- checks are performed.+unsafeSlice :: Unbox a => Int -> Int -> MVector s a -> MVector s a+unsafeInit :: Unbox a => MVector s a -> MVector s a+unsafeTail :: Unbox a => MVector s a -> MVector s a+unsafeTake :: Unbox a => Int -> MVector s a -> MVector s a+unsafeDrop :: Unbox a => Int -> MVector s a -> MVector s a+overlaps :: Unbox a => MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, Unbox a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length. The length is not+-- checked.+unsafeNew :: (PrimMonad m, Unbox a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, Unbox a) => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, Unbox a) => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive but this is not checked.+unsafeGrow :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> m ()++-- | <i>O(1)</i> Zip 2 vectors+zip :: (Unbox a, Unbox b) => MVector s a -> MVector s b -> MVector s (a, b)++-- | <i>O(1)</i> Zip 3 vectors+zip3 :: (Unbox a, Unbox b, Unbox c) => MVector s a -> MVector s b -> MVector s c -> MVector s (a, b, c)++-- | <i>O(1)</i> Zip 4 vectors+zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s (a, b, c, d)++-- | <i>O(1)</i> Zip 5 vectors+zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s e -> MVector s (a, b, c, d, e)++-- | <i>O(1)</i> Zip 6 vectors+zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s e -> MVector s f -> MVector s (a, b, c, d, e, f)++-- | <i>O(1)</i> Unzip 2 vectors+unzip :: (Unbox a, Unbox b) => MVector s (a, b) -> (MVector s a, MVector s b)++-- | <i>O(1)</i> Unzip 3 vectors+unzip3 :: (Unbox a, Unbox b, Unbox c) => MVector s (a, b, c) -> (MVector s a, MVector s b, MVector s c)++-- | <i>O(1)</i> Unzip 4 vectors+unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => MVector s (a, b, c, d) -> (MVector s a, MVector s b, MVector s c, MVector s d)++-- | <i>O(1)</i> Unzip 5 vectors+unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => MVector s (a, b, c, d, e) -> (MVector s a, MVector s b, MVector s c, MVector s d, MVector s e)++-- | <i>O(1)</i> Unzip 6 vectors+unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => MVector s (a, b, c, d, e, f) -> (MVector s a, MVector s b, MVector s c, MVector s d, MVector s e, MVector s f)++-- | Yield the element at the given position.+read :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Yield the element at the given position. No bounds checks are+-- performed.+unsafeRead :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position. No bounds checks are+-- performed.+unsafeWrite :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions. No bounds checks are+-- performed.+unsafeSwap :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap. This is not checked.+unsafeCopy :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length, but this is not checked.+-- +-- If the vectors do not overlap, then this is equivalent to+-- <a>unsafeCopy</a>. Otherwise, the copying is performed as if the+-- source vector were copied to a temporary vector and then the temporary+-- vector was copied to the target vector.+unsafeMove :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()+++-- | Safe interface to <a>Data.Vector.Unboxed.Mutable</a>+module Data.Vector.Unboxed.Mutable.Safe+type IOVector = MVector RealWorld+type STVector s = MVector s+class (Vector Vector a, MVector MVector a) => Unbox a++-- | Length of the mutable vector.+length :: Unbox a => MVector s a -> Int++-- | Check whether the vector is empty+null :: Unbox a => MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Unbox a => Int -> Int -> MVector s a -> MVector s a+init :: Unbox a => MVector s a -> MVector s a+tail :: Unbox a => MVector s a -> MVector s a+take :: Unbox a => Int -> MVector s a -> MVector s a+drop :: Unbox a => Int -> MVector s a -> MVector s a+splitAt :: Unbox a => Int -> MVector s a -> (MVector s a, MVector s a)+overlaps :: Unbox a => MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: (PrimMonad m, Unbox a) => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: (PrimMonad m, Unbox a) => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: (PrimMonad m, Unbox a) => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> m ()++-- | <i>O(1)</i> Zip 2 vectors+zip :: (Unbox a, Unbox b) => MVector s a -> MVector s b -> MVector s (a, b)++-- | <i>O(1)</i> Zip 3 vectors+zip3 :: (Unbox a, Unbox b, Unbox c) => MVector s a -> MVector s b -> MVector s c -> MVector s (a, b, c)++-- | <i>O(1)</i> Zip 4 vectors+zip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s (a, b, c, d)++-- | <i>O(1)</i> Zip 5 vectors+zip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s e -> MVector s (a, b, c, d, e)++-- | <i>O(1)</i> Zip 6 vectors+zip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s e -> MVector s f -> MVector s (a, b, c, d, e, f)++-- | <i>O(1)</i> Unzip 2 vectors+unzip :: (Unbox a, Unbox b) => MVector s (a, b) -> (MVector s a, MVector s b)++-- | <i>O(1)</i> Unzip 3 vectors+unzip3 :: (Unbox a, Unbox b, Unbox c) => MVector s (a, b, c) -> (MVector s a, MVector s b, MVector s c)++-- | <i>O(1)</i> Unzip 4 vectors+unzip4 :: (Unbox a, Unbox b, Unbox c, Unbox d) => MVector s (a, b, c, d) -> (MVector s a, MVector s b, MVector s c, MVector s d)++-- | <i>O(1)</i> Unzip 5 vectors+unzip5 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e) => MVector s (a, b, c, d, e) -> (MVector s a, MVector s b, MVector s c, MVector s d, MVector s e)++-- | <i>O(1)</i> Unzip 6 vectors+unzip6 :: (Unbox a, Unbox b, Unbox c, Unbox d, Unbox e, Unbox f) => MVector s (a, b, c, d, e, f) -> (MVector s a, MVector s b, MVector s c, MVector s d, MVector s e, MVector s f)++-- | Yield the element at the given position.+read :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: (PrimMonad m, Unbox a) => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()+++-- | Mutable boxed vectors.+module Data.Vector.Mutable++-- | Mutable boxed vectors keyed on the monad they live in (<a>IO</a> or+-- <tt><tt>ST</tt> s</tt>).+data MVector s a+MVector :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !MutableArray s a -> MVector s a+type IOVector = MVector RealWorld+type STVector s = MVector s++-- | Length of the mutable vector.+length :: MVector s a -> Int++-- | Check whether the vector is empty+null :: MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Int -> Int -> MVector s a -> MVector s a+init :: MVector s a -> MVector s a+tail :: MVector s a -> MVector s a+take :: Int -> MVector s a -> MVector s a+drop :: Int -> MVector s a -> MVector s a+splitAt :: Int -> MVector s a -> (MVector s a, MVector s a)++-- | Yield a part of the mutable vector without copying it. No bounds+-- checks are performed.+unsafeSlice :: Int -> Int -> MVector s a -> MVector s a+unsafeInit :: MVector s a -> MVector s a+unsafeTail :: MVector s a -> MVector s a+unsafeTake :: Int -> MVector s a -> MVector s a+unsafeDrop :: Int -> MVector s a -> MVector s a+overlaps :: MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: PrimMonad m => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length. The length is not+-- checked.+unsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: PrimMonad m => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: PrimMonad m => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: PrimMonad m => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: PrimMonad m => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive but this is not checked.+unsafeGrow :: PrimMonad m => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: PrimMonad m => MVector (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: PrimMonad m => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: PrimMonad m => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: PrimMonad m => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Yield the element at the given position. No bounds checks are+-- performed.+unsafeRead :: PrimMonad m => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position. No bounds checks are+-- performed.+unsafeWrite :: PrimMonad m => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions. No bounds checks are+-- performed.+unsafeSwap :: PrimMonad m => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: PrimMonad m => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap. This is not checked.+unsafeCopy :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length, but this is not checked.+-- +-- If the vectors do not overlap, then this is equivalent to+-- <a>unsafeCopy</a>. Otherwise, the copying is performed as if the+-- source vector were copied to a temporary vector and then the temporary+-- vector was copied to the target vector.+unsafeMove :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()+instance Typeable2 MVector+instance MVector MVector a+++-- | A library for boxed vectors (that is, polymorphic arrays capable of+-- holding any Haskell value). The vectors come in two flavours:+-- +-- <ul>+-- <li>mutable</li>+-- <li>immutable</li>+-- </ul>+-- +-- and support a rich interface of both list-like operations, and bulk+-- array operations.+-- +-- For unboxed arrays, use <a>Data.Vector.Unboxed</a>+module Data.Vector++-- | Boxed vectors, supporting efficient slicing.+data Vector a++-- | Mutable boxed vectors keyed on the monad they live in (<a>IO</a> or+-- <tt><tt>ST</tt> s</tt>).+data MVector s a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Vector a -> Bool++-- | O(1) Indexing+(!) :: Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Vector a -> a++-- | <i>O(1)</i> Last element+last :: Vector a -> a++-- | <i>O(1)</i> Unsafe indexing without bounds checking+unsafeIndex :: Vector a -> Int -> a++-- | <i>O(1)</i> First element without checking if the vector is empty+unsafeHead :: Vector a -> a++-- | <i>O(1)</i> Last element without checking if the vector is empty+unsafeLast :: Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: Monad m => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Indexing in a monad without bounds checks. See+-- <a>indexM</a> for an explanation of why this is useful.+unsafeIndexM :: Monad m => Vector a -> Int -> m a++-- | <i>O(1)</i> First element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeHeadM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Last element in a monad without checking for empty+-- vectors. See <a>indexM</a> for an explanation of why this is useful.+unsafeLastM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Yield a slice of the vector without copying. The vector+-- must contain at least <tt>i+n</tt> elements but this is not checked.+unsafeSlice :: Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty but this is not checked.+unsafeInit :: Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty but this is not checked.+unsafeTail :: Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements without copying. The+-- vector must contain at least <tt>n</tt> elements but this is not+-- checked.+unsafeTake :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector must contain at least <tt>n</tt> elements but this+-- is not checked.+unsafeDrop :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Empty vector+empty :: Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: Monad m => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: Monad m => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: Num a => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: Num a => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: Enum a => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: Enum a => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: Vector a -> Vector (Int, a) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- The function <a>update</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: Vector a -> Vector Int -> Vector a -> Vector a++-- | Same as (<a>//</a>) but without bounds checking.+unsafeUpd :: Vector a -> [(Int, a)] -> Vector a++-- | Same as <a>update</a> but without bounds checking.+unsafeUpdate :: Vector a -> Vector (Int, a) -> Vector a++-- | Same as <a>update_</a> but without bounds checking.+unsafeUpdate_ :: Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- The function <a>accumulate</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | Same as <a>accum</a> but without bounds checking.+unsafeAccum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | Same as <a>accumulate</a> but without bounds checking.+unsafeAccumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | Same as <a>accumulate_</a> but without bounds checking.+unsafeAccumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Vector a -> Vector Int -> Vector a++-- | Same as <a>backpermute</a> but without bounds checking.+unsafeBackpermute :: Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: Vector a -> Vector (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: Monad m => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | Elementwise pairing of array elements.+zip :: Vector a -> Vector b -> Vector (a, b)++-- | zip together three vectors into a vector of triples+zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)+zip4 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)+zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)+zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(min(m,n))</i> Unzip a vector of pairs.+unzip :: Vector (a, b) -> (Vector a, Vector b)+unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)+unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)+unzip5 :: Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)+unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: Eq a => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: Eq a => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: Eq a => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: Eq a => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: Num a => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: Num a => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: Ord a => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: Ord a => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: Ord a => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: Ord a => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: Monad m => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()++-- | Evaluate each action and collect the results+sequence :: Monad m => Vector (m a) -> m (Vector a)++-- | Evaluate each action and discard the results+sequence_ :: Monad m => Vector (m a) -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()++-- | <i>O(1)</i> Unsafe convert a mutable vector to an immutable one+-- without copying. The mutable vector may not be used after this+-- operation.+unsafeFreeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(1)</i> Unsafely convert an immutable vector to a mutable one+-- without copying. The immutable vector may not be used after this+-- operation.+unsafeThaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length. This is not checked.+unsafeCopy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()+instance Typeable1 Vector+instance Traversable Vector+instance Foldable Vector+instance Alternative Vector+instance Applicative Vector+instance MonadPlus Vector+instance Monad Vector+instance Functor Vector+instance Monoid (Vector a)+instance Ord a => Ord (Vector a)+instance Eq a => Eq (Vector a)+instance Vector Vector a+instance Data a => Data (Vector a)+instance Read a => Read (Vector a)+instance Show a => Show (Vector a)+++-- | Safe interface to <a>Data.Vector</a>+module Data.Vector.Safe++-- | Boxed vectors, supporting efficient slicing.+data Vector a++-- | Mutable boxed vectors keyed on the monad they live in (<a>IO</a> or+-- <tt><tt>ST</tt> s</tt>).+data MVector s a++-- | <i>O(1)</i> Yield the length of the vector.+length :: Vector a -> Int++-- | <i>O(1)</i> Test whether a vector if empty+null :: Vector a -> Bool++-- | O(1) Indexing+(!) :: Vector a -> Int -> a++-- | O(1) Safe indexing+(!?) :: Vector a -> Int -> Maybe a++-- | <i>O(1)</i> First element+head :: Vector a -> a++-- | <i>O(1)</i> Last element+last :: Vector a -> a++-- | <i>O(1)</i> Indexing in a monad.+-- +-- The monad allows operations to be strict in the vector when necessary.+-- Suppose vector copying is implemented like this:+-- +-- <pre>+-- copy mv v = ... write mv i (v ! i) ...+-- </pre>+-- +-- For lazy vectors, <tt>v ! i</tt> would not be evaluated which means+-- that <tt>mv</tt> would unnecessarily retain a reference to <tt>v</tt>+-- in each element written.+-- +-- With <a>indexM</a>, copying can be implemented like this instead:+-- +-- <pre>+-- copy mv v = ... do+-- x <- indexM v i+-- write mv i x+-- </pre>+-- +-- Here, no references to <tt>v</tt> are retained because indexing (but+-- <i>not</i> the elements) is evaluated eagerly.+indexM :: Monad m => Vector a -> Int -> m a++-- | <i>O(1)</i> First element of a vector in a monad. See <a>indexM</a>+-- for an explanation of why this is useful.+headM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Last element of a vector in a monad. See <a>indexM</a> for+-- an explanation of why this is useful.+lastM :: Monad m => Vector a -> m a++-- | <i>O(1)</i> Yield a slice of the vector without copying it. The vector+-- must contain at least <tt>i+n</tt> elements.+slice :: Int -> Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the last element without copying. The vector+-- may not be empty.+init :: Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first element without copying. The+-- vector may not be empty.+tail :: Vector a -> Vector a++-- | <i>O(1)</i> Yield at the first <tt>n</tt> elements without copying.+-- The vector may contain less than <tt>n</tt> elements in which case it+-- is returned unchanged.+take :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield all but the first <tt>n</tt> elements without+-- copying. The vector may contain less than <tt>n</tt> elements in which+-- case an empty vector is returned.+drop :: Int -> Vector a -> Vector a++-- | <i>O(1)</i> Yield the first <tt>n</tt> elements paired with the+-- remainder without copying.+-- +-- Note that <tt><a>splitAt</a> n v</tt> is equivalent to+-- <tt>(<a>take</a> n v, <a>drop</a> n v)</tt> but slightly more+-- efficient.+splitAt :: Int -> Vector a -> (Vector a, Vector a)++-- | <i>O(1)</i> Empty vector+empty :: Vector a++-- | <i>O(1)</i> Vector with exactly one element+singleton :: a -> Vector a++-- | <i>O(n)</i> Vector of the given length with the same value in each+-- position+replicate :: Int -> a -> Vector a++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- function to each index+generate :: Int -> (Int -> a) -> Vector a++-- | <i>O(n)</i> Apply function n times to value. Zeroth element is+-- original value.+iterateN :: Int -> (a -> a) -> a -> Vector a++-- | <i>O(n)</i> Execute the monadic action the given number of times and+-- store the results in a vector.+replicateM :: Monad m => Int -> m a -> m (Vector a)++-- | <i>O(n)</i> Construct a vector of the given length by applying the+-- monadic action to each index+generateM :: Monad m => Int -> (Int -> m a) -> m (Vector a)++-- | Execute the monadic action and freeze the resulting vector.+-- +-- <pre>+-- create (do { v <- new 2; write v 0 'a'; write v 1 'b' }) = <<tt>a</tt>,<tt>b</tt>>+-- </pre>+create :: (forall s. ST s (MVector s a)) -> Vector a++-- | <i>O(n)</i> Construct a vector by repeatedly applying the generator+-- function to a seed. The generator function yields <a>Just</a> the next+-- element and the new seed or <a>Nothing</a> if there are no more+-- elements.+-- +-- <pre>+-- unfoldr (\n -> if n == 0 then Nothing else Just (n,n-1)) 10+-- = <10,9,8,7,6,5,4,3,2,1>+-- </pre>+unfoldr :: (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with at most <tt>n</tt> by repeatedly+-- applying the generator function to the a seed. The generator function+-- yields <a>Just</a> the next element and the new seed or <a>Nothing</a>+-- if there are no more elements.+-- +-- <pre>+-- unfoldrN 3 (\n -> Just (n,n-1)) 10 = <10,9,8>+-- </pre>+unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements by repeatedly+-- applying the generator function to the already constructed part of the+-- vector.+-- +-- <pre>+-- constructN 3 f = let a = f <> ; b = f <a> ; c = f <a,b> in f <a,b,c>+-- </pre>+constructN :: Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Construct a vector with <tt>n</tt> elements from right to+-- left by repeatedly applying the generator function to the already+-- constructed part of the vector.+-- +-- <pre>+-- constructrN 3 f = let a = f <> ; b = f<a> ; c = f <b,a> in f <c,b,a>+-- </pre>+constructrN :: Int -> (Vector a -> a) -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+1</tt> etc. This operation is usually more efficient+-- than <a>enumFromTo</a>.+-- +-- <pre>+-- enumFromN 5 3 = <5,6,7>+-- </pre>+enumFromN :: Num a => a -> Int -> Vector a++-- | <i>O(n)</i> Yield a vector of the given length containing the values+-- <tt>x</tt>, <tt>x+y</tt>, <tt>x+y+y</tt> etc. This operations is+-- usually more efficient than <a>enumFromThenTo</a>.+-- +-- <pre>+-- enumFromStepN 1 0.1 5 = <1,1.1,1.2,1.3,1.4>+-- </pre>+enumFromStepN :: Num a => a -> a -> Int -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromN</a> instead.+enumFromTo :: Enum a => a -> a -> Vector a++-- | <i>O(n)</i> Enumerate values from <tt>x</tt> to <tt>y</tt> with a+-- specific step <tt>z</tt>.+-- +-- <i>WARNING:</i> This operation can be very inefficient. If at all+-- possible, use <a>enumFromStepN</a> instead.+enumFromThenTo :: Enum a => a -> a -> a -> Vector a++-- | <i>O(n)</i> Prepend an element+cons :: a -> Vector a -> Vector a++-- | <i>O(n)</i> Append an element+snoc :: Vector a -> a -> Vector a++-- | <i>O(m+n)</i> Concatenate two vectors+(++) :: Vector a -> Vector a -> Vector a++-- | <i>O(n)</i> Concatenate all vectors in the list+concat :: [Vector a] -> Vector a++-- | <i>O(n)</i> Yield the argument but force it not to retain any extra+-- memory, possibly by copying it.+-- +-- This is especially useful when dealing with slices. For example:+-- +-- <pre>+-- force (slice 0 2 <huge vector>)+-- </pre>+-- +-- Here, the slice retains a reference to the huge vector. Forcing it+-- creates a copy of just the elements that belong to the slice and+-- allows the huge vector to be garbage collected.+force :: Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the list, replace the+-- vector element at position <tt>i</tt> by <tt>a</tt>.+-- +-- <pre>+-- <5,9,2,7> // [(2,1),(0,3),(2,8)] = <3,9,8,7>+-- </pre>+(//) :: Vector a -> [(Int, a)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,a)</tt> from the vector of+-- index/value pairs, replace the vector element at position <tt>i</tt>+-- by <tt>a</tt>.+-- +-- <pre>+-- update <5,9,2,7> <(2,1),(0,3),(2,8)> = <3,9,8,7>+-- </pre>+update :: Vector a -> Vector (Int, a) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>a</tt> from the value vector, replace+-- the element of the initial vector at position <tt>i</tt> by+-- <tt>a</tt>.+-- +-- <pre>+-- update_ <5,9,2,7> <2,0,2> <1,3,8> = <3,9,8,7>+-- </pre>+-- +-- The function <a>update</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- update_ xs is ys = <a>update</a> xs (<a>zip</a> is ys)+-- </pre>+update_ :: Vector a -> Vector Int -> Vector a -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the list, replace the+-- vector element <tt>a</tt> at position <tt>i</tt> by <tt>f a b</tt>.+-- +-- <pre>+-- accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>+-- </pre>+accum :: (a -> b -> a) -> Vector a -> [(Int, b)] -> Vector a++-- | <i>O(m+n)</i> For each pair <tt>(i,b)</tt> from the vector of pairs,+-- replace the vector element <tt>a</tt> at position <tt>i</tt> by <tt>f+-- a b</tt>.+-- +-- <pre>+-- accumulate (+) <5,9,2> <(2,4),(1,6),(0,3),(1,7)> = <5+3, 9+6+7, 2+4>+-- </pre>+accumulate :: (a -> b -> a) -> Vector a -> Vector (Int, b) -> Vector a++-- | <i>O(m+min(n1,n2))</i> For each index <tt>i</tt> from the index vector+-- and the corresponding value <tt>b</tt> from the the value vector,+-- replace the element of the initial vector at position <tt>i</tt> by+-- <tt>f a b</tt>.+-- +-- <pre>+-- accumulate_ (+) <5,9,2> <2,1,0,1> <4,6,3,7> = <5+3, 9+6+7, 2+4>+-- </pre>+-- +-- The function <a>accumulate</a> provides the same functionality and is+-- usually more convenient.+-- +-- <pre>+-- accumulate_ f as is bs = <a>accumulate</a> f as (<a>zip</a> is bs)+-- </pre>+accumulate_ :: (a -> b -> a) -> Vector a -> Vector Int -> Vector b -> Vector a++-- | <i>O(n)</i> Reverse a vector+reverse :: Vector a -> Vector a++-- | <i>O(n)</i> Yield the vector obtained by replacing each element+-- <tt>i</tt> of the index vector by <tt>xs<a>!</a>i</tt>. This is+-- equivalent to <tt><a>map</a> (xs<a>!</a>) is</tt> but is often much+-- more efficient.+-- +-- <pre>+-- backpermute <a,b,c,d> <0,3,2,3,1,0> = <a,d,c,d,b,a>+-- </pre>+backpermute :: Vector a -> Vector Int -> Vector a++-- | Apply a destructive operation to a vector. The operation will be+-- performed in place if it is safe to do so and will modify a copy of+-- the vector otherwise.+-- +-- <pre>+-- modify (\v -> write v 0 'x') (<a>replicate</a> 3 'a') = <'x','a','a'>+-- </pre>+modify :: (forall s. MVector s a -> ST s ()) -> Vector a -> Vector a++-- | <i>O(n)</i> Pair each element in a vector with its index+indexed :: Vector a -> Vector (Int, a)++-- | <i>O(n)</i> Map a function over a vector+map :: (a -> b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply a function to every element of a vector and its+-- index+imap :: (Int -> a -> b) -> Vector a -> Vector b++-- | Map a function over a vector and concatenate the results.+concatMap :: (a -> Vector b) -> Vector a -> Vector b++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results+mapM :: Monad m => (a -> m b) -> Vector a -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results+mapM_ :: Monad m => (a -> m b) -> Vector a -> m ()++-- | <i>O(n)</i> Apply the monadic action to all elements of the vector,+-- yielding a vector of results. Equvalent to <tt>flip <a>mapM</a></tt>.+forM :: Monad m => Vector a -> (a -> m b) -> m (Vector b)++-- | <i>O(n)</i> Apply the monadic action to all elements of a vector and+-- ignore the results. Equivalent to <tt>flip <a>mapM_</a></tt>.+forM_ :: Monad m => Vector a -> (a -> m b) -> m ()++-- | <i>O(min(m,n))</i> Zip two vectors with the given function.+zipWith :: (a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors with the given function.+zipWith3 :: (a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+zipWith4 :: (a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+zipWith5 :: (a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | <i>O(min(m,n))</i> Zip two vectors with a function that also takes the+-- elements' indices.+izipWith :: (Int -> a -> b -> c) -> Vector a -> Vector b -> Vector c++-- | Zip three vectors and their indices with the given function.+izipWith3 :: (Int -> a -> b -> c -> d) -> Vector a -> Vector b -> Vector c -> Vector d+izipWith4 :: (Int -> a -> b -> c -> d -> e) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e+izipWith5 :: (Int -> a -> b -> c -> d -> e -> f) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f+izipWith6 :: (Int -> a -> b -> c -> d -> e -> f -> g) -> Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector g++-- | Elementwise pairing of array elements.+zip :: Vector a -> Vector b -> Vector (a, b)++-- | zip together three vectors into a vector of triples+zip3 :: Vector a -> Vector b -> Vector c -> Vector (a, b, c)+zip4 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector (a, b, c, d)+zip5 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector (a, b, c, d, e)+zip6 :: Vector a -> Vector b -> Vector c -> Vector d -> Vector e -> Vector f -> Vector (a, b, c, d, e, f)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- yield a vector of results+zipWithM :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m (Vector c)++-- | <i>O(min(m,n))</i> Zip the two vectors with the monadic action and+-- ignore the results+zipWithM_ :: Monad m => (a -> b -> m c) -> Vector a -> Vector b -> m ()++-- | <i>O(min(m,n))</i> Unzip a vector of pairs.+unzip :: Vector (a, b) -> (Vector a, Vector b)+unzip3 :: Vector (a, b, c) -> (Vector a, Vector b, Vector c)+unzip4 :: Vector (a, b, c, d) -> (Vector a, Vector b, Vector c, Vector d)+unzip5 :: Vector (a, b, c, d, e) -> (Vector a, Vector b, Vector c, Vector d, Vector e)+unzip6 :: Vector (a, b, c, d, e, f) -> (Vector a, Vector b, Vector c, Vector d, Vector e, Vector f)++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate+filter :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the predicate which is+-- applied to values and their indices+ifilter :: (Int -> a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop elements that do not satisfy the monadic predicate+filterM :: Monad m => (a -> m Bool) -> Vector a -> m (Vector a)++-- | <i>O(n)</i> Yield the longest prefix of elements satisfying the+-- predicate without copying.+takeWhile :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Drop the longest prefix of elements that satisfy the+-- predicate without copying.+dropWhile :: (a -> Bool) -> Vector a -> Vector a++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The relative order of the elements is preserved at the+-- cost of a sometimes reduced performance compared to+-- <a>unstablePartition</a>.+partition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector in two parts, the first one containing+-- those elements that satisfy the predicate and the second one those+-- that don't. The order of the elements is not preserved but the+-- operation is often faster than <a>partition</a>.+unstablePartition :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- satisfy the predicate and the rest without copying.+span :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Split the vector into the longest prefix of elements that+-- do not satisfy the predicate and the rest without copying.+break :: (a -> Bool) -> Vector a -> (Vector a, Vector a)++-- | <i>O(n)</i> Check if the vector contains an element+elem :: Eq a => a -> Vector a -> Bool++-- | <i>O(n)</i> Check if the vector does not contain an element (inverse+-- of <a>elem</a>)+notElem :: Eq a => a -> Vector a -> Bool++-- | <i>O(n)</i> Yield <a>Just</a> the first element matching the predicate+-- or <a>Nothing</a> if no such element exists.+find :: (a -> Bool) -> Vector a -> Maybe a++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first element matching+-- the predicate or <a>Nothing</a> if no such element exists.+findIndex :: (a -> Bool) -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of elements satisfying the predicate in+-- ascending order.+findIndices :: (a -> Bool) -> Vector a -> Vector Int++-- | <i>O(n)</i> Yield <a>Just</a> the index of the first occurence of the+-- given element or <a>Nothing</a> if the vector does not contain the+-- element. This is a specialised version of <a>findIndex</a>.+elemIndex :: Eq a => a -> Vector a -> Maybe Int++-- | <i>O(n)</i> Yield the indices of all occurences of the given element+-- in ascending order. This is a specialised version of+-- <a>findIndices</a>.+elemIndices :: Eq a => a -> Vector a -> Vector Int++-- | <i>O(n)</i> Left fold+foldl :: (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors+foldl1 :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold with strict accumulator+foldl' :: (a -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold on non-empty vectors with strict accumulator+foldl1' :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold+foldr :: (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors+foldr1 :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Right fold with a strict accumulator+foldr' :: (a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold on non-empty vectors with strict accumulator+foldr1' :: (a -> a -> a) -> Vector a -> a++-- | <i>O(n)</i> Left fold (function applied to each element and its index)+ifoldl :: (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Left fold with strict accumulator (function applied to+-- each element and its index)+ifoldl' :: (a -> Int -> b -> a) -> a -> Vector b -> a++-- | <i>O(n)</i> Right fold (function applied to each element and its+-- index)+ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Right fold with strict accumulator (function applied to+-- each element and its index)+ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b++-- | <i>O(n)</i> Check if all elements satisfy the predicate.+all :: (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if any element satisfies the predicate.+any :: (a -> Bool) -> Vector a -> Bool++-- | <i>O(n)</i> Check if all elements are <a>True</a>+and :: Vector Bool -> Bool++-- | <i>O(n)</i> Check if any element is <a>True</a>+or :: Vector Bool -> Bool++-- | <i>O(n)</i> Compute the sum of the elements+sum :: Num a => Vector a -> a++-- | <i>O(n)</i> Compute the produce of the elements+product :: Num a => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector. The vector may+-- not be empty.+maximum :: Ord a => Vector a -> a++-- | <i>O(n)</i> Yield the maximum element of the vector according to the+-- given comparison function. The vector may not be empty.+maximumBy :: (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector. The vector may+-- not be empty.+minimum :: Ord a => Vector a -> a++-- | <i>O(n)</i> Yield the minimum element of the vector according to the+-- given comparison function. The vector may not be empty.+minimumBy :: (a -> a -> Ordering) -> Vector a -> a++-- | <i>O(n)</i> Yield the index of the minimum element of the vector. The+-- vector may not be empty.+minIndex :: Ord a => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the minimum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+minIndexBy :: (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector. The+-- vector may not be empty.+maxIndex :: Ord a => Vector a -> Int++-- | <i>O(n)</i> Yield the index of the maximum element of the vector+-- according to the given comparison function. The vector may not be+-- empty.+maxIndexBy :: (a -> a -> Ordering) -> Vector a -> Int++-- | <i>O(n)</i> Monadic fold+foldM :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold with strict accumulator+foldM' :: Monad m => (a -> b -> m a) -> a -> Vector b -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors+fold1M :: Monad m => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator+fold1M' :: Monad m => (a -> a -> m a) -> Vector a -> m a++-- | <i>O(n)</i> Monadic fold that discards the result+foldM_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold with strict accumulator that discards the+-- result+foldM'_ :: Monad m => (a -> b -> m a) -> a -> Vector b -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors that discards the+-- result+fold1M_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()++-- | <i>O(n)</i> Monadic fold over non-empty vectors with strict+-- accumulator that discards the result+fold1M'_ :: Monad m => (a -> a -> m a) -> Vector a -> m ()++-- | Evaluate each action and collect the results+sequence :: Monad m => Vector (m a) -> m (Vector a)++-- | Evaluate each action and discard the results+sequence_ :: Monad m => Vector (m a) -> m ()++-- | <i>O(n)</i> Prescan+-- +-- <pre>+-- prescanl f z = <a>init</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>prescanl (+) 0 <1,2,3,4> = <0,1,3,6></tt>+prescanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Prescan with strict accumulator+prescanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan+-- +-- <pre>+-- postscanl f z = <a>tail</a> . <a>scanl</a> f z+-- </pre>+-- +-- Example: <tt>postscanl (+) 0 <1,2,3,4> = <1,3,6,10></tt>+postscanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan with strict accumulator+postscanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan+-- +-- <pre>+-- scanl f z <x1,...,xn> = <y1,...,y(n+1)>+-- where y1 = z+-- yi = f y(i-1) x(i-1)+-- </pre>+-- +-- Example: <tt>scanl (+) 0 <1,2,3,4> = <0,1,3,6,10></tt>+scanl :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Haskell-style scan with strict accumulator+scanl' :: (a -> b -> a) -> a -> Vector b -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector+-- +-- <pre>+-- scanl f <x1,...,xn> = <y1,...,yn>+-- where y1 = x1+-- yi = f y(i-1) xi+-- </pre>+scanl1 :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Scan over a non-empty vector with a strict accumulator+scanl1' :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left prescan+-- +-- <pre>+-- prescanr f z = <a>reverse</a> . <a>prescanl</a> (flip f) z . <a>reverse</a>+-- </pre>+prescanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left prescan with strict accumulator+prescanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan+postscanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan with strict accumulator+postscanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan+scanr :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left Haskell-style scan with strict accumulator+scanr' :: (a -> b -> b) -> b -> Vector a -> Vector b++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector+scanr1 :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Right-to-left scan over a non-empty vector with a strict+-- accumulator+scanr1' :: (a -> a -> a) -> Vector a -> Vector a++-- | <i>O(n)</i> Convert a vector to a list+toList :: Vector a -> [a]++-- | <i>O(n)</i> Convert a list to a vector+fromList :: [a] -> Vector a++-- | <i>O(n)</i> Convert the first <tt>n</tt> elements of a list to a+-- vector+-- +-- <pre>+-- fromListN n xs = <a>fromList</a> (<a>take</a> n xs)+-- </pre>+fromListN :: Int -> [a] -> Vector a++-- | <i>O(n)</i> Convert different vector types+convert :: (Vector v a, Vector w a) => v a -> w a++-- | <i>O(n)</i> Yield an immutable copy of the mutable vector.+freeze :: PrimMonad m => MVector (PrimState m) a -> m (Vector a)++-- | <i>O(n)</i> Yield a mutable copy of the immutable vector.+thaw :: PrimMonad m => Vector a -> m (MVector (PrimState m) a)++-- | <i>O(n)</i> Copy an immutable vector into a mutable one. The two+-- vectors must have the same length.+copy :: PrimMonad m => MVector (PrimState m) a -> Vector a -> m ()+++-- | Safe interface to <a>Data.Vector.Mutable</a>+module Data.Vector.Mutable.Safe++-- | Mutable boxed vectors keyed on the monad they live in (<a>IO</a> or+-- <tt><tt>ST</tt> s</tt>).+data MVector s a+type IOVector = MVector RealWorld+type STVector s = MVector s++-- | Length of the mutable vector.+length :: MVector s a -> Int++-- | Check whether the vector is empty+null :: MVector s a -> Bool++-- | Yield a part of the mutable vector without copying it.+slice :: Int -> Int -> MVector s a -> MVector s a+init :: MVector s a -> MVector s a+tail :: MVector s a -> MVector s a+take :: Int -> MVector s a -> MVector s a+drop :: Int -> MVector s a -> MVector s a+splitAt :: Int -> MVector s a -> (MVector s a, MVector s a)+overlaps :: MVector s a -> MVector s a -> Bool++-- | Create a mutable vector of the given length.+new :: PrimMonad m => Int -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with an initial value.+replicate :: PrimMonad m => Int -> a -> m (MVector (PrimState m) a)++-- | Create a mutable vector of the given length (0 if the length is+-- negative) and fill it with values produced by repeatedly executing the+-- monadic action.+replicateM :: PrimMonad m => Int -> m a -> m (MVector (PrimState m) a)++-- | Create a copy of a mutable vector.+clone :: PrimMonad m => MVector (PrimState m) a -> m (MVector (PrimState m) a)++-- | Grow a vector by the given number of elements. The number must be+-- positive.+grow :: PrimMonad m => MVector (PrimState m) a -> Int -> m (MVector (PrimState m) a)++-- | Reset all elements of the vector to some undefined value, clearing all+-- references to external objects. This is usually a noop for unboxed+-- vectors.+clear :: PrimMonad m => MVector (PrimState m) a -> m ()++-- | Yield the element at the given position.+read :: PrimMonad m => MVector (PrimState m) a -> Int -> m a++-- | Replace the element at the given position.+write :: PrimMonad m => MVector (PrimState m) a -> Int -> a -> m ()++-- | Swap the elements at the given positions.+swap :: PrimMonad m => MVector (PrimState m) a -> Int -> Int -> m ()++-- | Set all elements of the vector to the given value.+set :: PrimMonad m => MVector (PrimState m) a -> a -> m ()++-- | Copy a vector. The two vectors must have the same length and may not+-- overlap.+copy :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()++-- | Move the contents of a vector. The two vectors must have the same+-- length.+-- +-- If the vectors do not overlap, then this is equivalent to <a>copy</a>.+-- Otherwise, the copying is performed as if the source vector were+-- copied to a temporary vector and then the temporary vector was copied+-- to the target vector.+move :: PrimMonad m => MVector (PrimState m) a -> MVector (PrimState m) a -> m ()
+ data/wai.txt view
@@ -0,0 +1,127 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | Web Application Interface.+-- +-- Provides a common protocol for communication between web aplications+-- and web servers.+@package wai+@version 0.4.1+++-- | This module defines a generic web application interface. It is a+-- common protocol between web servers and web applications.+-- +-- The overriding design principles here are performance and generality .+-- To address performance, this library is built on top of the enumerator+-- and blaze-builder packages. The advantages of enumerators over lazy IO+-- have been debated elsewhere and so will not be addressed here.+-- However, helper functions like <a>responseLBS</a> allow you to+-- continue using lazy IO if you so desire.+-- +-- Generality is achieved by removing many variables commonly found in+-- similar projects that are not universal to all servers. The goal is+-- that the <a>Request</a> object contains only data which is meaningful+-- in all circumstances.+-- +-- Please remember when using this package that, while your application+-- may compile without a hitch against many different servers, there are+-- other considerations to be taken when moving to a new backend. For+-- example, if you transfer from a CGI application to a FastCGI one, you+-- might suddenly find you have a memory leak. Conversely, a FastCGI+-- application would be well served to preload all templates from disk+-- when first starting; this would kill the performance of a CGI+-- application.+-- +-- This package purposely provides very little functionality. You can+-- find various middlewares, backends and utilities on Hackage. Some of+-- the most commonly used include:+-- +-- <ul>+-- <li><i>warp</i> <a>http://hackage.haskell.org/package/warp</a></li>+-- <li><i>wai-extra</i>+-- <a>http://hackage.haskell.org/package/wai-extra</a></li>+-- <li><i>wai-test</i>+-- <a>http://hackage.haskell.org/package/wai-test</a></li>+-- </ul>+module Network.Wai++-- | Information on the request sent by the client. This abstracts away the+-- details of the underlying implementation.+data Request+Request :: Method -> HttpVersion -> ByteString -> ByteString -> ByteString -> Int -> RequestHeaders -> Bool -> SockAddr -> [Text] -> Query -> Request+requestMethod :: Request -> Method+httpVersion :: Request -> HttpVersion++-- | Extra path information sent by the client. The meaning varies slightly+-- depending on backend; in a standalone server setting, this is most+-- likely all information after the domain name. In a CGI application,+-- this would be the information following the path to the CGI executable+-- itself. Do not modify this raw value- modify pathInfo instead.+rawPathInfo :: Request -> ByteString++-- | If no query string was specified, this should be empty. This value+-- <i>will</i> include the leading question mark. Do not modify this raw+-- value- modify queryString instead.+rawQueryString :: Request -> ByteString++-- | Generally the host requested by the user via the Host request header.+-- Backends are free to provide alternative values as necessary. This+-- value should not be used to construct URLs.+serverName :: Request -> ByteString++-- | The listening port that the server received this request on. It is+-- possible for a server to listen on a non-numeric port (i.e., Unix+-- named socket), in which case this value will be arbitrary. Like+-- <a>serverName</a>, this value should not be used in URL construction.+serverPort :: Request -> Int+requestHeaders :: Request -> RequestHeaders++-- | Was this request made over an SSL connection?+isSecure :: Request -> Bool++-- | The client's host information.+remoteHost :: Request -> SockAddr++-- | Path info in individual pieces- the url without a hostname/port and+-- without a query string, split on forward slashes,+pathInfo :: Request -> [Text]++-- | Parsed query string information+queryString :: Request -> Query+data Response+ResponseFile :: Status -> ResponseHeaders -> FilePath -> (Maybe FilePart) -> Response+ResponseBuilder :: Status -> ResponseHeaders -> Builder -> Response+ResponseEnumerator :: (forall a. ResponseEnumerator a) -> Response+type ResponseEnumerator a = (Status -> ResponseHeaders -> Iteratee Builder IO a) -> IO a+responseEnumerator :: Response -> ResponseEnumerator a+type Application = Request -> Iteratee ByteString IO Response++-- | Middleware is a component that sits between the server and+-- application. It can do such tasks as GZIP encoding or response+-- caching. What follows is the general definition of middleware, though+-- a middleware author should feel free to modify this.+-- +-- As an example of an alternate type for middleware, suppose you write a+-- function to load up session information. The session information is+-- simply a string map [(String, String)]. A logical type signatures for+-- this middleware might be:+-- +-- <pre>+-- loadSession :: ([(String, String)] -> Application) -> Application+-- </pre>+-- +-- Here, instead of taking a standard <a>Application</a> as its first+-- argument, the middleware takes a function which consumes the session+-- information as well.+type Middleware = Application -> Application+data FilePart+FilePart :: Integer -> Integer -> FilePart+filePartOffset :: FilePart -> Integer+filePartByteCount :: FilePart -> Integer+responseLBS :: Status -> ResponseHeaders -> ByteString -> Response+instance Typeable Request+instance Typeable Response+instance Show Request+instance Show FilePart
+ data/warp.txt view
@@ -0,0 +1,91 @@+-- Hoogle documentation, generated by Haddock+-- See Hoogle, http://www.haskell.org/hoogle/+++-- | A fast, light-weight web server for WAI applications.+-- +-- The premier WAI handler. For more information, see+-- <a>http://steve.vinoski.net/blog/2011/05/01/warp-a-haskell-web-server/</a>.+@package warp+@version 0.4.4+++-- | A fast, light-weight HTTP server handler for WAI. Some random notes (a+-- FAQ, if you will):+-- +-- <ul>+-- <li>When a <a>ResponseFile</a> indicates a file which does not exist,+-- an exception is thrown. This will close the connection to the client+-- as well. You should handle file existance checks at the application+-- level.</li>+-- </ul>+module Network.Wai.Handler.Warp++-- | Run an <a>Application</a> on the given port. This calls+-- <a>runSettings</a> with <a>defaultSettings</a>.+run :: Port -> Application -> IO ()++-- | Run a Warp server with the given settings.+runSettings :: Settings -> Application -> IO ()++-- | Same as <a>runSettings</a>, but uses a user-supplied socket instead of+-- opening one. This allows the user to provide, for example, Unix named+-- socket, which can be used when reverse HTTP proxying into your+-- application.+-- +-- Note that the <a>settingsPort</a> will still be passed to+-- <a>Application</a>s via the <a>serverPort</a> record.+runSettingsSocket :: Settings -> Socket -> Application -> IO ()++-- | Various Warp server settings. This is purposely kept as an abstract+-- data type so that new settings can be added without breaking backwards+-- compatibility. In order to create a <a>Settings</a> value, use+-- <a>defaultSettings</a> and record syntax to modify individual records.+-- For example:+-- +-- <pre>+-- defaultSettings { settingsTimeout = 20 }+-- </pre>+data Settings++-- | The default settings for the Warp server. See the individual settings+-- for the default value.+defaultSettings :: Settings++-- | Port to listen on. Default value: 3000+settingsPort :: Settings -> Int++-- | Host to bind to, or * for all. Default value: *+settingsHost :: Settings -> String++-- | What to do with exceptions thrown by either the application or server.+-- Default: ignore server-generated exceptions (see+-- <a>InvalidRequest</a>) and print application-generated applications to+-- stderr.+settingsOnException :: Settings -> SomeException -> IO ()++-- | Timeout value in seconds. Default value: 30+settingsTimeout :: Settings -> Int+type Port = Int+data InvalidRequest+NotEnoughLines :: [String] -> InvalidRequest+BadFirstLine :: String -> InvalidRequest+NonHttp :: InvalidRequest+IncompleteHeaders :: InvalidRequest+OverLargeHeader :: InvalidRequest++-- | A timeout manager+data Manager++-- | Call the inner function with a timeout manager.+withManager :: Int -> (Manager -> IO a) -> IO a+parseRequest :: Port -> SockAddr -> Iteratee ByteString IO (Integer, Request)+sendResponse :: Handle -> Request -> Socket -> Response -> IO Bool+registerKillThread :: Manager -> IO Handle+bindPort :: Int -> String -> IO Socket+enumSocket :: Handle -> Int -> Socket -> Enumerator ByteString IO a+resume, pause :: Handle -> IO ()+instance Typeable InvalidRequest+instance Show InvalidRequest+instance Eq InvalidRequest+instance Exception InvalidRequest
+ docs/LICENSE view
@@ -0,0 +1,29 @@+Copyright 2011, Alejandro Serrano+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++- Redistributions of source code must retain the above copyright notice,+this list of conditions and the following disclaimer.+ +- Redistributions in binary form must reproduce the above copyright notice,+this list of conditions and the following disclaimer in the documentation+and/or other materials provided with the distribution.+ +- Neither name of the author nor the names of its contributors may be+used to endorse or promote products derived from this software without+specific prior written permission. ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND THE CONTRIBUTORS "AS+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY+COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ scion-browser.cabal view
@@ -0,0 +1,117 @@+name: scion-browser+version: 0.1.3+cabal-version: >= 1.8+build-type: Simple+license: BSD3+license-file: docs/LICENSE+author: Alejandro Serrano <trupill@gmail.com>+maintainer: Alejandro Serrano <trupill@gmail.com>+homepage: http://github.com/serras/scion-class-browser+category: Development+synopsis: Command-line interface for browsing and searching packages documentation+description: Scion Browser aims to be a command-line interface for getting information about installed Haskell packages, that could be later used by development environments. It also provides integration with Hoogle. By now, it has been integrated in EclipseFP.++source-repository head+ type: git+ location: https://github.com/serras/scion-class-browser++library+ hs-source-dirs: src+ build-depends: + base == 4.*,+ mtl >= 2,+ derive >= 2.5 && < 3,+ text == 0.11.*,+ parsec >= 3 && < 4,+ cereal == 0.3.*,+ Cabal >= 0.10, + haskell-src-exts >= 1.11 && < 2,+ process >= 1 && < 2,+ tar == 0.3.*,+ zlib == 0.5.*,+ HTTP >= 4000 && < 5000,+ deepseq >= 1.1 && < 2,+ aeson >= 0.3.2,+ parallel-io >= 0.3,+ utf8-string ,+ -- For Scion.packages (provisional)+ ghc-paths == 0.1.*+ + if !os(mingw32)+ build-depends:+ unix >= 2 && < 3+ + if impl(ghc >= 7.0)+ build-depends:+ containers >= 0.2 && < 0.5,+ directory == 1.1.*,+ filepath == 1.2.*,+ bytestring,+ -- For Scion.Packages (provisional)+ ghc >= 7+ else+ build-depends:+ containers >= 0.2 && < 0.4,+ directory == 1.0.*,+ filepath == 1.1.*,+ -- For Scion.Packages (provisional)+ ghc >= 6.10 && < 6.13+ + exposed-modules:+ Scion.Browser,+ Scion.Browser.Query,+ Scion.Browser.Build,+ Scion.Hoogle+ + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -fno-warn-orphans+ other-modules: Scion.Browser.Instances.Json, Scion.Browser.Instances.NFData, Scion.Browser.Instances.Serialize, Scion.Browser.Parser.Documentable, Scion.Browser.Parser.Internal, Scion.Browser.FileUtil, Scion.Browser.Parser, Scion.Browser.TempFile, Scion.Browser.Types, Scion.Browser.Util, Scion.Hoogle.Instances.Json, Scion.Hoogle.Parser, Scion.Hoogle.Types, Scion.Hoogle.Util, Scion.Packages, Scion.Browser.FromMissingH++executable scion-browser+ hs-source-dirs: src+ main-is: Main.hs+ build-depends:+ haskeline >= 0.6,+ attoparsec >= 0.8,+ -- From library+ base == 4.*,+ mtl >= 2,+ derive >= 2.5 && < 3,+ text == 0.11.*,+ parsec >= 3 && < 4,+ cereal == 0.3.*,+ Cabal >= 0.10, + haskell-src-exts >= 1.11 && < 2,+ process >= 1 && < 2,+ tar == 0.3.*,+ zlib == 0.5.*,+ HTTP >= 4000 && < 5000,+ deepseq >= 1.1 && < 2,+ aeson >= 0.3.2,+ parallel-io >= 0.3,+ utf8-string ,+ -- For Scion.packages (provisional)+ ghc-paths == 0.1.*+ + if !os(mingw32)+ build-depends:+ unix >= 2 && < 3+ + if impl(ghc >= 7.0)+ build-depends:+ containers >= 0.2 && < 0.5,+ directory == 1.1.*,+ filepath == 1.2.*,+ bytestring,+ -- For Scion.Packages (provisional)+ ghc >= 7+ else+ build-depends:+ containers >= 0.2 && < 0.4,+ directory == 1.0.*,+ filepath == 1.1.*,+ -- For Scion.Packages (provisional)+ ghc >= 6.10 && < 6.13+ + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -fno-warn-orphans -threaded+ other-modules: Server.Commands, Scion.Browser.Instances.Json, Scion.Browser.Instances.NFData, Scion.Browser.Instances.Serialize, Scion.Browser.Parser.Documentable, Scion.Browser.Parser.Internal, Scion.Browser.Build, Scion.Browser.FileUtil, Scion.Browser.Parser, Scion.Browser.Query, Scion.Browser.TempFile, Scion.Browser.Types, Scion.Browser.Util, Scion.Hoogle.Instances.Json, Scion.Hoogle.Parser, Scion.Hoogle.Types, Scion.Hoogle.Util, Scion.Browser, Scion.Hoogle, Scion.Packages, Scion.Browser.FromMissingH+
+ scion-browser.cabal~ view
@@ -0,0 +1,172 @@+name: scion-browser+version: 0.1.3+cabal-version: >= 1.8+build-type: Simple+license: BSD3+license-file: docs/LICENSE+author: Alejandro Serrano <trupill@gmail.com>+maintainer: Alejandro Serrano <trupill@gmail.com>+homepage: http://github.com/serras/scion-class-browser+category: Development+synopsis: Command-line interface for browsing and searching packages documentation+description: Scion Browser aims to be a command-line interface for getting information about installed Haskell packages, that could be later used by development environments. It also provides integration with Hoogle. By now, it has been integrated in EclipseFP.++source-repository head+ type: git+ location: https://github.com/serras/scion-class-browser++library+ hs-source-dirs: src+ build-depends: + base == 4.*,+ mtl >= 2,+ derive >= 2.5 && < 3,+ text == 0.11.*,+ parsec >= 3 && < 4,+ cereal == 0.3.*,+ Cabal >= 0.10, + haskell-src-exts >= 1.11 && < 2,+ process >= 1 && < 2,+ tar == 0.3.*,+ zlib == 0.5.*,+ HTTP >= 4000 && < 5000,+ deepseq >= 1.1 && < 2,+ aeson >= 0.3.2,+ parallel-io >= 0.3,+ utf8-string ,+ -- For Scion.packages (provisional)+ ghc-paths == 0.1.*+ + if !os(mingw32)+ build-depends:+ unix >= 2 && < 3+ + if impl(ghc >= 7.0)+ build-depends:+ containers >= 0.2 && < 0.5,+ directory == 1.1.*,+ filepath == 1.2.*,+ bytestring,+ -- For Scion.Packages (provisional)+ ghc >= 7+ else+ build-depends:+ containers >= 0.2 && < 0.4,+ directory == 1.0.*,+ filepath == 1.1.*,+ -- For Scion.Packages (provisional)+ ghc >= 6.10 && < 6.13+ + exposed-modules:+ Scion.Browser,+ Scion.Browser.Query,+ Scion.Browser.Build,+ Scion.Hoogle+ + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -fno-warn-orphans+ other-modules: Scion.Browser.Instances.Json, Scion.Browser.Instances.NFData, Scion.Browser.Instances.Serialize, Scion.Browser.Parser.Documentable, Scion.Browser.Parser.Internal, Scion.Browser.FileUtil, Scion.Browser.Parser, Scion.Browser.TempFile, Scion.Browser.Types, Scion.Browser.Util, Scion.Hoogle.Instances.Json, Scion.Hoogle.Parser, Scion.Hoogle.Types, Scion.Hoogle.Util, Scion.Packages, Scion.Browser.FromMissingH++executable scion-browser+ hs-source-dirs: src+ main-is: Main.hs+ build-depends:+ haskeline >= 0.6,+ attoparsec >= 0.8,+ -- From library+ base == 4.*,+ mtl >= 2,+ derive >= 2.5 && < 3,+ text == 0.11.*,+ parsec >= 3 && < 4,+ cereal == 0.3.*,+ Cabal >= 0.10, + haskell-src-exts >= 1.11 && < 2,+ process >= 1 && < 2,+ tar == 0.3.*,+ zlib == 0.5.*,+ HTTP >= 4000 && < 5000,+ deepseq >= 1.1 && < 2,+ aeson >= 0.3.2,+ parallel-io >= 0.3,+ utf8-string ,+ -- For Scion.packages (provisional)+ ghc-paths == 0.1.*+ + if !os(mingw32)+ build-depends:+ unix >= 2 && < 3+ + if impl(ghc >= 7.0)+ build-depends:+ containers >= 0.2 && < 0.5,+ directory == 1.1.*,+ filepath == 1.2.*,+ bytestring,+ -- For Scion.Packages (provisional)+ ghc >= 7+ else+ build-depends:+ containers >= 0.2 && < 0.4,+ directory == 1.0.*,+ filepath == 1.1.*,+ -- For Scion.Packages (provisional)+ ghc >= 6.10 && < 6.13+ + ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -fno-warn-orphans -threaded+ other-modules: Server.Commands, Scion.Browser.Instances.Json, Scion.Browser.Instances.NFData, Scion.Browser.Instances.Serialize, Scion.Browser.Parser.Documentable, Scion.Browser.Parser.Internal, Scion.Browser.Build, Scion.Browser.FileUtil, Scion.Browser.Parser, Scion.Browser.Query, Scion.Browser.TempFile, Scion.Browser.Types, Scion.Browser.Util, Scion.Hoogle.Instances.Json, Scion.Hoogle.Parser, Scion.Hoogle.Types, Scion.Hoogle.Util, Scion.Browser, Scion.Hoogle, Scion.Packages, Scion.Browser.FromMissingH++test-suite BrowserTests+ main-is: Test.hs+ type: exitcode-stdio-1.0+ ghc-options: -Wall -rtsopts+ hs-source-dirs: src, test+ other-modules: Scion.Browser.Parser.Documentable, Scion.Browser.Parser.Internal, Scion.Browser.Parser, Scion.Browser.ParserTests+ + build-depends:+ HUnit >= 1.2 && < 2,+ QuickCheck >= 2.4,+ test-framework >= 0.4.1,+ test-framework-quickcheck2,+ test-framework-hunit,+ split,+ haskeline >= 0.6,+ attoparsec >= 0.8,+ -- From library+ base == 4.*,+ mtl >= 2,+ derive >= 2.5 && < 3,+ text == 0.11.*,+ parsec >= 3 && < 4,+ cereal == 0.3.*,+ Cabal >= 0.10, + haskell-src-exts >= 1.11 && < 2,+ process >= 1 && < 2,+ tar == 0.3.*,+ zlib == 0.5.*,+ HTTP >= 4000 && < 5000,+ deepseq >= 1.1 && < 2,+ aeson >= 0.3.2,+ parallel-io >= 0.3,+ utf8-string ,+ -- For Scion.packages (provisional)+ ghc-paths == 0.1.*+ + if !os(mingw32)+ build-depends:+ unix >= 2 && < 3+ + if impl(ghc >= 7.0)+ build-depends:+ containers >= 0.2 && < 0.5,+ directory == 1.1.*,+ filepath == 1.2.*,+ bytestring,+ -- For Scion.Packages (provisional)+ ghc >= 7+ else+ build-depends:+ containers >= 0.2 && < 0.4,+ directory == 1.0.*,+ filepath == 1.1.*,+ -- For Scion.Packages (provisional)+ ghc >= 6.10 && < 6.13
+ src/Main.hs view
@@ -0,0 +1,28 @@+module Main where++import Control.Monad.State+import Data.Aeson+import qualified Data.Aeson.Types as T+import qualified Data.Attoparsec.Char8 as Atto+import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy.Char8 as LBS+import Server.Commands+import System.Console.Haskeline++main :: IO ()+main = do runStateT (runInputT defaultSettings loop) initialState+ return ()++loop :: InputT BrowserM ()+loop = do maybeLine <- getInputLine ""+ case maybeLine of+ Nothing -> return () -- ctrl+D or EOF+ Just line -> do+ case Atto.parse json (BS.pack line) of+ Atto.Fail _ _ e -> outputStrLn ("error in command: " ++ e) >> loop+ Atto.Done _ value -> case T.parse parseJSON value of+ Error e -> outputStrLn ("error in command: " ++ e) >> loop+ Success cmd -> do (res, continue) <- lift $ executeCommand cmd+ liftIO $ LBS.putStrLn $ encode res+ if continue then loop else return ()+
+ src/Scion/Browser.hs view
@@ -0,0 +1,35 @@+module Scion.Browser+( saveDatabase+, loadDatabase+, singletonDatabase+, module Scion.Browser.Types+, module Scion.Browser.Instances.Json+-- , module Scion.Browser.Instances.NFData+, module Scion.Browser.Instances.Serialize+) where++import Control.DeepSeq+import qualified Data.ByteString as BS+import qualified Data.Map as M+import Data.Serialize+import Scion.Browser.Types+import Scion.Browser.Instances.Json+import Scion.Browser.Instances.NFData ()+import Scion.Browser.Instances.Serialize+import System.IO++saveDatabase :: FilePath -> Database -> IO ()+saveDatabase fpath db = withFile fpath WriteMode $+ \hnd -> do BS.hPut hnd (encode db)+ hFlush hnd++loadDatabase :: FilePath -> IO (Maybe Database)+loadDatabase fpath = withFile fpath ReadMode $+ \hnd -> do s <- BS.hGetContents hnd+ return $ case decode s of+ Left _ -> Nothing+ Right p -> p `deepseq` Just p++singletonDatabase :: Documented Package -> Database+singletonDatabase pkg@(Package _ pid _) = M.singleton pid pkg+
+ src/Scion/Browser/Build.hs view
@@ -0,0 +1,184 @@+{-# LANGUAGE ScopedTypeVariables #-}++module Scion.Browser.Build+( saveHackageDatabase+, createHackageDatabase+, updateDatabase+, createCabalDatabase+, getCabalHoogle+) where++import Control.Concurrent.ParallelIO.Local+import Control.DeepSeq+import Control.Exception as E (catch, SomeException)+import Data.Either (rights)+import Data.List ((\\), nub)+import qualified Data.Map as M+import Data.Version (Version, showVersion)+import Distribution.InstalledPackageInfo+import Distribution.Package hiding (Package)+import Scion.Browser+import Scion.Browser.Parser+import Scion.Browser.FileUtil+import Scion.Browser.Util+import System.Directory+import System.Exit+import System.FilePath+import Text.Parsec.Error (ParseError)+import Text.ParserCombinators.Parsec.Error (newErrorMessage, Message(..))+import Text.ParserCombinators.Parsec.Pos (newPos)+++baseDbUrl :: String+baseDbUrl = "http://haskell.org/hoogle/base.txt"++ghcDbUrl :: String+ghcDbUrl = "http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/ghc.txt"++hoogleDbUrl :: String+hoogleDbUrl = "http://hackage.haskell.org/packages/archive/00-hoogle.tar.gz"++-- | Gets the url of a package from Hackage+getPackageUrlHackage :: PackageIdentifier -> String+getPackageUrlHackage (PackageIdentifier (PackageName name) version) =+ "http://hackage.haskell.org/packages/archive/" ++ name ++ "/" ++ showVersion version ++ "/doc/html/" ++ name ++ ".txt"++-- | Gets the version of GHC used+getGhcInstalledVersion :: [PackageIdentifier] -> Version+getGhcInstalledVersion [] = error "No GHC found"+getGhcInstalledVersion ((PackageIdentifier (PackageName "ghc") version):_) = version+getGhcInstalledVersion (_:xs) = getGhcInstalledVersion xs++-- | Gets the url of a package from GHC libraries+getPackageUrlGhcLibs :: Version -> PackageIdentifier -> String+getPackageUrlGhcLibs ghcVersion (PackageIdentifier (PackageName name) version) =+ "http://www.haskell.org/ghc/docs/" ++ showVersion ghcVersion ++ "/html/libraries/" ++ name ++ "-" ++ showVersion version ++ "/" ++ name ++ ".txt"++-- | Downloads the information for the entire Hackage database+-- and saves it to the specified location.+saveHackageDatabase :: FilePath -> IO ()+saveHackageDatabase file = withTemporaryDirectory (saveHackageDatabaseWithTmp file)++saveHackageDatabaseWithTmp :: FilePath -> FilePath -> IO ()+saveHackageDatabaseWithTmp file tmp = do (db, _) <- createHackageDatabase tmp+ saveDatabase file db++-- | Downloads the information for the entire Hackage database+-- creating an in-memory database with it.+-- It needs a temporary directory to work on.+createHackageDatabase :: FilePath -> IO (Database, [(FilePath, ParseError)])+createHackageDatabase tmp =+ do let hoogleDbDir = tmp </> "hoogle-db"+ tmpDir = tmp </> "tmp-db"+ -- Parse Hoogle database+ createDirectoryIfMissing True hoogleDbDir+ logToStdout "Started downloading Hoogle database"+ Just hoogleDownloaded <- downloadFileLazy hoogleDbUrl+ logToStdout "Uncompressing Hoogle database"+ unTarGzip hoogleDownloaded hoogleDbDir+ logToStdout $ "Hoogle database is now in " ++ hoogleDbDir+ createDirectoryIfMissing True tmpDir+ (pkgs, errors) <- parseDirectory hoogleDbDir tmpDir+ --let (pkgs, errors) = ([], [])+ {-+ -- Parse base package+ Just baseDownloaded <- downloadFileStrict baseDbUrl+ logToStdout "Base database successfully downloaded"+ -- Parse ghc package+ Just ghcDownloaded <- downloadFileStrict ghcDbUrl+ logToStdout "GHC database successfully downloaded"+ let (dbBase, errorsBase) = case parseHoogleString "base.txt" baseDownloaded of+ Right b -> (b:pkgs, errors)+ Left e -> (pkgs, ("base.txt", e):errors)+ let (dbGhc, errorsGhc) = case parseHoogleString "ghc.txt" ghcDownloaded of+ Right b -> (b:dbBase, errorsBase)+ Left e -> (dbBase, ("ghc.txt", e):errorsBase)+ return (pkgListToDb dbGhc, errorsGhc)+ -}+ return (pkgListToDb pkgs, errors)++-- | Updates a database with changes in the installed package base.+updateDatabase :: Database -> [InstalledPackageInfo] -> IO Database+updateDatabase oldDb pkgInfo = do let dbList = nub $ map fst $ M.toList oldDb+ installedList = nub $ removeSmallVersions $ map sourcePackageId pkgInfo+ toRemove = dbList \\ installedList+ toAdd = installedList \\ dbList+ filteredDb = foldr (\pid db -> M.delete pid db) oldDb toRemove+ let ghcVersion = getGhcInstalledVersion installedList+ logToStdout $ "Adding " ++ show (map (\(PackageIdentifier (PackageName name) _) -> name) toAdd)+ (addedDb, errors) <- createCabalDatabase' ghcVersion toAdd True+ logToStdout $ show errors+ return $ M.union filteredDb addedDb++removeSmallVersions :: [PackageIdentifier] -> [PackageIdentifier]+removeSmallVersions pids = filter+ (not . (\(PackageIdentifier name version) -> + any (\(PackageIdentifier name' version') -> name' == name && version' > version) pids))+ pids++-- | Get the database from a set of Cabal packages.+createCabalDatabase :: Version -> [PackageIdentifier] -> IO (Database, [(String, ParseError)])+createCabalDatabase ghcVersion pkgs = createCabalDatabase' ghcVersion pkgs False++-- | Get the database from a set of Cabal packages.+-- If `ifFailCreateEmpty' is set, when a package gives a parse error,+-- it is converted into an empty package with a note.+createCabalDatabase' :: Version -> [PackageIdentifier] -> Bool -> IO (Database, [(String, ParseError)])+createCabalDatabase' ghcVersion pkgs ifFailCreateEmpty =+ withTemporaryDirectory $ \tmp ->+ do let toExecute = map (\pid -> do db <- getCabalHoogle ghcVersion pid ifFailCreateEmpty tmp+ return (pkgString pid, db))+ pkgs+ eitherHooglePkgs <- withThreaded $ \pool -> parallelInterleavedE pool toExecute+ let hooglePkgs = rights eitherHooglePkgs+ (db, errors) = partitionPackages hooglePkgs+ return (db `deepseq` pkgListToDb db, errors)++-- | Get the database from a Cabal package.+getCabalHoogle :: Version -> PackageIdentifier -> Bool -> FilePath -> IO (Either ParseError (Documented Package))+getCabalHoogle ghcVersion pid ifFailCreateEmpty tmp = + E.catch (do result <- getCabalHoogle' ghcVersion pid tmp+ case result of+ Left e -> return $ failure e+ Right (Package doc _ info) -> return $ Right (Package doc pid info))+ (\(e :: E.SomeException) -> return $ failure (newErrorMessage (Message "error parsing")+ (newPos "" 0 0)))+ where failure e = if ifFailCreateEmpty+ then Right (Package NoDoc pid M.empty)+ else Left e++-- | Get the database from a Cabal package.+getCabalHoogle' :: Version -> PackageIdentifier -> FilePath -> IO (Either ParseError (Documented Package))+getCabalHoogle' ghcVersion pid tmp = do let downUrl1 = getPackageUrlHackage pid+ logToStdout $ "Download " ++ downUrl1+ tryDownload1 <- downloadHoogleFile downUrl1+ case tryDownload1 of+ Nothing -> do let downUrl2 = getPackageUrlGhcLibs ghcVersion pid+ logToStdout $ "Download " ++ downUrl2+ tryDownload2 <- downloadHoogleFile downUrl2+ case tryDownload2 of+ Nothing -> getCabalHoogleLocal pid tmp+ Just cnts -> return $ parseHoogleString "<package>" cnts+ Just cnts -> return $ parseHoogleString "<package>" cnts++-- | Get the database from a locally installed Cabal package.+getCabalHoogleLocal :: PackageIdentifier -> FilePath -> IO (Either ParseError (Documented Package))+getCabalHoogleLocal pid tmp = + do let pkgV = pkgString pid+ (PackageName pkg) = pkgName pid+ logToStdout $ "Parsing " ++ pkgV+ code <- executeCommand tmp "cabal" ["unpack", pkgV] True+ case code of+ ExitFailure _ -> return $ Left (newErrorMessage (Message "package not found")+ (newPos pkgV 0 0))+ ExitSuccess ->+ do let pkgdir = tmp </> pkgV+ withWorkingDirectory pkgdir $+ do executeCommand pkgdir "cabal" ["configure"] True+ executeCommand pkgdir "cabal" ["haddock", "--hoogle"] True+ let hoogleFile = pkgdir </> "dist" </> "doc" </> "html" </> pkg </> (pkg ++ ".txt")+ parseHoogleFile hoogleFile++pkgString :: PackageIdentifier -> String+pkgString (PackageIdentifier (PackageName name) version) = name ++ "-" ++ showVersion version+
+ src/Scion/Browser/FileUtil.hs view
@@ -0,0 +1,90 @@+{-# LANGUAGE ScopedTypeVariables, ForeignFunctionInterface #-}++module Scion.Browser.FileUtil where++import qualified Codec.Archive.Tar as Tar+import qualified Codec.Compression.GZip as GZip+import Control.Exception (bracket)+import qualified Data.ByteString as SBS+import qualified Data.ByteString.Char8 as SBS8+import qualified Data.ByteString.Lazy as LBS+import qualified Data.ByteString.Lazy.Char8 as LBS8+import Data.List (isPrefixOf)+import Network.Browser+import Network.HTTP+import Network.HTTP.Proxy+import System.Directory+import System.FilePath+import Scion.Browser.TempFile++-- |Takes out the "." and ".." special directory+-- entries from a list of file paths.+filterDots :: [FilePath] -> [FilePath]+filterDots = filter (\d -> d /= "." && d /= "..")++-- |Downloads a file from the internet.+downloadFileLazy :: String -> IO (Maybe LBS.ByteString)+downloadFileLazy url = do + response <- fetchURL url+ return $ Just (LBS8.pack response)++-- |Downloads a file from the internet.+downloadFileStrict :: String -> IO (Maybe SBS.ByteString)+downloadFileStrict url = do + response <- fetchURL url+ return $ Just (SBS8.pack response)++-- |Downloads a file from the internet and check it's a Hoogle file.+downloadHoogleFile :: String -> IO (Maybe SBS.ByteString)+downloadHoogleFile url = do + response <- fetchURL url+ if "-- Hoogle documentation" `isPrefixOf` response+ then return $ Just (SBS8.pack response)+ else return Nothing++-- |Downloads a file from the internet, using the system proxy+fetchURL :: String -> IO (String)+fetchURL url=do+ pr<-fetchProxy False+ (_,res) <- browse $ do + setProxy pr + request $ getRequest url+ return $ rspBody res+ +-- |Un-gzip and un-tar a file into a folder.+unTarGzip :: LBS.ByteString -> FilePath -> IO ()+unTarGzip cnts folder = let ungzip = GZip.decompress cnts+ entries = Tar.read ungzip+ in do createDirectories entries+ Tar.unpack folder entries+ where createDirectories Tar.Done = return ()+ createDirectories (Tar.Fail _) = return ()+ createDirectories (Tar.Next e es) =+ case Tar.entryContent e of+ Tar.NormalFile _ _ -> do let dir = folder </> takeDirectory (Tar.entryPath e)+ createDirectoryIfMissing True dir+ createDirectories es+ Tar.Directory -> do let dir = folder </> Tar.entryPath e+ createDirectoryIfMissing True dir+ createDirectories es+ _ -> createDirectories es++-- HACK: Taken from Unixutils.+-- The version in Hackage conflicts with some of our packages.++-- |temporarily change the working directory to |dir| while running |action|+withWorkingDirectory :: FilePath -> IO a -> IO a+withWorkingDirectory dir action = + bracket getCurrentDirectory setCurrentDirectory (\ _ -> setCurrentDirectory dir >> action)++-- |create a temporary directory, run the action, remove the temporary directory+-- the directory will be created inside the system temporary directory (cf bug 3413186)+-- the temporary directory will be automatically removed afterwards.+-- your working directory is not altered+withTemporaryDirectory :: (FilePath -> IO a) -> IO a+withTemporaryDirectory f =+ do home <- getTemporaryDirectory + bracket (createTempDirectory home ".scion")+ removeDirectoryRecursive+ f+
+ src/Scion/Browser/FromMissingH.hs view
@@ -0,0 +1,98 @@+-- |Utility functions that were first used from package MissingH.+-- But MissingH does not build in 7.2.1 yet, so I included them here.+module Scion.Browser.FromMissingH where++import Data.List (intersperse, isPrefixOf)++-- From Data.List.Utils++{- | Adds the specified (key, value) pair to the given list, removing any+existing pair with the same key already present. -}+addToAL :: Eq key => [(key, elt)] -> key -> elt -> [(key, elt)]+addToAL l key value = (key, value) : delFromAL l key++{- | Removes all (key, value) pairs from the given list where the key+matches the given one. -}+delFromAL :: Eq key => [(key, a)] -> key -> [(key, a)]+delFromAL l key = filter (\a -> (fst a) /= key) l+++-- From Data.String.Utils++{- | Returns true if the given list starts with the specified elements;+false otherwise. (This is an alias for "Data.List.isPrefixOf".)++Example:++> startswith "He" "Hello" -> True++-}++startswith :: Eq a => [a] -> [a] -> Bool+startswith = isPrefixOf++{- | Similar to Data.List.span, but performs the test on the entire remaining+list instead of just one element. ++@spanList p xs@ is the same as @(takeWhileList p xs, dropWhileList p xs)@ +-}+spanList :: ([a] -> Bool) -> [a] -> ([a], [a])++spanList _ [] = ([],[])+spanList func list@(x:xs) =+ if func list+ then (x:ys,zs)+ else ([],list)+ where (ys,zs) = spanList func xs++{- | Similar to Data.List.break, but performs the test on the entire remaining+list instead of just one element.+-}+breakList :: ([a] -> Bool) -> [a] -> ([a], [a])+breakList func = spanList (not . func)++{- | Given a delimiter and a list (or string), split into components.++Example:++> split "," "foo,bar,,baz," -> ["foo", "bar", "", "baz", ""]++> split "ba" ",foo,bar,,baz," -> [",foo,","r,,","z,"]+-}+split :: Eq a => [a] -> [a] -> [[a]]+split _ [] = []+split delim str =+ let (firstline, remainder) = breakList (startswith delim) str+ in + firstline : case remainder of+ [] -> []+ x -> if x == delim+ then [] : []+ else split delim + (drop (length delim) x)++{- | Given a list and a replacement list, replaces each occurance of the search+list with the replacement list in the operation list.++Example:++>replace "," "." "127,0,0,1" -> "127.0.0.1"++This could logically be thought of as:++>replace old new l = join new . split old $ l+-}++replace :: Eq a => [a] -> [a] -> [a] -> [a]+replace old new l = join new . split old $ l++{- | Given a delimiter and a list of items (or strings), join the items+by using the delimiter.++Example:++> join "|" ["foo", "bar", "baz"] -> "foo|bar|baz"+-}+join :: [a] -> [[a]] -> [a]+join delim l = concat (intersperse delim l)+
+ src/Scion/Browser/Instances/Json.hs view
@@ -0,0 +1,131 @@+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}++module Scion.Browser.Instances.Json where++import Control.Applicative+import Control.Monad+import Data.Aeson+import Data.Version+import qualified Data.Text as T+import Distribution.Package hiding (Package)+import Scion.Browser.Types+import Language.Haskell.Exts.Annotated.Syntax hiding (String)+import Language.Haskell.Exts.Pretty+import Text.ParserCombinators.ReadP++instance ToJSON (Documented Package) where+ toJSON (Package doc pid _) = object [ T.pack "id" .= pid+ , T.pack "doc" .= doc+ ]++instance ToJSON PackageIdentifier where+ toJSON (PackageIdentifier (PackageName name) version) = object [ T.pack "name" .= name+ , T.pack "version" .= version+ ]+instance FromJSON PackageIdentifier where+ parseJSON (Object v) = PackageIdentifier <$> (PackageName <$> v .: T.pack "name")+ <*> v .: T.pack "version"+ parseJSON _ = mzero++instance ToJSON Version where+ toJSON = String . T.pack . showVersion++instance FromJSON Version where+ parseJSON version = (fst . last . readP_to_S parseVersion . T.unpack) <$> parseJSON version++instance ToJSON Doc where+ toJSON (NoDoc) = Null+ toJSON (Doc txt) = String txt++instance ToJSON (Name l) where+ toJSON = String . T.pack . getNameString++instance ToJSON (QName l) where+ toJSON = String . T.pack . getQNameString++singleLinePrettyPrint :: Pretty a => a -> String+singleLinePrettyPrint = prettyPrintWithMode $ defaultMode { layout = PPNoLayout }++instance ToJSON (Kind l) where+ toJSON = String . T.pack . singleLinePrettyPrint++instance ToJSON (Type l) where+ toJSON = String . T.pack . singleLinePrettyPrint++instance ToJSON (Documented Module) where+ toJSON (Module doc (Just (ModuleHead _ (ModuleName _ name) _ _)) _ _ _) = object [ T.pack "doc" .= doc+ , T.pack "name" .= name+ ]+ toJSON _ = Null++maybeEmptyContext :: Maybe (Documented Context) -> Documented Context+maybeEmptyContext Nothing = CxEmpty NoDoc+maybeEmptyContext (Just ctx) = ctx++instance ToJSON (Documented Decl) where+ toJSON (GDataDecl doc dOrM ctx hd kind decls _) = object [ T.pack "doc" .= doc+ , T.pack "type" .= dOrM+ , T.pack "context" .= maybeEmptyContext ctx+ , T.pack "head" .= hd+ , T.pack "kind" .= kind+ , T.pack "decls" .= decls+ ]+ toJSON (ClassDecl doc ctx hd fdeps _) = object [ T.pack "doc" .= doc+ , T.pack "type" .= T.pack "class"+ , T.pack "context" .= maybeEmptyContext ctx+ , T.pack "head" .= hd+ , T.pack "fundeps" .= fdeps+ ]+ toJSON (InstDecl doc ctx hd _) = object [ T.pack "doc" .= doc+ , T.pack "type" .= T.pack "instance"+ , T.pack "context" .= maybeEmptyContext ctx+ , T.pack "head" .= hd+ ]+ toJSON (TypeSig doc names ty) = object [ T.pack "doc" .= doc+ , T.pack "type" .= T.pack "signature"+ , T.pack "name" .= names+ , T.pack "signature" .= ty+ ]+ toJSON (TypeDecl doc hd ty) = object [ T.pack "doc" .= doc+ , T.pack "type" .= T.pack "type"+ , T.pack "head" .= hd+ , T.pack "equals" .= ty+ ]+ toJSON _ = Null++instance ToJSON (Context l) where+ toJSON (CxSingle _ a) = toJSON [a]+ toJSON (CxTuple _ as) = toJSON as+ toJSON (CxParen _ ctx) = toJSON ctx+ toJSON (CxEmpty _) = toJSON ([] :: [Asst l])++instance ToJSON (Asst l) where+ toJSON = String . T.pack . singleLinePrettyPrint++instance ToJSON (DataOrNew l) where+ toJSON (DataType _) = String $ T.pack "data"+ toJSON (NewType _) = String $ T.pack "newtype"++instance ToJSON (DeclHead l) where+ toJSON (DHead _ name vars) = object [ T.pack "name" .= name+ , T.pack "vars" .= vars+ ]+ toJSON _ = Null++instance ToJSON (TyVarBind l) where+ toJSON = String . T.pack . singleLinePrettyPrint++instance ToJSON (FunDep l) where+ toJSON = String . T.pack . singleLinePrettyPrint++instance ToJSON (InstHead l) where+ toJSON (IHead _ name vars) = object [ T.pack "name" .= name+ , T.pack "vars" .= vars+ ]+ toJSON _ = Null++instance ToJSON (Documented GadtDecl) where+ toJSON (GadtDecl _ name ty) = object [ T.pack "name" .= name+ , T.pack "type" .= ty+ ]+
+ src/Scion/Browser/Instances/NFData.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE TemplateHaskell, TypeSynonymInstances, FlexibleInstances #-}++module Scion.Browser.Instances.NFData where++import Control.DeepSeq+import Data.DeriveTH+import Distribution.Package hiding (Package)+import Distribution.Version+import Language.Haskell.Exts.Annotated.Syntax+import Scion.Browser.Types++$( derive makeNFData ''Doc )+$( derive makeNFData ''Package )+$( derive makeNFData ''PackageIdentifier )+$( derive makeNFData ''PackageName )+$( derive makeNFData ''Version )++-- derive NFData instances for haskell-src-exts+$( derive makeNFData ''Module )+$( derive makeNFData ''ModuleHead )+$( derive makeNFData ''WarningText )+$( derive makeNFData ''ExportSpecList )+$( derive makeNFData ''ExportSpec )+$( derive makeNFData ''ImportDecl )+$( derive makeNFData ''ImportSpecList )+$( derive makeNFData ''ImportSpec )+$( derive makeNFData ''Assoc )+$( derive makeNFData ''Decl )+$( derive makeNFData ''DeclHead )+$( derive makeNFData ''InstHead )+$( derive makeNFData ''Binds )+$( derive makeNFData ''IPBind )+$( derive makeNFData ''ClassDecl )+$( derive makeNFData ''InstDecl )+$( derive makeNFData ''Deriving )+$( derive makeNFData ''DataOrNew )+$( derive makeNFData ''ConDecl )+$( derive makeNFData ''FieldDecl )+$( derive makeNFData ''QualConDecl )+$( derive makeNFData ''GadtDecl )+$( derive makeNFData ''BangType )+$( derive makeNFData ''Match )+$( derive makeNFData ''Rhs )+$( derive makeNFData ''GuardedRhs )+$( derive makeNFData ''Context )+$( derive makeNFData ''FunDep )+$( derive makeNFData ''Asst )+$( derive makeNFData ''Type )+$( derive makeNFData ''Boxed )+$( derive makeNFData ''Kind )+$( derive makeNFData ''TyVarBind )+$( derive makeNFData ''Exp )+$( derive makeNFData ''Stmt )+$( derive makeNFData ''QualStmt )+$( derive makeNFData ''FieldUpdate )+$( derive makeNFData ''Alt )+$( derive makeNFData ''GuardedAlts )+$( derive makeNFData ''GuardedAlt )+$( derive makeNFData ''XAttr )+$( derive makeNFData ''Pat )+$( derive makeNFData ''PatField )+$( derive makeNFData ''PXAttr )+$( derive makeNFData ''RPat )+$( derive makeNFData ''RPatOp )+$( derive makeNFData ''Literal )+$( derive makeNFData ''ModuleName )+$( derive makeNFData ''QName )+$( derive makeNFData ''Name )+$( derive makeNFData ''QOp )+$( derive makeNFData ''Op )+$( derive makeNFData ''SpecialCon )+$( derive makeNFData ''CName )+$( derive makeNFData ''IPName )+$( derive makeNFData ''XName )+$( derive makeNFData ''Bracket )+$( derive makeNFData ''Splice )+$( derive makeNFData ''Safety )+$( derive makeNFData ''CallConv )+$( derive makeNFData ''ModulePragma )+$( derive makeNFData ''Tool )+$( derive makeNFData ''Rule )+$( derive makeNFData ''RuleVar )+$( derive makeNFData ''Activation )+$( derive makeNFData ''Annotation )+
+ src/Scion/Browser/Instances/Serialize.hs view
@@ -0,0 +1,498 @@+{-# LANGUAGE TemplateHaskell, TypeSynonymInstances, FlexibleInstances, ScopedTypeVariables #-}++module Scion.Browser.Instances.Serialize where++import Control.DeepSeq+import Control.Monad (liftM)+import Data.DeriveTH+import Data.Serialize+import Data.IORef+import qualified Data.Map as M+import qualified Data.Text as T+import qualified Data.Text.Encoding as E+import Distribution.Package hiding (Package)+import Distribution.Version+import Language.Haskell.Exts.Annotated.Syntax+import Scion.Browser.Types+import Scion.Browser.Instances.NFData ()+import System.IO.Unsafe++$( derive makeSerialize ''Doc )+$( derive makeSerialize ''Package )+$( derive makeSerialize ''PackageIdentifier )+$( derive makeSerialize ''PackageName )+$( derive makeSerialize ''Version )++instance Serialize T.Text where+ put = put . E.encodeUtf8+ get = liftM E.decodeUtf8 get++-- Lookup table (yes, it uses unsafePerformIO)++lookupNameTable :: IORef (M.Map String (Documented Name))+lookupNameTable = unsafePerformIO $ newIORef M.empty++getNameInLookupTable :: String -> Bool {- is symbol? -} -> Documented Name+getNameInLookupTable name isSymbol = + unsafePerformIO $ do table <- readIORef lookupNameTable+ case M.lookup name table of+ Just v -> return v+ Nothing -> do let element = if isSymbol + then (Symbol noDoc name)+ else (Ident noDoc name)+ modifyIORef lookupNameTable (M.insert name element)+ return element++lookupQNameTable :: IORef (M.Map String (Documented QName))+lookupQNameTable = unsafePerformIO $ newIORef M.empty++getQNameInLookupTable :: Documented QName -> Documented QName+getQNameInLookupTable qname = + unsafePerformIO $ do table <- readIORef lookupQNameTable+ let rname = getQNameString qname+ case M.lookup rname table of+ Just v -> return v+ Nothing -> do modifyIORef lookupQNameTable (M.insert rname qname)+ return qname++lookupTyVarTable :: IORef (M.Map String (Documented Type))+lookupTyVarTable = unsafePerformIO $ newIORef M.empty++getTyVarInLookupTable :: Documented Name -> Documented Type+getTyVarInLookupTable name = + unsafePerformIO $ do table <- readIORef lookupTyVarTable+ let rname = getNameString name+ case M.lookup rname table of+ Just v -> return v+ Nothing -> do let element = TyVar noDoc name + modifyIORef lookupTyVarTable (M.insert rname element)+ return element++lookupTyConTable :: IORef (M.Map String (Documented Type))+lookupTyConTable = unsafePerformIO $ newIORef M.empty++getTyConInLookupTable :: Documented QName -> Documented Type+getTyConInLookupTable name = + unsafePerformIO $ do table <- readIORef lookupTyConTable+ let rname = getQNameString name+ case M.lookup rname table of+ Just v -> return v+ Nothing -> do let element = TyCon noDoc name + modifyIORef lookupTyConTable (M.insert rname element)+ return element++-- Serialize instances for haskell-src-exts++noDoc :: Doc+noDoc = NoDoc++nothing :: Maybe a+nothing = Nothing++instance Serialize (Documented Module) where+ -- Only possible value+ -- Module l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l]+ put (Module doc (Just hd) _ _ decls) = do put doc+ put hd+ put decls+ put _ = error "Not allowed Module"+ get = do doc <- get+ hd <- get+ decls <- get+ return $ decls `deepseq` Module doc (Just hd) [] [] decls++instance Serialize (Documented ModuleHead) where+ -- Only possible value+ -- ModuleHead l (ModuleName l) (Maybe (WarningText l)) (Maybe (ExportSpecList l))+ put (ModuleHead _ (ModuleName _ name) _ _) = do put name+ get = do name <- get+ return $ ModuleHead noDoc (ModuleName noDoc name) nothing nothing++dataType :: Documented DataOrNew+dataType = DataType noDoc++newType :: Documented DataOrNew+newType = NewType noDoc++instance Serialize (Documented Decl) where+ -- Possible values+ -- GDataDecl l (DataOrNew l) (Maybe (Context l)) (DeclHead l) (Maybe (Kind l)) [GadtDecl l] (Maybe (Deriving l))+ -- ClassDecl l (Maybe (Context l)) (DeclHead l) [FunDep l] (Maybe [ClassDecl l])+ -- InstDecl l (Maybe (Context l)) (InstHead l) (Maybe [InstDecl l])+ -- TypeSig l [Name l] (Type l)+ -- TypeDecl l (DeclHead l) (Type l)+ put (GDataDecl doc dOrM ctx hd kind decls _) = do put doc+ putWord8 0+ case dOrM of+ DataType _ -> putWord8 0+ NewType _ -> putWord8 1+ put ctx+ put hd+ put kind+ put decls+ put (ClassDecl doc ctx hd fdeps _) = do put doc+ putWord8 1+ put ctx+ put hd+ put fdeps+ put (InstDecl doc ctx hd _) = do put doc+ putWord8 2+ put ctx+ put hd+ put (TypeSig doc names ty) = do + put doc+ putWord8 3+ put names+ put ty+ put (TypeDecl doc hd ty) = do put doc+ putWord8 4+ put hd+ put ty+ put _ = error "Not allowed Decl"+ get = do doc <- get+ tag <- getWord8+ case tag of+ 0 -> do dOrM' <- getWord8+ let dOrM = case dOrM' of+ 0 -> dataType+ _ -> newType+ ctx <- get+ hd <- get+ kind <- get+ decls <- get+ return $ GDataDecl doc dOrM ctx hd kind decls nothing+ 1 -> do ctx <- get+ hd <- get+ fdeps <- get+ return $ ClassDecl doc ctx hd fdeps nothing+ 2 -> do ctx <- get+ hd <- get+ return $ InstDecl doc ctx hd nothing+ 3 -> do names <- get+ ty <- get+ return $ TypeSig doc names ty+ _ -> do hd <- get+ ty <- get+ return $ TypeDecl doc hd ty++cxEmpty :: Documented Context+cxEmpty = CxEmpty noDoc++instance Serialize (Documented Context) where+ -- Possible values+ -- CxSingle l (Asst l) + -- CxTuple l [Asst l] + -- CxParen l (Context l) + -- CxEmpty l+ put (CxSingle _ a) = put [a]+ put (CxTuple _ as) = put as+ put (CxParen _ ctx) = put ctx+ put (CxEmpty _) = put ([] :: [Documented Asst])+ get = do (as :: [Documented Asst]) <- get+ return $ case as of+ [] -> cxEmpty+ [a] -> CxSingle noDoc a+ ass -> CxTuple noDoc ass++instance Serialize (Documented Asst) where+ -- Possible values+ -- ClassA l (QName l) [Type l]+ -- InfixA l (Type l) (QName l) (Type l) + -- IParam l (IPName l) (Type l) + -- EqualP l (Type l) (Type l)+ put (ClassA _ name tys) = do putWord8 0+ put name+ put tys+ put (InfixA _ ty1 name ty2) = do putWord8 1+ put ty1+ put name+ put ty2+ put (IParam _ ipname ty) = do putWord8 2+ put ipname+ put ty+ put (EqualP _ ty1 ty2) = do putWord8 3+ put ty1+ put ty2+ get = do tag <- getWord8+ case tag of+ 0 -> do name <- get+ tys <- get+ return $ ClassA noDoc name tys+ 1 -> do ty1 <- get+ name <- get+ ty2 <- get+ return $ InfixA noDoc ty1 name ty2+ 2 -> do ipname <- get+ ty <- get+ return $ IParam noDoc ipname ty+ _ -> do ty1 <- get+ ty2 <- get+ return $ EqualP noDoc ty1 ty2++instance Serialize (Documented DeclHead) where+ -- Only possible value+ -- DHead l (Name l) [TyVarBind l]+ put (DHead _ name vars) = do put name+ put vars+ put _ = error "Not allowed DeclHead"+ get = do name <- get+ vars <- get+ return $ DHead noDoc name vars++instance Serialize (Documented TyVarBind) where+ -- Possible values+ -- KindedVar l (Name l) (Kind l)+ -- UnkindedVar l (Name l)+ put (KindedVar _ name kind) = do put name+ putWord8 0+ put kind+ put (UnkindedVar _ name) = do put name+ putWord8 1+ get = do name <- get+ tag <- getWord8+ case tag of+ 0 -> do kind <- get+ return $ KindedVar noDoc name kind+ _ -> return $ UnkindedVar noDoc name++kindStar :: Documented Kind+kindStar = KindStar noDoc++kindBang :: Documented Kind+kindBang = KindBang noDoc++instance Serialize (Documented Kind) where+ -- Possible values+ -- KindStar l+ -- KindBang l+ -- KindFn l (Kind l) (Kind l)+ -- KindParen l (Kind l)+ -- KindVar l (Name l)+ put (KindStar _) = putWord8 0+ put (KindBang _) = putWord8 1+ put (KindFn _ k1 k2) = do putWord8 2+ put k1+ put k2+ put (KindParen _ k) = do putWord8 3+ put k+ put (KindVar _ name) = do putWord8 4+ put name+ get = do tag <- getWord8+ case tag of+ 0 -> return kindStar+ 1 -> return kindBang+ 2 -> do k1 <- get+ k2 <- get+ return $ KindFn noDoc k1 k2+ 3 -> do k <- get+ return $ KindParen noDoc k+ _ -> do name <- get+ return $ KindVar noDoc name++instance Serialize (Documented FunDep) where+ -- Only possible value+ -- FunDep l [Name l] [Name l]+ put (FunDep _ n1 n2) = do put n1+ put n2+ get = do n1 <- get+ n2 <- get+ return $ FunDep noDoc n1 n2++instance Serialize (Documented GadtDecl) where+ -- Only possible value+ -- GadtDecl l (Name l) (Type l)+ put (GadtDecl _ name ty) = do put name+ put ty+ get = do name <- get+ ty <- get+ return $ GadtDecl noDoc name ty++instance Serialize (Documented InstHead) where+ -- Only possible value+ -- IHead l (QName l) [Type l]+ put (IHead _ qname tys) = do put qname+ put tys+ put _ = error "Not allowed IHead"+ get = do qname <- get+ tys <- get+ return $ IHead noDoc qname tys++instance Serialize (Documented Type) where+ -- Possible values+ -- TyForall l (Maybe [TyVarBind l]) (Maybe (Context l)) (Type l)+ -- TyFun l (Type l) (Type l)+ -- TyTuple l Boxed [Type l]+ -- TyList l (Type l)+ -- TyApp l (Type l) (Type l)+ -- TyVar l (Name l)+ -- TyCon l (QName l)+ -- TyParen l (Type l)+ -- TyInfix l (Type l) (QName l) (Type l)+ -- TyKind l (Type l) (Kind l)+ put (TyForall _ vars ctx ty) = do putWord8 0+ put vars+ put ctx+ put ty+ put (TyFun _ ty1 ty2) = do putWord8 1+ put ty1+ put ty2+ put (TyTuple _ boxed tys) = do putWord8 2+ put boxed+ put tys+ put (TyList _ ty) = do putWord8 3+ put ty+ put (TyApp _ ty1 ty2) = do putWord8 4+ put ty1+ put ty2+ put (TyVar _ name) = do putWord8 5+ put name+ put (TyCon _ qname) = do putWord8 6+ put qname+ put (TyParen _ ty) = do putWord8 7+ put ty+ put (TyInfix _ ty1 qname ty2) = do putWord8 8+ put ty1+ put qname+ put ty2+ put (TyKind _ ty k) = do putWord8 9+ put ty+ put k+ get = do tag <- getWord8+ case tag of+ 0 -> do vars <- get+ ctx <- get+ ty <- get+ return $ TyForall noDoc vars ctx ty+ 1 -> do ty1 <- get+ ty2 <- get+ return $ TyFun noDoc ty1 ty2+ 2 -> do boxed <- get+ tys <- get+ return $ TyTuple noDoc boxed tys+ 3 -> do ty <- get+ return $ TyList noDoc ty+ 4 -> do ty1 <- get+ ty2 <- get+ return $ TyApp noDoc ty1 ty2+ 5 -> do name <- get+ return $ getTyVarInLookupTable name+ 6 -> do qname <- get+ return $ getTyConInLookupTable qname+ 7 -> do ty <- get+ return $ TyParen noDoc ty+ 8 -> do ty1 <- get+ qname <- get+ ty2 <- get+ return $ TyInfix noDoc ty1 qname ty2+ _ -> do ty <- get+ k <- get+ return $ TyKind noDoc ty k++boxed_ :: Boxed+boxed_ = Boxed++unboxed_ :: Boxed+unboxed_ = Unboxed++instance Serialize Boxed where+ -- Possible values+ -- Boxed+ -- Unboxed+ put Boxed = putWord8 0+ put Unboxed = putWord8 1+ get = do tag <- getWord8+ return $ case tag of+ 0 -> boxed_+ _ -> unboxed_++instance Serialize (Documented Name) where+ -- Possible values+ -- Ident l String+ -- Symbol l String+ put (Ident _ s) = do putWord8 0+ put s+ put (Symbol _ s) = do putWord8 1+ put s+ get = do tag <- getWord8+ s <- get+ let isSymbol = tag /= 0+ return $ getNameInLookupTable s isSymbol++instance Serialize (Documented QName) where+ -- Possible values+ -- Qual l (ModuleName l) (Name l)+ -- UnQual l (Name l)+ -- Special l (SpecialCon l)+ put (Qual _ (ModuleName _ mn) name) = do putWord8 0+ put mn+ put name+ put (UnQual _ name) = do putWord8 1+ put name+ put (Special _ scon) = do putWord8 2+ put scon+ get = do tag <- getWord8+ case tag of+ 0 -> do mn <- get+ name <- get+ return $ getQNameInLookupTable $ Qual noDoc (ModuleName noDoc mn) name+ 1 -> do name <- get+ return $ getQNameInLookupTable $ UnQual noDoc name+ _ -> do scon <- get+ return $ getQNameInLookupTable $ Special noDoc scon++instance Serialize (Documented IPName) where+ -- Possible values+ -- IPDup l String+ -- IPLin l String+ put (IPDup _ s) = do put s+ putWord8 0+ put (IPLin _ s) = do put s+ putWord8 1+ get = do s <- get+ tag <- getWord8+ case tag of+ 0 -> return $ IPDup noDoc s+ _ -> return $ IPLin noDoc s++unitCon :: Documented SpecialCon+unitCon = UnitCon noDoc++listCon :: Documented SpecialCon+listCon = ListCon noDoc++funCon :: Documented SpecialCon+funCon = FunCon noDoc++cons_ :: Documented SpecialCon+cons_ = Cons noDoc++unboxedSingleCon :: Documented SpecialCon+unboxedSingleCon = UnboxedSingleCon noDoc++instance Serialize (Documented SpecialCon) where+ -- Possible values+ -- UnitCon l+ -- ListCon l+ -- FunCon l+ -- Cons l+ -- UnboxedSingleCon l+ -- TupleCon l Boxed Int+ put (UnitCon _) = putWord8 0+ put (ListCon _) = putWord8 1+ put (FunCon _) = putWord8 2+ put (Cons _) = putWord8 3+ put (UnboxedSingleCon _) = putWord8 4+ put (TupleCon _ boxed n) = do putWord8 5+ put boxed+ put n+ get = do tag <- getWord8+ case tag of+ 0 -> return unitCon+ 1 -> return listCon+ 2 -> return funCon+ 3 -> return cons_+ 4 -> return unboxedSingleCon+ _ -> do boxed <- get+ n <- get+ return $ TupleCon noDoc boxed n+
+ src/Scion/Browser/Parser.hs view
@@ -0,0 +1,98 @@+{-# LANGUAGE ScopedTypeVariables #-}++module Scion.Browser.Parser+( parseHoogleString+, parseHoogleFile+, parseDirectory+) where++import Control.Concurrent.ParallelIO.Local+import Control.DeepSeq+import Control.Monad+import qualified Data.ByteString as BS+import qualified Data.ByteString.UTF8 as BSU+import Data.Either (rights)+import Data.Serialize+import Scion.Browser+import Scion.Browser.Parser.Internal (hoogleParser)+import Scion.Browser.FileUtil+import Scion.Browser.Util+import System.Directory+import System.FilePath ((</>), takeFileName)+import System.IO+import Text.Parsec.Error (Message(..), newErrorMessage)+import Text.Parsec.Prim (runP)+-- import Text.Parsec.ByteString as BS+import Text.ParserCombinators.Parsec+import Text.ParserCombinators.Parsec.Pos (newPos)++-- | Parses the contents of a string containing the +-- Hoogle file contents.+parseHoogleString :: String -> BS.ByteString -> Either ParseError (Documented Package)+parseHoogleString name contents = case runP hoogleParser () name (BSU.toString contents) of+ Right pkg -> pkg `deepseq` (Right pkg)+ Left err -> Left err++-- | Parses a file in Hoogle documentation format, returning+-- the documentation of the entire package, or the corresponding+-- error during the parsing.+parseHoogleFile :: FilePath -> IO (Either ParseError (Documented Package))+parseHoogleFile fname = (withFile fname ReadMode $+ \hnd -> do c <- BS.hGetContents hnd+ return $ parseHoogleString fname c+ )+ `catch`+ (\_ -> return $ Left (newErrorMessage (Message "error reading file")+ (newPos fname 0 0)))++-- | Parses a entire directory of Hoogle documentation files+-- which must be following the format of the Hackage+-- Hoogle library, specifically:+-- +-- <root>+-- / package-name+-- / version+-- /doc/html/package-name.txt+-- +parseDirectory :: FilePath -> FilePath -> IO ([Documented Package], [(FilePath, ParseError)])+parseDirectory dir tmpdir = + do contents' <- getDirectoryContents dir+ let contents = map (\d -> dir </> d) (filterDots contents')+ dirs <- filterM doesDirectoryExist contents+ vDirs <- mapM getVersionDirectory dirs+ let innerDirs = map (\d -> d </> "doc" </> "html") (concat vDirs)+ -- Parse directories recursively+ let toExecute = map (\innerDir -> parseDirectoryFiles innerDir tmpdir) innerDirs+ eitherDPackages <- withThreaded $ \pool -> parallelInterleavedE pool toExecute+ let dPackages = rights eitherDPackages+ dbs = concat $ map fst dPackages+ errors = concat $ map snd dPackages+ return (dbs, errors)++getVersionDirectory :: FilePath -> IO [FilePath]+getVersionDirectory dir = do contents' <- getDirectoryContents dir+ let contents = map (\d -> dir </> d) (filterDots contents')+ filterM doesDirectoryExist contents++parseDirectoryFiles :: FilePath -> FilePath -> IO ([Documented Package], [(FilePath, ParseError)])+parseDirectoryFiles dir tmpdir =+ do contents' <- getDirectoryContents dir+ let contents = map (\d -> dir </> d) (filterDots contents')+ files <- filterM doesFileExist contents+ fPackages <- mapM (\fname -> do putChar '.'+ hFlush stdout+ p <- parseHoogleFile fname+ -- return (fname, p)+ case p of+ Left _ -> return (fname, p)+ Right pkg -> do let tmpFile = tmpdir </> takeFileName fname+ withFile tmpFile WriteMode $+ \hnd -> BS.hPut hnd (encode pkg)+ s <- withFile tmpFile ReadMode $+ \hnd -> do s <- BS.hGetContents hnd+ return s+ let Right (pkg' :: Documented Package) = decode s+ return (fname, Right pkg') )+ files+ return $ partitionPackages fPackages+
+ src/Scion/Browser/Parser/Documentable.hs view
@@ -0,0 +1,88 @@+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, TypeSynonymInstances #-}++module Scion.Browser.Parser.Documentable where++import Scion.Browser+import qualified Language.Haskell.Exts.Syntax as S+import qualified Language.Haskell.Exts.Annotated.Syntax as A++class Documentable a b | a -> b where+ document :: Doc -> a -> (Documented b)++instance Documentable S.Type A.Type where+ document d (S.TyForall b c t) = A.TyForall d (fmap (fmap (document d)) b)+ (Just (document d c))+ (document d t)+ document d (S.TyFun t1 t2) = A.TyFun d (document d t1)+ (document d t2)+ document d (S.TyTuple b t) = A.TyTuple d (documentBoxed d b)+ (fmap (document d) t)+ document d (S.TyList t) = A.TyList d (document d t)+ document d (S.TyApp t1 t2) = A.TyApp d (document d t1)+ (document d t2)+ document d (S.TyVar n) = A.TyVar d (document d n)+ document d (S.TyCon c) = A.TyCon d (document d c)+ document d (S.TyParen t) = A.TyParen d (document d t)+ document d (S.TyInfix l n r) = A.TyInfix d (document d l)+ (document d n)+ (document d r)+ document d (S.TyKind t k) = A.TyKind d (document d t)+ (document d k)++instance Documentable S.TyVarBind A.TyVarBind where+ document d (S.KindedVar n k) = A.KindedVar d (document d n)+ (document d k)+ document d (S.UnkindedVar n) = A.UnkindedVar d (document d n)++instance Documentable S.Context A.Context where+ document d [a] = A.CxSingle d (document d a)+ document d v = A.CxTuple d (fmap (document d) v)++instance Documentable S.Asst A.Asst where+ document d (S.ClassA q t) = A.ClassA d (document d q)+ (fmap (document d) t)+ document d (S.InfixA l q r) = A.InfixA d (document d l)+ (document d q)+ (document d r)+ document d (S.IParam n t) = A.IParam d (document d n)+ (document d t)+ document d (S.EqualP t1 t2) = A.EqualP d (document d t1)+ (document d t2)++instance Documentable S.Name A.Name where+ document d (S.Ident s) = A.Ident d s+ document d (S.Symbol s) = A.Symbol d s++instance Documentable S.QName A.QName where+ document d (S.Qual mn n) = A.Qual d (document d mn)+ (document d n)+ document d (S.UnQual n) = A.UnQual d (document d n)+ document d (S.Special c) = A.Special d (document d c)++instance Documentable S.ModuleName A.ModuleName where+ document d (S.ModuleName n) = A.ModuleName d n++instance Documentable S.IPName A.IPName where+ document d (S.IPDup s) = A.IPDup d s+ document d (S.IPLin s) = A.IPLin d s++instance Documentable S.SpecialCon A.SpecialCon where+ document d S.UnitCon = A.UnitCon d+ document d S.ListCon = A.ListCon d+ document d S.FunCon = A.FunCon d+ document d (S.TupleCon b n) = A.TupleCon d (documentBoxed d b) n+ document d S.Cons = A.Cons d+ document d S.UnboxedSingleCon = A.UnboxedSingleCon d++instance Documentable S.Kind A.Kind where+ document d S.KindStar = A.KindStar d+ document d S.KindBang = A.KindBang d+ document d (S.KindFn k1 k2) = A.KindFn d (document d k1)+ (document d k2)+ document d (S.KindParen k) = A.KindParen d (document d k)+ document d (S.KindVar n) = A.KindVar d (document d n)++documentBoxed :: Doc -> S.Boxed -> A.Boxed+documentBoxed _ S.Boxed = A.Boxed+documentBoxed _ S.Unboxed = A.Unboxed+
+ src/Scion/Browser/Parser/Internal.hs view
@@ -0,0 +1,543 @@+{-# LANGUAGE RankNTypes #-}+module Scion.Browser.Parser.Internal where++-- import Debug.Trace (trace)+import Control.Monad+import Data.Char (isControl, isLatin1, isUpper, ord)+import Data.List (intercalate)+import qualified Data.Map as M+import Distribution.Package (PackageIdentifier(..), PackageName(..))+import Distribution.Version+import Language.Haskell.Exts.Annotated.Syntax+import Language.Haskell.Exts.Extension+import qualified Language.Haskell.Exts.Parser as Parser+import Scion.Browser+import Scion.Browser.FromMissingH (replace)+import Scion.Browser.Parser.Documentable+import Text.Parsec.String as BS+import Text.Parsec.Char+import Text.Parsec.Combinator+import Text.Parsec.Prim++type BSParser a = forall st. BS.GenParser Char st a++hoogleParser :: BSParser (Documented Package)+hoogleParser = do spaces+ many initialComment+ spaces+ pkgDoc <- docComment+ spacesOrEol1+ pkgN <- package+ spacesOrEol1+ pkgV <- version+ spaces0+ modules <- many $ try (spacesOrEol0 >> documented module_)+ spaces+ eof+ return $ Package (docFromString pkgDoc)+ (PackageIdentifier (PackageName pkgN)+ pkgV)+ (M.fromList $ map (\m -> (getModuleName m, m)) modules)++initialComment :: BSParser String+initialComment = do try $ string "-- " >> notFollowedBy (char '|')+ restOfLine+ eol++docComment :: BSParser String+docComment = do string "-- | "+ initialLine <- restOfLine+ restOfLines <- many $ try (eol >> string "-- ") >> restOfLine+ return $ intercalate "\n" (initialLine:restOfLines)++documented :: (Doc -> BSParser a) -> BSParser a+documented p = try (do d <- try docComment+ try eol+ p (docFromString d))+ <|> try (p NoDoc)++package :: BSParser String+package = do string "@package"+ spaces1+ name <- restOfLine+ spaces0+ return name++version :: BSParser Version+version = try (do string "@version"+ spaces1+ numbers <- number `sepBy` char '.'+ restOfLine+ return $ Version numbers [])+ <|> (return $ Version [] [])++module_ :: Doc -> BSParser (Documented Module)+module_ doc = do string "module"+ spaces1+ name <- moduleName+ spaces0+ decls <- many $ try (spacesOrEol0 >> documented decl)+ return $ Module doc+ (Just (ModuleHead NoDoc name Nothing Nothing))+ []+ []+ (concat decls)++moduleName :: BSParser (Documented ModuleName)+moduleName = do cons <- conid `sepBy` char '.'+ let name = intercalate "." (map getid cons)+ return $ ModuleName NoDoc name++getModuleName :: Documented Module -> String+getModuleName (Module _ (Just (ModuleHead _ (ModuleName _ name) _ _)) _ _ _) = name+getModuleName _ = error "This should never happen"++decl :: Doc -> BSParser [Documented Decl]+decl doc = choice [ listed $ function doc+ , listed $ instance_ doc+ , listed $ class_ doc+ , listed $ type_ doc+ , listedPair $ data_ doc+ , listedPair $ newtype_ doc+ , lonelyComment+ ]++listed :: BSParser a -> BSParser [a]+listed p = do result <- try p+ return [result]++listedPair :: BSParser (a, [a]) -> BSParser [a]+listedPair p = do (h, t) <- p+ return (h:t)++lonelyComment :: BSParser [Documented Decl]+lonelyComment = try (docComment >> return [])++parseTypeMode :: Parser.ParseMode+parseTypeMode = Parser.ParseMode "" knownExtensions False False Nothing++parseType :: String -> BSParser (Documented Type)+parseType st = return (parseType' st)++parseType' :: String -> Documented Type+parseType' st = let parseString = eliminateUnwanted st+ nonAsciiChars = filter (not . isLatin1) parseString+ noHashString = (theReplacements . generateLatinReplacements nonAsciiChars) parseString + -- Parse using haskell-src-exts+ parsed = Parser.parseTypeWithMode parseTypeMode noHashString+ in case parsed of+ Parser.ParseFailed _ _ -> TyVar NoDoc (Ident NoDoc "not parsed")+ Parser.ParseOk ty -> mapOnNames (theInverseReplacements . generateInverseLatinReplacements nonAsciiChars) (document NoDoc ty)++theReplacements :: String -> String+theReplacements = (replace "#" "__HASH__") . (replace "[:" "__GHC_ARR_OPEN__") . (replace ":]" "__GHC_ARR_CLOSE__") . (replace "!" "BANG__")++theInverseReplacements :: String -> String+theInverseReplacements = (replace "__HASH__" "#") . (replace "__GHC_ARR_OPEN__" "[:") . (replace "__GHC_ARR_CLOSE__" ":]") . (replace "BANG__" "!")++generateLatinReplacements :: [Char] -> (String -> String)+generateLatinReplacements [] = id+generateLatinReplacements (c:cs) | isUpper c = (replace [c] ("UNICODE_SYMBOL_" ++ (show $ ord c) ++ "__")) . (generateLatinReplacements cs)+ | otherwise = (replace [c] ("unicode_symbol_" ++ (show $ ord c) ++ "__")) . (generateLatinReplacements cs)++generateInverseLatinReplacements :: [Char] -> (String -> String)+generateInverseLatinReplacements [] = id+generateInverseLatinReplacements (c:cs) | isUpper c = (replace ("UNICODE_SYMBOL_" ++ (show $ ord c) ++ "__") [c]) . (generateInverseLatinReplacements cs)+ | otherwise = (replace ("unicode_symbol_" ++ (show $ ord c) ++ "__") [c]) . (generateInverseLatinReplacements cs)++-- HACK: Types with ! are not parsed by haskell-src-exts+-- HACK: Control characters (like EOF) may appear+-- HACK: {-# UNPACK #-} comments and greek letters may appear+-- HACK: Greek letters may appear+eliminateUnwanted :: String -> String+eliminateUnwanted "" = ""+eliminateUnwanted ('{':('-':('#':(' ':('U':('N':('P':('A':('C':('K':(' ':('#':('-':('}': xs)))))))))))))) = eliminateUnwanted xs+eliminateUnwanted (x:xs) | isControl x = eliminateUnwanted xs+ | otherwise = x : (eliminateUnwanted xs)++mapOnNames :: (String -> String) -> Documented Type -> Documented Type+mapOnNames f (TyForall doc vars context ty) = TyForall doc+ (fmap (fmap (mapOnNamesTyVar f)) vars)+ (fmap (mapOnNamesContext f) context)+ (mapOnNames f ty)+mapOnNames f (TyFun doc t1 t2) = TyFun doc (mapOnNames f t1) (mapOnNames f t2)+mapOnNames f (TyTuple doc boxed tys) = TyTuple doc boxed (fmap (mapOnNames f) tys)+mapOnNames f (TyList doc ty) = TyList doc (mapOnNames f ty)+mapOnNames f (TyApp doc t1 t2) = TyApp doc (mapOnNames f t1) (mapOnNames f t2)+mapOnNames f (TyVar doc name) = TyVar doc (mapOnNamesName f name)+mapOnNames f (TyCon doc name) = TyCon doc (mapOnNamesQName f name)+mapOnNames f (TyParen doc ty) = TyParen doc (mapOnNames f ty)+mapOnNames f (TyInfix doc t1 name t2) = TyInfix doc (mapOnNames f t1) (mapOnNamesQName f name) (mapOnNames f t2)+mapOnNames f (TyKind doc ty k) = TyKind doc (mapOnNames f ty) k++mapOnNamesTyVar :: (String -> String) -> Documented TyVarBind -> Documented TyVarBind+mapOnNamesTyVar f (KindedVar doc name k) = KindedVar doc (mapOnNamesName f name) k+mapOnNamesTyVar f (UnkindedVar doc name) = UnkindedVar doc (mapOnNamesName f name)++mapOnNamesName :: (String -> String) -> Documented Name -> Documented Name+mapOnNamesName f (Ident doc s) = Ident doc (f s)+mapOnNamesName f (Symbol doc s) = Symbol doc (f s)++mapOnNamesQName :: (String -> String) -> Documented QName -> Documented QName+mapOnNamesQName f (Qual doc mname name) = Qual doc mname (mapOnNamesName f name)+mapOnNamesQName f (UnQual doc name) = UnQual doc (mapOnNamesName f name)+mapOnNamesQName _ q@(Special _ _) = q++mapOnNamesContext :: (String -> String) -> Documented Context -> Documented Context+mapOnNamesContext f (CxSingle doc asst) = CxSingle doc (mapOnNamesAsst f asst)+mapOnNamesContext f (CxTuple doc assts) = CxTuple doc (fmap (mapOnNamesAsst f) assts)+mapOnNamesContext f (CxParen doc ctx) = CxParen doc (mapOnNamesContext f ctx) +mapOnNamesContext _ (CxEmpty doc) = CxEmpty doc++mapOnNamesAsst :: (String -> String) -> Documented Asst -> Documented Asst+mapOnNamesAsst f (ClassA doc name tys) = ClassA doc (mapOnNamesQName f name) (fmap (mapOnNames f) tys)+mapOnNamesAsst f (InfixA doc ty1 name ty2) = InfixA doc (mapOnNames f ty1) (mapOnNamesQName f name) (mapOnNames f ty2)+mapOnNamesAsst f (IParam doc name ty) = IParam doc (mapOnNamesIPName f name) (mapOnNames f ty)+mapOnNamesAsst f (EqualP doc ty1 ty2) = EqualP doc (mapOnNames f ty1) (mapOnNames f ty2)++mapOnNamesIPName :: (String -> String) -> Documented IPName -> Documented IPName+mapOnNamesIPName f (IPDup doc s) = IPDup doc (f s)+mapOnNamesIPName f (IPLin doc s) = IPLin doc (f s)++multipleNames :: BSParser (Documented Name) ->BSParser [Documented Name]+multipleNames p=sepBy1 p (try $ do+ spaces0+ char ','+ spaces0)++functionLike :: BSParser (Documented Name) -> BSParser ([Documented Name], Documented Type)+functionLike p = do names <- choice [+ (try $ do+ char '(' + ns<-multipleNames p+ char ')'+ return ns),+ (multipleNames p)+ ]+ spaces0+ string "::"+ spaces0+ rest <- restOfLine+ ty <- parseType rest+ return (names, ty)++function :: Doc -> BSParser (Documented Decl)+function doc = do (names, ty) <- functionLike varid+ return $ TypeSig doc names ty++constructor :: Doc -> BSParser (Documented GadtDecl)+constructor doc = do (names, ty) <- functionLike conid+ return $ GadtDecl doc (head names) ty++constructorOrFunction :: Doc -> BSParser (Either (Documented Decl) (Documented GadtDecl))+constructorOrFunction doc = do f <- function doc+ return $ Left f+ <|>+ do c <- constructor doc+ return $ Right c++kind :: BSParser (Documented Kind)+kind = try (do k1 <- kindL+ spaces0+ string "->"+ spaces0+ k2 <- kind+ return $ KindFn NoDoc k1 k2)+ <|> kindL++kindL :: BSParser (Documented Kind)+kindL = (do char '('+ spaces0+ k <- kind+ spaces0+ char ')'+ return $ KindParen NoDoc k)+ <|>+ (do char '*'+ return $ KindStar NoDoc)+ <|>+ (do char '!'+ return $ KindBang NoDoc)+ <|>+ (do n <- varid+ return $ KindVar NoDoc n)++instance_ :: Doc -> BSParser (Documented Decl)+instance_ doc = do string "instance"+ -- HACK: in some Hoogle files things like [overlap ok] appear+ optional $ try (do spaces0+ char '['+ many $ noneOf "]\r\n"+ char ']')+ spaces1+ rest <- restOfLine+ ty' <- parseType rest+ let (ctx, ty) = getContextAndType ty'+ (qhead:params) = lineariseType ty+ case qhead of+ TyCon _ qname -> return $ InstDecl doc ctx (IHead NoDoc qname params) Nothing+ _ -> return $ InstDecl doc ctx (IHead NoDoc (UnQual NoDoc (Ident NoDoc "#unparsed#")) params) Nothing++type_ :: Doc -> BSParser (Documented Decl)+type_ doc = do string "type"+ spaces1+ con <- conid+ vars <- many (try (spaces1 >> tyVarBind))+ spaces0+ char '='+ spaces0+ rest <- restOfLine+ ty <- parseType rest+ return $ TypeDecl doc (DHead NoDoc con vars) ty++tyVarBind :: BSParser (Documented TyVarBind)+tyVarBind = (do char '('+ spaces0+ var <- varid+ spaces0+ string "::"+ spaces0+ k <- kind+ spaces0+ char ')'+ return $ KindedVar NoDoc var k)+ <|>+ (do var <- varid+ return $ UnkindedVar NoDoc var)++-- Here we return not only the datatype or newtype,+-- but also functions around them, that are put+-- between constructors when using record syntax.+dataOrNewType :: String -> (Documented DataOrNew) -> Doc -> BSParser (Documented Decl, [Documented Decl])+dataOrNewType keyword dOrN doc = do string keyword+ spaces0+ rests <- many1 possibleKind+ let rest = concat $ map fst rests+ k = snd (last rests)+ {- rest <- many $ allButDoubleColon+ k <- optionMaybe (do string "::"+ spaces0+ kind) -}+ ty <- parseType rest+ let (ctx, hd) = typeToContextAndHead ty+ consAndFns <- many $ try (spacesOrEol0 >> documented constructorOrFunction)+ let (fns, cons) = divideConstructorAndFunctions consAndFns+ return $ (GDataDecl doc dOrN ctx hd k cons Nothing, fns)++divideConstructorAndFunctions :: [Either (Documented Decl) (Documented GadtDecl)] -> ([Documented Decl], [Documented GadtDecl])+divideConstructorAndFunctions [] = ([], [])+divideConstructorAndFunctions (x:xs) = let (fns, cons) = divideConstructorAndFunctions xs+ in case x of+ Left fn -> (fn:fns, cons)+ Right con -> (fns, con:cons)++possibleKind :: BSParser (String, Maybe (Documented Kind))+possibleKind = do rest <- many1 $ allButDoubleColon+ k <- optionMaybe (do string "::"+ spaces0+ kind)+ return (rest, k)++allButDoubleColon :: BSParser Char+allButDoubleColon = try (do char ':'+ notFollowedBy $ char ':'+ return ':')+ <|> (noneOf ":\r\n")++data_ :: Doc -> BSParser (Documented Decl, [Documented Decl])+data_ = dataOrNewType "data" (DataType NoDoc)++newtype_ :: Doc -> BSParser (Documented Decl, [Documented Decl])+newtype_ = dataOrNewType "newtype" (NewType NoDoc)++dataOrNewTypeHead :: String -> (Documented DataOrNew) -> Doc -> BSParser (Documented Decl)+dataOrNewTypeHead keyword dOrN doc = do string keyword+ spaces0+ rests <- many1 possibleKind+ let rest = concat $ map fst rests+ k = snd (last rests)+ {- rest <- many $ allButDoubleColon+ k <- optionMaybe (do string "::"+ spaces0+ kind) -}+ ty <- parseType rest+ let (ctx, hd) = typeToContextAndHead ty+ return $ GDataDecl doc dOrN ctx hd k [] Nothing++dataHead :: Doc -> BSParser (Documented Decl)+dataHead = dataOrNewTypeHead "data" (DataType NoDoc)++newtypeHead :: Doc -> BSParser (Documented Decl)+newtypeHead = dataOrNewTypeHead "newtype" (NewType NoDoc)++class_ :: Doc -> BSParser (Documented Decl)+class_ doc = do string "class"+ spaces0+ rest <- many $ allButWhereColonPipe+ fd' <- optionMaybe (do string "|"+ spaces0+ iFunDep <- funDep+ rFunDep <- many $ try (spaces0 >> char ',' >> spaces0 >> funDep)+ return $ iFunDep:rFunDep)+ -- HACK: if a type family is introduced here, just discard it+ optional $ string "where" >> restOfLine+ -- HACK: in some Hoogle files, kinds are added to the class+ optional $ string "::" >> restOfLine+ ty <- parseType rest+ let (ctx, hd) = typeToContextAndHead ty+ fd = maybe [] id fd'+ return $ ClassDecl doc ctx hd fd Nothing++allButWhereColonPipe :: BSParser Char+allButWhereColonPipe = try (do char ':'+ notFollowedBy $ char ':'+ return ':')+ <|>+ try (do char 'w'+ notFollowedBy $ string "here"+ return 'w')+ <|> (noneOf "w|:\r\n") ++funDep :: BSParser (Documented FunDep)+funDep = do iVarLeft <- varid+ rVarLeft <- many $ try (spaces1 >> varid)+ spaces0+ string "->"+ spaces0+ iVarRight <- varid+ rVarRight <- many $ try (spaces1 >> varid)+ return $ FunDep NoDoc (iVarLeft:rVarLeft) (iVarRight:rVarRight)++{-+qualifiedVarid :: BSParser [String]+qualifiedVarid = do id <- varid+ return [id]+ <|> do mod <- many1 (do m <- conid+ char '.'+ return m)+ id <- varid+ return $ mod ++ [id]++qualifiedConid :: BSParser [String]+qualifiedConid = conid `sepBy` char '.'+-}++varid :: BSParser (Documented Name)+varid = try (do initial <- lower <|> char '_'+ rest <- many $ alphaNum <|> oneOf allowedSpecialCharactersInIds+ let var = initial:rest+ guard $ not (var `elem` haskellKeywords)+ return $ Ident NoDoc var)+ <|> +-- try (do --initial <- oneOf (tail specialCharacters)+-- var <- many1 (oneOf specialCharacters)+-- --let var = initial:rest+-- guard $ not (var `elem` haskellReservedOps)+-- return $ Symbol NoDoc var)+-- <|>+ try (do string "()"+ return $ Symbol NoDoc "()")+ <|>+ try (do char '('+ s<-many1 (char ',')+ char ')'+ return $ Symbol NoDoc s)+ <|>+ try (do char '('+ var <- varid+ char ')'+ return var)+ <|>+ try (do var <- many1 (noneOf [',',')','(',' ','\r','\n','\t'])+ guard $ not (isUpper $ head var)+ guard $ not (var `elem` haskellReservedOps)+ return $ Symbol NoDoc var)+ ++conid :: BSParser (Documented Name)+conid = (do initial <- upper+ rest <- many $ alphaNum <|> oneOf allowedSpecialCharactersInIds+ return $ Ident NoDoc (initial:rest))+ <|> + try (do initial <- char ':'+ rest <- many (oneOf specialCharacters)+ let con = initial:rest+ guard $ not (con `elem` haskellReservedOps)+ return $ Symbol NoDoc con)+ <|>+ try (do char '('+ con <- conid+ char ')'+ return con)++getid :: Documented Name -> String+getid (Ident _ s) = s+getid (Symbol _ s) = '(' : (s ++ ")" )++haskellKeywords :: [String]+haskellKeywords = [ "case", "class", "data", "default", "deriving", "do"+ , "else", "foreign", "if", "import", "in", "infix", "infixl"+ , "infixr", "instance", "let", "module", "newtype", "of"+ , "then", "type", "where", "_" ]++haskellReservedOps :: [String]+haskellReservedOps = [ "..", ":", "::", "=", "\\", "|", "<-", "->", "@", "~", "=>" ]++allowedSpecialCharactersInIds :: [Char]+allowedSpecialCharactersInIds = "_'-[]#"++specialCharacters :: [Char]+specialCharacters = ":!#$%&*+./<=>?@\\^|-~"++restOfLine :: BSParser String+restOfLine = many $ noneOf "\r\n"++eol :: BSParser String+eol = try (string "\r\n")+ <|> try (string "\r")+ <|> string "\n"+ -- <|> (lookAhead eof >> return "\n")+ <?> "new line"++number :: BSParser Int+number = do n <- many1 digit+ return $ read n++spaces0 :: BSParser String+spaces0 = many $ char ' '++spaces1 :: BSParser String+spaces1 = many1 $ char ' '++spacesOrEol0 :: BSParser String+spacesOrEol0 = many $ oneOf " \r\n\t"++spacesOrEol1 :: BSParser String+spacesOrEol1 = many1 $ oneOf " \r\n\t"++-- working with types++getContextAndType :: (Documented Type) -> (Maybe (Documented Context), Documented Type)+getContextAndType (TyForall _ _ ctx ty) = (ctx, ty)+getContextAndType ty = (Nothing, ty)++lineariseType :: Documented Type -> [Documented Type]+lineariseType (TyApp _ x y) = (lineariseType x) ++ [y]+lineariseType ty = [ty]++typeToContextAndHead :: (Documented Type) -> (Maybe (Documented Context), Documented DeclHead)+typeToContextAndHead t = let (ctx, ty) = getContextAndType t+ (name,vars) = case lineariseType ty of+ ((TyCon _ (UnQual _ name')):params) -> (name', toKindedVars params) + ((TyCon _ (Qual _ _ name')):params) -> (name', toKindedVars params) + ((TyCon _ (Special l _)):params) -> (Symbol l "", toKindedVars params)+ (_:params) -> (Ident NoDoc "#unparsed#", toKindedVars params)+ in (ctx, DHead NoDoc name vars)++toKindedVars :: [Type Doc] -> [TyVarBind Doc]+toKindedVars [] = []+toKindedVars ((TyVar d (Ident _ n1)):( (TyList _ (TyVar _ (Ident _ n2))): xs )) =+ (UnkindedVar d (Ident NoDoc $ n1 ++ "[" ++ n2 ++ "]")) : toKindedVars xs+toKindedVars ((TyVar d n):xs) = (UnkindedVar d n) : toKindedVars xs+toKindedVars (x:_) = error $ show x+
+ src/Scion/Browser/Query.hs view
@@ -0,0 +1,110 @@+module Scion.Browser.Query+( allPackageIds+, allPackages+, packagesByName+, getPackage+, getSingletonDatabase+, getModules+, getSubmodules+, getDeclsInModule+, getModulesWhereDeclarationIs+) where++import Data.List (isPrefixOf, stripPrefix)+import qualified Data.Map as M+import Distribution.Package hiding (Package)+import Language.Haskell.Exts.Annotated.Syntax+import Scion.Browser+import Scion.Browser.FromMissingH (addToAL)++-- |Get the identifiers of all packages in the database.+allPackageIds :: Database -> [PackageIdentifier]+allPackageIds = M.keys++-- |Get information of all packages in the database.+allPackages :: Database -> [Documented Package]+allPackages = M.elems++-- |Get information of all versions of the package with that name.+packagesByName :: String -> Database -> [Documented Package]+packagesByName name db = M.foldlWithKey (\lst k v -> let PackageName pkgN = pkgName k+ in if pkgN == name then v:lst else lst)+ [] db++-- |Get information about a package in the database.+getPackage :: PackageIdentifier -> Database -> Maybe (Documented Package)+getPackage = M.lookup++-- |Builds a database with only the specified package.+getSingletonDatabase :: PackageIdentifier -> Database -> Maybe Database+getSingletonDatabase pid db = case getPackage pid db of+ Nothing -> Nothing+ Just pkg -> Just $ singletonDatabase pkg++type ModuleWithPackage = (PackageIdentifier, Documented Module)++-- |Get all the modules hierarchically inside the specified one.+-- This function only goes one level deep, for the entire list+-- use getSubmodules.+-- For getting the upper modules, use "" as initial name.+getModules :: String -> Database -> [(String, [ModuleWithPackage])]+getModules = getSubmodules' getModulesFromPackage++-- |Get all the modules hierarchically inside the specified one.+-- For getting the entire list of modules modules, use "" as initial name.+getSubmodules :: String -> Database -> [(String, [ModuleWithPackage])]+getSubmodules = getSubmodules' getSubmodulesFromPackage++getSubmodules' :: (String -> Documented Package -> [Documented Module]) -> String -> Database -> [(String, [ModuleWithPackage])]+getSubmodules' f mname db = M.foldrWithKey (\pid pkg current -> mergeModules pid (f mname pkg) current) [] db++mergeModules :: PackageIdentifier -> [Documented Module] -> [(String, [ModuleWithPackage])] -> [(String, [ModuleWithPackage])]+mergeModules pid mods initial = foldr (\md current -> mergeModule pid md current) initial mods++mergeModule :: PackageIdentifier -> Documented Module -> [(String, [ModuleWithPackage])] -> [(String, [ModuleWithPackage])]+mergeModule pid md current = let mname = getName md+ in case lookup mname current of+ Nothing -> (mname, [(pid, md)]) : current+ Just mods -> addToAL current mname ((pid, md):mods)++getModulesFromPackage :: String -> Documented Package -> [Documented Module]+getModulesFromPackage "" (Package _ _ modMap) =+ M.foldlWithKey (\lst k v -> if '.' `elem` k then lst else v:lst) [] modMap+getModulesFromPackage initial (Package _ _ modMap) = + M.foldlWithKey (\lst k v -> if include k then v:lst else lst) [] modMap+ where minitial = initial ++ "."+ include k = case stripPrefix minitial k of+ Nothing -> False+ Just mn -> not ('.' `elem` mn)++getSubmodulesFromPackage :: String -> Documented Package -> [Documented Module]+getSubmodulesFromPackage "" (Package _ _ modMap) = M.elems modMap+getSubmodulesFromPackage initial (Package _ _ modMap) = + let minitial = initial ++ "."+ in M.foldlWithKey (\lst k v -> if minitial `isPrefixOf` k then v:lst else lst) [] modMap++-- |Gets the declarations inside some module,+-- along with information about which package it lives.+getDeclsInModule :: String -> Database -> [(PackageIdentifier, [Documented Decl])]+getDeclsInModule modName db = M.foldrWithKey (\k v lst -> (k, getDeclsInModuleFromPackage modName v):lst) [] db++getDeclsInModuleFromPackage :: String -> Documented Package -> [Documented Decl]+getDeclsInModuleFromPackage modName (Package _ _ modMap) =+ case M.lookup modName modMap of+ Just (Module _ _ _ _ decls) -> decls+ _ -> []++-- | Gets a list of modules where a declaration may live+getModulesWhereDeclarationIs :: String -> Database -> [Documented Module]+getModulesWhereDeclarationIs decl db = M.fold (\v lst -> (getModulesWhereDeclarationIsInPackage decl v) ++ lst) [] db++getModulesWhereDeclarationIsInPackage :: String -> Documented Package -> [Documented Module]+getModulesWhereDeclarationIsInPackage decl (Package _ _ modMap) = M.elems $ M.filter (moduleHasDecl decl) modMap++moduleHasDecl :: String -> Documented Module -> Bool+moduleHasDecl decl (Module _ _ _ _ decls) = isDeclName decls+ where isDeclName [] = False+ isDeclName (x:xs) = getName x == decl || isChildName (getChildren x) || isDeclName xs+ isChildName [] = False+ isChildName (x:xs) = getName x == decl || isChildName xs+
+ src/Scion/Browser/TempFile.hs view
@@ -0,0 +1,220 @@+-- Taken from Cabal source+-- http://hackage.haskell.org/package/Cabal-1.10.2.0++{-# OPTIONS -cpp #-}+-- OPTIONS required for ghc-6.4.x compat, and must appear first+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -cpp #-}+{-# OPTIONS_NHC98 -cpp #-}+{-# OPTIONS_JHC -fcpp #-}+-- #hide+module Scion.Browser.TempFile (+ openTempFile,+ openBinaryTempFile,+ openNewBinaryFile,+ createTempDirectory,+ ) where+++import System.FilePath ((</>))+import Foreign.C (eEXIST)++#if __NHC__ || __HUGS__+import System.IO (openFile, openBinaryFile,+ Handle, IOMode(ReadWriteMode))+import System.Directory (doesFileExist)+import System.FilePath ((<.>), splitExtension)+import System.IO.Error (try, isAlreadyExistsError)+#else+import System.IO (Handle, openTempFile, openBinaryTempFile)+import Data.Bits ((.|.))+import System.Posix.Internals (c_open, c_close, o_CREAT, o_EXCL, o_RDWR,+ o_BINARY, o_NONBLOCK, o_NOCTTY)+import System.IO.Error (try, isAlreadyExistsError)+#if __GLASGOW_HASKELL__ >= 611+import System.Posix.Internals (withFilePath)+#else+import Foreign.C (withCString)+#endif+import Foreign.C (CInt)+#if __GLASGOW_HASKELL__ >= 611+import GHC.IO.Handle.FD (fdToHandle)+#else+import GHC.Handle (fdToHandle)+#endif+#endif+import Foreign.C (getErrno, errnoToIOError)++#if __NHC__+import System.Posix.Types (CPid(..))+foreign import ccall unsafe "getpid" c_getpid :: IO CPid+#else+import System.Posix.Internals (c_getpid)+#endif++#ifdef mingw32_HOST_OS+import System.Directory ( createDirectory )+#else+import qualified System.Posix+#endif++#if !(defined(__HUGS__) || (defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 610))+#define NEW_EXCEPTION+#endif++import qualified Control.Exception as Exception++onException :: IO a -> IO b -> IO a+#ifdef NEW_EXCEPTION+onException = Exception.onException+#else+onException io what = io `Exception.catch` \e -> do what+ Exception.throw e+#endif++-- ------------------------------------------------------------+-- * temporary files+-- ------------------------------------------------------------++-- This is here for Haskell implementations that do not come with+-- System.IO.openTempFile. This includes nhc-1.20, hugs-2006.9.+-- TODO: Not sure about jhc++#if __NHC__ || __HUGS__+-- use a temporary filename that doesn't already exist.+-- NB. *not* secure (we don't atomically lock the tmp file we get)+openTempFile :: FilePath -> String -> IO (FilePath, Handle)+openTempFile tmp_dir template+ = do x <- getProcessID+ findTempName x+ where+ (templateBase, templateExt) = splitExtension template+ findTempName :: Int -> IO (FilePath, Handle)+ findTempName x+ = do let path = tmp_dir </> (templateBase ++ "-" ++ show x) <.> templateExt+ b <- doesFileExist path+ if b then findTempName (x+1)+ else do hnd <- openFile path ReadWriteMode+ return (path, hnd)++openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle)+openBinaryTempFile tmp_dir template+ = do x <- getProcessID+ findTempName x+ where+ (templateBase, templateExt) = splitExtension template+ findTempName :: Int -> IO (FilePath, Handle)+ findTempName x+ = do let path = tmp_dir </> (templateBase ++ show x) <.> templateExt+ b <- doesFileExist path+ if b then findTempName (x+1)+ else do hnd <- openBinaryFile path ReadWriteMode+ return (path, hnd)++openNewBinaryFile :: FilePath -> String -> IO (FilePath, Handle)+openNewBinaryFile = openBinaryTempFile++getProcessID :: IO Int+getProcessID = fmap fromIntegral c_getpid+#else+-- This is a copy/paste of the openBinaryTempFile definition, but+-- if uses 666 rather than 600 for the permissions. The base library+-- needs to be changed to make this better.+openNewBinaryFile :: FilePath -> String -> IO (FilePath, Handle)+openNewBinaryFile dir template = do+ pid <- c_getpid+ findTempName pid+ where+ -- We split off the last extension, so we can use .foo.ext files+ -- for temporary files (hidden on Unix OSes). Unfortunately we're+ -- below filepath in the hierarchy here.+ (prefix,suffix) =+ case break (== '.') $ reverse template of+ -- First case: template contains no '.'s. Just re-reverse it.+ (rev_suffix, "") -> (reverse rev_suffix, "")+ -- Second case: template contains at least one '.'. Strip the+ -- dot from the prefix and prepend it to the suffix (if we don't+ -- do this, the unique number will get added after the '.' and+ -- thus be part of the extension, which is wrong.)+ (rev_suffix, '.':rest) -> (reverse rest, '.':reverse rev_suffix)+ -- Otherwise, something is wrong, because (break (== '.')) should+ -- always return a pair with either the empty string or a string+ -- beginning with '.' as the second component.+ _ -> error "bug in System.IO.openTempFile"++ oflags = rw_flags .|. o_EXCL .|. o_BINARY++#if __GLASGOW_HASKELL__ < 611+ withFilePath = withCString+#endif++ findTempName x = do+ fd <- withFilePath filepath $ \ f ->+ c_open f oflags 0o666+ if fd < 0+ then do+ errno <- getErrno+ if errno == eEXIST+ then findTempName (x+1)+ else ioError (errnoToIOError "openNewBinaryFile" errno Nothing (Just dir))+ else do+ -- TODO: We want to tell fdToHandle what the filepath is,+ -- as any exceptions etc will only be able to report the+ -- fd currently+ h <-+#if __GLASGOW_HASKELL__ >= 609+ fdToHandle fd+#elif __GLASGOW_HASKELL__ <= 606 && defined(mingw32_HOST_OS)+ -- fdToHandle is borked on Windows with ghc-6.6.x+ openFd (fromIntegral fd) Nothing False filepath+ ReadWriteMode True+#else+ fdToHandle (fromIntegral fd)+#endif+ `onException` c_close fd+ return (filepath, h)+ where+ filename = prefix ++ show x ++ suffix+ filepath = dir `combine` filename++ -- FIXME: bits copied from System.FilePath+ combine a b+ | null b = a+ | null a = b+ | last a == pathSeparator = a ++ b+ | otherwise = a ++ [pathSeparator] ++ b++-- FIXME: Should use filepath library+pathSeparator :: Char+#ifdef mingw32_HOST_OS+pathSeparator = '\\'+#else+pathSeparator = '/'+#endif++-- FIXME: Copied from GHC.Handle+std_flags, output_flags, rw_flags :: CInt+std_flags = o_NONBLOCK .|. o_NOCTTY+output_flags = std_flags .|. o_CREAT+rw_flags = output_flags .|. o_RDWR+#endif++createTempDirectory :: FilePath -> String -> IO FilePath+createTempDirectory dir template = do+ pid <- c_getpid+ findTempName pid+ where+ findTempName x = do+ let dirpath = dir </> template ++ show x+ r <- try $ mkPrivateDir dirpath+ case r of+ Right _ -> return dirpath+ Left e | isAlreadyExistsError e -> findTempName (x+1)+ | otherwise -> ioError e++mkPrivateDir :: String -> IO ()+#ifdef mingw32_HOST_OS+mkPrivateDir s = createDirectory s+#else+mkPrivateDir s = System.Posix.createDirectory s 0o700+#endif
+ src/Scion/Browser/Types.hs view
@@ -0,0 +1,90 @@+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}++module Scion.Browser.Types where++import Data.List (find, intersperse)+import qualified Data.Map as M+import qualified Data.Text as T+import Distribution.Package hiding (Package)+import qualified Distribution.Package as P+import Language.Haskell.Exts.Annotated.Syntax++-- |Documentation for an item.+-- Now it is simply a Text element.+data Doc = NoDoc+ | Doc T.Text+ deriving Show++docFromString :: String -> Doc+docFromString s = Doc (T.pack s)++-- |A documented item.+type Documented a = a Doc++-- |A package.+data Package l = Package l+ PackageIdentifier+ (M.Map String (Documented Module))+ deriving Show++instance P.Package (Package l) where+ packageId (Package _ i _) = i++-- |A Database saves a list of packages. +type Database = M.Map PackageIdentifier (Documented Package)+++-- |Gets the name inside a Name constructor.+getNameString :: Name l -> String+getNameString (Ident _ s) = s+getNameString (Symbol _ s) = "(" ++ s ++ ")"++-- |Gets the qualified name as a string.+getQNameString :: QName l -> String+getQNameString (Qual _ (ModuleName _ "") ename) = getNameString ename+getQNameString (Qual _ (ModuleName _ mname) ename) = mname ++ "." ++ getNameString ename+getQNameString (UnQual _ ename) = getNameString ename+getQNameString (Special _ (UnitCon _)) = "()"+getQNameString (Special _ (ListCon _)) = "[]"+getQNameString (Special _ (FunCon _)) = "(->)"+getQNameString (Special _ (TupleCon _ box n)) = case box of+ Boxed -> "(" ++ replicate (n-1) ',' ++ ")"+ Unboxed -> "(#" ++ replicate (n-1) ',' ++ "#)"+getQNameString (Special _ (Cons _)) = "(:)"+getQNameString (Special _ (UnboxedSingleCon _)) = "(# #)"++-- ------------------------------+-- Datatypes for traversing docs.+-- ------------------------------++class Annotated e => Named e where+ getName :: Show l => (e l) -> String++class (Named parent, Named child) => DocItem parent child | parent -> child where+ getChildren :: Show l => (parent l) -> [child l]+ getChild :: Show l => (parent l) -> String -> Maybe (child l)+ getChild p name = find (\d -> (getName d) == name) (getChildren p)++instance Named Module where+ getName (Module _ (Just (ModuleHead _ (ModuleName _ name) _ _)) _ _ _) = name+ getName v = error $ "This should not be possible: " ++ show v++instance DocItem Module Decl where+ getChildren (Module _ _ _ _ decls) = decls+ getChildren _ = []++instance Named Decl where+ getName (TypeDecl _ (DHead _ name _) _) = getNameString name+ getName (GDataDecl _ _ _ (DHead _ name _) _ _ _) = getNameString name+ getName (ClassDecl _ _ (DHead _ name _) _ _) = getNameString name+ getName (InstDecl _ _ (IHead _ name _) _) = getQNameString name+ getName (TypeSig _ name _) = concat $ intersperse "," $ map getNameString name+ getName v = error $ "This should not be possible: " ++ show v++instance DocItem Decl GadtDecl where+ getChildren (GDataDecl _ _ _ _ _ cons _) = cons+ getChildren _ = []++instance Named GadtDecl where+ getName (GadtDecl _ name _) = getNameString name+
+ src/Scion/Browser/Util.hs view
@@ -0,0 +1,48 @@+module Scion.Browser.Util where++import Control.Concurrent.ParallelIO.Local+import qualified Data.Map as M+import Distribution.Package hiding (Package)+import Scion.Browser+import System.Exit (ExitCode)+import System.IO (hFlush, stdout)+import System.Process+import Text.Parsec.Error (ParseError)+import GHC.Conc.Sync (numCapabilities)++withThreaded :: (Pool -> IO a) -> IO a+withThreaded = withPool numCapabilities++-- |Executes a command in a directory.+executeCommand :: FilePath -- ^Working directory.+ -> String -- ^Executable to run.+ -> [String] -- ^Arguments.+ -> Bool -- ^Show output+ -> IO ExitCode+executeCommand tmp exe args showOutput =+ do let cproc = CreateProcess (RawCommand exe args)+ (Just tmp)+ Nothing+ Inherit + (if showOutput then Inherit else CreatePipe)+ (if showOutput then Inherit else CreatePipe)+ True+ (_, _, _, h) <- createProcess cproc+ waitForProcess h++-- |Converts a list of parsed packages into a complete database,+-- and merges a list of errors.+partitionPackages :: [(FilePath, Either ParseError (Documented Package))] -> ([Documented Package], [(FilePath, ParseError)])+partitionPackages [] = ([], [])+partitionPackages ((fname, Left err):xs) = let (db, errors) = partitionPackages xs+ in (db, (fname, err):errors)+partitionPackages ((_, Right pkg):xs) = let (db, errors) = partitionPackages xs+ in (pkg:db, errors)++-- |Converts a list of packages to a database+pkgListToDb :: [Documented Package] -> Database+pkgListToDb pkgs = M.fromList (map (\pkg -> (packageId pkg, pkg)) pkgs)++logToStdout :: String -> IO ()+logToStdout msg = putStrLn msg >> hFlush stdout+
+ src/Scion/Hoogle.hs view
@@ -0,0 +1,46 @@+module Scion.Hoogle+( query+, downloadData+, checkDatabase+, module Scion.Hoogle.Types+) where++import qualified Data.ByteString.Char8 as BS8+import Control.Monad+import Scion.Browser+import Scion.Hoogle.Types+import Scion.Hoogle.Instances.Json ()+import Scion.Hoogle.Parser+import Scion.Hoogle.Util+import System.Exit (ExitCode(..))+import System.Process+import Text.Parsec.Prim (runP)++query :: Database -> String -> IO [Result]+query db q = do mpath <- findHoogleBinPath+ case mpath of+ Nothing -> return []+ Just path -> do (exitCode, output, err) <- readProcessWithExitCode path [q] ""+ case exitCode of+ ExitSuccess -> case runP (hoogleElements db) () "hoogle-output" (output) of+ Right result -> return result+ Left _ -> return []+ _ -> do putStrLn err+ return []++downloadData :: IO Bool+downloadData = do mpath <- findHoogleBinPath+ case mpath of+ Nothing -> return False+ Just path -> do putStrLn "Running hoogle data..."+ (ec, _, err) <- readProcessWithExitCode path ["data"] ""+ when (ec/= ExitSuccess) (putStrLn err)+ return (ec == ExitSuccess)++checkDatabase :: IO Bool+checkDatabase = do mpath <- findHoogleBinPath+ case mpath of+ Nothing -> return False+ Just path -> do (exitCode, _, _) <- readProcessWithExitCode path ["fmap"] ""+ return (exitCode == ExitSuccess)+
+ src/Scion/Hoogle/Instances/Json.hs view
@@ -0,0 +1,28 @@+module Scion.Hoogle.Instances.Json where++import Control.Applicative+import Data.Aeson hiding (Result)+import qualified Data.Text as T+import Scion.Hoogle.Types++instance (ToJSON a, ToJSON b, ToJSON c, ToJSON d) => ToJSON (a,b,c,d) where+ toJSON (a,b,c,d) = toJSON [toJSON a, toJSON b, toJSON c, toJSON d]+ {-# INLINE toJSON #-}++instance ToJSON (Result) where+ toJSON (RPackage pids) = object [ T.pack "type" .= "package"+ , T.pack "results" .= pids+ ]+ toJSON (RModule mds) = object [ T.pack "type" .= "module"+ , T.pack "results" .= mds+ ]+ toJSON (RDeclaration decls) = object [ T.pack "type" .= "declaration"+ , T.pack "results" .= decls+ ]+ toJSON (RConstructor decls) = object [ T.pack "type" .= "constructor"+ , T.pack "results" .= decls+ ]++instance FromJSON (Query) where+ parseJSON q = Query <$> parseJSON q+
+ src/Scion/Hoogle/Parser.hs view
@@ -0,0 +1,122 @@+{-# LANGUAGE RankNTypes #-}++module Scion.Hoogle.Parser where++import Data.List (find, intercalate)+import qualified Data.Map as M+import Data.Maybe (fromJust, catMaybes)+import Distribution.Package hiding (Package)+import Language.Haskell.Exts.Annotated.Syntax+import Scion.Browser+import Scion.Browser.Parser.Internal+import Scion.Browser.Query+import Scion.Hoogle.Types+import Text.Parsec.Char+import Text.Parsec.Combinator+import Text.Parsec.Prim++data HalfResult = HalfPackage String+ | HalfModule String (Documented Module)+ | HalfDecl String (Documented Decl)+ | HalfGadtDecl String (Documented GadtDecl)++hoogleElements :: Database -> BSParser [Result]+hoogleElements db = do elts <- hoogleElements'+ return $ catMaybes $ map (convertHalfToResult db) elts++hoogleElements' :: BSParser [HalfResult]+hoogleElements' = try (do spaces0+ eof+ return [])+ <|> (do first <- hoogleElement+ rest <- many $ try (try eol >> try hoogleElement)+ spaces+ eof+ return $ first:rest)++hoogleElement :: BSParser HalfResult+hoogleElement = try (do pname <- hooglePackageName+ return $ HalfPackage pname)+ <|> try (do (mname, m) <- moduled (module_ NoDoc)+ return $ HalfModule mname m)+ <|> try (do (mname, d) <- moduled (function NoDoc)+ return $ HalfDecl mname d)+ <|> try (do (mname, d) <- moduled (dataHead NoDoc)+ return $ HalfDecl mname d)+ <|> try (do (mname, d) <- moduled (newtypeHead NoDoc)+ return $ HalfDecl mname d)+ <|> try (do (mname, d) <- moduled (type_ NoDoc)+ return $ HalfDecl mname d)+ <|> try (do (mname, d) <- moduled (class_ NoDoc)+ return $ HalfDecl mname d)+ <|> try (do (mname, d) <- moduled (constructor NoDoc)+ return $ HalfGadtDecl mname d)++moduled :: BSParser a -> BSParser (String, a)+moduled p = try (do mname <- try conid `sepBy` char '.'+ let name = intercalate "." (map getid mname)+ try spaces1+ rest <- p+ return (name, rest))++hooglePackageName :: BSParser String+hooglePackageName = do string "package"+ spaces1+ name <- restOfLine+ spaces0+ return name++convertHalfToResult :: Database -> HalfResult -> Maybe Result+convertHalfToResult db (HalfPackage pname) = case packagesByName pname db of+ [] -> Nothing+ pkgs -> Just $ RPackage pkgs+convertHalfToResult db (HalfModule mname _) = case findPackagesForModule db mname of+ [] -> Nothing+ mds -> Just $ RModule mds+convertHalfToResult db (HalfDecl mname dcl) = let pidMods = findPackagesForModule db mname+ in case findDeclsInModules pidMods dcl of+ [] -> Nothing+ decls -> Just $ RDeclaration decls+convertHalfToResult db (HalfGadtDecl mname dcl) = let pidMods = findPackagesForModule db mname+ gadts = concatMap filterGadtStyleItems pidMods+ in case findConstructorsInGadts gadts (getName dcl) of+ [] -> Nothing+ decls -> Just $ RConstructor decls++findPackagesForModule :: Database -> String -> [(PackageIdentifier, Documented Module)]+findPackagesForModule db md = let pkgs = M.filter (\(Package _ _ mds) -> M.member md mds) db+ in M.toAscList $ M.map (\(Package _ _ mds) -> fromJust $ M.lookup md mds) pkgs++findDeclsInModules :: [(PackageIdentifier, Documented Module)] -> Documented Decl -> [(PackageIdentifier, String, Documented Decl)]+findDeclsInModules pidMods declName = foldr (\pidMod lst -> case findDeclInModule pidMod declName of+ Nothing -> lst+ Just d -> d:lst)+ [] pidMods++findDeclInModule :: (PackageIdentifier, Documented Module) -> Documented Decl -> Maybe (PackageIdentifier, String, Documented Decl)+findDeclInModule (pid, md@(Module _ _ _ _ decls)) dname = case find (\d -> (fmap (const "") d) == (fmap (const "") dname)) decls of+ Nothing -> Nothing+ Just d -> Just (pid, getName md, d)+findDeclInModule _ _ = error "The impossible happened"++filterGadtStyleItems :: (PackageIdentifier, Documented Module) -> [(PackageIdentifier, String, Documented Decl)]+filterGadtStyleItems (pid, md@(Module _ _ _ _ decls)) = + map (\d -> (pid, getName md, d)) $ filter (\x -> case x of + (GDataDecl _ _ _ _ _ _ _) -> True+ _ -> False)+ decls+filterGadtStyleItems _ = error "The impossible happened"++findConstructorsInGadts :: [(PackageIdentifier, String, Documented Decl)] -> String -> [(PackageIdentifier, String, Documented Decl, Documented GadtDecl)]+findConstructorsInGadts gadts conName = foldr (\gadt lst -> case findConstructorInGadt gadt conName of+ Nothing -> lst+ Just c -> c:lst)+ [] gadts++findConstructorInGadt :: (PackageIdentifier, String, Documented Decl) -> String -> Maybe (PackageIdentifier, String, Documented Decl, Documented GadtDecl)+findConstructorInGadt (pid, mdName, gadt@(GDataDecl _ _ _ _ _ decls _)) cname = + case find (\c -> (getName c) == cname) decls of+ Nothing -> Nothing+ Just c -> Just (pid, mdName, gadt, c)+findConstructorInGadt _ _ = error "The impossible happened"+
+ src/Scion/Hoogle/Types.hs view
@@ -0,0 +1,15 @@+module Scion.Hoogle.Types where++import Distribution.Package hiding (Package)+import Language.Haskell.Exts.Annotated.Syntax+import Scion.Browser++type Results = [Result]++data Result = RPackage [Documented Package]+ | RModule [(PackageIdentifier, Documented Module)]+ | RDeclaration [(PackageIdentifier, String, Documented Decl)]+ | RConstructor [(PackageIdentifier, String, Documented Decl, Documented GadtDecl)]++data Query = Query String+
+ src/Scion/Hoogle/Util.hs view
@@ -0,0 +1,117 @@+{-# OPTIONS -cpp #-}++module Scion.Hoogle.Util+( findHoogleBinPath+) where++import Data.List (find)+import Distribution.InstalledPackageInfo+import Distribution.Package+import Scion.Packages+import System.FilePath+import System.Directory (doesFileExist)++#ifdef mingw32_HOST_OS+import System.Directory (getAppUserDataDirectory)+#endif++-- Functions for finding Hoogle in the system++findHoogleBinPath :: IO (Maybe String)+findHoogleBinPath = findPathsAndCheck placesToSearch+ where placesToSearch = [ findHoogleBinInLibrary getHoogleBinPath1+ , findHoogleBinInLibrary getHoogleBinPath2+#ifdef mingw32_HOST_OS+ , getHoogleBinPath3+#endif+ ]++findPathsAndCheck :: [IO (Maybe String)] -> IO (Maybe String)+findPathsAndCheck [] = return Nothing+findPathsAndCheck (f:fs) = do r <- findPathAndCheck f+ case r of+ Nothing -> findPathsAndCheck fs+ _ -> return r++findPathAndCheck :: IO (Maybe String) -> IO (Maybe String)+findPathAndCheck f = do p <- f+ case p of+ Nothing -> return Nothing+ Just path -> do exists <- doesFileExist path+ if exists+ then return (Just path)+ else return Nothing++findHoogleBinInLibrary :: (String -> String) -> IO (Maybe String)+findHoogleBinInLibrary f = do minfo <- findHoogleInfo+ case minfo of+ Nothing -> return Nothing+ Just info -> let [libDir] = libraryDirs info+ in return $ Just (f libDir)++findHoogleInfo :: IO (Maybe InstalledPackageInfo)+findHoogleInfo = do infos' <- getPkgInfos+ let infos = removeSmallVersions $ concat $ map snd infos'+ return $ find (\m -> (pkgName (sourcePackageId m)) == PackageName "hoogle") infos++removeSmallVersions :: [InstalledPackageInfo] -> [InstalledPackageInfo]+removeSmallVersions pids = filter+ (not . (\InstalledPackageInfo { sourcePackageId = (PackageIdentifier name version) } -> + any (\InstalledPackageInfo { sourcePackageId = (PackageIdentifier name' version') } ->+ name' == name && version' > version)+ pids))+ pids++getHoogleBinPath1 :: String -> String+getHoogleBinPath1 path = let (_:(_:(_:rest))) = reverse $ splitDirectories path+ in (joinPath $ reverse ("bin":rest)) </> "hoogle" <.> exeExtension++getHoogleBinPath2 :: String -> String+getHoogleBinPath2 path = let (_:(_:rest)) = reverse $ splitDirectories path+ in (joinPath $ reverse ("bin":rest)) </> "hoogle" <.> exeExtension++#ifdef mingw32_HOST_OS+getHoogleBinPath3 :: IO (Maybe String)+getHoogleBinPath3 = do cabalDir <- getAppUserDataDirectory "cabal"+ return $ Just (cabalDir </> "bin" </> "hoogle" <.> exeExtension)+#endif++exeExtension :: String+#ifdef mingw32_HOST_OS+exeExtension = "exe"+#else+exeExtension = ""+#endif++-- This part is commented out because Cabal does not work+-- well linking with the Hoogle library.+-- Instead, `hoogle` is called directly and the results+-- are parsed and converted into database items.++{-+-- |Loads the Hoogle search database into memory.+-- If no database is found, an empty one is returned.+getHoogleDatabases :: IO H.Database+getHoogleDatabases = do path <- findHoogleDatabasesPath+ case path of+ Nothing -> return mempty+ Just p -> do files <- getDirectoryContents p+ hooFiles <- filterM (\f -> do exists <- doesFileExist f+ let isHoo = takeExtension f == ".hoo"+ return $ exists && isHoo)+ files+ dbs <- mapM H.loadDatabase hooFiles+ return $ mconcat dbs++findHoogleDatabasesPath :: IO (Maybe String)+findHoogleDatabasesPath = do minfo <- findHoogleInfo+ case minfo of+ Nothing -> return Nothing+ Just info -> let [libDir] = libraryDirs info+ in return $ Just (getDatabasesDir libDir)++getDatabasesDir :: String -> String+getDatabasesDir path = let (_:(hoogleV:(_:rest))) = reverse $ splitDirectories path+ in (joinPath $ reverse (hoogleV:("share":rest))) </> "databases"+-}+
+ src/Scion/Packages.hs view
@@ -0,0 +1,200 @@+{-# LANGUAGE CPP #-}+-- |+-- Module : Scion.Packages+-- Author : Thiago Arrais+-- Copyright : (c) Thiago Arrais 2009+-- License : BSD-style+-- Url : http://stackoverflow.com/questions/1522104/how-to-programmatically-retrieve-ghc-package-information+-- +-- Maintainer : nominolo@gmail.com+-- Stability : experimental+-- Portability : portable+-- +-- Cabal-related functionality.+module Scion.Packages ( getPkgInfos ) where++import Prelude hiding (Maybe)+import qualified Config+import qualified System.Info+import Data.List+import Data.Maybe+import Control.Monad+import Distribution.InstalledPackageInfo+import Distribution.Text+import System.Directory+import System.Environment (getEnv)+import System.FilePath+import System.IO+import System.IO.Error++import GHC.Paths++import qualified Control.Exception as Exception++-- This was borrowed from the ghc-pkg source:+type InstalledPackageInfoString = InstalledPackageInfo_ String++-- | Types of cabal package databases+data CabalPkgDBType =+ PkgDirectory FilePath+ | PkgFile FilePath++type InstalledPackagesList = [(FilePath, [InstalledPackageInfo])]++-- | Fetch the installed package info from the global and user package.conf+-- databases, mimicking the functionality of ghc-pkg.++getPkgInfos :: IO InstalledPackagesList+getPkgInfos = + let+ -- | Test for package database's presence in a given directory+ -- NB: The directory is returned for later scanning by listConf,+ -- which parses the actual package database file(s).+ lookForPackageDBIn :: FilePath -> IO (Maybe InstalledPackagesList)+ lookForPackageDBIn dir =+ let+ path_dir = dir </> "package.conf.d"+ path_file = dir </> "package.conf"+ in do+ exists_dir <- doesDirectoryExist path_dir+ if exists_dir+ then do+ pkgs <- readContents (PkgDirectory path_dir)+ return $ Just pkgs+ else do+ exists_file <- doesFileExist path_file+ if exists_file+ then do+ pkgs <- readContents (PkgFile path_file)+ return $ Just pkgs + else return Nothing++ currentArch :: String+ currentArch = System.Info.arch++ currentOS :: String+ currentOS = System.Info.os++ ghcVersion :: String+ ghcVersion = Config.cProjectVersion+ in do+ -- Get the global package configuration database:+ global_conf <- do+ r <- lookForPackageDBIn getLibDir+ case r of+ Nothing -> ioError $ userError ("Can't find package database in " ++ getLibDir)+ Just pkgs -> return $ pkgs++ -- Get the user package configuration database+ e_appdir <- try $ getAppUserDataDirectory "ghc"+ user_conf <- do+ case e_appdir of+ Left _ -> return []+ Right appdir -> do+ let subdir = currentArch ++ '-':currentOS ++ '-':ghcVersion+ dir = appdir </> subdir+ r <- lookForPackageDBIn dir+ case r of+ Nothing -> return []+ Just pkgs -> return pkgs++ -- Process GHC_PACKAGE_PATH, if present:+ e_pkg_path <- try (getEnv "GHC_PACKAGE_PATH")+ env_stack <- do + case e_pkg_path of+ Left _ -> return []+ Right path -> do+ pkgs <- mapM readContents [(PkgDirectory pkg) | pkg <- splitSearchPath path]+ return $ concat pkgs++ -- Send back the combined installed packages list:+ return (env_stack ++ user_conf ++ global_conf)++-- | Read the contents of the given directory, searching for ".conf" files, and parse the+-- package contents. Returns a singleton list (directory, [installed packages])++readContents :: CabalPkgDBType -- ^ The package database+ -> IO [(FilePath, [InstalledPackageInfo])] -- ^ Installed packages++readContents pkgdb =+ let + -- | List package configuration files that might live in the given directory+ listConf :: FilePath -> IO [FilePath]+ listConf dbdir = do+ conf_dir_exists <- doesDirectoryExist dbdir+ if conf_dir_exists+ then do+ files <- getDirectoryContents dbdir+ return [ dbdir </> file | file <- files, isSuffixOf ".conf" file]+ else return []++ -- | Read a file, ensuring that UTF8 coding is used for GCH >= 6.12+ readUTF8File :: FilePath -> IO String+ readUTF8File file = do+ h <- openFile file ReadMode+#if __GLASGOW_HASKELL__ >= 612+ -- fix the encoding to UTF-8+ hSetEncoding h utf8+ catch (hGetContents h) (\_ -> do+ -- logInfo $ ioeGetErrorString err+ hClose h+ h' <- openFile file ReadMode+ hSetEncoding h' localeEncoding+ hGetContents h'+ )+#else+ hGetContents h+#endif+ ++ -- | This function was lifted directly from ghc-pkg. Its sole purpose is+ -- parsing an input package description string and producing an+ -- InstalledPackageInfo structure.+ convertPackageInfoIn :: InstalledPackageInfoString -> InstalledPackageInfo+ convertPackageInfoIn+ (pkgconf@(InstalledPackageInfo { exposedModules = e,+ hiddenModules = h })) =+ pkgconf{ exposedModules = map convert e,+ hiddenModules = map convert h }+ where convert = fromJust . simpleParse++ -- | Utility function that just flips the arguments to Control.Exception.catch+ catchError :: IO a -> (String -> IO a) -> IO a+ catchError io handler = io `Exception.catch` handler'+ where handler' (Exception.ErrorCall err) = handler err++ -- | Slightly different approach in Cabal 1.8 series, with the package.conf.d+ -- directories, where individual package configuration files are association+ -- pairs.+ pkgInfoReader :: FilePath+ -> IO [InstalledPackageInfo]+ pkgInfoReader f = + catch (+ do+ pkgStr <- readUTF8File f+ let pkgInfo = parseInstalledPackageInfo pkgStr+ case pkgInfo of+ ParseOk _ info -> return [info]+ ParseFailed _ -> do+ -- logInfo (show err)+ return [emptyInstalledPackageInfo]+ ) (\_->return [emptyInstalledPackageInfo])+ + in case pkgdb of+ (PkgDirectory pkgdbDir) -> do+ confs <- listConf pkgdbDir+ pkgInfoList <- mapM pkgInfoReader confs+ return [(pkgdbDir, join pkgInfoList)]++ (PkgFile dbFile) -> do+ pkgStr <- readUTF8File dbFile+ let pkgs = map convertPackageInfoIn $ read pkgStr+ pkgInfoList <-+ Exception.evaluate pkgs+ `catchError`+ (\e-> ioError $ userError $ "parsing " ++ dbFile ++ ": " ++ (show e))+ return [(takeDirectory dbFile, pkgInfoList)]++-- GHC.Path sets libdir for us...+getLibDir :: String+getLibDir = libdir
+ src/Server/Commands.hs view
@@ -0,0 +1,163 @@+{-# LANGUAGE OverloadedStrings #-}++module Server.Commands where++import Control.Applicative+import Control.Monad+import Control.Monad.State+import Data.Aeson+import Data.Maybe (fromMaybe)+import qualified Data.Map as M+import qualified Data.Text as T+import Distribution.Package hiding (Package)+import Language.Haskell.Exts.Annotated.Syntax hiding (String)+import Scion.Browser+import Scion.Browser.Build (saveHackageDatabase, updateDatabase)+import Scion.Browser.Query+import Scion.Browser.Util (logToStdout)+import qualified Scion.Hoogle as H+import Scion.Packages+import System.Directory++data Command = LoadLocalDatabase FilePath Bool+ | LoadHackageDatabase FilePath Bool+ | GetPackages+ | SetCurrentDatabase CurrentDatabase+ | GetModules String+ | GetDeclarations String+ | HoogleQuery String+ | HoogleDownloadData+ | HoogleCheckDatabase+ | GetDeclarationModules String+ | Quit++data CurrentDatabase = AllPackages+ | HackageDatabase+ | LocalDatabase+ | APackage PackageIdentifier++data BrowserState = BrowserState+ { allDb :: Database+ , localDb :: Database+ , hackageDb :: Database+ , currentDb :: Database+ }++initialState :: BrowserState+initialState = BrowserState M.empty M.empty M.empty M.empty++type BrowserM = StateT BrowserState IO++executeCommand :: Command -> BrowserM (Value, Bool) -- Bool indicates if continue receiving commands+executeCommand (LoadLocalDatabase path rebuild) =+ do fileExists <- lift $ doesFileExist path+ let fileExists' = fileExists `seq` fileExists+ curDb <- (if not fileExists'+ then return M.empty+ else do maybeDb <- lift $ loadDatabase path+ case maybeDb of+ Nothing -> return M.empty+ Just theDb -> return theDb)+ lift $ logToStdout "Local database loaded"+ newDb <- if not rebuild+ then return curDb+ else do pkgInfos' <- lift $ getPkgInfos+ let pkgInfos = concat $ map snd pkgInfos'+ newDb <- lift $ updateDatabase curDb pkgInfos+ lift $ logToStdout ("Saving on " ++ path)+ lift $ saveDatabase path newDb+ return newDb+ modify (\s -> s { allDb = newDb `M.union` hackageDb s, localDb = newDb, currentDb = newDb })+ return (String "ok", True)+executeCommand (LoadHackageDatabase path rebuild) =+ do fileExists <- lift $ doesFileExist path+ let fileExists' = fileExists `seq` fileExists+ if not fileExists' || rebuild+ then do lift $ logToStdout "Rebuilding Hackage database"+ lift $ saveHackageDatabase path+ else return ()+ maybeDb <- lift $ loadDatabase path+ lift $ logToStdout "Hackage database loaded"+ let db = fromMaybe M.empty maybeDb+ modify (\s -> s { allDb = localDb s `M.union` db, hackageDb = db, currentDb = db })+ return (String "ok", True)+executeCommand (SetCurrentDatabase db) =+ do case db of+ AllPackages -> do modify (\s -> s { currentDb = allDb s })+ return (String "ok", True)+ LocalDatabase -> do modify (\s -> s { currentDb = localDb s })+ return (String "ok", True)+ HackageDatabase -> do modify (\s -> s { currentDb = hackageDb s })+ return (String "ok", True)+ APackage pid -> do st <- get+ case getSingletonDatabase pid (allDb st) of+ Nothing -> return (String "error", True)+ Just newDb -> do modify (\s -> s { currentDb = newDb })+ return (String "ok", True)+executeCommand GetPackages = do db <- getCurrentDatabase+ return (toJSON (allPackages db), True)+executeCommand (GetModules mname) = do db <- getCurrentDatabase+ let smods = getDocumentedModules (getSubmodules mname db)+ return (toJSON smods, True)+executeCommand (GetDeclarations mname) = do db <- getCurrentDatabase+ -- let decls = concat $ map snd (getDeclsInModule mname db)+ let decls = getDeclsInModule mname db+ return (toJSON decls, True)+executeCommand (HoogleQuery query) = do db <- getCurrentDatabase+ results <- lift $ H.query db query+ return (toJSON results, True)+executeCommand HoogleDownloadData = do _ <- lift $ H.downloadData+ return (String "ok", True)+executeCommand HoogleCheckDatabase = do present <- lift $ H.checkDatabase+ return (Bool present, True)+executeCommand (GetDeclarationModules d) = do db <- getCurrentDatabase+ let mods = getModulesWhereDeclarationIs d db+ return (toJSON mods, True)+executeCommand Quit = return (String "ok", False)++getCurrentDatabase :: BrowserM Database+getCurrentDatabase = do s <- get+ return $ currentDb s++getEntireDatabase :: BrowserM Database+getEntireDatabase = do s <- get+ return $ allDb s++getDocumentedModules :: [(String, [(PackageIdentifier, Documented Module)])] -> [Documented Module]+getDocumentedModules = map (getDocumentedModule . snd)++getDocumentedModule :: [(PackageIdentifier, Documented Module)] -> Documented Module+getDocumentedModule [(_, md)] = md+getDocumentedModule mds@((_, Module _ hd _ _ _):_) = let decls = concat $ map (\(Module _ _ _ _ decl) -> decl) $ map snd mds+ in Module NoDoc hd [] [] decls+getDocumentedModule _ = error "The impossible happened"++instance FromJSON Command where+ parseJSON (Object v) = case M.lookup (T.pack "command") v of+ Just (String e) ->+ case T.unpack e of+ "load-local-db" -> LoadLocalDatabase <$> v .: "filepath"+ <*> v .: "rebuild"+ "load-hackage-db" -> LoadHackageDatabase <$> v .: "filepath"+ <*> v .: "rebuild"+ "get-packages" -> pure GetPackages+ "set-current-db" -> SetCurrentDatabase <$> v .: "new-db"+ "get-modules" -> GetModules <$> v .: "module"+ "get-declarations" -> GetDeclarations <$> v .: "module"+ "hoogle-query" -> HoogleQuery <$> v .: "query"+ "hoogle-data" -> pure HoogleDownloadData+ "hoogle-check" -> pure HoogleCheckDatabase+ "get-decl-module" -> GetDeclarationModules <$> v .: "decl"+ "quit" -> pure Quit+ _ -> mzero+ _ -> mzero+ parseJSON _ = mzero++instance FromJSON CurrentDatabase where+ parseJSON (String new) = case T.unpack new of+ "_all" -> pure AllPackages+ "_hackage" -> pure HackageDatabase+ "_local" -> pure LocalDatabase+ _ -> mzero+ parseJSON other = APackage <$> parseJSON other+
+ test/Scion/Browser/ParserTests.hs view
@@ -0,0 +1,84 @@++module Scion.Browser.ParserTests where++import Scion.Browser.Parser+import Scion.Browser.Types+import Scion.Browser.Util+import qualified Data.Map as M+import Test.HUnit+import Language.Haskell.Exts.Annotated.Syntax+import System.Directory+import System.FilePath+import Data.Serialize+import Data.List+import qualified Data.Aeson as A+import qualified Data.ByteString.Lazy.UTF8 as LBS+import qualified Data.ByteString.Lazy.Char8 as LBS+import qualified Language.Haskell.Exts.Parser as Parser+import Language.Haskell.Exts.Extension+import Data.List.Split+--import Scion.Browser.FileUtil++parserTests :: [Test]+parserTests = checkTypeParse:checkValids++checkValids :: [Test]+checkValids=map (\(f,exps)->TestLabel ("Testing parsing "++f) (TestCase (checkValid f exps))) [+ ("warp",[("Network.Wai.Handler.Warp",["run","resume,pause","Settings","Manager"])])+ ,("wai",[("Network.Wai",[])])+ ,("vector",[("Data.Vector.Storable.Internal",["getPtr"]),("Data.Vector",["Vector","length"])])+ ,("ghc-mtl",[("Control.Monad.Ghc",["runGhc","Ghc"])])+ ,("html",[("Text.Html",["HtmlElement","markupContent"])])+ ,("containers",[("Data.Tree",["Tree","drawTree"])])+ ,("haskell98",[("Maybe",["Maybe","isJust"])])+ ,("haskell2010",[("Data.Array",["Array","ixmap"]),("Data.Complex",["(:+)"])])+ ,("ghc-prim",[])+ ,("base-unicode-symbols",[("Data.Ord.Unicode",["(≯)"]),("Control.Arrow.Unicode",["(⋙)"])])+ ]++checkValid :: String -> [(String,[String])] -> IO()+checkValid name exps=do+ let f="data" </> addExtension name "txt"+ fe<-doesFileExist f+ assertBool (f++" does not exist") fe+ --Just txt<-downloadHoogleFile "http://hackage.haskell.org/packages/archive/warp/0.4.4/doc/html/warp.txt"+ --+ --let res=parseHoogleString "<package>" txt+ res<-parseHoogleFile f+ case res of+ Right p@(Package _ pid m)->do+ mapM_ (checkPresence m) exps+ let db=pkgListToDb [p]+ let bs=encode db+ case ((decode bs)::Either String Database) of+ Left _ -> assertFailure "cannot decode db"+ Right db2 ->do+ let mp=M.lookup pid db2+ case mp of+ Just (Package _ _ m2) -> mapM_ (checkPresence m2) exps+ Nothing -> assertFailure "cannot find pkg"+ Left e->assertFailure $ show e++checkPresence :: (M.Map String (Documented Module)) -> (String,[String]) -> IO()+checkPresence m (modName,exps)=do+ let mmod=M.lookup modName m+ case mmod of+ Nothing->assertFailure ("module not found:" ++ modName)+ Just (Module _ _ _ _ decls)->do+ let names=map getName decls+ mapM_ (\e->assertBool e (elem e names)) exps+ let res=A.toJSON decls+ let output=LBS.toString (A.encode res)+ assertBool modName (not $ isInfixOf "not parsed" output)+ mapM_ (\e->mapM_ (\e2->assertBool e2 (isInfixOf e2 output))(splitOn "," e)) exps+ return ()+ +checkTypeParse :: Test+checkTypeParse= TestLabel "Testing checkTypeParse" (TestCase (do+ let parseString="Category (⇝) => (α ⇝ β) -> (β ⇝ γ) -> (α ⇝ γ)" -- does not work if I remove the brackets around the first squiggly arrow+ let parseTypeMode=Parser.ParseMode "" knownExtensions False False Nothing+ let parsed = Parser.parseTypeWithMode parseTypeMode parseString + case parsed of+ Parser.ParseFailed _ msg -> assertFailure msg+ Parser.ParseOk _ -> return ()+ ))
+ test/Test.hs view
@@ -0,0 +1,9 @@++import Scion.Browser.ParserTests++import Test.Framework (defaultMain, testGroup)+import Test.Framework.Providers.HUnit++main = defaultMain tests++tests = [testGroup "Parser Tests" (concatMap (hUnitTestToTests) parserTests)]