Haskell

Haskell 笔记
Table of Contents
1 基本使用参考GHC userguides.pdf 
2 Bytestrings 
Bytestrings come in two flavors: strict and lazy ones. Strict bytestrings reside in Data.ByteString
and they do away with the laziness completely. There are no promises involved; a strict bytestring represents
a series of bytes in an array. You can't have things like infinite strict bytestrings. If you evaluate 
the first byte of a strict bytestring, you have to evaluate it whole. The upside is that there's less overhead
because there are no thunks (the technical term for promise) involved. The downside is that they're likely to
fill your memory up faster because they're read into memory at once.
The other variety of bytestrings resides in Data.ByteString.Lazy. They're lazy, but not quite as lazy as lists.
Like we said before, there are as many thunks in a list as there are elements. That's what makes them kind of 
slow for some purposes. Lazy bytestrings take a different approach — they are stored in chunks (not to be confused
with thunks!), each chunk has a size of 64K. So if you evaluate a byte in a lazy bytestring (by printing it or something),
the first 64K will be evaluated. After that, it's just a promise for the rest of the chunks. Lazy bytestrings are 
kind of like lists of strict bytestrings with a size of 64K. When you process a file with lazy bytestrings, it will
be read chunk by chunk. This is cool because it won't cause the memory usage to skyrocket and the 64K probably fits
neatly into your CPU's L2 cache.
3 haskell is sensitive to identation and spacing. 
Haskell compilers assume tabstop is 8 characters
4 <- 
it is not to assign a value. It is a way to evaluate an IO action,
in other words, to actually do some IO action and return its results, if any.Haskell 基础 2011-01-04 周二
5 入门 
6 windows 下进入 
cd / 回到根目录
cd Users/echo 进入到指定目录
7 Haskell module 的引入 
:info , :set + t
prelude 中命令行的引入:m+ Date.List
在script中引入 可以直接用 imprt，但是要明白如何解决冲突的问题。
8 编译haskell 程序 
建立源文件，source.hs
编译可执行文件 > ghc –make source.hs
运行文件> source.exe
9 进阶 
10 如何应用 ByteString？ 
The function pack has the type signature pack :: [Word8] -> ByteString. What that means is that it takes
a list of bytes of type Word8 and returns a ByteString. You can think of it as taking a list, which is lazy,
and making it less lazy, so that it's lazy only at 64K intervals.
What's the deal with that Word8 type? Well, it's like Int, only that it has a much smaller range,
namely 0-255. It represents an 8-bit number. And just like Int, it's in the Num typeclass. For instance,
we know that the value 5 is polymorphic in that it can act like any numeral type. Well, it can also take the type of Word8.
11 问题 
如何卸载一个module？
12 do 
to bind a serious IO action.
 Author: echo
<a href="mailto:echowuhao@gmail.com"><echowuhao@gmail.com></a>
 Date: 2011-02-17 15:31:56 
HTML generated by org-mode 6.33x in emacs 23