Improving library documentation
(I would have longed for an array example, so here is a suggestion.)
Revision as of 14:43, 26 November 2006
If you find standard library documentation lacking in any way, please log it here. At the minimum record what library/module/function isn't properly documented. Please also suggest how to improve the documentation, in terms of examples, explanations and so on.
package base Data.List unfoldr
An example would be useful. Perhaps:
-- A simple use of unfoldr: -- -- > unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10 -- > [10,9,8,7,6,5,4,3,2,1] --
dons 00:31, 26 November 2006 (UTC)
Tag your submission with your name by using 4 ~ characters, which will be expanded to your name and the date.
If you'd like, you can directly submit your suggestion as a darcs patch via the bug tracking system.
Please add your comments under the appropriate package:
package base Data.Array.IO and Data.Array.MArray descriptions
An example would be usefull. Arrays can be very difficult when you see them the very first time ever with the assumption that you want to try them right now and that Haskell is a relatively new to you. Maybe something like this could be added into the descriptions of the array-modules.
module Main where import Data.Array.IO -- Replace each element with 1/i, where i is the index starting from 1. -- Loop uses array reading and writing. loop :: IOUArray Int Double -> Int -> Int -> IO () loop arr i aLast | i > aLast = return () | otherwise = do val <- readArray arr i writeArray arr i (val / (1+fromIntegral i)) loop arr (i+1) aLast
main = do arr <- newArray (0,9) 1.0 -- initialise an array with 10 doubles. loop arr 0 9 -- selfmade loop over elements arr <- mapArray (+1) arr -- a map over elements elems <- getElems arr putStrLn $ "Array elements: " ++ (show elems)
Isto 14:43, 26 November 2006 (UTC)