[[project @ 2001-04-05 09:10:35 by simonmar]
simonmar**20010405091035
Add notes on parallel list comprehensions from Jeff Lewis.
] {
hunk ./ghc/docs/users_guide/5-00-notes.sgml 53
- Parallel list comprehensions added.
+ Parallel list comprehensions added. See .
hunk ./ghc/docs/users_guide/5-00-notes.sgml 122
- The Integer type now has an instance
- of Bits ().
+ The Int and
+ Integer types now have instances of
+ Bits ().
hunk ./ghc/docs/users_guide/5-00-notes.sgml 131
+
+ The methods fromInt and
+ toInt, which used to be in class
+ Num but exported from module
+ Int, are no longer in class
+ Num. They're still available from module
+ Int, however.
+
+ In most cases, there should be no benefit from using
+ fromInt instead of
+ fromIntegral, which is specialised for all
+ integral types.
+
hunk ./ghc/docs/users_guide/glasgow_exts.sgml 98
+
+ Parallel list comprehensions
+
+ An extension to the list comprehension syntax to support
+ zipWith-like functionality. See .
+
+
+
hunk ./ghc/docs/users_guide/glasgow_exts.sgml 545
+
+ Parallel List Comprehensions
+ list comprehensionsparallel
+
+ parallel list comprehensions
+
+
+ Parallel list comprehensions are a natural extension to list
+ comprehensions. List comprehensions can be thought of as a nice
+ syntax for writing maps and filters. Parallel comprehensions
+ extend this to include the zipWith family.
+
+ A parallel list comprehension has multiple independent
+ branches of qualifier lists, each separated by a `|' symbol. For
+ example, the following zips together two lists:
+
+
+ [ (x, y) | x <- xs | y <- ys ]
+
+
+ The behavior of parallel list comprehensions follows that of
+ zip, in that the resulting list will have the same length as the
+ shortest branch.
+
+ We can define parallel list comprehensions by translation to
+ regular comprehensions. Here's the basic idea:
+
+ Given a parallel comprehension of the form:
+
+
+ [ e | p1 <- e11, p2 <- e12, ...
+ | q1 <- e21, q2 <- e22, ...
+ ...
+ ]
+
+
+ This will be translated to:
+
+
+ [ e | ((p1,p2), (q1,q2), ...) <- zipN [(p1,p2) | p1 <- e11, p2 <- e12, ...]
+ [(q1,q2) | q1 <- e21, q2 <- e22, ...]
+ ...
+ ]
+
+
+ where `zipN' is the appropriate zip for the given number of
+ branches.
+
+
+
}