├── 0000-relaxed-dependency-analysis.rst ├── 0000-template.rst ├── README.rst ├── report ├── Makefile ├── README ├── packages │ ├── Makefile │ └── pkg-spec.sgml ├── report │ ├── Makefile │ ├── Prelude.hs │ ├── PreludeIO.hs │ ├── PreludeList.hs │ ├── PreludeText.hs │ ├── README │ ├── basic.verb │ ├── classes.eps │ ├── classes.gif │ ├── classes.pdf │ ├── classes.ppt │ ├── decls.verb │ ├── derived.verb │ ├── exps.verb │ ├── ffi.verb │ ├── fixity.verb │ ├── h98.ppt │ ├── haddock.sty │ ├── haskell.bib │ ├── haskell.verb │ ├── hprime.png │ ├── hprime.ppt │ ├── ht │ │ ├── haddock.sty │ │ └── haskell.cfg │ ├── index-extra.verb │ ├── index-intro.verb │ ├── index.html │ ├── intro.verb │ ├── io-13.verb │ ├── iso-chars.verb │ ├── lambda.gif │ ├── lexemes.verb │ ├── libs │ │ ├── Control-Monad.tex │ │ ├── Data-Array.tex │ │ ├── Data-Bits.tex │ │ ├── Data-Char.tex │ │ ├── Data-Complex.tex │ │ ├── Data-Int.tex │ │ ├── Data-Ix.tex │ │ ├── Data-List.tex │ │ ├── Data-Maybe.tex │ │ ├── Data-Ratio.tex │ │ ├── Data-Word.tex │ │ ├── Foreign-C-Error.tex │ │ ├── Foreign-C-String.tex │ │ ├── Foreign-C-Types.tex │ │ ├── Foreign-C.tex │ │ ├── Foreign-ForeignPtr.tex │ │ ├── Foreign-Marshal-Alloc.tex │ │ ├── Foreign-Marshal-Array.tex │ │ ├── Foreign-Marshal-Error.tex │ │ ├── Foreign-Marshal-Utils.tex │ │ ├── Foreign-Marshal.tex │ │ ├── Foreign-Ptr.tex │ │ ├── Foreign-StablePtr.tex │ │ ├── Foreign-Storable.tex │ │ ├── Foreign.tex │ │ ├── Numeric.tex │ │ ├── System-Environment.tex │ │ ├── System-Exit.tex │ │ ├── System-IO-Error.tex │ │ └── System-IO.tex │ ├── modules.verb │ ├── plain_haskell.verb │ ├── pragmas.verb │ ├── preface-13.verb │ ├── preface.verb │ ├── standard-prelude.verb │ ├── syntax-iso.verb │ └── syntax-lexical.verb ├── styles │ ├── code.sty │ ├── grammar.sty │ └── proof.sty └── tools │ ├── Makefile │ ├── index.hs │ ├── splitAndIndexPgm │ ├── subsection │ ├── verb-tex4ht.lex │ └── verbatim.lex └── texts └── .gitkeep /0000-relaxed-dependency-analysis.rst: -------------------------------------------------------------------------------- 1 | - Feature Name: Complete the relaxed dependency analysis, a.k.a. ``-XRelaxedPolyRec`` 2 | - Start Date: 2017-06-18 3 | - RFC PR: Leave this empty, filled on proposal accept 4 | - Haskell Report Issue: Leave this empty, filled on proposal accept 5 | 6 | 7 | 8 | ####### 9 | Summary 10 | ####### 11 | 12 | The `RelaxedDependencyAnalysis proposal `_ that got adopted 13 | into Haskell 2010 is only a half of GHC's ``-XRelaxedPolyRec`` language extension. This proposal is to adopt the rest of 14 | the extension and make it Haskell's official type-checking algorithm. 15 | 16 | 17 | ########## 18 | Motivation 19 | ########## 20 | 21 | The only effect of the change would be to make more Haskell programs compile, with no negative consequences I can think 22 | of. Furthermore, the ``-XRelaxedPolyRec`` extension has been thoroughly tested: it is implicitly activated by the widely 23 | used ``-XScopedTypeVariables`` extension. If the present proposal is accepted, the feature pragma can be dropped from 24 | the list of encouraged extensions in `section 12.3 of the language report 25 | `_. 26 | 27 | 28 | ############### 29 | Detailed design 30 | ############### 31 | 32 | Section 4.5.2 of the Haskell 98 report describes the algorithm for type checking and inference of let bindings. In a 33 | sentence: every syntactic group of ``let`` bindings is broken up in a list of subgroups of mutually recursive bindings 34 | by dependency order, then the types of each subgroup are inferred in order, then some restrictions are imposed. 35 | 36 | Section *11.6.3 Combined Binding Groups* of [MarkJones1999] identified several problems with this section of the Haskell 37 | 98 report: 38 | 39 | 1. the algorithm description is vague and gave rise to inconsistent implementations, 40 | 2. no distinction is made for bindings with explicit type signature, and 41 | 3. the last sentence of the section imposes an unnecessary constraint on the explicit contexts of mutually recursive 42 | bindings. 43 | 44 | Neither this proposal nor the already adopted `RelaxedDependencyAnalysis proposal 45 | `_ aim to completely fix the first problem. This would require 46 | a formal specification of the algorihm, which might constrain the implementations too tightly. This task is better left 47 | to papers like [MarkJones1999]. 48 | 49 | The second problem has already been fixed by the RelaxedDependencyAnalysis proposal in Haskell 2010. The present 50 | proposal is solely about the last problem, and the fix is to simply remove the last sentence of section 4.5.2: 51 | 52 | If the programmer supplies explicit type signatures for more than one variable in a declaration group, the contexts 53 | of these signatures must be identical up to renaming of the type variables. 54 | 55 | As it happens, one language extension from the list of Haskell 2010 `encouraged language extensions 56 | `_, namely `-XRelaxedPolyRec 57 | `_ 58 | in GHC has two effects on the language semantics which exactly correspond to issues #2 and #3 above. If this proposal is 59 | accepted, therefore, the ``-XRelaxedPolyRec`` behaviour would become the default and the extension could then be removed 60 | from the list. 61 | 62 | ######### 63 | Drawbacks 64 | ######### 65 | 66 | None whatsoever. 67 | 68 | 69 | ############ 70 | Alternatives 71 | ############ 72 | 73 | There may be other algorithms proposed for dealing with let binding groups. This is the one implemented by GHC and 74 | tested by user code. 75 | 76 | 77 | 78 | #################### 79 | Unresolved questions 80 | #################### 81 | 82 | 83 | None in my mind. 84 | 85 | .. [MarkJones1999] Jones, Mark P. *Typing haskell in haskell.* Haskell workshop. Vol. 7. 1999. 86 | -------------------------------------------------------------------------------- /0000-template.rst: -------------------------------------------------------------------------------- 1 | - Feature Name: Catchy, descriptive name 2 | - Start Date: Today’s date 3 | - RFC PR: Leave this empty, filled on proposal accept 4 | - Haskell Report Issue: Leave this empty, filled on proposal accept 5 | 6 | 7 | 8 | ####### 9 | Summary 10 | ####### 11 | 12 | A one-paragraph explanation of the feature. This is your main sales pitch. 13 | 14 | 15 | 16 | ########## 17 | Motivation 18 | ########## 19 | 20 | Why is this a good idea? Why is it worth the effort to discuss and implement it? 21 | 22 | 23 | 24 | ############### 25 | Detailed design 26 | ############### 27 | 28 | This is the main part of the proposal. Explain it so that someone familiar with 29 | the language can understand and implement it. Explain details, corner cases, and 30 | provide examples. 31 | 32 | If there are choices to be made about certain particularities of the proposal, 33 | list them here so people can weigh and refer to the alternatives. 34 | 35 | 36 | ######### 37 | Drawbacks 38 | ######### 39 | 40 | Why should we *not* do this? 41 | 42 | 43 | 44 | ############ 45 | Alternatives 46 | ############ 47 | 48 | What other solutions exist to this problem? Does the proposal relate to others? 49 | What is the cost of this proposal compared to alternative solutions? 50 | 51 | 52 | 53 | #################### 54 | Unresolved questions 55 | #################### 56 | 57 | What parts of the proposal are not decided yet? Are there choices to be made 58 | that are still up for discussion? 59 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | RFCs for Haskell Prime 3 | ====================== 4 | 5 | 6 | **Before contributing, please read this entire document.** 7 | 8 | This repository is used to discuss and keep track of proposals for the next 9 | Haskell standard, in a process known as *Haskell Prime*. It is currently 10 | intended to be used similar to `Rust’s RFCs repo`_. 11 | 12 | While the process is open for everyone to participate, contributing entirely new 13 | issues is currently limited to the members of the Core Language Committee. 14 | 15 | 16 | 17 | .. contents:: Table of contents 18 | :local: 19 | :backlinks: none 20 | 21 | 22 | 23 | .. _Rust’s RFCs repo: https://github.com/rust-lang/rfcs 24 | 25 | 26 | 27 | 28 | ----------- 29 | Active RFCs 30 | ----------- 31 | 32 | 1. None so far! 33 | 34 | 35 | 36 | -------------------------------------------- 37 | Is this the right place for my contribution? 38 | -------------------------------------------- 39 | 40 | The key idea of this process is making changes to the Haskell language, as 41 | described in the `Haskell Report`_. Here are some examples of RFCs a user might 42 | want to discuss here: 43 | 44 | Good: 45 | 46 | - Standardize ``LambdaCase``, a GHC extension to Haskell 47 | - Change Haskell syntax to allow trailing commas 48 | - Change ``Monad`` to have ``Applicative`` as superclass 49 | - Add ``for_`` to `Prelude` 50 | 51 | Bad: 52 | 53 | - Add a heap data structure to ``containers`` *(not part of 54 | Haskell-the-language)* 55 | - Impactful, novel language change ideas not tested as an extension for a decent 56 | amount of time *(this is a standardization process, not research of new 57 | ideas)* 58 | 59 | .. _Haskell Report: https://www.haskell.org/onlinereport/haskell2010/ 60 | 61 | 62 | 63 | ---------------- 64 | Proposal process 65 | ---------------- 66 | 67 | 1. Fork this repo at https://github.com/haskell/rfcs 68 | 2. Copy ``0000-template.rst`` to ``texts/0000-GOOD-NAME.rst``; do not assign a 69 | number yet 70 | 3. Fill in the template with your suggestion. Make sure the proposal is as 71 | well-written as you’d expect the final version of it to be; do not submit 72 | drafts with essential parts left out for discussion. 73 | 4. File a pull request to this repo. *(Do not rebase after this! You’re now 74 | live.)* 75 | 5. The request will be discussed in the comment thread of the pull request, if 76 | possible. A Core Language Committee member will be pronounced the *Shepherd*, 77 | and that member is responsible for guiding through the process, making sure 78 | it is not stalled, and an appropriate timeframe for the discussion is 79 | maintained. 80 | 6. The request ends with the pull request being closed. 81 | 82 | .. _Haskell Report Repo: https://github.com/haskell/haskell-report/ 83 | 84 | 85 | Successful proposals 86 | ~~~~~~~~~~~~~~~~~~~~ 87 | 88 | Being successful means that a proposal may be implemented in the Haskell Report. 89 | 90 | - The pull request is merged, giving the proposal an ID corresponding to the 91 | pull request. 92 | - The document is added to the `Active RFCs`_ 93 | - The proposal contents are ready to be implemented in the `Haskell Report 94 | Repo`_. 95 | - No one is appointed responsible for actually implementing the change, in 96 | particular neither the shepherd nor the author of the proposal. 97 | - Changes to the proposal are now impossble, a new proposal is the place for 98 | this. 99 | 100 | Unsuccessful proposals 101 | ~~~~~~~~~~~~~~~~~~~~~~ 102 | 103 | The proposal is discarded without further action. This does not necessarily mean 104 | its ideas are never going to make it into Haskell, just that at this point it 105 | was decided not to continue the idea further. Example scenarios: 106 | 107 | - The change is is inappropriate for the Haskell Prime process 108 | - Substantial changes are required to adapt the proposal, and a fresh start of 109 | the amended version is a good idea. 110 | -------------------------------------------------------------------------------- /report/Makefile: -------------------------------------------------------------------------------- 1 | VERSION = 2010 2 | 3 | default: 4 | cd tools && make 5 | cd report && make 6 | 7 | clean: 8 | cd report && make clean 9 | cd tools && make clean 10 | 11 | release: 12 | cd tools && make 13 | cd report && make 14 | mkdir haskell$(VERSION) || true 15 | cp report/ht/*.html report/ht/*.png report/ht/*.css haskell$(VERSION) 16 | tar cvzf haskell$(VERSION)-html.tar.gz haskell$(VERSION) 17 | 18 | # If you have an account on www.haskell.org, the following rules will upload 19 | # the finished report to the correct places. 20 | UPLOAD_HOST = www.haskell.org 21 | UPLOAD_HTML_DIR = /home/haskell/onlinereport/haskell$(VERSION) 22 | UPLOAD_DEFN_DIR = /home/haskell/definition 23 | 24 | upload: 25 | ssh $(UPLOAD_HOST) "mkdir $(UPLOAD_HTML_DIR) || true" 26 | ssh $(UPLOAD_HOST) "mkdir $(UPLOAD_DEFN_DIR) || true" 27 | scp report/haskell.pdf $(UPLOAD_HOST):$(UPLOAD_DEFN_DIR)/haskell$(VERSION).pdf 28 | scp haskell$(VERSION)-html.tar.gz $(UPLOAD_HOST):$(UPLOAD_DEFN_DIR) 29 | ssh $(UPLOAD_HOST) "cd $(UPLOAD_HTML_DIR); tar xvzf $(UPLOAD_DEFN_DIR)/haskell$(VERSION)-html.tar.gz; mv haskell$(VERSION)/* .; rmdir haskell$(VERSION); rm -f index.html; ln -s haskell.html index.html" 30 | -------------------------------------------------------------------------------- /report/README: -------------------------------------------------------------------------------- 1 | Haskell Report README 2 | ~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | These are the sources to the Haskell report, including all the source 5 | files you will need to generate either the PDF or the HTML version of 6 | the report. 7 | 8 | 9 | Tools you will need 10 | ~~~~~~~~~~~~~~~~~~~ 11 | 12 | PDF version: a decent LaTeX installation with pdflatex. We use the 13 | following additional packages: 14 | 15 | - times 16 | - makeidx 17 | - graphicx 18 | - url 19 | - color 20 | - hyperref 21 | 22 | Also you need the following tools 23 | 24 | - makeindex 25 | 26 | all of which are usually available with a good TeX distribution 27 | (e.g. TeX Live). 28 | 29 | The following are also required for building the tools: 30 | 31 | - flex 32 | - GHC 33 | 34 | The HTML version additionally requires 35 | 36 | - tex4ht (e.g. install 'tex4ht' on a Debian or Ubuntu system, or 37 | 'tetex-tex4ht' on a Fedora system) 38 | 39 | Building the report 40 | ~~~~~~~~~~~~~~~~~~~ 41 | 42 | Firstly: 43 | 44 | $ cd tools 45 | $ make 46 | 47 | should build a few tools required for building the report itself. 48 | Then you should be able to say 49 | 50 | $ cd report 51 | $ make 52 | 53 | This will create: 54 | 55 | - PDF version: report/haskell.pdf 56 | 57 | - HTML version: report/ht/haskell.html 58 | (NB. requires report/ht/*.{html,png,css}) 59 | 60 | 61 | Roadmap 62 | ~~~~~~~ 63 | 64 | SOURCE FILES 65 | 66 | report/ The Language and Libraries Reports (now together 67 | in a single document) 68 | 69 | tools/ Tools needed to build the Reports 70 | (cd into here and type make) 71 | 72 | Makefile Build a distribution of the Reports 73 | 74 | 75 | .verb files 76 | ~~~~~~~~~~~ 77 | 78 | 79 | -------------------------------------------------------------------------------- /report/packages/Makefile: -------------------------------------------------------------------------------- 1 | default: 2 | $(HOME)/builds/HEAD/glafp-utils/docbook/db2dvi -d $(HOME)/builds/HEAD/docs/fptools-both.dsl pkg-spec.sgml 3 | dvips -f < pkg-spec.dvi > pkg-spec.ps -------------------------------------------------------------------------------- /report/report/PreludeIO.hs: -------------------------------------------------------------------------------- 1 | module PreludeIO ( 2 | FilePath, IOError, ioError, userError, catch, 3 | putChar, putStr, putStrLn, print, 4 | getChar, getLine, getContents, interact, 5 | readFile, writeFile, appendFile, readIO, readLn 6 | ) where 7 | 8 | import PreludeBuiltin 9 | 10 | 11 | type FilePath = String 12 | 13 | data IOError -- The internals of this type are system dependent 14 | 15 | instance Show IOError where ... 16 | instance Eq IOError where ... 17 | 18 | ioError :: IOError -> IO a 19 | ioError = primIOError 20 | 21 | userError :: String -> IOError 22 | userError = primUserError 23 | 24 | catch :: IO a -> (IOError -> IO a) -> IO a 25 | catch = primCatch 26 | 27 | putChar :: Char -> IO () 28 | putChar = primPutChar 29 | 30 | putStr :: String -> IO () 31 | putStr s = mapM_ putChar s 32 | 33 | putStrLn :: String -> IO () 34 | putStrLn s = do putStr s 35 | putStr "\n" 36 | 37 | print :: Show a => a -> IO () 38 | print x = putStrLn (show x) 39 | 40 | getChar :: IO Char 41 | getChar = primGetChar 42 | 43 | getLine :: IO String 44 | getLine = do c <- getChar 45 | if c == '\n' then return "" else 46 | do s <- getLine 47 | return (c:s) 48 | 49 | getContents :: IO String 50 | getContents = primGetContents 51 | 52 | interact :: (String -> String) -> IO () 53 | -- The hSetBuffering ensures the expected interactive behaviour 54 | interact f = do hSetBuffering stdin NoBuffering 55 | hSetBuffering stdout NoBuffering 56 | s <- getContents 57 | putStr (f s) 58 | 59 | readFile :: FilePath -> IO String 60 | readFile = primReadFile 61 | 62 | writeFile :: FilePath -> String -> IO () 63 | writeFile = primWriteFile 64 | 65 | appendFile :: FilePath -> String -> IO () 66 | appendFile = primAppendFile 67 | 68 | -- raises an exception instead of an error 69 | readIO :: Read a => String -> IO a 70 | readIO s = case [x | (x,t) <- reads s, ("","") <- lex t] of 71 | [x] -> return x 72 | [] -> ioError (userError "Prelude.readIO: no parse") 73 | _ -> ioError (userError "Prelude.readIO: ambiguous parse") 74 | 75 | readLn :: Read a => IO a 76 | readLn = do l <- getLine 77 | r <- readIO l 78 | return r 79 | -------------------------------------------------------------------------------- /report/report/PreludeText.hs: -------------------------------------------------------------------------------- 1 | module PreludeText ( 2 | ReadS, ShowS, 3 | Read(readsPrec, readList), 4 | Show(showsPrec, show, showList), 5 | reads, shows, read, lex, 6 | showChar, showString, readParen, showParen ) where 7 | 8 | -- The instances of Read and Show for 9 | -- Bool, Maybe, Either, Ordering 10 | -- are done via "deriving" clauses in Prelude.hs 11 | 12 | import Data.Char(isSpace, isAlpha, isDigit, isAlphaNum, 13 | showLitChar, readLitChar, lexLitChar) 14 | 15 | import Numeric(showSigned, showInt, readSigned, readDec, showFloat, 16 | readFloat, lexDigits) 17 | 18 | type ReadS a = String -> [(a,String)] 19 | type ShowS = String -> String 20 | 21 | class Read a where 22 | readsPrec :: Int -> ReadS a 23 | readList :: ReadS [a] 24 | 25 | -- Minimal complete definition: 26 | -- readsPrec 27 | readList = readParen False (\r -> [pr | ("[",s) <- lex r, 28 | pr <- readl s]) 29 | where readl s = [([],t) | ("]",t) <- lex s] ++ 30 | [(x:xs,u) | (x,t) <- reads s, 31 | (xs,u) <- readl' t] 32 | readl' s = [([],t) | ("]",t) <- lex s] ++ 33 | [(x:xs,v) | (",",t) <- lex s, 34 | (x,u) <- reads t, 35 | (xs,v) <- readl' u] 36 | 37 | class Show a where 38 | showsPrec :: Int -> a -> ShowS 39 | show :: a -> String 40 | showList :: [a] -> ShowS 41 | 42 | -- Mimimal complete definition: 43 | -- show or showsPrec 44 | showsPrec _ x s = show x ++ s 45 | 46 | show x = showsPrec 0 x "" 47 | 48 | showList [] = showString "[]" 49 | showList (x:xs) = showChar '[' . shows x . showl xs 50 | where showl [] = showChar ']' 51 | showl (x:xs) = showChar ',' . shows x . 52 | showl xs 53 | 54 | reads :: (Read a) => ReadS a 55 | reads = readsPrec 0 56 | 57 | shows :: (Show a) => a -> ShowS 58 | shows = showsPrec 0 59 | 60 | read :: (Read a) => String -> a 61 | read s = case [x | (x,t) <- reads s, ("","") <- lex t] of 62 | [x] -> x 63 | [] -> error "Prelude.read: no parse" 64 | _ -> error "Prelude.read: ambiguous parse" 65 | 66 | showChar :: Char -> ShowS 67 | showChar = (:) 68 | 69 | showString :: String -> ShowS 70 | showString = (++) 71 | 72 | showParen :: Bool -> ShowS -> ShowS 73 | showParen b p = if b then showChar '(' . p . showChar ')' else p 74 | 75 | readParen :: Bool -> ReadS a -> ReadS a 76 | readParen b g = if b then mandatory else optional 77 | where optional r = g r ++ mandatory r 78 | mandatory r = [(x,u) | ("(",s) <- lex r, 79 | (x,t) <- optional s, 80 | (")",u) <- lex t ] 81 | 82 | -- This lexer is not completely faithful to the Haskell lexical syntax. 83 | -- Current limitations: 84 | -- Qualified names are not handled properly 85 | -- Octal and hexidecimal numerics are not recognized as a single token 86 | -- Comments are not treated properly 87 | 88 | lex :: ReadS String 89 | lex "" = [("","")] 90 | lex (c:s) 91 | | isSpace c = lex (dropWhile isSpace s) 92 | lex ('\'':s) = [('\'':ch++"'", t) | (ch,'\'':t) <- lexLitChar s, 93 | ch /= "'" ] 94 | lex ('"':s) = [('"':str, t) | (str,t) <- lexString s] 95 | where 96 | lexString ('"':s) = [("\"",s)] 97 | lexString s = [(ch++str, u) 98 | | (ch,t) <- lexStrItem s, 99 | (str,u) <- lexString t ] 100 | 101 | lexStrItem ('\\':'&':s) = [("\\&",s)] 102 | lexStrItem ('\\':c:s) | isSpace c 103 | = [("\\&",t) | 104 | '\\':t <- 105 | [dropWhile isSpace s]] 106 | lexStrItem s = lexLitChar s 107 | 108 | lex (c:s) | isSingle c = [([c],s)] 109 | | isSym c = [(c:sym,t) | (sym,t) <- [span isSym s]] 110 | | isAlpha c = [(c:nam,t) | (nam,t) <- [span isIdChar s]] 111 | | isDigit c = [(c:ds++fe,t) | (ds,s) <- [span isDigit s], 112 | (fe,t) <- lexFracExp s ] 113 | | otherwise = [] -- bad character 114 | where 115 | isSingle c = c `elem` ",;()[]{}_`" 116 | isSym c = c `elem` "!@#$%&*+./<=>?\\^|:-~" 117 | isIdChar c = isAlphaNum c || c `elem` "_'" 118 | 119 | lexFracExp ('.':c:cs) | isDigit c 120 | = [('.':ds++e,u) | (ds,t) <- lexDigits (c:cs), 121 | (e,u) <- lexExp t] 122 | lexFracExp s = lexExp s 123 | 124 | lexExp (e:s) | e `elem` "eE" 125 | = [(e:c:ds,u) | (c:t) <- [s], c `elem` "+-", 126 | (ds,u) <- lexDigits t] ++ 127 | [(e:ds,t) | (ds,t) <- lexDigits s] 128 | lexExp s = [("",s)] 129 | 130 | instance Show Int where 131 | showsPrec n = showsPrec n . toInteger 132 | -- Converting to Integer avoids 133 | -- possible difficulty with minInt 134 | 135 | instance Read Int where 136 | readsPrec p r = [(fromInteger i, t) | (i,t) <- readsPrec p r] 137 | -- Reading at the Integer type avoids 138 | -- possible difficulty with minInt 139 | 140 | instance Show Integer where 141 | showsPrec = showSigned showInt 142 | 143 | instance Read Integer where 144 | readsPrec p = readSigned readDec 145 | 146 | instance Show Float where 147 | showsPrec p = showFloat 148 | 149 | instance Read Float where 150 | readsPrec p = readSigned readFloat 151 | 152 | instance Show Double where 153 | showsPrec p = showFloat 154 | 155 | instance Read Double where 156 | readsPrec p = readSigned readFloat 157 | 158 | instance Show () where 159 | showsPrec p () = showString "()" 160 | 161 | instance Read () where 162 | readsPrec p = readParen False 163 | (\r -> [((),t) | ("(",s) <- lex r, 164 | (")",t) <- lex s ] ) 165 | instance Show Char where 166 | showsPrec p '\'' = showString "'\\''" 167 | showsPrec p c = showChar '\'' . showLitChar c . showChar '\'' 168 | 169 | showList cs = showChar '"' . showl cs 170 | where showl "" = showChar '"' 171 | showl ('"':cs) = showString "\\\"" . showl cs 172 | showl (c:cs) = showLitChar c . showl cs 173 | 174 | instance Read Char where 175 | readsPrec p = readParen False 176 | (\r -> [(c,t) | ('\'':s,t)<- lex r, 177 | (c,"\'") <- readLitChar s]) 178 | 179 | readList = readParen False (\r -> [(l,t) | ('"':s, t) <- lex r, 180 | (l,_) <- readl s ]) 181 | where readl ('"':s) = [("",s)] 182 | readl ('\\':'&':s) = readl s 183 | readl s = [(c:cs,u) | (c ,t) <- readLitChar s, 184 | (cs,u) <- readl t ] 185 | 186 | instance (Show a) => Show [a] where 187 | showsPrec p = showList 188 | 189 | instance (Read a) => Read [a] where 190 | readsPrec p = readList 191 | 192 | -- Tuples 193 | 194 | instance (Show a, Show b) => Show (a,b) where 195 | showsPrec p (x,y) = showChar '(' . shows x . showChar ',' . 196 | shows y . showChar ')' 197 | 198 | instance (Read a, Read b) => Read (a,b) where 199 | readsPrec p = readParen False 200 | (\r -> [((x,y), w) | ("(",s) <- lex r, 201 | (x,t) <- reads s, 202 | (",",u) <- lex t, 203 | (y,v) <- reads u, 204 | (")",w) <- lex v ] ) 205 | 206 | -- Other tuples have similar Read and Show instances 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /report/report/README: -------------------------------------------------------------------------------- 1 | Haskell Report Sources 2 | ~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | .verb files 5 | ~~~~~~~~~~~ 6 | 7 | .verb files are converted to .tex by the preprocessor "verbatim" in 8 | ../tools. When generating HTML via tex4ht, we use a slightly 9 | different version of the preprocesor, in ../tools/verb-tex4ht. 10 | 11 | 12 | make targets 13 | ~~~~~~~~~~~~ 14 | 15 | all make both HTML and PDF versions 16 | html make the HTML version 17 | pdf make the PDF version 18 | clean remove generated files 19 | haddock re-generate the library documentation using Haddock 20 | (see Makefile for instructions) 21 | 22 | 23 | Re-generating the library documentation using Haddock 24 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 | 26 | The documentation for library modules is generated automatically by 27 | Haddock (http://www.haskell.org/haddock) from the library source code. 28 | You don't need Haddock to build the report though - the generated .tex 29 | files have been checked into the repository. 30 | 31 | The library specifications generated for the Haskell 2010 report were 32 | generated using libraries from these repositories: 33 | 34 | base (http://darcs.haskell.org/packages/base) 35 | ghc-prim (http://darcs.haskell.org/packages/ghc-prim) 36 | integer-gmp (http://darcs.haskell.org/packages/integer-gmp) 37 | array (http://darcs.haskell.org/packages/array) 38 | haskell2010 (http://darcs.haskell.org/packages/haskell2010) 39 | 40 | each of the repositories was tagged with 41 | 42 | "Haskell 2010 report generated" 43 | 44 | at the point the libray module documentation was generated, so you 45 | should be able to reproduce exactly what is checked into the 46 | repository. 47 | 48 | Right now, the only practical way to re-generate the library module 49 | documentation is to have a GHC build. Fortunately building GHC isn't 50 | that hard these days: go to 51 | 52 | http://hackage.haskell.org/trac/ghc/wiki/Building 53 | 54 | and follow the instructions. Make sure you don't disable 55 | documentation building, i.e. don't set HADDOCK_DOCS=NO in your 56 | mk/build.mk configuration file. 57 | 58 | When you have built GHC 59 | 60 | To update the library documentation see the Makefile, in the section 61 | "Haddock-generated library docs". 62 | 63 | 64 | Roadmap 65 | ~~~~~~~ 66 | 67 | haskell.verb -- Top level of the report 68 | 69 | Sections of the report: 70 | intro.verb 71 | lexemes.verb 72 | exps.verb 73 | decls.verb 74 | modules.verb 75 | basic.verb 76 | io-13.verb 77 | ffi.verb 78 | standard-prelude.verb 79 | syntax-iso.verb 80 | fixity.verb 81 | derived.verb 82 | pragmas.verb 83 | haskell.bib 84 | 85 | Library documentation, generated by Haddock: 86 | 87 | libs/*.verb -- documentation for each library module 88 | haddck.sty -- definitions for macros used by Haddock 89 | 90 | Extra .verb files: 91 | iso-chars.verb -- Some bogus definitions for ISO chars. Probably not 92 | -- needed since I removed them from the syntax. 93 | index-extra.verb -- extra stuff to get indexed (see also's) 94 | index-intro.verb -- header for index 95 | 96 | Haskell source files: 97 | 98 | Prelude.hs 99 | PreludeList.hs 100 | PreludeIO.hs 101 | PreludeText.hs 102 | 103 | Figures: 104 | 105 | classes.ppt -- The original class figure (Powerpoint) 106 | classes.eps (*) -- Postscript version of class-fig 107 | classes.gif (*) -- For html version 108 | cover.cdr -- A nice looking cover for the report 109 | cover.eps (*) 110 | 111 | Html support: 112 | 113 | ht/haskell.cfg -- tex4ht configuration file 114 | ht/haddock.sty -- customised Haddock style for HTML output 115 | 116 | index.html -- (unused now) Top level of the html report (hand generated) 117 | lambda.gif -- (unused now) background for title page 118 | 119 | Other files: 120 | 121 | Makefile -- Lots of extra cruft no longer used. 122 | 123 | Report any problems to the most recent editor, or failing that, one of 124 | the past editors of the report. 125 | 126 | 127 | Making figures 128 | ~~~~~~~~~~~~~~ 129 | The classes.eps files, which contains the classes hierarchy figure, 130 | is made in Powerpoint, from classses.ppt. To get the .eps file, 131 | do the following: 132 | 133 | * Open classes.ppt 134 | * Print.. 135 | * Check the print-to-file box, and save as classes.prn 136 | * Edit classes.prn 137 | Kill the .prn header and footer (before % PS-Adobe), and after %EOF 138 | Kill the entire setup code (from BeginSetup to EndSetup) 139 | Kill the showpage near the end 140 | * Save as classes.eps 141 | * Open with Ghostview 142 | * Note the coords of the bottom LH and top RH corner, as reported by 143 | Ghostview 144 | * Re-edit classes.eps, and put those coords in the 145 | %BoundingBox line 146 | 147 | You also need to do 148 | Save As.. 149 | in Powerpoint, and save the thing as classes.gif, for the HTML version 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /report/report/classes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/classes.gif -------------------------------------------------------------------------------- /report/report/classes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/classes.pdf -------------------------------------------------------------------------------- /report/report/classes.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/classes.ppt -------------------------------------------------------------------------------- /report/report/fixity.verb: -------------------------------------------------------------------------------- 1 | %**The Haskell 2010 Report: Fixity Resolution 2 | %**~header 3 | \subsection{Fixity Resolution} 4 | \label{fixity-resolution} 5 | \index{fixity@@resolution} 6 | 7 | \begin{haskellprime} 8 | 9 | The following is an example implementation of fixity resolution for 10 | Haskell expressions. Fixity resolution also applies to Haskell 11 | patterns, but patterns are a subset of expressions so in what follows 12 | we consider only expressions for simplicity. 13 | 14 | The function @resolve@ takes a list in which the elements are 15 | expressions or operators, i.e. an instance of the "infixexp" 16 | non-terminal in the context-free grammar. It returns either @Just e@ 17 | where @e@ is the resolved expression, or @Nothing@ if the input does 18 | not represent a valid expression. In a compiler, of course, it would 19 | be better to return more information about the operators involved for 20 | the purposes of producing a useful error message, but the @Maybe@ type 21 | will suffice to illustrate the algorithm here. 22 | 23 | \bprog 24 | @ 25 | import Control.Monad 26 | 27 | type Prec = Int 28 | type Var = String 29 | 30 | data Op = Op String Prec Fixity 31 | deriving (Eq,Show) 32 | 33 | data Fixity = Leftfix | Rightfix | Nonfix 34 | deriving (Eq,Show) 35 | 36 | data Exp = Var Var | OpApp Exp Op Exp | Neg Exp 37 | deriving (Eq,Show) 38 | 39 | data Tok = TExp Exp | TOp Op | TNeg 40 | deriving (Eq,Show) 41 | 42 | resolve :: [Tok] -> Maybe Exp 43 | resolve tokens = fmap fst $ parseNeg (Op "" (-1) Nonfix) tokens 44 | where 45 | parseNeg :: Op -> [Tok] -> Maybe (Exp,[Tok]) 46 | parseNeg op1 (TExp e1 : rest) 47 | = parse op1 e1 rest 48 | parseNeg op1 (TNeg : rest) 49 | = do guard (prec1 < 6) 50 | (r, rest') <- parseNeg (Op "-" 6 Leftfix) rest 51 | parse op1 (Neg r) rest' 52 | where 53 | Op _ prec1 fix1 = op1 54 | 55 | parse :: Op -> Exp -> [Tok] -> Maybe (Exp, [Tok]) 56 | parse _ e1 [] = Just (e1, []) 57 | parse op1 e1 (TOp op2 : rest) 58 | -- case (1): check for illegal expressions 59 | | prec1 == prec2 && (fix1 /= fix2 || fix1 == Nonfix) 60 | = Nothing 61 | 62 | -- case (2): op1 and op2 should associate to the left 63 | | prec1 > prec2 || (prec1 == prec2 && fix1 == Leftfix) 64 | = Just (e1, TOp op2 : rest) 65 | 66 | -- case (3): op1 and op2 should associate to the right 67 | | otherwise 68 | = do (r,rest') <- parseNeg op2 rest 69 | parse op1 (OpApp e1 op2 r) rest' 70 | where 71 | Op _ prec1 fix1 = op1 72 | Op _ prec2 fix2 = op2 73 | @ 74 | \eprog 75 | 76 | The algorithm works as follows. At each stage we have a call 77 | 78 | @ 79 | parse op1 E1 (op2 : tokens) 80 | @ 81 | 82 | which means that we are looking at an expression like 83 | 84 | @ 85 | E0 `op1` E1 `op2` ... (1) 86 | @ 87 | 88 | (the caller holds E0). The job of @parse@ is to build the expression 89 | to the right of @op1@, returning the expression and any remaining 90 | input. 91 | 92 | There are three cases to consider: 93 | 94 | \begin{enumerate} 95 | 96 | \item if @op1@ and @op2@ have the same precedence, but they do not 97 | have the same associativity, or they are declared to be nonfix, then 98 | the expression is illegal. 99 | 100 | \item If @op1@ has a higher precedence than @op2@, or @op1@ and @op2@ 101 | should left-associate, then we know that the expression to the right 102 | of @op1@ is @E1@, so we return this to the caller. 103 | 104 | \item Otherwise, we know we want to build an expression of the form 105 | @E1 `op2` R@. To find @R@, we call @parseNeg op2 tokens@ to compute 106 | the expression to the right of @op2@, namely @R@ (more about 107 | @parseNeg@ below, but essentially if @tokens@ is of the form @(E2 : rest)@, 108 | then this is equivalent to @parse op2 E2 rest@). Now, we 109 | have 110 | \[ 111 | @E0 `op1` (E1 `op2` R) `op3` ...@ 112 | \] 113 | where @op3@ is the next operator in the input. This is an instance of 114 | (1) above, so to continue we call parse, with the new @E1 == (E1 `op2` R)@. 115 | \end{enumerate} 116 | 117 | To initialise the algorithm, we set @op1@ to be an imaginary operator 118 | with precedence lower than anything else. Hence @parse@ will consume 119 | the whole input, and return the resulting expression. 120 | 121 | The handling of the prefix negation operator, @-@, complicates matters 122 | only slightly. Recall that prefix negation has the same fixity as 123 | infix negation: left-associative with precedence 6. The operator to 124 | the left of @-@, if there is one, must have precedence lower than 6 125 | for the expression to be legal. The negation operator itself may 126 | left-associate with operators of the same fixity (e.g. @+@). So for 127 | example @-a + b@ is legal and resolves as @(-a) + b@, but @a + -b@ is 128 | illegal. 129 | 130 | The function @parseNeg@ handles prefix negation. If we encounter a 131 | negation operator, and it is legal in this position (the operator to 132 | the left has precedence lower than 6), then we proceed in a similar 133 | way to case (3) above: compute the argument to @-@ by recursively 134 | calling @parseNeg@, and then continue by calling @parse@. 135 | 136 | Note that this algorithm is insensitive to the range and resolution of 137 | precedences. There is no reason in principle that Haskell should be 138 | limited to integral precedences in the range 1 to 10; a larger range, 139 | or fractional values, would present no additional difficulties. 140 | 141 | \end{haskellprime} 142 | 143 | %**~footer 144 | -------------------------------------------------------------------------------- /report/report/h98.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/h98.ppt -------------------------------------------------------------------------------- /report/report/haddock.sty: -------------------------------------------------------------------------------- 1 | % Modified version of the Haddock style sheet 2 | 3 | \usepackage{tabulary} % see below 4 | 5 | \newenvironment{haddocktitle} 6 | {\begin{center}\bgroup\large\bfseries} 7 | {\egroup\end{center}} 8 | \newenvironment{haddockprologue}{\vspace{1in}}{} 9 | 10 | \newcommand{\haddockmoduleheading}[1]{\chapter{\texttt{#1}}} 11 | 12 | \newcommand{\haddockbeginheader}{\hrulefill} 13 | \newcommand{\haddockendheader}{\noindent\hrulefill} 14 | 15 | % a little gap before the ``Methods'' header 16 | \newcommand{\haddockpremethods}{\vspace{2ex}} 17 | 18 | % inserted before \\begin{verbatim} 19 | \newcommand{\haddockverb}{\small} 20 | 21 | % an identifier: add an index entry 22 | \newcommand{\haddockid}[1]{\haddocktt{#1}\index{#1@\texttt{#1}}} 23 | 24 | % The tabulary environment lets us have a column that takes up ``the 25 | % rest of the space''. Unfortunately it doesn't allow 26 | % the \end{tabulary} to be in the expansion of a macro, it must appear 27 | % literally in the document text, so Haddock inserts 28 | % the \end{tabulary} itself. 29 | \newcommand{\haddockbeginconstrs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}} 30 | \newcommand{\haddockbeginargs}{\begin{tabulary}{\linewidth}{@{}llJ@{}}} 31 | 32 | \newcommand{\haddocktt}[1]{{\small \texttt{#1}}} 33 | \newcommand{\haddockdecltt}[1]{{\small\bfseries \texttt{#1}}} 34 | 35 | \makeatletter 36 | \newenvironment{haddockdesc} 37 | {\list{}{\labelwidth\z@ \itemindent-\leftmargin 38 | \let\makelabel\haddocklabel}} 39 | {\endlist} 40 | \newcommand*\haddocklabel[1]{\hspace\labelsep\haddockdecltt{#1}} 41 | \makeatother 42 | 43 | % after a declaration, start a new line for the documentation. 44 | % Otherwise, the documentation starts right after the declaration, 45 | % because we're using the list environment and the declaration is the 46 | % ``label''. I tried making this newline part of the label, but 47 | % couldn't get that to work reliably (the space seemed to stretch 48 | % sometimes). 49 | \newcommand{\haddockbegindoc}{\hfill\\[1ex]} 50 | 51 | % spacing between paragraphs and no \parindent looks better 52 | \parskip=10pt plus2pt minus2pt 53 | \setlength{\parindent}{0cm} 54 | -------------------------------------------------------------------------------- /report/report/haskell.bib: -------------------------------------------------------------------------------- 1 | @article{hindley69 2 | ,key={hindley} 3 | ,author={Hindley, R.} 4 | ,title={The Principal Type Scheme of an Object in Combinatory Logic} 5 | ,journal={Transactions of the American Mathematical Society} 6 | ,volume=146 7 | ,year=1969 8 | ,month=Dec 9 | ,pages={29--60} 10 | } 11 | 12 | @article{milner78 13 | ,key={milner} 14 | ,author={Milner, R.A.} 15 | ,title={A Theory of Type Polymorphism in Programming} 16 | ,journal={Journal of Computer and System Sciences} 17 | ,volume=17 18 | ,number=3 19 | ,year=1978 20 | ,month=Dec 21 | ,pages={348--375} 22 | } 23 | 24 | @book{curry&feys:book 25 | ,key={curry} 26 | ,author={Curry, H.K. and Feys, R.} 27 | ,title={Combinatory Logic} 28 | ,publisher={North-Holland Pub. Co.} 29 | ,address={Amsterdam} 30 | ,year=1958 31 | } 32 | 33 | @book{steele:common-lisp, 34 | author="{Steele Jr.}, G.L.", 35 | title="{Common} {Lisp}: The Language", 36 | publisher="Digital Press", 37 | address="Burlington, Mass.", 38 | year=1984} 39 | 40 | @article{RRRRS 41 | ,key={rees} 42 | ,author={Rees, J. and Clinger (eds.), W.} 43 | ,title={The Revised$^3$ Report on the Algorithmic Language {S}cheme} 44 | ,journal={SIGPLAN Notices} 45 | ,volume=21 46 | ,number=12 47 | ,year=1986 48 | ,month=dec 49 | ,pages={37--79} 50 | } 51 | 52 | @inproceedings{penfield:complex-apl, 53 | author="Penfield, Jr., P.", 54 | title="Principal Values and Branch Cuts in Complex {APL}", 55 | booktitle="APL '81 Conference Proceedings", 56 | address="San Francisco", 57 | year=1981, 58 | month=sep, 59 | pages="248--256"} 60 | 61 | @techreport{nikhil:id-nouveau, 62 | author="Nikhil, R.S.", 63 | title="{Id-Nouveau} (Version 88.0) Reference Manual", 64 | institution="MIT Laboratory for Computer Science", 65 | address="Cambridge, Mass.", 66 | year=1988, 67 | month=mar} 68 | 69 | @techreport{hudak:io 70 | ,key="Hudak" 71 | ,author="Hudak, P. and Sundaresh, R." 72 | ,title="On the Expressiveness of Purely Functional {I/O} Systems" 73 | ,institution="Yale University, Department of Computer Science" 74 | ,month=dec 75 | ,number="YALEU/DCS/RR665" 76 | ,year=1988 77 | } 78 | 79 | @book{peyton-jones:book 80 | ,key={peyton jones} 81 | ,author={Peyton Jones, S.} 82 | ,title={The Implementation of Functional Programming Languages} 83 | ,publisher={Prentice-Hall International} 84 | ,address={Englewood Cliffs, New Jersey} 85 | ,year=1987 86 | } 87 | 88 | @book{gordon 89 | ,key={gordon} 90 | ,author={Gordon, J.C.} 91 | ,title={The Denotational Description of Programming Languages} 92 | ,publisher={Springer-Verlag} 93 | ,address={New York} 94 | ,year=1979 95 | } 96 | 97 | @article{mcca60 98 | ,key="McCarthy" 99 | ,author="McCarthy, J." 100 | ,title="Recursive functions of symbolic expressions and their 101 | computation by machine, {P}art {I}" 102 | ,journal="CACM" 103 | ,volume=3 104 | ,number=4 105 | ,pages="184--195" 106 | ,month=Apr 107 | ,year=1960 108 | } 109 | 110 | @article{back78 111 | ,key="Backus" 112 | ,author="Backus, J." 113 | ,title="Can programming be liberated from the von {N}eumann style? 114 | {A} functional style and its algebra of programs" 115 | ,journal="CACM" 116 | ,volume=21 117 | ,number=8 118 | ,pages="613--641" 119 | ,month=Aug 120 | ,year=1978 121 | } 122 | 123 | @InProceedings{wadler:array-primitive, 124 | author="Wadler, P.", 125 | title="A New Array Operation", 126 | editor="Fasel, J.H. and Keller, R.M.", 127 | booktitle="Graph Reduction", 128 | publisher="Springer-Verlag", 129 | volume="279", 130 | series="Lecture Notes in Computer Science", 131 | address="Heidelberg", 132 | year=1987, 133 | pages="328--335"} 134 | 135 | @InProceedings{turn85 136 | ,key={turner} 137 | ,author={Turner, D.A.} 138 | ,title={Miranda: a non-strict functional language with polymorphic types} 139 | ,booktitle={Functional Programming Languages and Computer Architecture} 140 | ,month=Sep 141 | ,year=1985 142 | ,publisher={Springer-Verlag} 143 | ,address={Nancy, France} 144 | ,volume="201" 145 | ,series="Lecture Notes in Computer Science" 146 | ,pages={1--16} 147 | } 148 | 149 | @article{landin66 150 | ,key={landin} 151 | ,author={Landin, P.J.} 152 | ,title={The Next 700 Programming Languages} 153 | ,journal="CACM" 154 | ,volume=9 155 | ,number=3 156 | ,year=1966 157 | ,month=mar 158 | ,pages={157--166} 159 | } 160 | 161 | @InProceedings{wadler:classes 162 | ,key={wadler} 163 | ,author={Wadler, P. and Blott, S.} 164 | ,title={How to Make {\em ad hoc} Polymorphism Less {\em ad hoc}} 165 | ,booktitle={Proceedings of 16th ACM Symposium 166 | on Principles of Programming Languages} 167 | ,month=Jan 168 | ,address="Austin, Texas" 169 | ,year=1989 170 | ,pages={60--76} 171 | } 172 | 173 | @inproceedings{gordonetal78 174 | ,key={gordon} 175 | ,author={Gordon, M. and Milner, R. and Morris, L. and Newey, M. and 176 | Wadsworth, C.} 177 | ,title={A Metalanguage for Interactive Proof in {LCF}} 178 | ,booktitle={Proceedings of 5th ACM Symposium 179 | on Principles of Programming Languages} 180 | ,year=1978 181 | ,pages={119--130} 182 | } 183 | 184 | @InProceedings{burs80 185 | ,key={burstall} 186 | ,author={Burstall, R.M. and MacQueen, D.B. and Sannella, D.T.} 187 | ,title={{HOPE}: An experimental Applicative Language} 188 | ,booktitle={The 1980 LISP Conference} 189 | ,address={Stanford University} 190 | ,year=1980 191 | ,month=aug 192 | ,pages={136--143} 193 | } 194 | 195 | @Article{haskell98, 196 | author = {Simon {Peyton Jones} and others}, 197 | title = {Haskell 98 Language and Libraries: the Revised Report}, 198 | journal = {Journal of Functional Programming}, 199 | year = 2003, 200 | volume = 13, 201 | number = 1, 202 | URL = "http://haskell.org/definition/", 203 | } 204 | 205 | @InProceedings{boehm:finalizers, 206 | author = {{Hans-J.} Boehm}, 207 | title = {Destructors, Finalizers, and Synchronization}, 208 | booktitle = {Proceedings of the 30th {ACM} {SIGPLAN}-{SIGACT} Symposium 209 | on Principles of Programming Languages}, 210 | pages = {262--272}, 211 | year = 2003, 212 | publisher = {ACM Press} 213 | } 214 | 215 | @Book{C, 216 | author = "Brian W. Kernighan and Dennis M. Ritchie", 217 | title = "The C Programming Language", 218 | publisher = "Prentice Hall", 219 | edition = "second", 220 | year = 1988 221 | } 222 | 223 | @Book{gosling-etal:Java, 224 | author = "James Gosling and Bill Joy and Guy Steele", 225 | title = "The {Java} Language Specification", 226 | publisher = "Addison-Wesley", 227 | year = 1997, 228 | series = "The Java Series" 229 | } 230 | 231 | @Book{lindholm-etal:JVM, 232 | author = {Tim Lindholm and Frank Yellin}, 233 | title = {The {Java} Virtual Machine Specification}, 234 | publisher = {Addison-Wesley}, 235 | year = 1996 236 | } 237 | 238 | @Book{liang:JNI, 239 | author = {Sheng Liang}, 240 | title = {The Java Native Interface: Programmer's Guide and 241 | Specification}, 242 | publisher = {Addison Wesley}, 243 | year = 1999 244 | } 245 | 246 | @Misc{C99, 247 | author = {International Standard {ISO/IEC}}, 248 | title = {Programming Languages -- {C}}, 249 | note = {9899:1999 (E)} 250 | } 251 | 252 | 253 | 254 | @Misc{unicode, 255 | author = {Unicode Consortium}, 256 | title = {Unicode Standard}, 257 | note = {\url{http://unicode.org/standard/standard.html}}} 258 | 259 | @inproceedings{damas-milner82, 260 | Author = "Luis Damas and Robin Milner", 261 | Title = "Principal Type-Schemes for Functional Programs", 262 | Publisher = "ACM Press",address="New York", 263 | BookTitle = {Conference Record of the 9th Annual ACM Symposium on Principles of Programming Languages}, 264 | Pages = "207-12", 265 | Year = 1982, 266 | keywords = "Main cite for Damas-Milner type inference" 267 | } 268 | 269 | @article{jones:cclasses, 270 | author = {MP Jones}, 271 | title = {A system of constructor classes: overloading and implicit higher-order polymorphism}, 272 | journal = {Journal of Functional Programming}, 273 | volume = {5}, 274 | number = {1}, 275 | pages = {1-36}, 276 | month = jan, 277 | year = {1995}, 278 | keywords = {Haskell} 279 | } 280 | 281 | -------------------------------------------------------------------------------- /report/report/hprime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/hprime.png -------------------------------------------------------------------------------- /report/report/hprime.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/hprime.ppt -------------------------------------------------------------------------------- /report/report/ht/haddock.sty: -------------------------------------------------------------------------------- 1 | % Modified version of the Haddock style sheet 2 | 3 | \usepackage{tabulary} % see below 4 | 5 | \newenvironment{haddocktitle} 6 | {\begin{center}\bgroup\large\bfseries} 7 | {\egroup\end{center}} 8 | \newenvironment{haddockprologue}{\vspace{1in}}{} 9 | 10 | \newcommand{\haddockmoduleheading}[1]{\chapter{\texttt{#1}}} 11 | 12 | \newcommand{\haddockbeginheader}{\begin{quote}} 13 | \newcommand{\haddockendheader}{\end{quote}} 14 | 15 | % a little gap before the ``Methods'' header 16 | \newcommand{\haddockpremethods}{\vspace{2ex}} 17 | 18 | % inserted before \\begin{verbatim} 19 | \newcommand{\haddockverb}{} 20 | 21 | % an identifier: add an index entry 22 | \newcommand{\haddockid}[1]{\haddocktt{#1}\index{#1@\texttt{#1}}} 23 | 24 | % The tabulary environment lets us have a column that takes up ``the 25 | % rest of the space''. Unfortunately it doesn't allow 26 | % the \end{tabulary} to be in the expansion of a macro, it must appear 27 | % literally in the document text, so Haddock inserts 28 | % the \end{tabulary} itself. 29 | \newcommand{\haddockbeginconstrs}{\begin{tabulary}{\linewidth}{llL}} 30 | \newcommand{\haddockbeginargs}{\begin{tabulary}{\linewidth}{llL}} 31 | 32 | \newcommand{\haddocktt}[1]{{\texttt{#1}}} 33 | \newcommand{\haddockdecltt}[1]{{\bfseries \texttt{#1}}} 34 | 35 | \makeatletter 36 | \newenvironment{haddockdesc} 37 | {\list{}{\labelwidth\z@ \itemindent-\leftmargin 38 | \let\makelabel\haddocklabel}} 39 | {\endlist} 40 | \newcommand*\haddocklabel[1]{\hspace\labelsep\haddockdecltt{#1}} 41 | \makeatother 42 | 43 | % after a declaration, start a new line for the documentation. 44 | % Otherwise, the documentation starts right after the declaration, 45 | % because we're using the list environment and the declaration is the 46 | % ``label''. I tried making this newline part of the label, but 47 | % couldn't get that to work reliably (the space seemed to stretch 48 | % sometimes). 49 | \newcommand{\haddockbegindoc}{} 50 | 51 | % spacing between paragraphs and no \parindent looks better 52 | \parskip=10pt plus2pt minus2pt 53 | \setlength{\parindent}{0cm} 54 | -------------------------------------------------------------------------------- /report/report/ht/haskell.cfg: -------------------------------------------------------------------------------- 1 | \Preamble{xhtml} 2 | 3 | % Don't indent paragraphs in HTML 4 | \Configure{HtmlPar}{ 5 | \HCode{

} 6 | }{ 7 | \HCode{

} 8 | }{}{} 9 | 10 | % No pictures for math 11 | % 12 | \Configure{[]}{$$}{$$} 13 | \Configure{()}{$}{$} 14 | 15 | % Formatting details of signatures descriptions 16 | % 17 | \ConfigureList{haddockdesc}{% 18 | \HCode{

} 19 | }{% 20 | \HCode{
} 21 | }{% 22 | \HCode{
} 23 | }{% 24 | \HCode{
} 25 | } 26 | 27 | %\ConfigureEnv{grammar}{\HCode{
}}{\HCode{
}}{}{} 28 | 29 | \begin{document} 30 | 31 | % Style sheet additions 32 | % 33 | \Css{ 34 | % We like a smaller sans font. 35 | % body { 36 | % font-family: Bitstream Vera Sans, Arial, Helvetica, sans-serif; 37 | % font-size : 14px; 38 | % } 39 | % 40 | % Environment for library signature descriptions. 41 | % - Signatures in dark red 42 | dt.haddockdesc { 43 | color: darkred; 44 | } 45 | % - Avoid too much space between items. 46 | dd.haddockdesc { 47 | padding-bottom: .2em; 48 | } 49 | % - Verbatim displays in item descriptions should not have too wide margins. 50 | % dd.haddockdesc table { 51 | % margin-bottom: -.8em; 52 | % } 53 | % - Paragraph start margin should be smaller in items. 54 | % - Shrink paragraph end margins to avoid gap to next item. 55 | % dd.haddockdesc p { 56 | % margin-top: .5em; 57 | % margin-bottom: 0; 58 | % } 59 | % Otherwise, the font size get's reduced twice. 60 | sub { 61 | font-size: 100\%; 62 | } 63 | % Here we need to reduce, as tex4ht doesn't grok the subscript. 64 | sub.gnterm { 65 | font-size: 70\%; 66 | } 67 | % We don't want tabular's centered; 68 | table.tabular { 69 | margin-left: 1em; 70 | } 71 | % Put verbatim blocks in a grey background. Doesn't look great, not 72 | % all code blocks are in verbatim, some are in math. 73 | % div.verbatim { 74 | % background-color: \#e8e8e8; 75 | % } 76 | % don't center the text in our fboxes 77 | div.center div.fbox { text-align: left; } 78 | % 79 | % get rid of borders on tables 80 | table[rules] { border-left: 0; 81 | border-right: 0; } 82 | } 83 | 84 | \EndPreamble 85 | -------------------------------------------------------------------------------- /report/report/index-extra.verb: -------------------------------------------------------------------------------- 1 | % "see XXX" and "see also YYY" index entries 2 | % 3 | % collected here and inserted at the END of the report 4 | % so that those index entries will always appear LAST 5 | % ------------------------------------------------------------------- 6 | % but first some ... 7 | % 8 | % NOTES ON INDEXING: by Will Partain (partain@@dcs.glasgow.ac.uk) 9 | 10 | % Paul Hudak did the initial selection of index entries for the report 11 | % (version 1.0); I haven't changed that, really. I did the automatic 12 | % indexing of the code in the prelude (Appendix A), and the 13 | % plug-and-chug indexing of the syntax non-terminals. 14 | 15 | % The important thing is consistency! Here's what I've done -- my 16 | % model has been the index for the LaTeX manual. This doesn't mean 17 | % that there aren't plenty of shortcomings. 18 | % 19 | % 1) I always index the singular form, i.e., "file", not "files"; 20 | % "expression", not "expressions". 21 | % 22 | % 2) The tricky part is how to index things that could come under 23 | % several possible titles. Here's an example and how I handled it. 24 | % Let's say we have several index entries for "list expression", 25 | % "conditional expression", and "case expression". 26 | % 27 | % * we want each index entry to appear under exactly one name 28 | % 29 | % * we want other likely/interesting entries to at least be 30 | % cross-referenced. 31 | % 32 | % So: 33 | % 34 | % * put each entry under the straightforward un-reordered thing; 35 | % in the example, "list expression", "case expression", etc. 36 | % 37 | % * under "expression" (a likely place for someone to look), have: 38 | % 39 | % expression 40 | % case, {\em see} case expression 41 | % conditional, {\em see} conditional expression 42 | % list, {\em see} list expression 43 | % ------------------------------------------------------------------- 44 | % 45 | \index{application!function|see{function application}} 46 | \index{application!operator|see{operator application}} 47 | \index{binding!function|see{function binding}} 48 | \index{binding!pattern|see{pattern binding}} 49 | \index{binding!simple pattern|see{simple pattern binding}} 50 | \index{character set!ASCII|see{ASCII character set}} 51 | \index{character set!transparent|see{transparent character set}} 52 | \index{datatype!abstract|see{abstract datatype}} 53 | \index{datatype!algebraic|see{algebraic datatype}} 54 | \index{datatype!declaration|see{{\tt data} declaration}} 55 | \index{datatype!recursive|see{recursive datatype}} 56 | \index{datatype!renaming|see{{\tt newtype} declaration}} 57 | \index{declaration!datatype|see{{\tt data} declaration}} 58 | \index{declaration!class|see{class declaration}} 59 | \index{declaration!instance|see{instance declaration}} 60 | \index{declaration!default|see{{\tt default} declaration}} 61 | \index{declaration!import|see{import declaration}} 62 | \index{declaration!fixity|see{fixity declaration}} 63 | \index{environment!class|see{class environment}} 64 | \index{environment!type|see{type environment}} 65 | \index{expression!type|see{type expression}} 66 | \index{expression!conditional|see{conditional expression}} 67 | \index{expression!unit|see{unit expression}} 68 | \index{expression!let|see{let expression}} 69 | \index{expression!case|see{case expression}} 70 | \index{expression!simple case|see{simple case expression}} 71 | \index{""@@-pattern@@{\tt {\char'100}}|see{as-pattern}} 72 | \index{_@@{\tt {\char'137}}|see{wildcard pattern}} 73 | \index{pattern!""@@-pattern@@{\tt {\char'100}}|see{as-pattern}} 74 | \index{pattern!_@@{\tt {\char'137}}|see{wildcard pattern}} 75 | \index{pattern!constructed|see{constructed pattern}} 76 | \index{pattern!integer|see{integer literal pattern}} 77 | \index{pattern!floating|see{floating literal pattern}} 78 | \index{pattern!linear|see{linear pattern}} 79 | \index{pattern!irrefutable|see{irrefutable pattern}} 80 | \index{pattern!refutable|see{refutable pattern}} 81 | \index{semantics!formal|see{formal semantics}} 82 | \index{string!transparent|see{transparent string}} 83 | \index{type!ambiguous|see{ambiguous type}} 84 | \index{type!monomorphic|see{monomorphic type}} 85 | \index{type!principal|see{principal type}} 86 | \index{type!trivial|see{trivial type}} 87 | \index{type!numeric|see{numeric type}} 88 | \index{type!function|see{function type}} 89 | \index{type!constructed|see{constructed type}} 90 | \index{type!tuple|see{tuple type}} 91 | \index{type!list|see{list type}} 92 | \index{type renaming|see{{\tt newtype} declaration}} 93 | \index{type signature!for an expression|see{expression type-signature}} 94 | % 95 | \index{(aaa)@@{\tt ()}|see{trivial type and unit expression}}% 96 | \index{-@@{\tt -}|hseealso{negation}} 97 | \index{\\@@{\tt {\char'134}}|see{lambda abstraction}} 98 | \index{~@@{\tt {\char'176}}|see{irrefutable pattern}} 99 | \index{derived instance|hseealso{instance declaration}} 100 | \index{if-then-else expression|see{conditional expression}} 101 | \index{instance declaration|hseealso{derived instance}} 102 | \index{layout|hseealso{off-side rule}} 103 | \index{off-side rule|hseealso{layout}} 104 | \index{method|see{class method}} 105 | \index{overloaded pattern|see{pattern-matching}} 106 | \index{precedence|hseealso{fixity}} 107 | \index{section|hseealso{operator application}} 108 | \index{signature|see{type signature}} 109 | \index{standard prelude|hseealso{{\tt Prelude}}} 110 | \index{synonym|see{type synonym}} 111 | \index{type class|see{class}} 112 | \index{type synonym|hseealso{datatype}} 113 | \index{unit datatype|see{trivial type}} 114 | \index{name!qualified|see{qualified name}} 115 | \index{name!special|see{special name}} 116 | -------------------------------------------------------------------------------- /report/report/index-intro.verb: -------------------------------------------------------------------------------- 1 | Index entries that refer to nonterminals in the \Haskell{} syntax are 2 | shown in an "italic" font. Code entities 3 | are shown in @typewriter@ font. Ordinary index entries are 4 | shown in a roman font. 5 | -------------------------------------------------------------------------------- /report/report/index.html: -------------------------------------------------------------------------------- 1 | The Haskell Prime Language Report 2 | 3 |
4 |
5 | Haskell Prime 6 | 7 |

Haskell Prime Language and Libraries

8 |

Working Draft (2007)

9 |
10 |
11 |

Brief Table of Contents

12 | 16 | 17 | 18 | 34 | 35 |
19 |

Part I: Language

20 |
    21 |
  1. Introduction 22 |
  2. Lexical Structure 23 |
  3. Expressions 24 |
  4. Declarations and Bindings 25 |
  5. Modules 26 |
  6. Predefined Types and Classes 27 |
  7. Basic Input/Output 28 |
  8. Standard Prelude 29 |
  9. Syntax Reference 30 |
  10. Specification of Derived Instances 31 |
  11. Compiler Pragmas 32 |
33 |
36 |

Part II: Libraries

37 | 38 | 39 | 51 | 63 |
40 |
    41 |
  1. Ratio 42 |
  2. Complex 43 |
  3. Numeric 44 |
  4. Ix 45 |
  5. Array 46 |
  6. List 47 |
  7. Maybe 48 |
  8. Char 49 |
50 |
52 |
    53 |
  1. Monad 54 |
  2. IO 55 |
  3. Directory 56 |
  4. System 57 |
  5. Time 58 |
  6. Locale 59 |
  7. CPUTime 60 |
  8. Random 61 |
62 |
64 |
65 | 66 | 70 |
71 |
72 | 73 | Simon Peyton Jones, Microsoft Research, Cambridge
74 | 75 | Lennart Augustsson, Sandburst Corporation
76 | 77 | Dave Barton, Intermetrics
78 | 79 | Brian Boutel, Victoria University of Wellington
80 | 81 | Warren Burton, Simon Fraser University
82 | 83 | Joseph Fasel, Los Alamos National Laboratory
84 | 85 | Kevin Hammond, University of St. Andrews
86 | 87 | Ralf Hinze, University of Bonn
88 | 89 | Paul Hudak, Yale University
90 | 91 | John Hughes, Chalmers University of Technology
92 | 93 | Thomas Johnsson, Chalmers University of Technology
94 | 95 | Mark Jones, Oregon Graduate Institute
96 | 97 | John Launchbury, Oregon Graduate Institute
98 | 99 | Erik Meijer, Microsoft Corporation
100 | 101 | John Peterson, Yale University
102 | 103 | Alastair Reid, University of Utah
104 | 105 | Colin Runciman, York University
106 | 107 | Philip Wadler, Avaya Labs
108 |
109 |

110 | Copyright (c) Simon Peyton Jones. 111 |
112 | The authors intend this Report to belong to the entire Haskell 113 | community, and so we grant permission to copy and distribute it for 114 | any purpose, provided that it is reproduced in its entirety, 115 | including this Notice. Modified versions of this Report may also be 116 | copied and distributed for any purpose, provided that the modified 117 | version is clearly presented as such, and that it does not claim to be 118 | a definition of the language Haskell 98. 119 |

120 | 121 | The master version of the Haskell Report is at haskell.org. Any corrections or 123 | changes in the report are found there. 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /report/report/intro.verb: -------------------------------------------------------------------------------- 1 | % 2 | % $Header: /home/cvs/root/haskell-report/report/intro.verb,v 1.7 2002/12/10 11:51:11 simonpj Exp $ 3 | % 4 | %**The Haskell 2010 Report: Introduction 5 | %*section 1 6 | %**~header 7 | \section{Introduction} 8 | \label{introduction} 9 | 10 | \Haskell{}\index{Haskell@@\Haskell{}} is a general purpose, purely functional 11 | programming language incorporating many recent innovations in 12 | programming language design. \Haskell{} provides 13 | higher-order functions, 14 | non-strict semantics, static polymorphic typing, user-defined 15 | algebraic datatypes, pattern-matching, list comprehensions, a module 16 | system, a monadic I/O system, and a rich set of primitive datatypes, 17 | including lists, 18 | arrays, arbitrary and fixed precision integers, and floating-point 19 | numbers. \Haskell{} is both the culmination 20 | and solidification of many years of research on non-strict functional 21 | languages. 22 | 23 | % Although the initial emphasis was on standardization, \Haskell{} 24 | % also has several new features that both simplify and 25 | % generalize the design. For example, 26 | % \begin{enumerate} 27 | % \item Rather than using {\em ad hoc} techniques for 28 | % overloading,\index{overloading} 29 | % \Haskell{} provides an explicit overloading facility, integrated with 30 | % the polymorphic type system\index{type system}, that allows the 31 | % precise definition of overloading behavior for any operator or function. 32 | 33 | % \item The conventional notion of ``abstract data 34 | % type''\index{abstract datatype} 35 | % has been unbundled 36 | % into two orthogonal components: 37 | % data abstraction\index{data abstraction} 38 | % and information hiding.\index{information hiding} 39 | 40 | % \item \Haskell{} has a flexible I/O facility based on the use of 41 | % monads~\cite{Imperative-Functional-Programming}. The system supports 42 | % most of the standard operations provided by conventional operating 43 | % systems while retaining referential transparency within a program. 44 | 45 | % \item Recognising the importance of arrays, \Haskell{} has a 46 | % family of multidimensional non-strict immutable arrays\index{array} 47 | % whose special interaction with list comprehensions provides a 48 | % convenient ``array comprehension'' syntax for defining arrays 49 | % monolithically. 50 | % \end{enumerate} 51 | 52 | This report defines the syntax for \Haskell{} programs and an 53 | informal abstract semantics for the meaning of such 54 | programs. 55 | %; the formal abstract semantics is in preparation.% 56 | \index{formal semantics} 57 | We leave as implementation 58 | dependent the ways in which \Haskell{} programs are to be 59 | manipulated, interpreted, compiled, etc. This includes such issues as 60 | the nature of programming environments and 61 | the error messages returned for undefined programs 62 | (i.e.~programs that formally evaluate to $\bot$). 63 | 64 | \subsection{Program Structure}\index{program structure} 65 | \label{programs} 66 | 67 | In this section, we describe the abstract syntactic and semantic structure of 68 | \Haskell{}, as well as how it relates to the organization of the 69 | rest of the report. 70 | \begin{enumerate} 71 | \item At the topmost level a \Haskell{} program is a set 72 | of {\em modules}, described in Chapter~\ref{modules}. Modules provide 73 | a way to control namespaces 74 | and to re-use software in large programs. 75 | 76 | \item The top level of a module consists of a collection of 77 | {\em declarations}, of which there are several kinds, all described 78 | in Chapter~\ref{declarations}. Declarations 79 | define things such as ordinary values, datatypes, type 80 | classes, and fixity information. 81 | 82 | \item At the next lower level are {\em expressions}, described 83 | in Chapter~\ref{expressions}. An expression denotes a {\em value} 84 | and has a {\em static type}; expressions are at the heart of 85 | \Haskell{} programming ``in the small.'' 86 | 87 | \item At the bottom level is \Haskell{}'s {\em 88 | lexical structure}, defined in Chapter~\ref{lexical-structure}. The 89 | lexical structure captures the concrete 90 | representation of \Haskell{} programs in text files. 91 | 92 | \end{enumerate} 93 | This report proceeds bottom-up with respect 94 | to \Haskell{}'s syntactic structure. 95 | 96 | The chapters not mentioned above are 97 | Chapter~\ref{basic-types-and-classes}, which 98 | describes the standard built-in datatypes and classes in \Haskell{}, and 99 | Chapter~\ref{io}, which discusses the I/O facility in \Haskell{} 100 | (i.e.~how \Haskell{} programs communicate with the outside world). 101 | Also, there are several chapters describing the Prelude, 102 | the concrete syntax, literate programming, the specification of derived 103 | instances, and pragmas supported by most \Haskell{} compilers. 104 | 105 | Examples of \Haskell{} program fragments in running text are given 106 | in typewriter font: 107 | % highlighted with a vertical line to the left of the text: 108 | % as in: 109 | \bprog 110 | @ 111 | let x = 1 112 | z = x+y 113 | in z+1 114 | @ 115 | \eprog 116 | ``Holes'' in program fragments representing arbitrary 117 | pieces of \Haskell{} code are written in italics, as in 118 | "@if@ e_1 @then@ e_2 @else@ e_3". Generally the italicized names are 119 | mnemonic, such as "e" for expressions, "d" for 120 | declarations, "t" for types, etc. 121 | 122 | \subsection{The \Haskell{} Kernel} 123 | \index{Haskell kernel@@\Haskell{} kernel} 124 | \label{intro-kernel} 125 | 126 | \Haskell{} has adopted many of the convenient syntactic structures 127 | that have become popular 128 | in functional programming. In this Report, the meaning of such 129 | syntactic sugar is given by translation into simpler constructs. 130 | If these translations are applied exhaustively, the result is a program 131 | written in a small subset of Haskell that we call the \Haskell{} {\em kernel}. 132 | 133 | Although the kernel is not formally specified, it is essentially a 134 | slightly sugared variant of the lambda calculus with a straightforward 135 | denotational semantics. The translation of each syntactic structure 136 | into the kernel is given as the syntax is introduced. This modular 137 | design facilitates reasoning about \Haskell{} programs and provides 138 | useful guidelines for implementors of the language. 139 | 140 | % In specifying the translation of special syntax, named entities are 141 | % often referred to ``as defined in the standard prelude.'' This means 142 | % that even if these names are rebound (i.e.~the standard prelude name 143 | % is not currently in scope), the translation still takes on the meaning 144 | % as defined in the standard prelude. In other words, the meaning of 145 | % \Haskell{}'s syntax is invariant. 146 | 147 | \subsection{Values and Types} 148 | \index{value}\index{type} 149 | \label{errors}\index{error} 150 | 151 | An expression\index{expression} evaluates to a {\em value} and has a 152 | static {\em type}. Values and types are not mixed in 153 | \Haskell{}. 154 | However, the type system 155 | allows user-defined datatypes of various sorts, and permits not only 156 | parametric polymorphism\index{polymorphism} (using a 157 | traditional Hindley-Milner\index{Hindley-Milner type system} type structure) but 158 | also {\em ad hoc} polymorphism, or {\em overloading} (using 159 | {\em type classes}).\index{type class} 160 | 161 | Errors in \Haskell{} are semantically equivalent to 162 | $\bot$ (``bottom''\index{bottom}). Technically, they are indistinguishable 163 | from nontermination, so the language includes no mechanism 164 | for detecting or acting upon errors. However, implementations 165 | will probably try to provide useful information about 166 | errors. See Section~\ref{basic-errors}. 167 | 168 | 169 | \subsection{Namespaces} 170 | \index{namespaces} 171 | \label{namespaces} 172 | 173 | There are six kinds of names in \Haskell{}: those for {\em variables} and 174 | {\em constructors} denote values; those for {\em type variables}, {\em 175 | type constructors}, and {\em type classes} refer to entities related 176 | to the type system; and {\em module names} refer to modules. 177 | There are two constraints on naming:\nopagebreak[4] 178 | \begin{enumerate} 179 | \item Names for variables and type variables are identifiers beginning 180 | with lowercase letters or underscore; the other four kinds of names are 181 | identifiers beginning with uppercase letters. 182 | \item An identifier must not be used as the name of a type constructor 183 | and a class in the same scope. 184 | \end{enumerate} 185 | These are the only constraints; for example, 186 | @Int@ may simultaneously be the name of a module, class, and constructor 187 | within a single scope. 188 | 189 | 190 | %\subsection{Conformance} 191 | 192 | %A strictly-conforming \Haskell{} implementation implements this 193 | %language definition completely and exactly. A mostly-conforming 194 | %\Haskell{} implementation implements a large subset of this 195 | %definition, and provides full and complete documentation of any 196 | %extensions to or deviations from the specification given here. For 197 | %any conforming implementation, all implementation dependencies which 198 | %are allowed by the standard must be explicitly documented. 199 | 200 | %**~footer 201 | % Local Variables: 202 | % mode: latex 203 | % End: 204 | -------------------------------------------------------------------------------- /report/report/iso-chars.verb: -------------------------------------------------------------------------------- 1 | \newcommand{\Thorn}{Thorn} 2 | \newcommand{\thorn}{thorn} 3 | \newcommand{\Eth}{D\hspace{-7pt}@-@\hspace{2pt}} 4 | \newcommand{\eth}{{\tt d\hspace{-2pt}}\bar{ }\hspace{2pt}} 5 | \newcommand{\macron}{\bar{ }} 6 | \newcommand{\currency}{currency} 7 | \newcommand{\registered}{{\tiny R}\hspace{-8pt}{$\bigcirc$}\hspace{2pt}} 8 | \newcommand{\cents}{@c@\hspace{-5pt}{@|@}\hspace{2pt}} 9 | \newcommand{\degree}{^{\circ}} 10 | \newcommand{\pilcrow}{pilcrow} 11 | \newcommand{\yen}{Y\hspace{-5pt}$_{^{=}}$\hspace{2pt}} 12 | \newcommand{\male}{^a} 13 | \newcommand{\female}{^o} 14 | \newcommand{\brokenline}{\stackrel{_{\mid}}{_{_{\mid}}}} 15 | \newcommand{\isoacute}{\tt \acute{ }} 16 | \newcounter{four} 17 | \setcounter{four}{4} 18 | \newcommand{\isosectionmark}{\fnsymbol{four}} 19 | \newcounter{five} 20 | \setcounter{five}{5} 21 | \newcommand{\isoparamark}{\fnsymbol{five}} 22 | 23 | \newcommand{\ISOiexcl}{\mbox{\tt !`}} 24 | \newcommand{\ISOcent}{\mbox{$\tt \cents$}} 25 | \newcommand{\ISOcurren}{\mbox{$\currency$}} 26 | \newcommand{\ISOpound}{\mbox{\pounds{}}} 27 | \newcommand{\ISOyen}{\mbox{\tt \yen}} 28 | \newcommand{\ISObrkbar}{\mbox{{$\tt \brokenline$}}} 29 | \newcommand{\ISOsect}{\mbox{$\isosectionmark$}} 30 | \newcommand{\ISOuml}{\mbox{${\tt \ddot{ }}$}} 31 | \newcommand{\ISOcopy}{\mbox{${\tt \copyright}$}} 32 | \newcommand{\ISOordf}{\mbox{$\male$}} 33 | \newcommand{\ISOlaquo}{\mbox{$\ll$}} 34 | \newcommand{\ISOnot}{\mbox{$\neg$}} 35 | \newcommand{\ISOshy}{\mbox{${\tt -}$}} 36 | \newcommand{\ISOreg}{\mbox{$${\tt \registered}$$}} 37 | \newcommand{\ISOhibar}{\mbox{${\tt \macron}$}} 38 | \newcommand{\ISOdeg}{\mbox{${\tt \degree}$}} 39 | \newcommand{\ISOplusmn}{\mbox{$\pm$}} 40 | \newcommand{\ISOsuptwo}{\mbox{$^2$}} 41 | \newcommand{\ISOsupthree}{\mbox{$^3$}} 42 | \newcommand{\ISOacute}{\mbox{$\isoacute$}} 43 | \newcommand{\ISOmicro}{\mbox{$\mu$}} 44 | \newcommand{\ISOpara}{\mbox{$\isoparamark$}} 45 | \newcommand{\ISOmiddot}{\mbox{$\cdot$}} 46 | \newcommand{\ISOcedil}{\mbox{$${\tt \c{ }}$$}} 47 | \newcommand{\ISOsupone}{\mbox{$^1$}} 48 | \newcommand{\ISOordm}{\mbox{$\female$}} 49 | \newcommand{\ISOraquo}{\mbox{$\gg$}} 50 | \newcommand{\ISOfracfourth}{\mbox{$\frac{1}{4}$}} 51 | \newcommand{\ISOfrachalf}{\mbox{$\frac{1}{2}$}} 52 | \newcommand{\ISOfracthreeforths}{\mbox{$\frac{3}{4}$}} 53 | \newcommand{\ISOiquest}{\mbox{$${\tt ?`}$$}} 54 | \newcommand{\ISOtimes}{\mbox{$\times$}} 55 | \newcommand{\ISOdivide}{\mbox{$\div$}} 56 | \newcommand{\ISOagrave}{\mbox{${\tt \grave{a}}$}} 57 | \newcommand{\ISOaacute}{\mbox{${\tt \acute{a}}$}} 58 | \newcommand{\ISOacirc}{\mbox{${\tt \hat{a}}$}} 59 | \newcommand{\ISOatilde}{\mbox{${\tt \tilde{a}}$}} 60 | \newcommand{\ISOauml}{\mbox{${\tt \ddot{a}}$}} 61 | \newcommand{\ISOaring}{\mbox{$${\tt \aa}$$}} 62 | \newcommand{\ISOaelig}{\mbox{$${\tt \ae}$$}} 63 | \newcommand{\ISOccedil}{\mbox{$${\tt \c{c}}$$}} 64 | \newcommand{\ISOegrave}{\mbox{${\tt \grave{e}}$}} 65 | \newcommand{\ISOeacute}{\mbox{${\tt \acute{e}}$}} 66 | \newcommand{\ISOecirc}{\mbox{${\tt \hat{e}}$}} 67 | \newcommand{\ISOeuml}{\mbox{${\tt \ddot{e}}$}} 68 | \newcommand{\ISOigrave}{\mbox{${\tt \grave{\i}}$}} 69 | \newcommand{\ISOiacute}{\mbox{${\tt \acute{\i}}$}} 70 | \newcommand{\ISOicirc}{\mbox{${\tt \hat{\i}}$}} 71 | \newcommand{\ISOiuml}{\mbox{${\tt \ddot{\i}}$}} 72 | \newcommand{\ISOeth}{\mbox{$\eth$}} 73 | \newcommand{\ISOntilde}{\mbox{${\tt \tilde{n}}$}} 74 | \newcommand{\ISOograve}{\mbox{${\tt \grave{o}}$}} 75 | \newcommand{\ISOoacute}{\mbox{${\tt \acute{o}}$}} 76 | \newcommand{\ISOocirc}{\mbox{${\tt \hat{o}}$}} 77 | \newcommand{\ISOotilde}{\mbox{${\tt \tilde{o}}$}} 78 | \newcommand{\ISOouml}{\mbox{${\tt \ddot{o}}$}} 79 | \newcommand{\ISOoslash}{\mbox{${\tt \o}$}} 80 | \newcommand{\ISOugrave}{\mbox{${\tt \grave{u}}$}} 81 | \newcommand{\ISOuacute}{\mbox{${\tt \acute{u}}$}} 82 | \newcommand{\ISOucirc}{\mbox{${\tt \hat{u}}$}} 83 | \newcommand{\ISOuuml}{\mbox{${\tt \ddot{u}}$}} 84 | \newcommand{\ISOyacute}{\mbox{${\tt \acute{y}}$}} 85 | \newcommand{\ISOthorn}{\mbox{$\thorn$}} 86 | \newcommand{\ISOyuml}{\mbox{${\tt \ddot{y}}$}} 87 | \newcommand{\ISOAgrave}{\mbox{${\tt \grave{A}}$}} 88 | \newcommand{\ISOAacute}{\mbox{${\tt \acute{A}}$}} 89 | \newcommand{\ISOAcirc}{\mbox{${\tt \hat{A}}$}} 90 | \newcommand{\ISOAtilde}{\mbox{${\tt \tilde{A}}$}} 91 | \newcommand{\ISOAuml}{\mbox{${\tt \ddot{A}}$}} 92 | \newcommand{\ISOAring}{\mbox{$${\tt \AA}$$}} 93 | \newcommand{\ISOAElig}{\mbox{$${\tt \AE}$$}} 94 | \newcommand{\ISOCcedil}{\mbox{$${\tt \c{C}}$$}} 95 | \newcommand{\ISOEgrave}{\mbox{${\tt \grave{E}}$}} 96 | \newcommand{\ISOEacute}{\mbox{${\tt \acute{E}}$}} 97 | \newcommand{\ISOEcirc}{\mbox{${\tt \hat{E}}$}} 98 | \newcommand{\ISOEuml}{\mbox{${\tt \ddot{E}}$}} 99 | \newcommand{\ISOIgrave}{\mbox{${\tt \grave{I}}$}} 100 | \newcommand{\ISOIacute}{\mbox{${\tt \acute{I}}$}} 101 | \newcommand{\ISOIcirc}{\mbox{${\tt \hat{I}}$}} 102 | \newcommand{\ISOIuml}{\mbox{${\tt \ddot{I}}$}} 103 | \newcommand{\ISOETH}{\mbox{${\tt \Eth}$}} 104 | \newcommand{\ISONtilde}{\mbox{${\tt \tilde{N}}$}} 105 | \newcommand{\ISOOgrave}{\mbox{${\tt \grave{O}}$}} 106 | \newcommand{\ISOOacute}{\mbox{${\tt \acute{O}}$}} 107 | \newcommand{\ISOOcirc}{\mbox{${\tt \hat{O}}$}} 108 | \newcommand{\ISOOtilde}{\mbox{${\tt \tilde{O}}$}} 109 | \newcommand{\ISOOuml}{\mbox{${\tt \ddot{O}}$}} 110 | \newcommand{\ISOOslash}{\mbox{${\tt \O}$}} 111 | \newcommand{\ISOUgrave}{\mbox{${\tt \grave{U}}$}} 112 | \newcommand{\ISOUacute}{\mbox{${\tt \acute{U}}$}} 113 | \newcommand{\ISOUcirc}{\mbox{${\tt \hat{U}}$}} 114 | \newcommand{\ISOUuml}{\mbox{${\tt \ddot{U}}$}} 115 | \newcommand{\ISOYacute}{\mbox{${\tt \acute{Y}}$}} 116 | \newcommand{\ISOTHORN}{\mbox{$\Thorn$}} 117 | \newcommand{\ISOszlig}{\mbox{$${\tt \ss}$$}} 118 | -------------------------------------------------------------------------------- /report/report/lambda.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haskell/rfcs/f6cde7832b1e1d686253fe734cf9012a6f3b308f/report/report/lambda.gif -------------------------------------------------------------------------------- /report/report/libs/Data-Bits.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Bits} 2 | \label{module:Data.Bits} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Bits ( 6 | Bits((.&.), 7 | (.|.), 8 | xor, 9 | complement, 10 | shift, 11 | rotate, 12 | bit, 13 | setBit, 14 | clearBit, 15 | complementBit, 16 | testBit, 17 | bitSize, 18 | isSigned, 19 | shiftL, 20 | shiftR, 21 | rotateL, 22 | rotateR) 23 | ) where\end{verbatim}} 24 | \haddockendheader 25 | 26 | This module defines bitwise operations for signed and unsigned 27 | integers. 28 | \par 29 | 30 | \begin{haddockdesc} 31 | \item[\begin{tabular}{@{}l} 32 | class\ Num\ a\ =>\ Bits\ a\ where 33 | \end{tabular}]\haddockbegindoc 34 | The \haddockid{Bits} class defines bitwise operations over integral types. 35 | \par 36 | \begin{itemize} 37 | \item 38 | Bits are numbered from 0 with bit 0 being the least 39 | significant bit. 40 | \par 41 | 42 | \end{itemize} 43 | Minimal complete definition: \haddockid{.{\char '46}.}, \haddockid{.|.}, \haddockid{xor}, \haddockid{complement}, 44 | (\haddockid{shift} or (\haddockid{shiftL} and \haddockid{shiftR})), (\haddockid{rotate} or (\haddockid{rotateL} and \haddockid{rotateR})), 45 | \haddockid{bitSize} and \haddockid{isSigned}. 46 | \par 47 | 48 | \haddockpremethods{}\textbf{Methods} 49 | \begin{haddockdesc} 50 | \item[\begin{tabular}{@{}l} 51 | (.{\char '46}.)\ ::\ a\ ->\ a\ ->\ a 52 | \end{tabular}]\haddockbegindoc 53 | Bitwise "and" 54 | \par 55 | 56 | \end{haddockdesc} 57 | \begin{haddockdesc} 58 | \item[\begin{tabular}{@{}l} 59 | (.|.)\ ::\ a\ ->\ a\ ->\ a 60 | \end{tabular}]\haddockbegindoc 61 | Bitwise "or" 62 | \par 63 | 64 | \end{haddockdesc} 65 | \begin{haddockdesc} 66 | \item[\begin{tabular}{@{}l} 67 | xor\ ::\ a\ ->\ a\ ->\ a 68 | \end{tabular}]\haddockbegindoc 69 | Bitwise "xor" 70 | \par 71 | 72 | \end{haddockdesc} 73 | \begin{haddockdesc} 74 | \item[\begin{tabular}{@{}l} 75 | complement\ ::\ a\ ->\ a 76 | \end{tabular}]\haddockbegindoc 77 | Reverse all the bits in the argument 78 | \par 79 | 80 | \end{haddockdesc} 81 | \begin{haddockdesc} 82 | \item[\begin{tabular}{@{}l} 83 | shift\ ::\ a\ ->\ Int\ ->\ a 84 | \end{tabular}]\haddockbegindoc 85 | \haddocktt{shift\ x\ i} shifts \haddocktt{x} left by \haddocktt{i} bits if \haddocktt{i} is positive, 86 | or right by \haddocktt{-i} bits otherwise. 87 | Right shifts perform sign extension on signed number types; 88 | i.e. they fill the top bits with 1 if the \haddocktt{x} is negative 89 | and with 0 otherwise. 90 | \par 91 | An instance can define either this unified \haddockid{shift} or \haddockid{shiftL} and 92 | \haddockid{shiftR}, depending on which is more convenient for the type in 93 | question. 94 | \par 95 | 96 | \end{haddockdesc} 97 | \begin{haddockdesc} 98 | \item[\begin{tabular}{@{}l} 99 | rotate\ ::\ a\ ->\ Int\ ->\ a 100 | \end{tabular}]\haddockbegindoc 101 | \haddocktt{rotate\ x\ i} rotates \haddocktt{x} left by \haddocktt{i} bits if \haddocktt{i} is positive, 102 | or right by \haddocktt{-i} bits otherwise. 103 | \par 104 | For unbounded types like \haddockid{Integer}, \haddockid{rotate} is equivalent to \haddockid{shift}. 105 | \par 106 | An instance can define either this unified \haddockid{rotate} or \haddockid{rotateL} and 107 | \haddockid{rotateR}, depending on which is more convenient for the type in 108 | question. 109 | \par 110 | 111 | \end{haddockdesc} 112 | \begin{haddockdesc} 113 | \item[\begin{tabular}{@{}l} 114 | bit\ ::\ Int\ ->\ a 115 | \end{tabular}]\haddockbegindoc 116 | \haddocktt{bit\ i} is a value with the \haddocktt{i}th bit set and all other bits clear 117 | \par 118 | 119 | \end{haddockdesc} 120 | \begin{haddockdesc} 121 | \item[\begin{tabular}{@{}l} 122 | setBit\ ::\ a\ ->\ Int\ ->\ a 123 | \end{tabular}]\haddockbegindoc 124 | \haddocktt{x\ `setBit`\ i} is the same as \haddocktt{x\ .|.\ bit\ i} 125 | \par 126 | 127 | \end{haddockdesc} 128 | \begin{haddockdesc} 129 | \item[\begin{tabular}{@{}l} 130 | clearBit\ ::\ a\ ->\ Int\ ->\ a 131 | \end{tabular}]\haddockbegindoc 132 | \haddocktt{x\ `clearBit`\ i} is the same as \haddocktt{x\ .{\char '46}.\ complement\ (bit\ i)} 133 | \par 134 | 135 | \end{haddockdesc} 136 | \begin{haddockdesc} 137 | \item[\begin{tabular}{@{}l} 138 | complementBit\ ::\ a\ ->\ Int\ ->\ a 139 | \end{tabular}]\haddockbegindoc 140 | \haddocktt{x\ `complementBit`\ i} is the same as \haddocktt{x\ `xor`\ bit\ i} 141 | \par 142 | 143 | \end{haddockdesc} 144 | \begin{haddockdesc} 145 | \item[\begin{tabular}{@{}l} 146 | testBit\ ::\ a\ ->\ Int\ ->\ Bool 147 | \end{tabular}]\haddockbegindoc 148 | Return \haddockid{True} if the \haddocktt{n}th bit of the argument is 1 149 | \par 150 | 151 | \end{haddockdesc} 152 | \begin{haddockdesc} 153 | \item[\begin{tabular}{@{}l} 154 | bitSize\ ::\ a\ ->\ Int 155 | \end{tabular}]\haddockbegindoc 156 | Return the number of bits in the type of the argument. The actual 157 | value of the argument is ignored. The function \haddockid{bitSize} is 158 | undefined for types that do not have a fixed bitsize, like \haddockid{Integer}. 159 | \par 160 | 161 | \end{haddockdesc} 162 | \begin{haddockdesc} 163 | \item[\begin{tabular}{@{}l} 164 | isSigned\ ::\ a\ ->\ Bool 165 | \end{tabular}]\haddockbegindoc 166 | Return \haddockid{True} if the argument is a signed type. The actual 167 | value of the argument is ignored 168 | \par 169 | 170 | \end{haddockdesc} 171 | \begin{haddockdesc} 172 | \item[\begin{tabular}{@{}l} 173 | shiftL\ ::\ a\ ->\ Int\ ->\ a 174 | \end{tabular}]\haddockbegindoc 175 | Shift the argument left by the specified number of bits 176 | (which must be non-negative). 177 | \par 178 | An instance can define either this and \haddockid{shiftR} or the unified 179 | \haddockid{shift}, depending on which is more convenient for the type in 180 | question. 181 | \par 182 | 183 | \end{haddockdesc} 184 | \begin{haddockdesc} 185 | \item[\begin{tabular}{@{}l} 186 | shiftR\ ::\ a\ ->\ Int\ ->\ a 187 | \end{tabular}]\haddockbegindoc 188 | Shift the first argument right by the specified number of bits 189 | (which must be non-negative). 190 | Right shifts perform sign extension on signed number types; 191 | i.e. they fill the top bits with 1 if the \haddocktt{x} is negative 192 | and with 0 otherwise. 193 | \par 194 | An instance can define either this and \haddockid{shiftL} or the unified 195 | \haddockid{shift}, depending on which is more convenient for the type in 196 | question. 197 | \par 198 | 199 | \end{haddockdesc} 200 | \begin{haddockdesc} 201 | \item[\begin{tabular}{@{}l} 202 | rotateL\ ::\ a\ ->\ Int\ ->\ a 203 | \end{tabular}]\haddockbegindoc 204 | Rotate the argument left by the specified number of bits 205 | (which must be non-negative). 206 | \par 207 | An instance can define either this and \haddockid{rotateR} or the unified 208 | \haddockid{rotate}, depending on which is more convenient for the type in 209 | question. 210 | \par 211 | 212 | \end{haddockdesc} 213 | \begin{haddockdesc} 214 | \item[\begin{tabular}{@{}l} 215 | rotateR\ ::\ a\ ->\ Int\ ->\ a 216 | \end{tabular}]\haddockbegindoc 217 | Rotate the argument right by the specified number of bits 218 | (which must be non-negative). 219 | \par 220 | An instance can define either this and \haddockid{rotateL} or the unified 221 | \haddockid{rotate}, depending on which is more convenient for the type in 222 | question. 223 | \par 224 | 225 | \end{haddockdesc} 226 | \end{haddockdesc} 227 | \begin{haddockdesc} 228 | \item[\begin{tabular}{@{}l} 229 | instance\ Bits\ Int\\instance\ Bits\ Int8\\instance\ Bits\ Int16\\instance\ Bits\ Int32\\instance\ Bits\ Int64\\instance\ Bits\ Integer\\instance\ Bits\ Word\\instance\ Bits\ Word8\\instance\ Bits\ Word16\\instance\ Bits\ Word32\\instance\ Bits\ Word64\\instance\ Bits\ WordPtr\\instance\ Bits\ IntPtr\\instance\ Bits\ CChar\\instance\ Bits\ CSChar\\instance\ Bits\ CUChar\\instance\ Bits\ CShort\\instance\ Bits\ CUShort\\instance\ Bits\ CInt\\instance\ Bits\ CUInt\\instance\ Bits\ CLong\\instance\ Bits\ CULong\\instance\ Bits\ CLLong\\instance\ Bits\ CULLong\\instance\ Bits\ CPtrdiff\\instance\ Bits\ CSize\\instance\ Bits\ CWchar\\instance\ Bits\ CSigAtomic\\instance\ Bits\ CIntPtr\\instance\ Bits\ CUIntPtr\\instance\ Bits\ CIntMax\\instance\ Bits\ CUIntMax 230 | \end{tabular}] 231 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Data-Complex.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Complex} 2 | \label{module:Data.Complex} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Complex ( 6 | Complex(:+), realPart, imagPart, mkPolar, cis, polar, magnitude, 7 | phase, conjugate 8 | ) where\end{verbatim}} 9 | \haddockendheader 10 | 11 | \section{Rectangular form 12 | } 13 | \begin{haddockdesc} 14 | \item[\begin{tabular}{@{}l} 15 | data\ RealFloat\ a\ =>\ Complex\ a 16 | \end{tabular}]\haddockbegindoc 17 | \haddockbeginconstrs 18 | \haddockdecltt{=} & \haddockdecltt{!a :+ !a} & forms a complex number from its real and imaginary 19 | rectangular components. 20 | \\ 21 | \end{tabulary}\par 22 | Complex numbers are an algebraic type. 23 | \par 24 | For a complex number \haddocktt{z}, \haddocktt{abs\ z} is a number with the magnitude of \haddocktt{z}, 25 | but oriented in the positive real direction, whereas \haddocktt{signum\ z} 26 | has the phase of \haddocktt{z}, but unit magnitude. 27 | \par 28 | 29 | \end{haddockdesc} 30 | \begin{haddockdesc} 31 | \item[\begin{tabular}{@{}l} 32 | instance\ RealFloat\ a\ =>\ Eq\ (Complex\ a)\\instance\ RealFloat\ a\ =>\ Floating\ (Complex\ a)\\instance\ RealFloat\ a\ =>\ Fractional\ (Complex\ a)\\instance\ RealFloat\ a\ =>\ Num\ (Complex\ a)\\instance\ (Read\ a,\ RealFloat\ a)\ =>\ Read\ (Complex\ a)\\instance\ RealFloat\ a\ =>\ Show\ (Complex\ a) 33 | \end{tabular}] 34 | \end{haddockdesc} 35 | \begin{haddockdesc} 36 | \item[\begin{tabular}{@{}l} 37 | realPart\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ a 38 | \end{tabular}]\haddockbegindoc 39 | Extracts the real part of a complex number. 40 | \par 41 | 42 | \end{haddockdesc} 43 | \begin{haddockdesc} 44 | \item[\begin{tabular}{@{}l} 45 | imagPart\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ a 46 | \end{tabular}]\haddockbegindoc 47 | Extracts the imaginary part of a complex number. 48 | \par 49 | 50 | \end{haddockdesc} 51 | \section{Polar form 52 | } 53 | \begin{haddockdesc} 54 | \item[\begin{tabular}{@{}l} 55 | mkPolar\ ::\ RealFloat\ a\ =>\ a\ ->\ a\ ->\ Complex\ a 56 | \end{tabular}]\haddockbegindoc 57 | Form a complex number from polar components of magnitude and phase. 58 | \par 59 | 60 | \end{haddockdesc} 61 | \begin{haddockdesc} 62 | \item[\begin{tabular}{@{}l} 63 | cis\ ::\ RealFloat\ a\ =>\ a\ ->\ Complex\ a 64 | \end{tabular}]\haddockbegindoc 65 | \haddocktt{cis\ t} is a complex value with magnitude \haddocktt{1} 66 | and phase \haddocktt{t} (modulo \haddocktt{2*pi}). 67 | \par 68 | 69 | \end{haddockdesc} 70 | \begin{haddockdesc} 71 | \item[\begin{tabular}{@{}l} 72 | polar\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ (a,\ a) 73 | \end{tabular}]\haddockbegindoc 74 | The function \haddockid{polar} takes a complex number and 75 | returns a (magnitude, phase) pair in canonical form: 76 | the magnitude is nonnegative, and the phase in the range \haddocktt{(-pi,\ pi{\char 93}}; 77 | if the magnitude is zero, then so is the phase. 78 | \par 79 | 80 | \end{haddockdesc} 81 | \begin{haddockdesc} 82 | \item[\begin{tabular}{@{}l} 83 | magnitude\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ a 84 | \end{tabular}]\haddockbegindoc 85 | The nonnegative magnitude of a complex number. 86 | \par 87 | 88 | \end{haddockdesc} 89 | \begin{haddockdesc} 90 | \item[\begin{tabular}{@{}l} 91 | phase\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ a 92 | \end{tabular}]\haddockbegindoc 93 | The phase of a complex number, in the range \haddocktt{(-pi,\ pi{\char 93}}. 94 | If the magnitude is zero, then so is the phase. 95 | \par 96 | 97 | \end{haddockdesc} 98 | \section{Conjugate 99 | } 100 | \begin{haddockdesc} 101 | \item[\begin{tabular}{@{}l} 102 | conjugate\ ::\ RealFloat\ a\ =>\ Complex\ a\ ->\ Complex\ a 103 | \end{tabular}]\haddockbegindoc 104 | The conjugate of a complex number. 105 | \par 106 | 107 | \end{haddockdesc} 108 | \section{Specification 109 | } 110 | \begin{quote} 111 | {\haddockverb\begin{verbatim} 112 | module Data.Complex(Complex((:+)), realPart, imagPart, conjugate, mkPolar, 113 | cis, polar, magnitude, phase) where 114 | 115 | infix 6 :+ 116 | 117 | data (RealFloat a) => Complex a = !a :+ !a deriving (Eq,Read,Show) 118 | 119 | 120 | realPart, imagPart :: (RealFloat a) => Complex a -> a 121 | realPart (x:+y) = x 122 | imagPart (x:+y) = y 123 | 124 | conjugate :: (RealFloat a) => Complex a -> Complex a 125 | conjugate (x:+y) = x :+ (-y) 126 | 127 | mkPolar :: (RealFloat a) => a -> a -> Complex a 128 | mkPolar r theta = r * cos theta :+ r * sin theta 129 | 130 | cis :: (RealFloat a) => a -> Complex a 131 | cis theta = cos theta :+ sin theta 132 | 133 | polar :: (RealFloat a) => Complex a -> (a,a) 134 | polar z = (magnitude z, phase z) 135 | 136 | magnitude :: (RealFloat a) => Complex a -> a 137 | magnitude (x:+y) = scaleFloat k 138 | (sqrt ((scaleFloat mk x)^2 + (scaleFloat mk y)^2)) 139 | where k = max (exponent x) (exponent y) 140 | mk = - k 141 | 142 | phase :: (RealFloat a) => Complex a -> a 143 | phase (0 :+ 0) = 0 144 | phase (x :+ y) = atan2 y x 145 | 146 | 147 | instance (RealFloat a) => Num (Complex a) where 148 | (x:+y) + (x':+y') = (x+x') :+ (y+y') 149 | (x:+y) - (x':+y') = (x-x') :+ (y-y') 150 | (x:+y) * (x':+y') = (x*x'-y*y') :+ (x*y'+y*x') 151 | negate (x:+y) = negate x :+ negate y 152 | abs z = magnitude z :+ 0 153 | signum 0 = 0 154 | signum z@(x:+y) = x/r :+ y/r where r = magnitude z 155 | fromInteger n = fromInteger n :+ 0 156 | 157 | instance (RealFloat a) => Fractional (Complex a) where 158 | (x:+y) / (x':+y') = (x*x''+y*y'') / d :+ (y*x''-x*y'') / d 159 | where x'' = scaleFloat k x' 160 | y'' = scaleFloat k y' 161 | k = - max (exponent x') (exponent y') 162 | d = x'*x'' + y'*y'' 163 | 164 | fromRational a = fromRational a :+ 0 165 | 166 | instance (RealFloat a) => Floating (Complex a) where 167 | pi = pi :+ 0 168 | exp (x:+y) = expx * cos y :+ expx * sin y 169 | where expx = exp x 170 | log z = log (magnitude z) :+ phase z 171 | 172 | sqrt 0 = 0 173 | sqrt z@(x:+y) = u :+ (if y < 0 then -v else v) 174 | where (u,v) = if x < 0 then (v',u') else (u',v') 175 | v' = abs y / (u'*2) 176 | u' = sqrt ((magnitude z + abs x) / 2) 177 | 178 | sin (x:+y) = sin x * cosh y :+ cos x * sinh y 179 | cos (x:+y) = cos x * cosh y :+ (- sin x * sinh y) 180 | tan (x:+y) = (sinx*coshy:+cosx*sinhy)/(cosx*coshy:+(-sinx*sinhy)) 181 | where sinx = sin x 182 | cosx = cos x 183 | sinhy = sinh y 184 | coshy = cosh y 185 | 186 | sinh (x:+y) = cos y * sinh x :+ sin y * cosh x 187 | cosh (x:+y) = cos y * cosh x :+ sin y * sinh x 188 | tanh (x:+y) = (cosy*sinhx:+siny*coshx)/(cosy*coshx:+siny*sinhx) 189 | where siny = sin y 190 | cosy = cos y 191 | sinhx = sinh x 192 | coshx = cosh x 193 | 194 | asin z@(x:+y) = y':+(-x') 195 | where (x':+y') = log (((-y):+x) + sqrt (1 - z*z)) 196 | acos z@(x:+y) = y'':+(-x'') 197 | where (x'':+y'') = log (z + ((-y'):+x')) 198 | (x':+y') = sqrt (1 - z*z) 199 | atan z@(x:+y) = y':+(-x') 200 | where (x':+y') = log (((1-y):+x) / sqrt (1+z*z)) 201 | 202 | asinh z = log (z + sqrt (1+z*z)) 203 | acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1))) 204 | atanh z = log ((1+z) / sqrt (1-z*z)) 205 | 206 | \end{verbatim}} 207 | \end{quote} 208 | -------------------------------------------------------------------------------- /report/report/libs/Data-Int.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Int} 2 | \label{module:Data.Int} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Int ( 6 | Int, Int8, Int16, Int32, Int64 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \section{Signed integer types 11 | } 12 | This module provides signed integer types of unspecified width (\haddockid{Int}) 13 | and fixed widths (\haddockid{Int8}, \haddockid{Int16}, \haddockid{Int32} and \haddockid{Int64}). All 14 | arithmetic is performed modulo 2{\char '136}n, where \haddocktt{n} is the number of bits in 15 | the type. 16 | \par 17 | For coercing between any two integer types, use 18 | \haddockid{fromIntegral}. Coercing word types (see \haddocktt{Data.Word}) to and 19 | from integer types preserves representation, not sign. 20 | \par 21 | The rules that hold for \haddockid{Enum} instances over a bounded type 22 | such as \haddockid{Int} (see the section of the Haskell language report dealing with 23 | arithmetic sequences) also hold for the \haddockid{Enum} instances over 24 | the various \haddockid{Int} types defined here. 25 | \par 26 | Right and left shifts by amounts greater than or equal to the width of 27 | the type result in either zero or -1, depending on the sign of the 28 | value being shifted. This is contrary to the behaviour in C, which is 29 | undefined; a common interpretation is to truncate the shift count to 30 | the width of the type, for example \haddocktt{1\ <<\ 32\ ==\ 1} in some C 31 | implementations. 32 | \par 33 | 34 | \begin{haddockdesc} 35 | \item[\begin{tabular}{@{}l} 36 | data\ Int 37 | \end{tabular}]\haddockbegindoc 38 | A fixed-precision integer type with at least the range \haddocktt{{\char 91}-2{\char '136}29\ ..\ 2{\char '136}29-1{\char 93}}. 39 | The exact range for a given implementation can be determined by using 40 | \haddocktt{Prelude.minBound} and \haddocktt{Prelude.maxBound} from the \haddocktt{Prelude.Bounded} class. 41 | \par 42 | 43 | \end{haddockdesc} 44 | \begin{haddockdesc} 45 | \item[\begin{tabular}{@{}l} 46 | instance\ Bounded\ Int\\instance\ Enum\ Int\\instance\ Eq\ Int\\instance\ Integral\ Int\\instance\ Num\ Int\\instance\ Ord\ Int\\instance\ Read\ Int\\instance\ Real\ Int\\instance\ Show\ Int\\instance\ Ix\ Int\\instance\ Storable\ Int\\instance\ Bits\ Int 47 | \end{tabular}] 48 | \end{haddockdesc} 49 | \begin{haddockdesc} 50 | \item[\begin{tabular}{@{}l} 51 | data\ Int8 52 | \end{tabular}]\haddockbegindoc 53 | 8-bit signed integer type 54 | \par 55 | 56 | \end{haddockdesc} 57 | \begin{haddockdesc} 58 | \item[\begin{tabular}{@{}l} 59 | instance\ Bounded\ Int8\\instance\ Enum\ Int8\\instance\ Eq\ Int8\\instance\ Integral\ Int8\\instance\ Num\ Int8\\instance\ Ord\ Int8\\instance\ Read\ Int8\\instance\ Real\ Int8\\instance\ Show\ Int8\\instance\ Ix\ Int8\\instance\ Storable\ Int8\\instance\ Bits\ Int8 60 | \end{tabular}] 61 | \end{haddockdesc} 62 | \begin{haddockdesc} 63 | \item[\begin{tabular}{@{}l} 64 | data\ Int16 65 | \end{tabular}]\haddockbegindoc 66 | 16-bit signed integer type 67 | \par 68 | 69 | \end{haddockdesc} 70 | \begin{haddockdesc} 71 | \item[\begin{tabular}{@{}l} 72 | instance\ Bounded\ Int16\\instance\ Enum\ Int16\\instance\ Eq\ Int16\\instance\ Integral\ Int16\\instance\ Num\ Int16\\instance\ Ord\ Int16\\instance\ Read\ Int16\\instance\ Real\ Int16\\instance\ Show\ Int16\\instance\ Ix\ Int16\\instance\ Storable\ Int16\\instance\ Bits\ Int16 73 | \end{tabular}] 74 | \end{haddockdesc} 75 | \begin{haddockdesc} 76 | \item[\begin{tabular}{@{}l} 77 | data\ Int32 78 | \end{tabular}]\haddockbegindoc 79 | 32-bit signed integer type 80 | \par 81 | 82 | \end{haddockdesc} 83 | \begin{haddockdesc} 84 | \item[\begin{tabular}{@{}l} 85 | instance\ Bounded\ Int32\\instance\ Enum\ Int32\\instance\ Eq\ Int32\\instance\ Integral\ Int32\\instance\ Num\ Int32\\instance\ Ord\ Int32\\instance\ Read\ Int32\\instance\ Real\ Int32\\instance\ Show\ Int32\\instance\ Ix\ Int32\\instance\ Storable\ Int32\\instance\ Bits\ Int32 86 | \end{tabular}] 87 | \end{haddockdesc} 88 | \begin{haddockdesc} 89 | \item[\begin{tabular}{@{}l} 90 | data\ Int64 91 | \end{tabular}]\haddockbegindoc 92 | 64-bit signed integer type 93 | \par 94 | 95 | \end{haddockdesc} 96 | \begin{haddockdesc} 97 | \item[\begin{tabular}{@{}l} 98 | instance\ Bounded\ Int64\\instance\ Enum\ Int64\\instance\ Eq\ Int64\\instance\ Integral\ Int64\\instance\ Num\ Int64\\instance\ Ord\ Int64\\instance\ Read\ Int64\\instance\ Real\ Int64\\instance\ Show\ Int64\\instance\ Ix\ Int64\\instance\ Storable\ Int64\\instance\ Bits\ Int64 99 | \end{tabular}] 100 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Data-Ix.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Ix} 2 | \label{module:Data.Ix} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Ix ( 6 | Ix(range, index, inRange, rangeSize) 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \section{The \haddockid{Ix} class 11 | } 12 | \begin{haddockdesc} 13 | \item[\begin{tabular}{@{}l} 14 | class\ Ord\ a\ =>\ Ix\ a\ where 15 | \end{tabular}]\haddockbegindoc 16 | The \haddockid{Ix} class is used to map a contiguous subrange of values in 17 | a type onto integers. It is used primarily for array indexing 18 | (see the array package). 19 | \par 20 | The first argument \haddocktt{(l,u)} of each of these operations is a pair 21 | specifying the lower and upper bounds of a contiguous subrange of values. 22 | \par 23 | An implementation is entitled to assume the following laws about these 24 | operations: 25 | \par 26 | \begin{itemize} 27 | \item 28 | \haddocktt{inRange\ (l,u)\ i\ ==\ elem\ i\ (range\ (l,u))} \haddocktt{\ } 29 | \par 30 | 31 | \item 32 | \haddocktt{range\ (l,u)\ !!\ index\ (l,u)\ i\ ==\ i}, when \haddocktt{inRange\ (l,u)\ i} 33 | \par 34 | 35 | \item 36 | \haddocktt{map\ (index\ (l,u))\ (range\ (l,u)))\ ==\ {\char 91}0..rangeSize\ (l,u)-1{\char 93}} \haddocktt{\ } 37 | \par 38 | 39 | \item 40 | \haddocktt{rangeSize\ (l,u)\ ==\ length\ (range\ (l,u))} \haddocktt{\ } 41 | \par 42 | 43 | \end{itemize} 44 | Minimal complete instance: \haddockid{range}, \haddockid{index} and \haddockid{inRange}. 45 | \par 46 | 47 | \haddockpremethods{}\textbf{Methods} 48 | \begin{haddockdesc} 49 | \item[\begin{tabular}{@{}l} 50 | range\ ::\ (a,\ a)\ ->\ {\char 91}a{\char 93} 51 | \end{tabular}]\haddockbegindoc 52 | The list of values in the subrange defined by a bounding pair. 53 | \par 54 | 55 | \end{haddockdesc} 56 | \begin{haddockdesc} 57 | \item[\begin{tabular}{@{}l} 58 | index\ ::\ (a,\ a)\ ->\ a\ ->\ Int 59 | \end{tabular}]\haddockbegindoc 60 | The position of a subscript in the subrange. 61 | \par 62 | 63 | \end{haddockdesc} 64 | \begin{haddockdesc} 65 | \item[\begin{tabular}{@{}l} 66 | inRange\ ::\ (a,\ a)\ ->\ a\ ->\ Bool 67 | \end{tabular}]\haddockbegindoc 68 | Returns \haddockid{True} the given subscript lies in the range defined 69 | the bounding pair. 70 | \par 71 | 72 | \end{haddockdesc} 73 | \begin{haddockdesc} 74 | \item[\begin{tabular}{@{}l} 75 | rangeSize\ ::\ (a,\ a)\ ->\ Int 76 | \end{tabular}]\haddockbegindoc 77 | The size of the subrange defined by a bounding pair. 78 | \par 79 | 80 | \end{haddockdesc} 81 | \end{haddockdesc} 82 | \begin{haddockdesc} 83 | \item[\begin{tabular}{@{}l} 84 | instance\ Ix\ Bool\\instance\ Ix\ Char\\instance\ Ix\ Int\\instance\ Ix\ Int8\\instance\ Ix\ Int16\\instance\ Ix\ Int32\\instance\ Ix\ Int64\\instance\ Ix\ Integer\\instance\ Ix\ Ordering\\instance\ Ix\ Word\\instance\ Ix\ Word8\\instance\ Ix\ Word16\\instance\ Ix\ Word32\\instance\ Ix\ Word64\\instance\ Ix\ ()\\instance\ Ix\ GeneralCategory\\instance\ Ix\ SeekMode\\instance\ Ix\ IOMode\\instance\ (Ix\ a,\ Ix\ b)\ =>\ Ix\ (a,\ b)\\instance\ (Ix\ a1,\ Ix\ a2,\ Ix\ a3)\ =>\ Ix\ (a1,\ a2,\ a3)\\instance\ (Ix\ a1,\ Ix\ a2,\ Ix\ a3,\ Ix\ a4)\ =>\ Ix\ (a1,\ a2,\ a3,\ a4)\\instance\ (Ix\ a1,\ Ix\ a2,\ Ix\ a3,\ Ix\ a4,\ Ix\ a5)\ =>\ Ix\ (a1,\ a2,\ a3,\ a4,\ a5) 85 | \end{tabular}] 86 | \end{haddockdesc} 87 | \section{Deriving Instances of \haddocktt{Ix} 88 | } 89 | It is possible to derive an instance of \haddocktt{Ix} automatically, using 90 | a \haddocktt{deriving} clause on a \haddocktt{data} declaration. 91 | Such derived instance declarations for the class \haddocktt{Ix} are only possible 92 | for enumerations (i.e. datatypes having 93 | only nullary constructors) and single-constructor datatypes, 94 | whose constituent types are instances of \haddocktt{Ix}. A Haskell implementation 95 | must provide \haddocktt{Ix} instances for tuples up to at least size 15. 96 | \par 97 | For an \emph{enumeration}, the nullary constructors are assumed to be 98 | numbered left-to-right with the indices being 0 to n-1 inclusive. 99 | This is the same numbering defined by the \haddocktt{Enum} class. For example, 100 | given the datatype: 101 | \par 102 | \begin{quote} 103 | {\haddockverb\begin{verbatim} 104 | data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet 105 | \end{verbatim}} 106 | \end{quote} 107 | we would have: 108 | \par 109 | \begin{quote} 110 | {\haddockverb\begin{verbatim} 111 | range (Yellow,Blue) == [Yellow,Green,Blue] 112 | index (Yellow,Blue) Green == 1 113 | inRange (Yellow,Blue) Red == False 114 | \end{verbatim}} 115 | \end{quote} 116 | For \emph{single-constructor datatypes}, the derived instance declarations 117 | are as shown for tuples: 118 | \par 119 | \begin{quote} 120 | {\haddockverb\begin{verbatim} 121 | instance (Ix a, Ix b) => Ix (a,b) where 122 | range ((l,l'),(u,u')) 123 | = [(i,i') | i <- range (l,u), i' <- range (l',u')] 124 | index ((l,l'),(u,u')) (i,i') 125 | = index (l,u) i * rangeSize (l',u') + index (l',u') i' 126 | inRange ((l,l'),(u,u')) (i,i') 127 | = inRange (l,u) i && inRange (l',u') i' 128 | 129 | -- Instances for other tuples are obtained from this scheme: 130 | -- 131 | -- instance (Ix a1, Ix a2, ... , Ix ak) => Ix (a1,a2,...,ak) where 132 | -- range ((l1,l2,...,lk),(u1,u2,...,uk)) = 133 | -- [(i1,i2,...,ik) | i1 <- range (l1,u1), 134 | -- i2 <- range (l2,u2), 135 | -- ... 136 | -- ik <- range (lk,uk)] 137 | -- 138 | -- index ((l1,l2,...,lk),(u1,u2,...,uk)) (i1,i2,...,ik) = 139 | -- index (lk,uk) ik + rangeSize (lk,uk) * ( 140 | -- index (lk-1,uk-1) ik-1 + rangeSize (lk-1,uk-1) * ( 141 | -- ... 142 | -- index (l1,u1))) 143 | -- 144 | -- inRange ((l1,l2,...lk),(u1,u2,...,uk)) (i1,i2,...,ik) = 145 | -- inRange (l1,u1) i1 && inRange (l2,u2) i2 && 146 | -- ... && inRange (lk,uk) ik 147 | \end{verbatim}} 148 | \end{quote} 149 | -------------------------------------------------------------------------------- /report/report/libs/Data-Maybe.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Maybe} 2 | \label{module:Data.Maybe} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Maybe ( 6 | Maybe(Nothing, Just), maybe, isJust, isNothing, fromJust, fromMaybe, 7 | listToMaybe, maybeToList, catMaybes, mapMaybe 8 | ) where\end{verbatim}} 9 | \haddockendheader 10 | 11 | \section{The \haddocktt{Maybe} type and operations 12 | } 13 | \begin{haddockdesc} 14 | \item[\begin{tabular}{@{}l} 15 | data\ Maybe\ a 16 | \end{tabular}]\haddockbegindoc 17 | \haddockbeginconstrs 18 | \haddockdecltt{=} & \haddockdecltt{Nothing} & \\ 19 | \haddockdecltt{|} & \haddockdecltt{Just a} & \\ 20 | \end{tabulary}\par 21 | The \haddockid{Maybe} type encapsulates an optional value. A value of type 22 | \haddocktt{Maybe\ a} either contains a value of type \haddocktt{a} (represented as \haddocktt{Just\ a}), 23 | or it is empty (represented as \haddockid{Nothing}). Using \haddockid{Maybe} is a good way to 24 | deal with errors or exceptional cases without resorting to drastic 25 | measures such as \haddockid{error}. 26 | \par 27 | The \haddockid{Maybe} type is also a monad. It is a simple kind of error 28 | monad, where all errors are represented by \haddockid{Nothing}. A richer 29 | error monad can be built using the \haddocktt{Data.Either.Either} type. 30 | \par 31 | 32 | \end{haddockdesc} 33 | \begin{haddockdesc} 34 | \item[\begin{tabular}{@{}l} 35 | instance\ Monad\ Maybe\\instance\ Functor\ Maybe\\instance\ MonadPlus\ Maybe\\instance\ Eq\ a\ =>\ Eq\ (Maybe\ a)\\instance\ Ord\ a\ =>\ Ord\ (Maybe\ a)\\instance\ Read\ a\ =>\ Read\ (Maybe\ a)\\instance\ Show\ a\ =>\ Show\ (Maybe\ a) 36 | \end{tabular}] 37 | \end{haddockdesc} 38 | \begin{haddockdesc} 39 | \item[\begin{tabular}{@{}l} 40 | maybe\ ::\ b\ ->\ (a\ ->\ b)\ ->\ Maybe\ a\ ->\ b 41 | \end{tabular}]\haddockbegindoc 42 | The \haddockid{maybe} function takes a default value, a function, and a \haddockid{Maybe} 43 | value. If the \haddockid{Maybe} value is \haddockid{Nothing}, the function returns the 44 | default value. Otherwise, it applies the function to the value inside 45 | the \haddockid{Just} and returns the result. 46 | \par 47 | 48 | \end{haddockdesc} 49 | \begin{haddockdesc} 50 | \item[\begin{tabular}{@{}l} 51 | isJust\ ::\ Maybe\ a\ ->\ Bool 52 | \end{tabular}]\haddockbegindoc 53 | The \haddockid{isJust} function returns \haddockid{True} iff its argument is of the 54 | form \haddocktt{Just\ {\char '137}}. 55 | \par 56 | 57 | \end{haddockdesc} 58 | \begin{haddockdesc} 59 | \item[\begin{tabular}{@{}l} 60 | isNothing\ ::\ Maybe\ a\ ->\ Bool 61 | \end{tabular}]\haddockbegindoc 62 | The \haddockid{isNothing} function returns \haddockid{True} iff its argument is \haddockid{Nothing}. 63 | \par 64 | 65 | \end{haddockdesc} 66 | \begin{haddockdesc} 67 | \item[\begin{tabular}{@{}l} 68 | fromJust\ ::\ Maybe\ a\ ->\ a 69 | \end{tabular}]\haddockbegindoc 70 | The \haddockid{fromJust} function extracts the element out of a \haddockid{Just} and 71 | throws an error if its argument is \haddockid{Nothing}. 72 | \par 73 | 74 | \end{haddockdesc} 75 | \begin{haddockdesc} 76 | \item[\begin{tabular}{@{}l} 77 | fromMaybe\ ::\ a\ ->\ Maybe\ a\ ->\ a 78 | \end{tabular}]\haddockbegindoc 79 | The \haddockid{fromMaybe} function takes a default value and and \haddockid{Maybe} 80 | value. If the \haddockid{Maybe} is \haddockid{Nothing}, it returns the default values; 81 | otherwise, it returns the value contained in the \haddockid{Maybe}. 82 | \par 83 | 84 | \end{haddockdesc} 85 | \begin{haddockdesc} 86 | \item[\begin{tabular}{@{}l} 87 | listToMaybe\ ::\ {\char 91}a{\char 93}\ ->\ Maybe\ a 88 | \end{tabular}]\haddockbegindoc 89 | The \haddockid{listToMaybe} function returns \haddockid{Nothing} on an empty list 90 | or \haddocktt{Just\ a} where \haddocktt{a} is the first element of the list. 91 | \par 92 | 93 | \end{haddockdesc} 94 | \begin{haddockdesc} 95 | \item[\begin{tabular}{@{}l} 96 | maybeToList\ ::\ Maybe\ a\ ->\ {\char 91}a{\char 93} 97 | \end{tabular}]\haddockbegindoc 98 | The \haddockid{maybeToList} function returns an empty list when given 99 | \haddockid{Nothing} or a singleton list when not given \haddockid{Nothing}. 100 | \par 101 | 102 | \end{haddockdesc} 103 | \begin{haddockdesc} 104 | \item[\begin{tabular}{@{}l} 105 | catMaybes\ ::\ {\char 91}Maybe\ a{\char 93}\ ->\ {\char 91}a{\char 93} 106 | \end{tabular}]\haddockbegindoc 107 | The \haddockid{catMaybes} function takes a list of \haddockid{Maybe}s and returns 108 | a list of all the \haddockid{Just} values. 109 | \par 110 | 111 | \end{haddockdesc} 112 | \begin{haddockdesc} 113 | \item[\begin{tabular}{@{}l} 114 | mapMaybe\ ::\ (a\ ->\ Maybe\ b)\ ->\ {\char 91}a{\char 93}\ ->\ {\char 91}b{\char 93} 115 | \end{tabular}]\haddockbegindoc 116 | The \haddockid{mapMaybe} function is a version of \haddockid{map} which can throw 117 | out elements. In particular, the functional argument returns 118 | something of type \haddocktt{Maybe\ b}. If this is \haddockid{Nothing}, no element 119 | is added on to the result list. If it just \haddocktt{Just\ b}, then \haddocktt{b} is 120 | included in the result list. 121 | \par 122 | 123 | \end{haddockdesc} 124 | \section{Specification 125 | } 126 | \begin{quote} 127 | {\haddockverb\begin{verbatim} 128 | module Data.Maybe( 129 | Maybe(Nothing, Just), 130 | isJust, isNothing, 131 | fromJust, fromMaybe, listToMaybe, maybeToList, 132 | catMaybes, mapMaybe, 133 | maybe 134 | ) where 135 | 136 | maybe :: b -> (a -> b) -> Maybe a -> b 137 | maybe n _ Nothing = n 138 | maybe _ f (Just x) = f x 139 | 140 | isJust :: Maybe a -> Bool 141 | isJust (Just a) = True 142 | isJust Nothing = False 143 | 144 | isNothing :: Maybe a -> Bool 145 | isNothing = not . isJust 146 | 147 | fromJust :: Maybe a -> a 148 | fromJust (Just a) = a 149 | fromJust Nothing = error "Maybe.fromJust: Nothing" 150 | 151 | fromMaybe :: a -> Maybe a -> a 152 | fromMaybe d Nothing = d 153 | fromMaybe d (Just a) = a 154 | 155 | maybeToList :: Maybe a -> [a] 156 | maybeToList Nothing = [] 157 | maybeToList (Just a) = [a] 158 | 159 | listToMaybe :: [a] -> Maybe a 160 | listToMaybe [] = Nothing 161 | listToMaybe (a:_) = Just a 162 | 163 | catMaybes :: [Maybe a] -> [a] 164 | catMaybes ms = [ m | Just m <- ms ] 165 | 166 | mapMaybe :: (a -> Maybe b) -> [a] -> [b] 167 | mapMaybe f = catMaybes . map f 168 | \end{verbatim}} 169 | \end{quote} 170 | -------------------------------------------------------------------------------- /report/report/libs/Data-Ratio.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Ratio} 2 | \label{module:Data.Ratio} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Ratio ( 6 | Ratio, Rational, (%), numerator, denominator, approxRational 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \begin{haddockdesc} 11 | \item[\begin{tabular}{@{}l} 12 | data\ Integral\ a\ =>\ Ratio\ a 13 | \end{tabular}]\haddockbegindoc 14 | Rational numbers, with numerator and denominator of some \haddockid{Integral} type. 15 | \par 16 | 17 | \end{haddockdesc} 18 | \begin{haddockdesc} 19 | \item[\begin{tabular}{@{}l} 20 | instance\ Integral\ a\ =>\ Enum\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Eq\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Fractional\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Num\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Ord\ (Ratio\ a)\\instance\ (Integral\ a,\ Read\ a)\ =>\ Read\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Real\ (Ratio\ a)\\instance\ Integral\ a\ =>\ RealFrac\ (Ratio\ a)\\instance\ Integral\ a\ =>\ Show\ (Ratio\ a) 21 | \end{tabular}] 22 | \end{haddockdesc} 23 | \begin{haddockdesc} 24 | \item[\begin{tabular}{@{}l} 25 | type\ Rational\ =\ Ratio\ Integer 26 | \end{tabular}]\haddockbegindoc 27 | Arbitrary-precision rational numbers, represented as a ratio of 28 | two \haddockid{Integer} values. A rational number may be constructed using 29 | the \haddockid{{\char '45}} operator. 30 | \par 31 | 32 | \end{haddockdesc} 33 | \begin{haddockdesc} 34 | \item[\begin{tabular}{@{}l} 35 | ({\char '45})\ ::\ Integral\ a\ =>\ a\ ->\ a\ ->\ Ratio\ a 36 | \end{tabular}]\haddockbegindoc 37 | Forms the ratio of two integral numbers. 38 | \par 39 | 40 | \end{haddockdesc} 41 | \begin{haddockdesc} 42 | \item[\begin{tabular}{@{}l} 43 | numerator\ ::\ Integral\ a\ =>\ Ratio\ a\ ->\ a 44 | \end{tabular}]\haddockbegindoc 45 | Extract the numerator of the ratio in reduced form: 46 | the numerator and denominator have no common factor and the denominator 47 | is positive. 48 | \par 49 | 50 | \end{haddockdesc} 51 | \begin{haddockdesc} 52 | \item[\begin{tabular}{@{}l} 53 | denominator\ ::\ Integral\ a\ =>\ Ratio\ a\ ->\ a 54 | \end{tabular}]\haddockbegindoc 55 | Extract the denominator of the ratio in reduced form: 56 | the numerator and denominator have no common factor and the denominator 57 | is positive. 58 | \par 59 | 60 | \end{haddockdesc} 61 | \begin{haddockdesc} 62 | \item[\begin{tabular}{@{}l} 63 | approxRational\ ::\ RealFrac\ a\ =>\ a\ ->\ a\ ->\ Rational 64 | \end{tabular}]\haddockbegindoc 65 | \haddockid{approxRational}, applied to two real fractional numbers \haddocktt{x} and \haddocktt{epsilon}, 66 | returns the simplest rational number within \haddocktt{epsilon} of \haddocktt{x}. 67 | A rational number \haddocktt{y} is said to be \emph{simpler} than another \haddocktt{y'} if 68 | \par 69 | \begin{itemize} 70 | \item 71 | \haddocktt{abs\ (numerator\ y)\ <=\ abs\ (numerator\ y')}, and 72 | \par 73 | 74 | \item 75 | \haddocktt{denominator\ y\ <=\ denominator\ y'}. 76 | \par 77 | 78 | \end{itemize} 79 | Any real interval contains a unique simplest rational; 80 | in particular, note that \haddocktt{0/1} is the simplest rational of all. 81 | \par 82 | 83 | \end{haddockdesc} 84 | \section{Specification 85 | } 86 | \begin{quote} 87 | {\haddockverb\begin{verbatim} 88 | module Data.Ratio ( 89 | Ratio, Rational, (%), numerator, denominator, approxRational ) where 90 | 91 | infixl 7 % 92 | 93 | ratPrec = 7 :: Int 94 | 95 | data (Integral a) => Ratio a = !a :% !a deriving (Eq) 96 | type Rational = Ratio Integer 97 | 98 | (%) :: (Integral a) => a -> a -> Ratio a 99 | numerator, denominator :: (Integral a) => Ratio a -> a 100 | approxRational :: (RealFrac a) => a -> a -> Rational 101 | 102 | 103 | -- "reduce" is a subsidiary function used only in this module. 104 | -- It normalises a ratio by dividing both numerator 105 | -- and denominator by their greatest common divisor. 106 | -- 107 | -- E.g., 12 `reduce` 8 == 3 :% 2 108 | -- 12 `reduce` (-8) == 3 :% (-2) 109 | 110 | reduce _ 0 = error "Data.Ratio.% : zero denominator" 111 | reduce x y = (x `quot` d) :% (y `quot` d) 112 | where d = gcd x y 113 | 114 | x % y = reduce (x * signum y) (abs y) 115 | 116 | numerator (x :% _) = x 117 | 118 | denominator (_ :% y) = y 119 | 120 | 121 | instance (Integral a) => Ord (Ratio a) where 122 | (x:%y) <= (x':%y') = x * y' <= x' * y 123 | (x:%y) < (x':%y') = x * y' < x' * y 124 | 125 | instance (Integral a) => Num (Ratio a) where 126 | (x:%y) + (x':%y') = reduce (x*y' + x'*y) (y*y') 127 | (x:%y) * (x':%y') = reduce (x * x') (y * y') 128 | negate (x:%y) = (-x) :% y 129 | abs (x:%y) = abs x :% y 130 | signum (x:%y) = signum x :% 1 131 | fromInteger x = fromInteger x :% 1 132 | 133 | instance (Integral a) => Real (Ratio a) where 134 | toRational (x:%y) = toInteger x :% toInteger y 135 | 136 | instance (Integral a) => Fractional (Ratio a) where 137 | (x:%y) / (x':%y') = (x*y') % (y*x') 138 | recip (x:%y) = y % x 139 | fromRational (x:%y) = fromInteger x :% fromInteger y 140 | 141 | instance (Integral a) => RealFrac (Ratio a) where 142 | properFraction (x:%y) = (fromIntegral q, r:%y) 143 | where (q,r) = quotRem x y 144 | 145 | instance (Integral a) => Enum (Ratio a) where 146 | succ x = x+1 147 | pred x = x-1 148 | toEnum = fromIntegral 149 | fromEnum = fromInteger . truncate -- May overflow 150 | enumFrom = numericEnumFrom -- These numericEnumXXX functions 151 | enumFromThen = numericEnumFromThen -- are as defined in Prelude.hs 152 | enumFromTo = numericEnumFromTo -- but not exported from it! 153 | enumFromThenTo = numericEnumFromThenTo 154 | 155 | instance (Read a, Integral a) => Read (Ratio a) where 156 | readsPrec p = readParen (p > ratPrec) 157 | (\r -> [(x%y,u) | (x,s) <- readsPrec (ratPrec+1) r, 158 | ("%",t) <- lex s, 159 | (y,u) <- readsPrec (ratPrec+1) t ]) 160 | 161 | instance (Integral a) => Show (Ratio a) where 162 | showsPrec p (x:%y) = showParen (p > ratPrec) 163 | showsPrec (ratPrec+1) x . 164 | showString " % " . 165 | showsPrec (ratPrec+1) y) 166 | 167 | 168 | 169 | approxRational x eps = simplest (x-eps) (x+eps) 170 | where simplest x y | y < x = simplest y x 171 | | x == y = xr 172 | | x > 0 = simplest' n d n' d' 173 | | y < 0 = - simplest' (-n') d' (-n) d 174 | | otherwise = 0 :% 1 175 | where xr@(n:%d) = toRational x 176 | (n':%d') = toRational y 177 | 178 | simplest' n d n' d' -- assumes 0 < n%d < n'%d' 179 | | r == 0 = q :% 1 180 | | q /= q' = (q+1) :% 1 181 | | otherwise = (q*n''+d'') :% n'' 182 | where (q,r) = quotRem n d 183 | (q',r') = quotRem n' d' 184 | (n'':%d'') = simplest' d' r' d r 185 | \end{verbatim}} 186 | \end{quote} 187 | -------------------------------------------------------------------------------- /report/report/libs/Data-Word.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Data.Word} 2 | \label{module:Data.Word} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Data.Word ( 6 | Word, Word8, Word16, Word32, Word64 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \section{Unsigned integral types 11 | } 12 | This module provides unsigned integer types of unspecified width (\haddockid{Word}) 13 | and fixed widths (\haddockid{Word8}, \haddockid{Word16}, \haddockid{Word32} and \haddockid{Word64}). All 14 | arithmetic is performed modulo 2{\char '136}n, where \haddocktt{n} is the number of bits in 15 | the type. 16 | \par 17 | For coercing between any two integer types, use 18 | \haddockid{fromIntegral}. Coercing word types to and from integer 19 | types preserves representation, not sign. 20 | \par 21 | The rules that hold for \haddockid{Enum} instances over a bounded type 22 | such as \haddockid{Int} (see the section of the Haskell language report dealing 23 | with arithmetic sequences) also hold for the \haddockid{Enum} instances 24 | over the various \haddockid{Word} types defined here. 25 | \par 26 | Right and left shifts by amounts greater than or equal to the width of 27 | the type result in a zero result. This is contrary to the behaviour 28 | in C, which is undefined; a common interpretation is to truncate the 29 | shift count to the width of the type, for example \haddocktt{1\ <<\ 32\ ==\ 1} in 30 | some C implementations. 31 | \par 32 | 33 | \begin{haddockdesc} 34 | \item[\begin{tabular}{@{}l} 35 | data\ Word 36 | \end{tabular}]\haddockbegindoc 37 | A \haddockid{Word} is an unsigned integral type, with the same size as \haddockid{Int}. 38 | \par 39 | 40 | \end{haddockdesc} 41 | \begin{haddockdesc} 42 | \item[\begin{tabular}{@{}l} 43 | instance\ Bounded\ Word\\instance\ Enum\ Word\\instance\ Eq\ Word\\instance\ Integral\ Word\\instance\ Num\ Word\\instance\ Ord\ Word\\instance\ Read\ Word\\instance\ Real\ Word\\instance\ Show\ Word\\instance\ Ix\ Word\\instance\ Storable\ Word\\instance\ Bits\ Word 44 | \end{tabular}] 45 | \end{haddockdesc} 46 | \begin{haddockdesc} 47 | \item[\begin{tabular}{@{}l} 48 | data\ Word8 49 | \end{tabular}]\haddockbegindoc 50 | 8-bit unsigned integer type 51 | \par 52 | 53 | \end{haddockdesc} 54 | \begin{haddockdesc} 55 | \item[\begin{tabular}{@{}l} 56 | instance\ Bounded\ Word8\\instance\ Enum\ Word8\\instance\ Eq\ Word8\\instance\ Integral\ Word8\\instance\ Num\ Word8\\instance\ Ord\ Word8\\instance\ Read\ Word8\\instance\ Real\ Word8\\instance\ Show\ Word8\\instance\ Ix\ Word8\\instance\ Storable\ Word8\\instance\ Bits\ Word8 57 | \end{tabular}] 58 | \end{haddockdesc} 59 | \begin{haddockdesc} 60 | \item[\begin{tabular}{@{}l} 61 | data\ Word16 62 | \end{tabular}]\haddockbegindoc 63 | 16-bit unsigned integer type 64 | \par 65 | 66 | \end{haddockdesc} 67 | \begin{haddockdesc} 68 | \item[\begin{tabular}{@{}l} 69 | instance\ Bounded\ Word16\\instance\ Enum\ Word16\\instance\ Eq\ Word16\\instance\ Integral\ Word16\\instance\ Num\ Word16\\instance\ Ord\ Word16\\instance\ Read\ Word16\\instance\ Real\ Word16\\instance\ Show\ Word16\\instance\ Ix\ Word16\\instance\ Storable\ Word16\\instance\ Bits\ Word16 70 | \end{tabular}] 71 | \end{haddockdesc} 72 | \begin{haddockdesc} 73 | \item[\begin{tabular}{@{}l} 74 | data\ Word32 75 | \end{tabular}]\haddockbegindoc 76 | 32-bit unsigned integer type 77 | \par 78 | 79 | \end{haddockdesc} 80 | \begin{haddockdesc} 81 | \item[\begin{tabular}{@{}l} 82 | instance\ Bounded\ Word32\\instance\ Enum\ Word32\\instance\ Eq\ Word32\\instance\ Integral\ Word32\\instance\ Num\ Word32\\instance\ Ord\ Word32\\instance\ Read\ Word32\\instance\ Real\ Word32\\instance\ Show\ Word32\\instance\ Ix\ Word32\\instance\ Storable\ Word32\\instance\ Bits\ Word32 83 | \end{tabular}] 84 | \end{haddockdesc} 85 | \begin{haddockdesc} 86 | \item[\begin{tabular}{@{}l} 87 | data\ Word64 88 | \end{tabular}]\haddockbegindoc 89 | 64-bit unsigned integer type 90 | \par 91 | 92 | \end{haddockdesc} 93 | \begin{haddockdesc} 94 | \item[\begin{tabular}{@{}l} 95 | instance\ Bounded\ Word64\\instance\ Enum\ Word64\\instance\ Eq\ Word64\\instance\ Integral\ Word64\\instance\ Num\ Word64\\instance\ Ord\ Word64\\instance\ Read\ Word64\\instance\ Real\ Word64\\instance\ Show\ Word64\\instance\ Ix\ Word64\\instance\ Storable\ Word64\\instance\ Bits\ Word64 96 | \end{tabular}] 97 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-C.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.C} 2 | \label{module:Foreign.C} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.C ( 6 | module Foreign.C.Types, module Foreign.C.String, module Foreign.C.Error 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | The module \haddocktt{Foreign.C} combines the interfaces of all 11 | modules providing C-specific marshalling support, namely 12 | \par 13 | 14 | \begin{haddockdesc} 15 | \item[\begin{tabular}{@{}l} 16 | module\ Foreign.C.Types\\module\ Foreign.C.String\\module\ Foreign.C.Error 17 | \end{tabular}] 18 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-Marshal-Alloc.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Marshal.Alloc} 2 | \label{module:Foreign.Marshal.Alloc} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Marshal.Alloc ( 6 | alloca, allocaBytes, malloc, mallocBytes, realloc, reallocBytes, 7 | free, finalizerFree 8 | ) where\end{verbatim}} 9 | \haddockendheader 10 | 11 | The module \haddocktt{Foreign.Marshal.Alloc} provides operations to allocate and 12 | deallocate blocks of raw memory (i.e., unstructured chunks of memory 13 | outside of the area maintained by the Haskell storage manager). These 14 | memory blocks are commonly used to pass compound data structures to 15 | foreign functions or to provide space in which compound result values 16 | are obtained from foreign functions. 17 | \par 18 | If any of the allocation functions fails, a value of \haddocktt{nullPtr} is 19 | produced. If \haddockid{free} or \haddockid{reallocBytes} is applied to a memory area 20 | that has been allocated with \haddockid{alloca} or \haddockid{allocaBytes}, the 21 | behaviour is undefined. Any further access to memory areas allocated with 22 | \haddockid{alloca} or \haddockid{allocaBytes}, after the computation that was passed to 23 | the allocation function has terminated, leads to undefined behaviour. Any 24 | further access to the memory area referenced by a pointer passed to 25 | \haddockid{realloc}, \haddockid{reallocBytes}, or \haddockid{free} entails undefined 26 | behaviour. 27 | \par 28 | All storage allocated by functions that allocate based on a \emph{size in bytes} 29 | must be sufficiently aligned for any of the basic foreign types 30 | that fits into the newly allocated storage. All storage allocated by 31 | functions that allocate based on a specific type must be sufficiently 32 | aligned for that type. Array allocation routines need to obey the same 33 | alignment constraints for each array element. 34 | \par 35 | 36 | \section{Memory allocation 37 | } 38 | \subsection{Local allocation 39 | } 40 | \begin{haddockdesc} 41 | \item[\begin{tabular}{@{}l} 42 | alloca\ ::\ Storable\ a\ =>\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 43 | \end{tabular}]\haddockbegindoc 44 | \haddocktt{alloca\ f} executes the computation \haddocktt{f}, passing as argument 45 | a pointer to a temporarily allocated block of memory sufficient to 46 | hold values of type \haddocktt{a}. 47 | \par 48 | The memory is freed when \haddocktt{f} terminates (either normally or via an 49 | exception), so the pointer passed to \haddocktt{f} must \emph{not} be used after this. 50 | \par 51 | 52 | \end{haddockdesc} 53 | \begin{haddockdesc} 54 | \item[\begin{tabular}{@{}l} 55 | allocaBytes\ ::\ Int\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 56 | \end{tabular}]\haddockbegindoc 57 | \haddocktt{allocaBytes\ n\ f} executes the computation \haddocktt{f}, passing as argument 58 | a pointer to a temporarily allocated block of memory of \haddocktt{n} bytes. 59 | The block of memory is sufficiently aligned for any of the basic 60 | foreign types that fits into a memory block of the allocated size. 61 | \par 62 | The memory is freed when \haddocktt{f} terminates (either normally or via an 63 | exception), so the pointer passed to \haddocktt{f} must \emph{not} be used after this. 64 | \par 65 | 66 | \end{haddockdesc} 67 | \subsection{Dynamic allocation 68 | } 69 | \begin{haddockdesc} 70 | \item[\begin{tabular}{@{}l} 71 | malloc\ ::\ Storable\ a\ =>\ IO\ (Ptr\ a) 72 | \end{tabular}]\haddockbegindoc 73 | Allocate a block of memory that is sufficient to hold values of type 74 | \haddocktt{a}. The size of the area allocated is determined by the \haddockid{sizeOf} 75 | method from the instance of \haddockid{Storable} for the appropriate type. 76 | \par 77 | The memory may be deallocated using \haddockid{free} or \haddockid{finalizerFree} when 78 | no longer required. 79 | \par 80 | 81 | \end{haddockdesc} 82 | \begin{haddockdesc} 83 | \item[\begin{tabular}{@{}l} 84 | mallocBytes\ ::\ Int\ ->\ IO\ (Ptr\ a) 85 | \end{tabular}]\haddockbegindoc 86 | Allocate a block of memory of the given number of bytes. 87 | The block of memory is sufficiently aligned for any of the basic 88 | foreign types that fits into a memory block of the allocated size. 89 | \par 90 | The memory may be deallocated using \haddockid{free} or \haddockid{finalizerFree} when 91 | no longer required. 92 | \par 93 | 94 | \end{haddockdesc} 95 | \begin{haddockdesc} 96 | \item[\begin{tabular}{@{}l} 97 | realloc\ ::\ Storable\ b\ =>\ Ptr\ a\ ->\ IO\ (Ptr\ b) 98 | \end{tabular}]\haddockbegindoc 99 | Resize a memory area that was allocated with \haddockid{malloc} or \haddockid{mallocBytes} 100 | to the size needed to store values of type \haddocktt{b}. The returned pointer 101 | may refer to an entirely different memory area, but will be suitably 102 | aligned to hold values of type \haddocktt{b}. The contents of the referenced 103 | memory area will be the same as of the original pointer up to the 104 | minimum of the original size and the size of values of type \haddocktt{b}. 105 | \par 106 | If the argument to \haddockid{realloc} is \haddockid{nullPtr}, \haddockid{realloc} behaves like 107 | \haddockid{malloc}. 108 | \par 109 | 110 | \end{haddockdesc} 111 | \begin{haddockdesc} 112 | \item[\begin{tabular}{@{}l} 113 | reallocBytes\ ::\ Ptr\ a\ ->\ Int\ ->\ IO\ (Ptr\ a) 114 | \end{tabular}]\haddockbegindoc 115 | Resize a memory area that was allocated with \haddockid{malloc} or \haddockid{mallocBytes} 116 | to the given size. The returned pointer may refer to an entirely 117 | different memory area, but will be sufficiently aligned for any of the 118 | basic foreign types that fits into a memory block of the given size. 119 | The contents of the referenced memory area will be the same as of 120 | the original pointer up to the minimum of the original size and the 121 | given size. 122 | \par 123 | If the pointer argument to \haddockid{reallocBytes} is \haddockid{nullPtr}, \haddockid{reallocBytes} 124 | behaves like \haddockid{malloc}. If the requested size is 0, \haddockid{reallocBytes} 125 | behaves like \haddockid{free}. 126 | \par 127 | 128 | \end{haddockdesc} 129 | \begin{haddockdesc} 130 | \item[\begin{tabular}{@{}l} 131 | free\ ::\ Ptr\ a\ ->\ IO\ () 132 | \end{tabular}]\haddockbegindoc 133 | Free a block of memory that was allocated with \haddockid{malloc}, 134 | \haddockid{mallocBytes}, \haddockid{realloc}, \haddockid{reallocBytes}, \haddocktt{Foreign.Marshal.Utils.new} 135 | or any of the \haddocktt{new}\emph{X} functions in \haddocktt{Foreign.Marshal.Array} or 136 | \haddocktt{Foreign.C.String}. 137 | \par 138 | 139 | \end{haddockdesc} 140 | \begin{haddockdesc} 141 | \item[\begin{tabular}{@{}l} 142 | finalizerFree\ ::\ FinalizerPtr\ a 143 | \end{tabular}]\haddockbegindoc 144 | A pointer to a foreign function equivalent to \haddockid{free}, which may be 145 | used as a finalizer (cf \haddocktt{Foreign.ForeignPtr.ForeignPtr}) for storage 146 | allocated with \haddockid{malloc}, \haddockid{mallocBytes}, \haddockid{realloc} or \haddockid{reallocBytes}. 147 | \par 148 | 149 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-Marshal-Array.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Marshal.Array} 2 | \label{module:Foreign.Marshal.Array} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Marshal.Array ( 6 | mallocArray, mallocArray0, allocaArray, allocaArray0, reallocArray, 7 | reallocArray0, peekArray, peekArray0, pokeArray, pokeArray0, newArray, 8 | newArray0, withArray, withArray0, withArrayLen, withArrayLen0, 9 | copyArray, moveArray, lengthArray0, advancePtr 10 | ) where\end{verbatim}} 11 | \haddockendheader 12 | 13 | The module \haddocktt{Foreign.Marshal.Array} provides operations for marshalling Haskell 14 | lists into monolithic arrays and vice versa. Most functions come in two 15 | flavours: one for arrays terminated by a special termination element and one 16 | where an explicit length parameter is used to determine the extent of an 17 | array. The typical example for the former case are C's NUL terminated 18 | strings. However, please note that C strings should usually be marshalled 19 | using the functions provided by \haddocktt{Foreign.C.String} as 20 | the Unicode encoding has to be taken into account. All functions specifically 21 | operating on arrays that are terminated by a special termination element have 22 | a name ending on \haddocktt{0}---e.g., \haddockid{mallocArray} allocates space for an 23 | array of the given size, whereas \haddockid{mallocArray0} allocates space for one 24 | more element to ensure that there is room for the terminator. 25 | \par 26 | 27 | \section{Marshalling arrays 28 | } 29 | \subsection{Allocation 30 | } 31 | \begin{haddockdesc} 32 | \item[\begin{tabular}{@{}l} 33 | mallocArray\ ::\ Storable\ a\ =>\ Int\ ->\ IO\ (Ptr\ a) 34 | \end{tabular}]\haddockbegindoc 35 | Allocate storage for the given number of elements of a storable type 36 | (like \haddocktt{Foreign.Marshal.Alloc.malloc}, but for multiple elements). 37 | \par 38 | 39 | \end{haddockdesc} 40 | \begin{haddockdesc} 41 | \item[\begin{tabular}{@{}l} 42 | mallocArray0\ ::\ Storable\ a\ =>\ Int\ ->\ IO\ (Ptr\ a) 43 | \end{tabular}]\haddockbegindoc 44 | Like \haddockid{mallocArray}, but add an extra position to hold a special 45 | termination element. 46 | \par 47 | 48 | \end{haddockdesc} 49 | \begin{haddockdesc} 50 | \item[\begin{tabular}{@{}l} 51 | allocaArray\ ::\ Storable\ a\ =>\ Int\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 52 | \end{tabular}]\haddockbegindoc 53 | Temporarily allocate space for the given number of elements 54 | (like \haddocktt{Foreign.Marshal.Alloc.alloca}, but for multiple elements). 55 | \par 56 | 57 | \end{haddockdesc} 58 | \begin{haddockdesc} 59 | \item[\begin{tabular}{@{}l} 60 | allocaArray0\ ::\ Storable\ a\ =>\ Int\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 61 | \end{tabular}]\haddockbegindoc 62 | Like \haddockid{allocaArray}, but add an extra position to hold a special 63 | termination element. 64 | \par 65 | 66 | \end{haddockdesc} 67 | \begin{haddockdesc} 68 | \item[\begin{tabular}{@{}l} 69 | reallocArray\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ Int\ ->\ IO\ (Ptr\ a) 70 | \end{tabular}]\haddockbegindoc 71 | Adjust the size of an array 72 | \par 73 | 74 | \end{haddockdesc} 75 | \begin{haddockdesc} 76 | \item[\begin{tabular}{@{}l} 77 | reallocArray0\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ Int\ ->\ IO\ (Ptr\ a) 78 | \end{tabular}]\haddockbegindoc 79 | Adjust the size of an array including an extra position for the end marker. 80 | \par 81 | 82 | \end{haddockdesc} 83 | \subsection{Marshalling 84 | } 85 | \begin{haddockdesc} 86 | \item[\begin{tabular}{@{}l} 87 | peekArray\ ::\ Storable\ a\ =>\ Int\ ->\ Ptr\ a\ ->\ IO\ {\char 91}a{\char 93} 88 | \end{tabular}]\haddockbegindoc 89 | Convert an array of given length into a Haskell list. 90 | \par 91 | 92 | \end{haddockdesc} 93 | \begin{haddockdesc} 94 | \item[\begin{tabular}{@{}l} 95 | peekArray0\ ::\ (Storable\ a,\ Eq\ a)\ =>\ a\ ->\ Ptr\ a\ ->\ IO\ {\char 91}a{\char 93} 96 | \end{tabular}]\haddockbegindoc 97 | Convert an array terminated by the given end marker into a Haskell list 98 | \par 99 | 100 | \end{haddockdesc} 101 | \begin{haddockdesc} 102 | \item[\begin{tabular}{@{}l} 103 | pokeArray\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ {\char 91}a{\char 93}\ ->\ IO\ () 104 | \end{tabular}]\haddockbegindoc 105 | Write the list elements consecutive into memory 106 | \par 107 | 108 | \end{haddockdesc} 109 | \begin{haddockdesc} 110 | \item[\begin{tabular}{@{}l} 111 | pokeArray0\ ::\ Storable\ a\ =>\ a\ ->\ Ptr\ a\ ->\ {\char 91}a{\char 93}\ ->\ IO\ () 112 | \end{tabular}]\haddockbegindoc 113 | Write the list elements consecutive into memory and terminate them with the 114 | given marker element 115 | \par 116 | 117 | \end{haddockdesc} 118 | \subsection{Combined allocation and marshalling 119 | } 120 | \begin{haddockdesc} 121 | \item[\begin{tabular}{@{}l} 122 | newArray\ ::\ Storable\ a\ =>\ {\char 91}a{\char 93}\ ->\ IO\ (Ptr\ a) 123 | \end{tabular}]\haddockbegindoc 124 | Write a list of storable elements into a newly allocated, consecutive 125 | sequence of storable values 126 | (like \haddocktt{Foreign.Marshal.Utils.new}, but for multiple elements). 127 | \par 128 | 129 | \end{haddockdesc} 130 | \begin{haddockdesc} 131 | \item[\begin{tabular}{@{}l} 132 | newArray0\ ::\ Storable\ a\ =>\ a\ ->\ {\char 91}a{\char 93}\ ->\ IO\ (Ptr\ a) 133 | \end{tabular}]\haddockbegindoc 134 | Write a list of storable elements into a newly allocated, consecutive 135 | sequence of storable values, where the end is fixed by the given end marker 136 | \par 137 | 138 | \end{haddockdesc} 139 | \begin{haddockdesc} 140 | \item[\begin{tabular}{@{}l} 141 | withArray\ ::\ Storable\ a\ =>\ {\char 91}a{\char 93}\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 142 | \end{tabular}]\haddockbegindoc 143 | Temporarily store a list of storable values in memory 144 | (like \haddocktt{Foreign.Marshal.Utils.with}, but for multiple elements). 145 | \par 146 | 147 | \end{haddockdesc} 148 | \begin{haddockdesc} 149 | \item[\begin{tabular}{@{}l} 150 | withArray0\ ::\ Storable\ a\ =>\ a\ ->\ {\char 91}a{\char 93}\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 151 | \end{tabular}]\haddockbegindoc 152 | Like \haddockid{withArray}, but a terminator indicates where the array ends 153 | \par 154 | 155 | \end{haddockdesc} 156 | \begin{haddockdesc} 157 | \item[\begin{tabular}{@{}l} 158 | withArrayLen\ ::\ Storable\ a\ =>\ {\char 91}a{\char 93}\ ->\ (Int\ ->\ Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 159 | \end{tabular}]\haddockbegindoc 160 | Like \haddockid{withArray}, but the action gets the number of values 161 | as an additional parameter 162 | \par 163 | 164 | \end{haddockdesc} 165 | \begin{haddockdesc} 166 | \item[\begin{tabular}{@{}l} 167 | withArrayLen0\ ::\ Storable\ a\ =>\ a\\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ->\ {\char 91}a{\char 93}\ ->\ (Int\ ->\ Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 168 | \end{tabular}]\haddockbegindoc 169 | Like \haddockid{withArrayLen}, but a terminator indicates where the array ends 170 | \par 171 | 172 | \end{haddockdesc} 173 | \subsection{Copying 174 | } 175 | (argument order: destination, source) 176 | \par 177 | 178 | \begin{haddockdesc} 179 | \item[\begin{tabular}{@{}l} 180 | copyArray\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ Ptr\ a\ ->\ Int\ ->\ IO\ () 181 | \end{tabular}]\haddockbegindoc 182 | Copy the given number of elements from the second array (source) into the 183 | first array (destination); the copied areas may \emph{not} overlap 184 | \par 185 | 186 | \end{haddockdesc} 187 | \begin{haddockdesc} 188 | \item[\begin{tabular}{@{}l} 189 | moveArray\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ Ptr\ a\ ->\ Int\ ->\ IO\ () 190 | \end{tabular}]\haddockbegindoc 191 | Copy the given number of elements from the second array (source) into the 192 | first array (destination); the copied areas \emph{may} overlap 193 | \par 194 | 195 | \end{haddockdesc} 196 | \subsection{Finding the length 197 | } 198 | \begin{haddockdesc} 199 | \item[\begin{tabular}{@{}l} 200 | lengthArray0\ ::\ (Storable\ a,\ Eq\ a)\ =>\ a\ ->\ Ptr\ a\ ->\ IO\ Int 201 | \end{tabular}]\haddockbegindoc 202 | Return the number of elements in an array, excluding the terminator 203 | \par 204 | 205 | \end{haddockdesc} 206 | \subsection{Indexing 207 | } 208 | \begin{haddockdesc} 209 | \item[\begin{tabular}{@{}l} 210 | advancePtr\ ::\ Storable\ a\ =>\ Ptr\ a\ ->\ Int\ ->\ Ptr\ a 211 | \end{tabular}]\haddockbegindoc 212 | Advance a pointer into an array by the given number of elements 213 | \par 214 | 215 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-Marshal-Error.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Marshal.Error} 2 | \label{module:Foreign.Marshal.Error} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Marshal.Error ( 6 | throwIf, throwIf_, throwIfNeg, throwIfNeg_, throwIfNull, void 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \begin{haddockdesc} 11 | \item[\begin{tabular}{@{}l} 12 | throwIf 13 | \end{tabular}]\haddockbegindoc 14 | \haddockbeginargs 15 | \haddockdecltt{::} & \haddockdecltt{(a 16 | -> Bool)} & error condition on the result of the \haddockid{IO} action 17 | \\ 18 | \haddockdecltt{->} & \haddockdecltt{(a 19 | -> String)} & computes an error message from erroneous results 20 | of the \haddockid{IO} action 21 | \\ 22 | \haddockdecltt{->} & \haddockdecltt{IO a} & the \haddockid{IO} action to be executed 23 | \\ 24 | \haddockdecltt{->} & \haddockdecltt{IO a} & \\ 25 | \end{tabulary}\par 26 | Execute an \haddockid{IO} action, throwing a \haddockid{userError} if the predicate yields 27 | \haddockid{True} when applied to the result returned by the \haddockid{IO} action. 28 | If no exception is raised, return the result of the computation. 29 | \par 30 | 31 | \end{haddockdesc} 32 | \begin{haddockdesc} 33 | \item[\begin{tabular}{@{}l} 34 | throwIf{\char '137}\ ::\ (a\ ->\ Bool)\ ->\ (a\ ->\ String)\ ->\ IO\ a\ ->\ IO\ () 35 | \end{tabular}]\haddockbegindoc 36 | Like \haddockid{throwIf}, but discarding the result 37 | \par 38 | 39 | \end{haddockdesc} 40 | \begin{haddockdesc} 41 | \item[\begin{tabular}{@{}l} 42 | throwIfNeg\ ::\ (Ord\ a,\ Num\ a)\ =>\ (a\ ->\ String)\ ->\ IO\ a\ ->\ IO\ a 43 | \end{tabular}]\haddockbegindoc 44 | Guards against negative result values 45 | \par 46 | 47 | \end{haddockdesc} 48 | \begin{haddockdesc} 49 | \item[\begin{tabular}{@{}l} 50 | throwIfNeg{\char '137}\ ::\ (Ord\ a,\ Num\ a)\ =>\ (a\ ->\ String)\ ->\ IO\ a\ ->\ IO\ () 51 | \end{tabular}]\haddockbegindoc 52 | Like \haddockid{throwIfNeg}, but discarding the result 53 | \par 54 | 55 | \end{haddockdesc} 56 | \begin{haddockdesc} 57 | \item[\begin{tabular}{@{}l} 58 | throwIfNull\ ::\ String\ ->\ IO\ (Ptr\ a)\ ->\ IO\ (Ptr\ a) 59 | \end{tabular}]\haddockbegindoc 60 | Guards against null pointers 61 | \par 62 | 63 | \end{haddockdesc} 64 | \begin{haddockdesc} 65 | \item[\begin{tabular}{@{}l} 66 | void\ ::\ IO\ a\ ->\ IO\ () 67 | \end{tabular}]\haddockbegindoc 68 | Discard the return value of an \haddockid{IO} action 69 | \par 70 | 71 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-Marshal-Utils.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Marshal.Utils} 2 | \label{module:Foreign.Marshal.Utils} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Marshal.Utils ( 6 | with, new, fromBool, toBool, maybeNew, maybeWith, maybePeek, 7 | withMany, copyBytes, moveBytes 8 | ) where\end{verbatim}} 9 | \haddockendheader 10 | 11 | \section{General marshalling utilities 12 | } 13 | \subsection{Combined allocation and marshalling 14 | } 15 | \begin{haddockdesc} 16 | \item[\begin{tabular}{@{}l} 17 | with\ ::\ Storable\ a\ =>\ a\ ->\ (Ptr\ a\ ->\ IO\ b)\ ->\ IO\ b 18 | \end{tabular}]\haddockbegindoc 19 | \haddocktt{with\ val\ f} executes the computation \haddocktt{f}, passing as argument 20 | a pointer to a temporarily allocated block of memory into which 21 | \haddocktt{val} has been marshalled (the combination of \haddockid{alloca} and \haddockid{poke}). 22 | \par 23 | The memory is freed when \haddocktt{f} terminates (either normally or via an 24 | exception), so the pointer passed to \haddocktt{f} must \emph{not} be used after this. 25 | \par 26 | 27 | \end{haddockdesc} 28 | \begin{haddockdesc} 29 | \item[\begin{tabular}{@{}l} 30 | new\ ::\ Storable\ a\ =>\ a\ ->\ IO\ (Ptr\ a) 31 | \end{tabular}]\haddockbegindoc 32 | Allocate a block of memory and marshal a value into it 33 | (the combination of \haddockid{malloc} and \haddockid{poke}). 34 | The size of the area allocated is determined by the \haddocktt{Foreign.Storable.sizeOf} 35 | method from the instance of \haddockid{Storable} for the appropriate type. 36 | \par 37 | The memory may be deallocated using \haddocktt{Foreign.Marshal.Alloc.free} or 38 | \haddocktt{Foreign.Marshal.Alloc.finalizerFree} when no longer required. 39 | \par 40 | 41 | \end{haddockdesc} 42 | \subsection{Marshalling of Boolean values (non-zero corresponds to \haddockid{True}) 43 | } 44 | \begin{haddockdesc} 45 | \item[\begin{tabular}{@{}l} 46 | fromBool\ ::\ Num\ a\ =>\ Bool\ ->\ a 47 | \end{tabular}]\haddockbegindoc 48 | Convert a Haskell \haddockid{Bool} to its numeric representation 49 | \par 50 | 51 | \end{haddockdesc} 52 | \begin{haddockdesc} 53 | \item[\begin{tabular}{@{}l} 54 | toBool\ ::\ Num\ a\ =>\ a\ ->\ Bool 55 | \end{tabular}]\haddockbegindoc 56 | Convert a Boolean in numeric representation to a Haskell value 57 | \par 58 | 59 | \end{haddockdesc} 60 | \subsection{Marshalling of Maybe values 61 | } 62 | \begin{haddockdesc} 63 | \item[\begin{tabular}{@{}l} 64 | maybeNew\ ::\ (a\ ->\ IO\ (Ptr\ a))\ ->\ Maybe\ a\ ->\ IO\ (Ptr\ a) 65 | \end{tabular}]\haddockbegindoc 66 | Allocate storage and marshal a storable value wrapped into a \haddockid{Maybe} 67 | \par 68 | \begin{itemize} 69 | \item 70 | the \haddockid{nullPtr} is used to represent \haddockid{Nothing} 71 | \par 72 | 73 | \end{itemize} 74 | 75 | \end{haddockdesc} 76 | \begin{haddockdesc} 77 | \item[\begin{tabular}{@{}l} 78 | maybeWith\ ::\ (a\ ->\ (Ptr\ b\ ->\ IO\ c)\ ->\ IO\ c)\\\ \ \ \ \ \ \ \ \ \ \ \ \ ->\ Maybe\ a\ ->\ (Ptr\ b\ ->\ IO\ c)\ ->\ IO\ c 79 | \end{tabular}]\haddockbegindoc 80 | Converts a \haddocktt{withXXX} combinator into one marshalling a value wrapped 81 | into a \haddockid{Maybe}, using \haddockid{nullPtr} to represent \haddockid{Nothing}. 82 | \par 83 | 84 | \end{haddockdesc} 85 | \begin{haddockdesc} 86 | \item[\begin{tabular}{@{}l} 87 | maybePeek\ ::\ (Ptr\ a\ ->\ IO\ b)\ ->\ Ptr\ a\ ->\ IO\ (Maybe\ b) 88 | \end{tabular}]\haddockbegindoc 89 | Convert a peek combinator into a one returning \haddockid{Nothing} if applied to a 90 | \haddockid{nullPtr} 91 | \par 92 | 93 | \end{haddockdesc} 94 | \subsection{Marshalling lists of storable objects 95 | } 96 | \begin{haddockdesc} 97 | \item[\begin{tabular}{@{}l} 98 | withMany\ ::\ (a\ ->\ (b\ ->\ res)\ ->\ res)\ ->\ {\char 91}a{\char 93}\ ->\ ({\char 91}b{\char 93}\ ->\ res)\ ->\ res 99 | \end{tabular}]\haddockbegindoc 100 | Replicates a \haddocktt{withXXX} combinator over a list of objects, yielding a list of 101 | marshalled objects 102 | \par 103 | 104 | \end{haddockdesc} 105 | \subsection{Haskellish interface to memcpy and memmove 106 | } 107 | (argument order: destination, source) 108 | \par 109 | 110 | \begin{haddockdesc} 111 | \item[\begin{tabular}{@{}l} 112 | copyBytes\ ::\ Ptr\ a\ ->\ Ptr\ a\ ->\ Int\ ->\ IO\ () 113 | \end{tabular}]\haddockbegindoc 114 | Copies the given number of bytes from the second area (source) into the 115 | first (destination); the copied areas may \emph{not} overlap 116 | \par 117 | 118 | \end{haddockdesc} 119 | \begin{haddockdesc} 120 | \item[\begin{tabular}{@{}l} 121 | moveBytes\ ::\ Ptr\ a\ ->\ Ptr\ a\ ->\ Int\ ->\ IO\ () 122 | \end{tabular}]\haddockbegindoc 123 | Copies the given number of bytes from the second area (source) into the 124 | first (destination); the copied areas \emph{may} overlap 125 | \par 126 | 127 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-Marshal.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Marshal} 2 | \label{module:Foreign.Marshal} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Marshal ( 6 | module Foreign.Marshal.Alloc, module Foreign.Marshal.Array, 7 | module Foreign.Marshal.Error, module Foreign.Marshal.Utils, 8 | unsafeLocalState 9 | ) where\end{verbatim}} 10 | \haddockendheader 11 | 12 | The module \haddocktt{Foreign.Marshal} re-exports the other modules in the 13 | \haddocktt{Foreign.Marshal} hierarchy: 14 | \par 15 | 16 | \begin{haddockdesc} 17 | \item[\begin{tabular}{@{}l} 18 | module\ Foreign.Marshal.Alloc\\module\ Foreign.Marshal.Array\\module\ Foreign.Marshal.Error\\module\ Foreign.Marshal.Utils 19 | \end{tabular}] 20 | \end{haddockdesc} 21 | and provides one function: 22 | \par 23 | 24 | \begin{haddockdesc} 25 | \item[\begin{tabular}{@{}l} 26 | unsafeLocalState\ ::\ IO\ a\ ->\ a 27 | \end{tabular}]\haddockbegindoc 28 | Sometimes an external entity is a pure function, except that it passes 29 | arguments and/or results via pointers. The function 30 | \haddocktt{unsafeLocalState} permits the packaging of such entities as pure 31 | functions. 32 | \par 33 | The only IO operations allowed in the IO action passed to 34 | \haddocktt{unsafeLocalState} are (a) local allocation (\haddocktt{alloca}, \haddocktt{allocaBytes} 35 | and derived operations such as \haddocktt{withArray} and \haddocktt{withCString}), and (b) 36 | pointer operations (\haddocktt{Foreign.Storable} and \haddocktt{Foreign.Ptr}) on the 37 | pointers to local storage, and (c) foreign functions whose only 38 | observable effect is to read and/or write the locally allocated 39 | memory. Passing an IO operation that does not obey these rules 40 | results in undefined behaviour. 41 | \par 42 | It is expected that this operation will be 43 | replaced in a future revision of Haskell. 44 | \par 45 | 46 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign-StablePtr.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.StablePtr} 2 | \label{module:Foreign.StablePtr} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.StablePtr ( 6 | StablePtr, newStablePtr, deRefStablePtr, freeStablePtr, 7 | castStablePtrToPtr, castPtrToStablePtr 8 | ) where\end{verbatim}} 9 | \haddockendheader 10 | 11 | \section{Stable references to Haskell values 12 | } 13 | \begin{haddockdesc} 14 | \item[\begin{tabular}{@{}l} 15 | data\ StablePtr\ a 16 | \end{tabular}]\haddockbegindoc 17 | A \emph{stable pointer} is a reference to a Haskell expression that is 18 | guaranteed not to be affected by garbage collection, i.e., it will neither be 19 | deallocated nor will the value of the stable pointer itself change during 20 | garbage collection (ordinary references may be relocated during garbage 21 | collection). Consequently, stable pointers can be passed to foreign code, 22 | which can treat it as an opaque reference to a Haskell value. 23 | \par 24 | A value of type \haddocktt{StablePtr\ a} is a stable pointer to a Haskell 25 | expression of type \haddocktt{a}. 26 | \par 27 | 28 | \end{haddockdesc} 29 | \begin{haddockdesc} 30 | \item[\begin{tabular}{@{}l} 31 | instance\ Eq\ (StablePtr\ a)\\instance\ Storable\ (StablePtr\ a) 32 | \end{tabular}] 33 | \end{haddockdesc} 34 | \begin{haddockdesc} 35 | \item[\begin{tabular}{@{}l} 36 | newStablePtr\ ::\ a\ ->\ IO\ (StablePtr\ a) 37 | \end{tabular}]\haddockbegindoc 38 | Create a stable pointer referring to the given Haskell value. 39 | \par 40 | 41 | \end{haddockdesc} 42 | \begin{haddockdesc} 43 | \item[\begin{tabular}{@{}l} 44 | deRefStablePtr\ ::\ StablePtr\ a\ ->\ IO\ a 45 | \end{tabular}]\haddockbegindoc 46 | Obtain the Haskell value referenced by a stable pointer, i.e., the 47 | same value that was passed to the corresponding call to 48 | \haddocktt{makeStablePtr}. If the argument to \haddockid{deRefStablePtr} has 49 | already been freed using \haddockid{freeStablePtr}, the behaviour of 50 | \haddockid{deRefStablePtr} is undefined. 51 | \par 52 | 53 | \end{haddockdesc} 54 | \begin{haddockdesc} 55 | \item[\begin{tabular}{@{}l} 56 | freeStablePtr\ ::\ StablePtr\ a\ ->\ IO\ () 57 | \end{tabular}]\haddockbegindoc 58 | Dissolve the association between the stable pointer and the Haskell 59 | value. Afterwards, if the stable pointer is passed to 60 | \haddockid{deRefStablePtr} or \haddockid{freeStablePtr}, the behaviour is 61 | undefined. However, the stable pointer may still be passed to 62 | \haddockid{castStablePtrToPtr}, but the \haddocktt{\haddocktt{Foreign.Ptr.Ptr}\ ()} value returned 63 | by \haddockid{castStablePtrToPtr}, in this case, is undefined (in particular, 64 | it may be \haddocktt{Foreign.Ptr.nullPtr}). Nevertheless, the call 65 | to \haddockid{castStablePtrToPtr} is guaranteed not to diverge. 66 | \par 67 | 68 | \end{haddockdesc} 69 | \begin{haddockdesc} 70 | \item[\begin{tabular}{@{}l} 71 | castStablePtrToPtr\ ::\ StablePtr\ a\ ->\ Ptr\ () 72 | \end{tabular}]\haddockbegindoc 73 | Coerce a stable pointer to an address. No guarantees are made about 74 | the resulting value, except that the original stable pointer can be 75 | recovered by \haddockid{castPtrToStablePtr}. In particular, the address may not 76 | refer to an accessible memory location and any attempt to pass it to 77 | the member functions of the class \haddocktt{Foreign.Storable.Storable} leads to 78 | undefined behaviour. 79 | \par 80 | 81 | \end{haddockdesc} 82 | \begin{haddockdesc} 83 | \item[\begin{tabular}{@{}l} 84 | castPtrToStablePtr\ ::\ Ptr\ ()\ ->\ StablePtr\ a 85 | \end{tabular}]\haddockbegindoc 86 | The inverse of \haddockid{castStablePtrToPtr}, i.e., we have the identity 87 | \par 88 | \begin{quote} 89 | {\haddockverb\begin{verbatim} 90 | sp == castPtrToStablePtr (castStablePtrToPtr sp) 91 | \end{verbatim}} 92 | \end{quote} 93 | for any stable pointer \haddocktt{sp} on which \haddockid{freeStablePtr} has 94 | not been executed yet. Moreover, \haddockid{castPtrToStablePtr} may 95 | only be applied to pointers that have been produced by 96 | \haddockid{castStablePtrToPtr}. 97 | \par 98 | 99 | \end{haddockdesc} 100 | \subsection{The C-side interface 101 | } 102 | The following definition is available to C programs inter-operating with 103 | Haskell code when including the header \haddocktt{HsFFI.h}. 104 | \par 105 | \begin{quote} 106 | {\haddockverb\begin{verbatim} 107 | typedef void *HsStablePtr; 108 | \end{verbatim}} 109 | \end{quote} 110 | Note that no assumptions may be made about the values representing stable 111 | pointers. In fact, they need not even be valid memory addresses. The only 112 | guarantee provided is that if they are passed back to Haskell land, the 113 | function \haddockid{deRefStablePtr} will be able to reconstruct the 114 | Haskell value referred to by the stable pointer. 115 | \par 116 | -------------------------------------------------------------------------------- /report/report/libs/Foreign-Storable.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign.Storable} 2 | \label{module:Foreign.Storable} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign.Storable ( 6 | Storable(sizeOf, 7 | alignment, 8 | peekElemOff, 9 | pokeElemOff, 10 | peekByteOff, 11 | pokeByteOff, 12 | peek, 13 | poke) 14 | ) where\end{verbatim}} 15 | \haddockendheader 16 | 17 | \begin{haddockdesc} 18 | \item[\begin{tabular}{@{}l} 19 | class\ Storable\ a\ where 20 | \end{tabular}]\haddockbegindoc 21 | The member functions of this class facilitate writing values of 22 | primitive types to raw memory (which may have been allocated with the 23 | above mentioned routines) and reading values from blocks of raw 24 | memory. The class, furthermore, includes support for computing the 25 | storage requirements and alignment restrictions of storable types. 26 | \par 27 | Memory addresses are represented as values of type \haddocktt{Ptr\ a}, for some 28 | \haddocktt{a} which is an instance of class \haddockid{Storable}. The type argument to 29 | \haddockid{Ptr} helps provide some valuable type safety in FFI code (you can't 30 | mix pointers of different types without an explicit cast), while 31 | helping the Haskell type system figure out which marshalling method is 32 | needed for a given pointer. 33 | \par 34 | All marshalling between Haskell and a foreign language ultimately 35 | boils down to translating Haskell data structures into the binary 36 | representation of a corresponding data structure of the foreign 37 | language and vice versa. To code this marshalling in Haskell, it is 38 | necessary to manipulate primitive data types stored in unstructured 39 | memory blocks. The class \haddockid{Storable} facilitates this manipulation on 40 | all types for which it is instantiated, which are the standard basic 41 | types of Haskell, the fixed size \haddocktt{Int} types (\haddockid{Int8}, \haddockid{Int16}, 42 | \haddockid{Int32}, \haddockid{Int64}), the fixed size \haddocktt{Word} types (\haddockid{Word8}, \haddockid{Word16}, 43 | \haddockid{Word32}, \haddockid{Word64}), \haddockid{StablePtr}, all types from \haddocktt{Foreign.C.Types}, 44 | as well as \haddockid{Ptr}. 45 | \par 46 | Minimal complete definition: \haddockid{sizeOf}, \haddockid{alignment}, one of \haddockid{peek}, 47 | \haddockid{peekElemOff} and \haddockid{peekByteOff}, and one of \haddockid{poke}, \haddockid{pokeElemOff} and 48 | \haddockid{pokeByteOff}. 49 | \par 50 | 51 | \haddockpremethods{}\textbf{Methods} 52 | \begin{haddockdesc} 53 | \item[\begin{tabular}{@{}l} 54 | sizeOf\ ::\ a\ ->\ Int 55 | \end{tabular}]\haddockbegindoc 56 | Computes the storage requirements (in bytes) of the argument. 57 | The value of the argument is not used. 58 | \par 59 | 60 | \end{haddockdesc} 61 | \begin{haddockdesc} 62 | \item[\begin{tabular}{@{}l} 63 | alignment\ ::\ a\ ->\ Int 64 | \end{tabular}]\haddockbegindoc 65 | Computes the alignment constraint of the argument. An 66 | alignment constraint \haddocktt{x} is fulfilled by any address divisible 67 | by \haddocktt{x}. The value of the argument is not used. 68 | \par 69 | 70 | \end{haddockdesc} 71 | \begin{haddockdesc} 72 | \item[\begin{tabular}{@{}l} 73 | peekElemOff\ ::\ Ptr\ a\ ->\ Int\ ->\ IO\ a 74 | \end{tabular}]\haddockbegindoc 75 | Read a value from a memory area regarded as an array 76 | of values of the same kind. The first argument specifies 77 | the start address of the array and the second the index into 78 | the array (the first element of the array has index 79 | \haddocktt{0}). The following equality holds, 80 | \par 81 | \begin{quote} 82 | {\haddockverb\begin{verbatim} 83 | peekElemOff addr idx = IOExts.fixIO $ \result -> 84 | peek (addr `plusPtr` (idx * sizeOf result)) 85 | \end{verbatim}} 86 | \end{quote} 87 | Note that this is only a specification, not 88 | necessarily the concrete implementation of the 89 | function. 90 | \par 91 | 92 | \end{haddockdesc} 93 | \begin{haddockdesc} 94 | \item[\begin{tabular}{@{}l} 95 | pokeElemOff\ ::\ Ptr\ a\ ->\ Int\ ->\ a\ ->\ IO\ () 96 | \end{tabular}]\haddockbegindoc 97 | Write a value to a memory area regarded as an array of 98 | values of the same kind. The following equality holds: 99 | \par 100 | \begin{quote} 101 | {\haddockverb\begin{verbatim} 102 | pokeElemOff addr idx x = 103 | poke (addr `plusPtr` (idx * sizeOf x)) x 104 | \end{verbatim}} 105 | \end{quote} 106 | 107 | \end{haddockdesc} 108 | \begin{haddockdesc} 109 | \item[\begin{tabular}{@{}l} 110 | peekByteOff\ ::\ Ptr\ b\ ->\ Int\ ->\ IO\ a 111 | \end{tabular}]\haddockbegindoc 112 | Read a value from a memory location given by a base 113 | address and offset. The following equality holds: 114 | \par 115 | \begin{quote} 116 | {\haddockverb\begin{verbatim} 117 | peekByteOff addr off = peek (addr `plusPtr` off) 118 | \end{verbatim}} 119 | \end{quote} 120 | 121 | \end{haddockdesc} 122 | \begin{haddockdesc} 123 | \item[\begin{tabular}{@{}l} 124 | pokeByteOff\ ::\ Ptr\ b\ ->\ Int\ ->\ a\ ->\ IO\ () 125 | \end{tabular}]\haddockbegindoc 126 | Write a value to a memory location given by a base 127 | address and offset. The following equality holds: 128 | \par 129 | \begin{quote} 130 | {\haddockverb\begin{verbatim} 131 | pokeByteOff addr off x = poke (addr `plusPtr` off) x 132 | \end{verbatim}} 133 | \end{quote} 134 | 135 | \end{haddockdesc} 136 | \begin{haddockdesc} 137 | \item[\begin{tabular}{@{}l} 138 | peek\ ::\ Ptr\ a\ ->\ IO\ a 139 | \end{tabular}]\haddockbegindoc 140 | Read a value from the given memory location. 141 | \par 142 | Note that the peek and poke functions might require properly 143 | aligned addresses to function correctly. This is architecture 144 | dependent; thus, portable code should ensure that when peeking or 145 | poking values of some type \haddocktt{a}, the alignment 146 | constraint for \haddocktt{a}, as given by the function 147 | \haddockid{alignment} is fulfilled. 148 | \par 149 | 150 | \end{haddockdesc} 151 | \begin{haddockdesc} 152 | \item[\begin{tabular}{@{}l} 153 | poke\ ::\ Ptr\ a\ ->\ a\ ->\ IO\ () 154 | \end{tabular}]\haddockbegindoc 155 | Write the given value to the given memory location. Alignment 156 | restrictions might apply; see \haddockid{peek}. 157 | \par 158 | 159 | \end{haddockdesc} 160 | \end{haddockdesc} 161 | \begin{haddockdesc} 162 | \item[\begin{tabular}{@{}l} 163 | instance\ Storable\ Bool\\instance\ Storable\ Char\\instance\ Storable\ Double\\instance\ Storable\ Float\\instance\ Storable\ Int\\instance\ Storable\ Int8\\instance\ Storable\ Int16\\instance\ Storable\ Int32\\instance\ Storable\ Int64\\instance\ Storable\ Word\\instance\ Storable\ Word8\\instance\ Storable\ Word16\\instance\ Storable\ Word32\\instance\ Storable\ Word64\\instance\ Storable\ WordPtr\\instance\ Storable\ IntPtr\\instance\ Storable\ CChar\\instance\ Storable\ CSChar\\instance\ Storable\ CUChar\\instance\ Storable\ CShort\\instance\ Storable\ CUShort\\instance\ Storable\ CInt\\instance\ Storable\ CUInt\\instance\ Storable\ CLong\\instance\ Storable\ CULong\\instance\ Storable\ CLLong\\instance\ Storable\ CULLong\\instance\ Storable\ CFloat\\instance\ Storable\ CDouble\\instance\ Storable\ CPtrdiff\\instance\ Storable\ CSize\\instance\ Storable\ CWchar\\instance\ Storable\ CSigAtomic\\instance\ Storable\ CClock\\instance\ Storable\ CTime\\instance\ Storable\ CIntPtr\\instance\ Storable\ CUIntPtr\\instance\ Storable\ CIntMax\\instance\ Storable\ CUIntMax\\instance\ Storable\ (StablePtr\ a)\\instance\ Storable\ (Ptr\ a)\\instance\ Storable\ (FunPtr\ a) 164 | \end{tabular}] 165 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Foreign.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Foreign} 2 | \label{module:Foreign} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Foreign ( 6 | module Data.Bits, module Data.Int, module Data.Word, module Foreign.Ptr, 7 | module Foreign.ForeignPtr, module Foreign.StablePtr, 8 | module Foreign.Storable, module Foreign.Marshal 9 | ) where\end{verbatim}} 10 | \haddockendheader 11 | 12 | The module \haddocktt{Foreign} combines the interfaces of all 13 | modules providing language-independent marshalling support, 14 | namely 15 | \par 16 | 17 | \begin{haddockdesc} 18 | \item[\begin{tabular}{@{}l} 19 | module\ Data.Bits\\module\ Data.Int\\module\ Data.Word\\module\ Foreign.Ptr\\module\ Foreign.ForeignPtr\\module\ Foreign.StablePtr\\module\ Foreign.Storable\\module\ Foreign.Marshal 20 | \end{tabular}] 21 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/Numeric.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{Numeric} 2 | \label{module:Numeric} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module Numeric ( 6 | showSigned, showIntAtBase, showInt, showHex, showOct, showEFloat, 7 | showFFloat, showGFloat, showFloat, floatToDigits, readSigned, readInt, 8 | readDec, readOct, readHex, readFloat, lexDigits, fromRat 9 | ) where\end{verbatim}} 10 | \haddockendheader 11 | 12 | \section{Showing 13 | } 14 | \begin{haddockdesc} 15 | \item[\begin{tabular}{@{}l} 16 | showSigned 17 | \end{tabular}]\haddockbegindoc 18 | \haddockbeginargs 19 | \haddockdecltt{::} & \haddockdecltt{Real a} \\ 20 | \haddockdecltt{=>} & \haddockdecltt{(a 21 | -> ShowS)} & a function that can show unsigned values 22 | \\ 23 | \haddockdecltt{->} & \haddockdecltt{Int} & the precedence of the enclosing context 24 | \\ 25 | \haddockdecltt{->} & \haddockdecltt{a} & the value to show 26 | \\ 27 | \haddockdecltt{->} & \haddockdecltt{ShowS} & \\ 28 | \end{tabulary}\par 29 | Converts a possibly-negative \haddockid{Real} value to a string. 30 | \par 31 | 32 | \end{haddockdesc} 33 | \begin{haddockdesc} 34 | \item[\begin{tabular}{@{}l} 35 | showIntAtBase\ ::\ Integral\ a\ =>\ a\ ->\ (Int\ ->\ Char)\ ->\ a\ ->\ ShowS 36 | \end{tabular}]\haddockbegindoc 37 | Shows a \emph{non-negative} \haddockid{Integral} number using the base specified by the 38 | first argument, and the character representation specified by the second. 39 | \par 40 | 41 | \end{haddockdesc} 42 | \begin{haddockdesc} 43 | \item[\begin{tabular}{@{}l} 44 | showInt\ ::\ Integral\ a\ =>\ a\ ->\ ShowS 45 | \end{tabular}]\haddockbegindoc 46 | Show \emph{non-negative} \haddockid{Integral} numbers in base 10. 47 | \par 48 | 49 | \end{haddockdesc} 50 | \begin{haddockdesc} 51 | \item[\begin{tabular}{@{}l} 52 | showHex\ ::\ Integral\ a\ =>\ a\ ->\ ShowS 53 | \end{tabular}]\haddockbegindoc 54 | Show \emph{non-negative} \haddockid{Integral} numbers in base 16. 55 | \par 56 | 57 | \end{haddockdesc} 58 | \begin{haddockdesc} 59 | \item[\begin{tabular}{@{}l} 60 | showOct\ ::\ Integral\ a\ =>\ a\ ->\ ShowS 61 | \end{tabular}]\haddockbegindoc 62 | Show \emph{non-negative} \haddockid{Integral} numbers in base 8. 63 | \par 64 | 65 | \end{haddockdesc} 66 | \begin{haddockdesc} 67 | \item[\begin{tabular}{@{}l} 68 | showEFloat\ ::\ RealFloat\ a\ =>\ Maybe\ Int\ ->\ a\ ->\ ShowS 69 | \end{tabular}]\haddockbegindoc 70 | Show a signed \haddockid{RealFloat} value 71 | using scientific (exponential) notation (e.g. \haddocktt{2.45e2}, \haddocktt{1.5e-3}). 72 | \par 73 | In the call \haddocktt{showEFloat\ digs\ val}, if \haddocktt{digs} is \haddockid{Nothing}, 74 | the value is shown to full precision; if \haddocktt{digs} is \haddocktt{Just\ d}, 75 | then at most \haddocktt{d} digits after the decimal point are shown. 76 | \par 77 | 78 | \end{haddockdesc} 79 | \begin{haddockdesc} 80 | \item[\begin{tabular}{@{}l} 81 | showFFloat\ ::\ RealFloat\ a\ =>\ Maybe\ Int\ ->\ a\ ->\ ShowS 82 | \end{tabular}]\haddockbegindoc 83 | Show a signed \haddockid{RealFloat} value 84 | using standard decimal notation (e.g. \haddocktt{245000}, \haddocktt{0.0015}). 85 | \par 86 | In the call \haddocktt{showFFloat\ digs\ val}, if \haddocktt{digs} is \haddockid{Nothing}, 87 | the value is shown to full precision; if \haddocktt{digs} is \haddocktt{Just\ d}, 88 | then at most \haddocktt{d} digits after the decimal point are shown. 89 | \par 90 | 91 | \end{haddockdesc} 92 | \begin{haddockdesc} 93 | \item[\begin{tabular}{@{}l} 94 | showGFloat\ ::\ RealFloat\ a\ =>\ Maybe\ Int\ ->\ a\ ->\ ShowS 95 | \end{tabular}]\haddockbegindoc 96 | Show a signed \haddockid{RealFloat} value 97 | using standard decimal notation for arguments whose absolute value lies 98 | between \haddocktt{0.1} and \haddocktt{9,999,999}, and scientific notation otherwise. 99 | \par 100 | In the call \haddocktt{showGFloat\ digs\ val}, if \haddocktt{digs} is \haddockid{Nothing}, 101 | the value is shown to full precision; if \haddocktt{digs} is \haddocktt{Just\ d}, 102 | then at most \haddocktt{d} digits after the decimal point are shown. 103 | \par 104 | 105 | \end{haddockdesc} 106 | \begin{haddockdesc} 107 | \item[\begin{tabular}{@{}l} 108 | showFloat\ ::\ RealFloat\ a\ =>\ a\ ->\ ShowS 109 | \end{tabular}]\haddockbegindoc 110 | Show a signed \haddockid{RealFloat} value to full precision 111 | using standard decimal notation for arguments whose absolute value lies 112 | between \haddocktt{0.1} and \haddocktt{9,999,999}, and scientific notation otherwise. 113 | \par 114 | 115 | \end{haddockdesc} 116 | \begin{haddockdesc} 117 | \item[\begin{tabular}{@{}l} 118 | floatToDigits\ ::\ RealFloat\ a\ =>\ Integer\ ->\ a\ ->\ ({\char 91}Int{\char 93},\ Int) 119 | \end{tabular}]\haddockbegindoc 120 | \haddockid{floatToDigits} takes a base and a non-negative \haddockid{RealFloat} number, 121 | and returns a list of digits and an exponent. 122 | In particular, if \haddocktt{x>=0}, and 123 | \par 124 | \begin{quote} 125 | {\haddockverb\begin{verbatim} 126 | floatToDigits base x = ([d1,d2,...,dn], e) 127 | \end{verbatim}} 128 | \end{quote} 129 | then 130 | \par 131 | \begin{enumerate} 132 | \item 133 | \begin{quote} 134 | {\haddockverb\begin{verbatim} 135 | n >= 1\end{verbatim}} 136 | \end{quote} 137 | 138 | \item 139 | \begin{quote} 140 | {\haddockverb\begin{verbatim} 141 | x = 0.d1d2...dn * (base**e)\end{verbatim}} 142 | \end{quote} 143 | 144 | \item 145 | \begin{quote} 146 | {\haddockverb\begin{verbatim} 147 | 0 <= di <= base-1\end{verbatim}} 148 | \end{quote} 149 | 150 | \end{enumerate} 151 | 152 | \end{haddockdesc} 153 | \section{Reading 154 | } 155 | \emph{NB:} \haddockid{readInt} is the 'dual' of \haddockid{showIntAtBase}, 156 | and \haddockid{readDec} is the `dual' of \haddockid{showInt}. 157 | The inconsistent naming is a historical accident. 158 | \par 159 | 160 | \begin{haddockdesc} 161 | \item[\begin{tabular}{@{}l} 162 | readSigned\ ::\ Real\ a\ =>\ ReadS\ a\ ->\ ReadS\ a 163 | \end{tabular}]\haddockbegindoc 164 | Reads a \emph{signed} \haddockid{Real} value, given a reader for an unsigned value. 165 | \par 166 | 167 | \end{haddockdesc} 168 | \begin{haddockdesc} 169 | \item[\begin{tabular}{@{}l} 170 | readInt 171 | \end{tabular}]\haddockbegindoc 172 | \haddockbeginargs 173 | \haddockdecltt{::} & \haddockdecltt{Num a} \\ 174 | \haddockdecltt{=>} & \haddockdecltt{a} & the base 175 | \\ 176 | \haddockdecltt{->} & \haddockdecltt{(Char 177 | -> Bool)} & a predicate distinguishing valid digits in this base 178 | \\ 179 | \haddockdecltt{->} & \haddockdecltt{(Char 180 | -> Int)} & a function converting a valid digit character to an \haddockid{Int} \\ 181 | \haddockdecltt{->} & \haddockdecltt{ReadS a} & \\ 182 | \end{tabulary}\par 183 | Reads an \emph{unsigned} \haddockid{Integral} value in an arbitrary base. 184 | \par 185 | 186 | \end{haddockdesc} 187 | \begin{haddockdesc} 188 | \item[\begin{tabular}{@{}l} 189 | readDec\ ::\ Num\ a\ =>\ ReadS\ a 190 | \end{tabular}]\haddockbegindoc 191 | Read an unsigned number in decimal notation. 192 | \par 193 | 194 | \end{haddockdesc} 195 | \begin{haddockdesc} 196 | \item[\begin{tabular}{@{}l} 197 | readOct\ ::\ Num\ a\ =>\ ReadS\ a 198 | \end{tabular}]\haddockbegindoc 199 | Read an unsigned number in octal notation. 200 | \par 201 | 202 | \end{haddockdesc} 203 | \begin{haddockdesc} 204 | \item[\begin{tabular}{@{}l} 205 | readHex\ ::\ Num\ a\ =>\ ReadS\ a 206 | \end{tabular}]\haddockbegindoc 207 | Read an unsigned number in hexadecimal notation. 208 | Both upper or lower case letters are allowed. 209 | \par 210 | 211 | \end{haddockdesc} 212 | \begin{haddockdesc} 213 | \item[\begin{tabular}{@{}l} 214 | readFloat\ ::\ RealFrac\ a\ =>\ ReadS\ a 215 | \end{tabular}]\haddockbegindoc 216 | Reads an \emph{unsigned} \haddockid{RealFrac} value, 217 | expressed in decimal scientific notation. 218 | \par 219 | 220 | \end{haddockdesc} 221 | \begin{haddockdesc} 222 | \item[\begin{tabular}{@{}l} 223 | lexDigits\ ::\ ReadS\ String 224 | \end{tabular}]\haddockbegindoc 225 | Reads a non-empty string of decimal digits. 226 | \par 227 | 228 | \end{haddockdesc} 229 | \section{Miscellaneous 230 | } 231 | \begin{haddockdesc} 232 | \item[\begin{tabular}{@{}l} 233 | fromRat\ ::\ RealFloat\ a\ =>\ Rational\ ->\ a 234 | \end{tabular}]\haddockbegindoc 235 | Converts a \haddockid{Rational} value into any type in class \haddockid{RealFloat}. 236 | \par 237 | 238 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/System-Environment.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{System.Environment} 2 | \label{module:System.Environment} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module System.Environment ( 6 | getArgs, getProgName, getEnv 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \begin{haddockdesc} 11 | \item[\begin{tabular}{@{}l} 12 | getArgs\ ::\ IO\ {\char 91}String{\char 93} 13 | \end{tabular}]\haddockbegindoc 14 | Computation \haddockid{getArgs} returns a list of the program's command 15 | line arguments (not including the program name). 16 | \par 17 | 18 | \end{haddockdesc} 19 | \begin{haddockdesc} 20 | \item[\begin{tabular}{@{}l} 21 | getProgName\ ::\ IO\ String 22 | \end{tabular}]\haddockbegindoc 23 | Computation \haddockid{getProgName} returns the name of the program as it was 24 | invoked. 25 | \par 26 | However, this is hard-to-impossible to implement on some non-Unix 27 | OSes, so instead, for maximum portability, we just return the leafname 28 | of the program as invoked. Even then there are some differences 29 | between platforms: on Windows, for example, a program invoked as foo 30 | is probably really \haddocktt{FOO.EXE}, and that is what \haddockid{getProgName} will return. 31 | \par 32 | 33 | \end{haddockdesc} 34 | \begin{haddockdesc} 35 | \item[\begin{tabular}{@{}l} 36 | getEnv\ ::\ String\ ->\ IO\ String 37 | \end{tabular}]\haddockbegindoc 38 | Computation \haddockid{getEnv} \haddocktt{var} returns the value 39 | of the environment variable \haddocktt{var}. 40 | \par 41 | This computation may fail with: 42 | \par 43 | \begin{itemize} 44 | \item 45 | \haddocktt{System.IO.Error.isDoesNotExistError} if the environment variable 46 | does not exist. 47 | \par 48 | 49 | \end{itemize} 50 | 51 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/System-Exit.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{System.Exit} 2 | \label{module:System.Exit} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module System.Exit ( 6 | ExitCode(ExitSuccess, ExitFailure), exitWith, exitFailure, exitSuccess 7 | ) where\end{verbatim}} 8 | \haddockendheader 9 | 10 | \begin{haddockdesc} 11 | \item[\begin{tabular}{@{}l} 12 | data\ ExitCode 13 | \end{tabular}]\haddockbegindoc 14 | \haddockbeginconstrs 15 | \haddockdecltt{=} & \haddockdecltt{ExitSuccess} & indicates successful termination; 16 | \\ 17 | \haddockdecltt{|} & \haddockdecltt{ExitFailure Int} & indicates program failure with an exit code. 18 | The exact interpretation of the code is 19 | operating-system dependent. In particular, some values 20 | may be prohibited (e.g. 0 on a POSIX-compliant system). 21 | \\ 22 | \end{tabulary}\par 23 | Defines the exit codes that a program can return. 24 | \par 25 | 26 | \end{haddockdesc} 27 | \begin{haddockdesc} 28 | \item[\begin{tabular}{@{}l} 29 | instance\ Eq\ ExitCode\\instance\ Ord\ ExitCode\\instance\ Read\ ExitCode\\instance\ Show\ ExitCode\\ 30 | \end{tabular}] 31 | \end{haddockdesc} 32 | \begin{haddockdesc} 33 | \item[\begin{tabular}{@{}l} 34 | exitWith\ ::\ ExitCode\ ->\ IO\ a 35 | \end{tabular}]\haddockbegindoc 36 | Computation \haddocktt{exitWith\ code} terminates the program, returning \haddocktt{code} 37 | to the program's caller. 38 | The caller may interpret the return code as it wishes, but the program 39 | should return \haddockid{ExitSuccess} to mean normal completion, and 40 | \haddocktt{ExitFailure\ n} to mean that the program encountered a problem from 41 | which it could not recover. The value \haddockid{exitFailure} is equal to 42 | \haddocktt{exitWith\ (ExitFailure\ exitfail)}, where \haddocktt{exitfail} is 43 | implementation-dependent. \haddockid{exitWith} bypasses the error handling in 44 | the I/O monad and cannot be intercepted by \haddockid{catch} from the \haddocktt{Prelude}. 45 | \par 46 | 47 | \end{haddockdesc} 48 | \begin{haddockdesc} 49 | \item[\begin{tabular}{@{}l} 50 | exitFailure\ ::\ IO\ a 51 | \end{tabular}]\haddockbegindoc 52 | The computation \haddockid{exitFailure} is equivalent to 53 | \haddockid{exitWith} \haddocktt{(}\haddockid{ExitFailure} \emph{exitfail}\haddocktt{)}, 54 | where \emph{exitfail} is implementation-dependent. 55 | \par 56 | 57 | \end{haddockdesc} 58 | \begin{haddockdesc} 59 | \item[\begin{tabular}{@{}l} 60 | exitSuccess\ ::\ IO\ a 61 | \end{tabular}]\haddockbegindoc 62 | The computation \haddockid{exitSuccess} is equivalent to 63 | \haddockid{exitWith} \haddockid{ExitSuccess}, It terminates the program 64 | successfully. 65 | \par 66 | 67 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/libs/System-IO-Error.tex: -------------------------------------------------------------------------------- 1 | \haddockmoduleheading{System.IO.Error} 2 | \label{module:System.IO.Error} 3 | \haddockbeginheader 4 | {\haddockverb\begin{verbatim} 5 | module System.IO.Error ( 6 | IOError, userError, mkIOError, annotateIOError, isAlreadyExistsError, 7 | isDoesNotExistError, isAlreadyInUseError, isFullError, isEOFError, 8 | isIllegalOperation, isPermissionError, isUserError, ioeGetErrorString, 9 | ioeGetHandle, ioeGetFileName, IOErrorType, alreadyExistsErrorType, 10 | doesNotExistErrorType, alreadyInUseErrorType, fullErrorType, 11 | eofErrorType, illegalOperationErrorType, permissionErrorType, 12 | userErrorType, ioError, catch, try 13 | ) where\end{verbatim}} 14 | \haddockendheader 15 | 16 | \section{I/O errors 17 | } 18 | \begin{haddockdesc} 19 | \item[\begin{tabular}{@{}l} 20 | type\ IOError\ =\ IOError 21 | \end{tabular}]\haddockbegindoc 22 | Errors of type \haddockid{IOError} are used by the \haddockid{IO} monad. This is an 23 | abstract type; the module \haddocktt{System.IO.Error} provides functions to 24 | interrogate and construct values of type \haddockid{IOError}. 25 | \par 26 | 27 | \end{haddockdesc} 28 | \begin{haddockdesc} 29 | \item[\begin{tabular}{@{}l} 30 | userError\ ::\ String\ ->\ IOError 31 | \end{tabular}]\haddockbegindoc 32 | Construct an \haddockid{IOError} value with a string describing the error. 33 | The \haddockid{fail} method of the \haddockid{IO} instance of the \haddockid{Monad} class raises a 34 | \haddockid{userError}, thus: 35 | \par 36 | \begin{quote} 37 | {\haddockverb\begin{verbatim} 38 | instance Monad IO where 39 | ... 40 | fail s = ioError (userError s) 41 | \end{verbatim}} 42 | \end{quote} 43 | 44 | \end{haddockdesc} 45 | \begin{haddockdesc} 46 | \item[\begin{tabular}{@{}l} 47 | mkIOError\ ::\ IOErrorType\\\ \ \ \ \ \ \ \ \ \ \ \ \ ->\ String\ ->\ Maybe\ Handle\ ->\ Maybe\ FilePath\ ->\ IOError 48 | \end{tabular}]\haddockbegindoc 49 | Construct an \haddockid{IOError} of the given type where the second argument 50 | describes the error location and the third and fourth argument 51 | contain the file handle and file path of the file involved in the 52 | error if applicable. 53 | \par 54 | 55 | \end{haddockdesc} 56 | \begin{haddockdesc} 57 | \item[\begin{tabular}{@{}l} 58 | annotateIOError\ ::\ IOError\\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ->\ String\ ->\ Maybe\ Handle\ ->\ Maybe\ FilePath\ ->\ IOError 59 | \end{tabular}]\haddockbegindoc 60 | Adds a location description and maybe a file path and file handle 61 | to an \haddockid{IOError}. If any of the file handle or file path is not given 62 | the corresponding value in the \haddockid{IOError} remains unaltered. 63 | \par 64 | 65 | \end{haddockdesc} 66 | \subsection{Classifying I/O errors 67 | } 68 | \begin{haddockdesc} 69 | \item[\begin{tabular}{@{}l} 70 | isAlreadyExistsError\ ::\ IOError\ ->\ Bool 71 | \end{tabular}]\haddockbegindoc 72 | An error indicating that an \haddockid{IO} operation failed because 73 | one of its arguments already exists. 74 | \par 75 | 76 | \end{haddockdesc} 77 | \begin{haddockdesc} 78 | \item[\begin{tabular}{@{}l} 79 | isDoesNotExistError\ ::\ IOError\ ->\ Bool 80 | \end{tabular}]\haddockbegindoc 81 | An error indicating that an \haddockid{IO} operation failed because 82 | one of its arguments does not exist. 83 | \par 84 | 85 | \end{haddockdesc} 86 | \begin{haddockdesc} 87 | \item[\begin{tabular}{@{}l} 88 | isAlreadyInUseError\ ::\ IOError\ ->\ Bool 89 | \end{tabular}]\haddockbegindoc 90 | An error indicating that an \haddockid{IO} operation failed because 91 | one of its arguments is a single-use resource, which is already 92 | being used (for example, opening the same file twice for writing 93 | might give this error). 94 | \par 95 | 96 | \end{haddockdesc} 97 | \begin{haddockdesc} 98 | \item[\begin{tabular}{@{}l} 99 | isFullError\ ::\ IOError\ ->\ Bool 100 | \end{tabular}]\haddockbegindoc 101 | An error indicating that an \haddockid{IO} operation failed because 102 | the device is full. 103 | \par 104 | 105 | \end{haddockdesc} 106 | \begin{haddockdesc} 107 | \item[\begin{tabular}{@{}l} 108 | isEOFError\ ::\ IOError\ ->\ Bool 109 | \end{tabular}]\haddockbegindoc 110 | An error indicating that an \haddockid{IO} operation failed because 111 | the end of file has been reached. 112 | \par 113 | 114 | \end{haddockdesc} 115 | \begin{haddockdesc} 116 | \item[\begin{tabular}{@{}l} 117 | isIllegalOperation\ ::\ IOError\ ->\ Bool 118 | \end{tabular}]\haddockbegindoc 119 | An error indicating that an \haddockid{IO} operation failed because 120 | the operation was not possible. 121 | Any computation which returns an \haddockid{IO} result may fail with 122 | \haddockid{isIllegalOperation}. In some cases, an implementation will not be 123 | able to distinguish between the possible error causes. In this case 124 | it should fail with \haddockid{isIllegalOperation}. 125 | \par 126 | 127 | \end{haddockdesc} 128 | \begin{haddockdesc} 129 | \item[\begin{tabular}{@{}l} 130 | isPermissionError\ ::\ IOError\ ->\ Bool 131 | \end{tabular}]\haddockbegindoc 132 | An error indicating that an \haddockid{IO} operation failed because 133 | the user does not have sufficient operating system privilege 134 | to perform that operation. 135 | \par 136 | 137 | \end{haddockdesc} 138 | \begin{haddockdesc} 139 | \item[\begin{tabular}{@{}l} 140 | isUserError\ ::\ IOError\ ->\ Bool 141 | \end{tabular}]\haddockbegindoc 142 | A programmer-defined error value constructed using \haddockid{userError}. 143 | \par 144 | 145 | \end{haddockdesc} 146 | \subsection{Attributes of I/O errors 147 | } 148 | \begin{haddockdesc} 149 | \item[ 150 | ioeGetErrorString\ ::\ IOError\ ->\ String 151 | ] 152 | \item[ 153 | ioeGetHandle\ ::\ IOError\ ->\ Maybe\ Handle 154 | ] 155 | \item[ 156 | ioeGetFileName\ ::\ IOError\ ->\ Maybe\ FilePath 157 | ] 158 | \end{haddockdesc} 159 | \section{Types of I/O error 160 | } 161 | \begin{haddockdesc} 162 | \item[\begin{tabular}{@{}l} 163 | data\ IOErrorType 164 | \end{tabular}]\haddockbegindoc 165 | An abstract type that contains a value for each variant of \haddockid{IOError}. 166 | \par 167 | 168 | \end{haddockdesc} 169 | \begin{haddockdesc} 170 | \item[\begin{tabular}{@{}l} 171 | instance\ Eq\ IOErrorType\\instance\ Show\ IOErrorType 172 | \end{tabular}] 173 | \end{haddockdesc} 174 | \begin{haddockdesc} 175 | \item[\begin{tabular}{@{}l} 176 | alreadyExistsErrorType\ ::\ IOErrorType 177 | \end{tabular}]\haddockbegindoc 178 | I/O error where the operation failed because one of its arguments 179 | already exists. 180 | \par 181 | 182 | \end{haddockdesc} 183 | \begin{haddockdesc} 184 | \item[\begin{tabular}{@{}l} 185 | doesNotExistErrorType\ ::\ IOErrorType 186 | \end{tabular}]\haddockbegindoc 187 | I/O error where the operation failed because one of its arguments 188 | does not exist. 189 | \par 190 | 191 | \end{haddockdesc} 192 | \begin{haddockdesc} 193 | \item[\begin{tabular}{@{}l} 194 | alreadyInUseErrorType\ ::\ IOErrorType 195 | \end{tabular}]\haddockbegindoc 196 | I/O error where the operation failed because one of its arguments 197 | is a single-use resource, which is already being used. 198 | \par 199 | 200 | \end{haddockdesc} 201 | \begin{haddockdesc} 202 | \item[\begin{tabular}{@{}l} 203 | fullErrorType\ ::\ IOErrorType 204 | \end{tabular}]\haddockbegindoc 205 | I/O error where the operation failed because the device is full. 206 | \par 207 | 208 | \end{haddockdesc} 209 | \begin{haddockdesc} 210 | \item[\begin{tabular}{@{}l} 211 | eofErrorType\ ::\ IOErrorType 212 | \end{tabular}]\haddockbegindoc 213 | I/O error where the operation failed because the end of file has 214 | been reached. 215 | \par 216 | 217 | \end{haddockdesc} 218 | \begin{haddockdesc} 219 | \item[\begin{tabular}{@{}l} 220 | illegalOperationErrorType\ ::\ IOErrorType 221 | \end{tabular}]\haddockbegindoc 222 | I/O error where the operation is not possible. 223 | \par 224 | 225 | \end{haddockdesc} 226 | \begin{haddockdesc} 227 | \item[\begin{tabular}{@{}l} 228 | permissionErrorType\ ::\ IOErrorType 229 | \end{tabular}]\haddockbegindoc 230 | I/O error where the operation failed because the user does not 231 | have sufficient operating system privilege to perform that operation. 232 | \par 233 | 234 | \end{haddockdesc} 235 | \begin{haddockdesc} 236 | \item[\begin{tabular}{@{}l} 237 | userErrorType\ ::\ IOErrorType 238 | \end{tabular}]\haddockbegindoc 239 | I/O error that is programmer-defined. 240 | \par 241 | 242 | \end{haddockdesc} 243 | \section{Throwing and catching I/O errors 244 | } 245 | \begin{haddockdesc} 246 | \item[\begin{tabular}{@{}l} 247 | ioError\ ::\ IOError\ ->\ IO\ a 248 | \end{tabular}]\haddockbegindoc 249 | Raise an \haddockid{IOError} in the \haddockid{IO} monad. 250 | \par 251 | 252 | \end{haddockdesc} 253 | \begin{haddockdesc} 254 | \item[\begin{tabular}{@{}l} 255 | catch\ ::\ IO\ a\ ->\ (IOError\ ->\ IO\ a)\ ->\ IO\ a 256 | \end{tabular}]\haddockbegindoc 257 | The \haddockid{catch} function establishes a handler that receives any \haddockid{IOError} 258 | raised in the action protected by \haddockid{catch}. An \haddockid{IOError} is caught by 259 | the most recent handler established by \haddockid{catch}. These handlers are 260 | not selective: all \haddockid{IOError}s are caught. Exception propagation 261 | must be explicitly provided in a handler by re-raising any unwanted 262 | exceptions. For example, in 263 | \par 264 | \begin{quote} 265 | {\haddockverb\begin{verbatim} 266 | f = catch g (\e -> if IO.isEOFError e then return [] else ioError e) 267 | \end{verbatim}} 268 | \end{quote} 269 | the function \haddocktt{f} returns \haddocktt{{\char 91}{\char 93}} when an end-of-file exception 270 | (cf. \haddockid{isEOFError}) occurs in \haddocktt{g}; otherwise, the 271 | exception is propagated to the next outer handler. 272 | \par 273 | When an exception propagates outside the main program, the Haskell 274 | system prints the associated \haddockid{IOError} value and exits the program. 275 | \par 276 | 277 | \end{haddockdesc} 278 | \begin{haddockdesc} 279 | \item[\begin{tabular}{@{}l} 280 | try\ ::\ IO\ a\ ->\ IO\ (Either\ IOError\ a) 281 | \end{tabular}]\haddockbegindoc 282 | The construct \haddockid{try} \haddocktt{comp} exposes IO errors which occur within a 283 | computation, and which are not fully handled. 284 | \par 285 | 286 | \end{haddockdesc} -------------------------------------------------------------------------------- /report/report/pragmas.verb: -------------------------------------------------------------------------------- 1 | % 2 | % $Header: /home/cvs/root/haskell-report/report/pragmas.verb,v 1.6 2002/12/10 11:51:11 simonpj Exp $ 3 | % 4 | %**The Haskell 98 Report: Compiler Pragmas 5 | %**~header 6 | \section{Compiler Pragmas} 7 | \label{pragmas} 8 | \index{pragmas} 9 | 10 | Some compiler implementations support compiler {\em pragmas}, which 11 | are used to give additional instructions or hints to the compiler, but 12 | which do not form part of the \Haskell{} language proper and do not 13 | change a program's semantics. This chapter summarizes this existing 14 | practice. An implementation is not required to respect any pragma, 15 | although pragmas that are not recognised by the implementation should 16 | be ignored. \hprime{Implementations are strongly encouraged to support the 17 | LANGUAGE pragma described below as there are many language extensions 18 | being used in practice.} 19 | 20 | Lexically, pragmas appear as comments, except that the enclosing 21 | syntax is @{-#@ @#-}@. 22 | 23 | \subsection{Inlining} 24 | \index{inlining} 25 | @@@ 26 | decl -> @{-#@ @INLINE@ qvars @#-}@ 27 | decl -> @{-#@ @NOINLINE@ qvars @#-}@ 28 | @@@ 29 | % The optional digit represents the level of optimization at which the 30 | % inlining is to occur. If omitted, it is assumed to be 0. A compiler 31 | % may use a numeric optimization level setting in which increasing level 32 | % numbers indicate increasing amounts of optimization. Trivial 33 | % inlinings that have no 34 | % impact on compilation time or code size should have an optimization 35 | % level of 0; more complex inlinings that may lead to slow compilation 36 | % or large executables should be associated with higher optimization levels. 37 | 38 | The @INLINE@ pragma instructs the compiler to inline the specified variables 39 | at their use sites. 40 | Compilers will often automatically inline simple expressions. This 41 | may be prevented by the @NOINLINE@ pragma. 42 | 43 | \subsection{Specialization} 44 | @@@ 45 | decl -> @{-#@ @SPECIALIZE@ spec_1 @,@ ... @,@ spec_k @#-}@ & (k>=1) 46 | spec -> vars :: type 47 | @@@ 48 | Specialization is used to avoid inefficiencies involved in dispatching 49 | overloaded functions. For example, in 50 | \bprog 51 | @ 52 | factorial :: Num a => a -> a 53 | factorial 0 = 0 54 | factorial n = n * factorial (n-1) 55 | {-# SPECIALIZE factorial :: Int -> Int, 56 | factorial :: Integer -> Integer #-} 57 | @ 58 | \eprog 59 | calls to @factorial@ in which the compiler can detect that the 60 | parameter is either @Int@ or @Integer@ will 61 | use specialized versions of @factorial@ which do not involve 62 | overloaded numeric operations. 63 | 64 | \subsection{Language extensions} 65 | 66 | \begin{haskellprime} 67 | 68 | The @LANGUAGE@ pragma is a file-header pragma. A file-header pragma must 69 | precede the module keyword in a source file. There can be as many 70 | file-header pragmas as you please, and they can be preceded or 71 | followed by comments. An individual language pragma begins with the 72 | keyword @LANGUAGE@ and is followed by a comma-separated list of named 73 | language features. 74 | 75 | For example, to enable scoped type variables and preprocessing with 76 | CPP, if your Haskell implementation supports these extensions: 77 | \bprog 78 | @ 79 | {-# LANGUAGE ScopedTypeVariables, CPP #-} 80 | @ 81 | \eprog 82 | If a Haskell implementation does not recognize or support a particular 83 | language feature that a source file requests (or cannot support the 84 | combination of language features requested), any attempt to compile 85 | or otherwise use that file with that Haskell implementation must fail 86 | with an error. 87 | 88 | In the interests of portability, multiple attempts to enable the same, 89 | supported language features (e.g. via command-line arguments, 90 | implementation-specific features dependencies or non-standard 91 | pragmas) are specifically permitted. Haskell 2010 implementations that 92 | support the @LANGUAGE@ pragma are required to support 93 | \bprog 94 | @ 95 | {-# LANGUAGE Haskell2010 #-} 96 | @ 97 | \eprog 98 | Those implementations are also encouraged to support the following 99 | named language features: 100 | \bprog 101 | @ 102 | PatternGuards, NoNPlusKPatterns, 103 | EmptyDataDecls, ForeignFunctionInterface 104 | @ 105 | \eprog 106 | These are the named language extensions supported by some pre-Haskell 107 | 2010 implementations, that have been integrated into this report. 108 | 109 | \end{haskellprime} 110 | 111 | %**~footer 112 | -------------------------------------------------------------------------------- /report/report/standard-prelude.verb: -------------------------------------------------------------------------------- 1 | % 2 | % $Header: /home/cvs/root/haskell-report/report/standard-prelude.verb,v 1.4 2002/12/10 11:51:11 simonpj Exp $ 3 | % 4 | %**The Haskell 98 Report: Standard Prelude 5 | %**~header 6 | %*anchor on 7 | \section{Standard Prelude} 8 | \label{stdprelude} 9 | 10 | In this chapter the entire \Haskell{} Prelude is given. It constitutes 11 | a {\em specification} for the Prelude. Many of the definitions are 12 | written with clarity rather than efficiency in mind, 13 | and it is not required that the specification be implemented as shown here. 14 | 15 | The default method definitions, given with @class@ declarations, constitute 16 | a specification {\em only} of the default method. They do not constitute a 17 | specification of the meaning of the method in all instances. To take 18 | one particular example, the default method for @enumFrom@ in class @Enum@ 19 | will not work properly for types whose range exceeds that of @Int@ (because 20 | @fromEnum@ cannot map all values in the type to distinct @Int@ values). 21 | 22 | The Prelude shown here is organized into a root module, @Prelude@, 23 | and three sub-modules, @PreludeList@, @PreludeText@, and @PreludeIO@. 24 | This structure is purely presentational. 25 | An implementation is not required to use 26 | this organisation for the Prelude, 27 | nor are these three modules available for import separately. 28 | Only the exports of module @Prelude@ are significant. 29 | 30 | Some of these modules import Library modules, such as @Data.Char@, @Control.Monad@, @System.IO@, 31 | and @Numeric@. These modules are described fully in Part~\ref{libraries}. 32 | These imports are not, of course, part of the specification 33 | of the @Prelude@. That is, an implementation is free to import more, or less, 34 | of the Library modules, as it pleases. 35 | 36 | Primitives that 37 | are not definable in \Haskell{}, indicated by names starting with ``@prim@'', are 38 | defined in a system dependent manner in module @PreludeBuiltin@ and 39 | are not shown here. Instance declarations that simply bind primitives to 40 | class methods are omitted. Some of the more verbose instances with 41 | obvious functionality have been left out for the sake of brevity. 42 | 43 | Declarations for special types such as @Integer@, or @()@ are 44 | included in the Prelude for completeness even though the declaration 45 | may be incomplete or syntactically invalid. An ellipsis ``@...@'' is often 46 | used in places where the remainder of a definition cannot be given in Haskell. 47 | 48 | To reduce the occurrence of unexpected ambiguity errors, and to 49 | improve efficiency, a number of commonly-used functions over lists use 50 | the @Int@ type rather than using a more general numeric type, such as 51 | @Integral a@ or @Num a@. These functions are: @take@, @drop@, 52 | @!!@, @length@, @splitAt@, and @replicate@. The more general 53 | versions are given in the @Data.List@ library, with the prefix 54 | ``@generic@''; for example @genericLength@. 55 | 56 | \clearpage 57 | % The index entries for :, [], (), and tuples are here 58 | % it just so HAPPENS that they'll end up referring to the right page 59 | % HHAACCKK!! <---- Partain, you scoundrel! -- KH 60 | % Well, they aren't there anymore so I nuked them. So there! jcp 61 | \inputHS{Prelude}\clearpage 62 | 63 | %\subsection{Prelude {\tt PreludeBuiltin}} 64 | %\label{preludebuiltin} 65 | %\input{PreludeBuiltin}\clearpage 66 | 67 | 68 | \subsection{Prelude \texorpdfstring{{\tt PreludeList}}{PreludeList}} 69 | \label{preludelist} 70 | \inputHS{PreludeList}\clearpage 71 | \subsection{Prelude \texorpdfstring{{\tt PreludeText}}{PreludeText}} 72 | \label{preludetext} 73 | \inputHS{PreludeText}\cleardoublepage 74 | 75 | \subsection{Prelude \texorpdfstring{{\tt PreludeIO}}{PreludeIO}} 76 | \label{preludeio} 77 | \inputHS{PreludeIO} 78 | %**~footer 79 | 80 | 81 | -------------------------------------------------------------------------------- /report/report/syntax-lexical.verb: -------------------------------------------------------------------------------- 1 | % 2 | % $Header: /home/cvs/root/haskell-report/report/syntax-lexical.verb,v 1.10 2003/01/13 13:08:56 simonpj Exp $ 3 | % 4 | 5 | @@@ 6 | 7 | program -> \{ lexeme | whitespace \} 8 | lexeme -> qvarid | qconid | qvarsym | qconsym 9 | | literal | special | reservedop | reservedid 10 | literal -> integer | float | char | string 11 | special -> @(@ | @)@ | @,@ | @;@ | @[@ | @]@ | \bkq | @{@ | @}@ 12 | 13 | whitespace -> whitestuff \{whitestuff\} 14 | whitestuff -> whitechar | comment | ncomment 15 | whitechar -> newline | vertab | space | tab | uniWhite 16 | newline -> return linefeed | return | linefeed | formfeed 17 | return -> \tr{a carriage return} 18 | linefeed -> \tr{a line feed} 19 | vertab -> \tr{a vertical tab} 20 | formfeed -> \tr{a form feed} 21 | space -> \tr{a space} 22 | tab -> \tr{a horizontal tab} 23 | uniWhite -> \tr{any Unicode character defined as whitespace} 24 | 25 | comment -> dashes [ any_{\langle{}symbol\rangle} \{any\} ] newline 26 | dashes -> @--@ \{@-@\} 27 | opencom -> @{-@ 28 | closecom -> @-}@ 29 | ncomment -> opencom ANYseq \{ncomment ANYseq\} closecom 30 | ANYseq -> \{ANY\}_{\langle{}\{ANY\} ( opencom | closecom ) \{ANY\}\rangle{}} 31 | ANY -> graphic | whitechar 32 | any -> graphic | space | tab 33 | graphic -> small | large | symbol | digit | special | @"@ | @'@ 34 | 35 | small -> ascSmall | uniSmall | @_@ 36 | ascSmall -> @a@ | @b@ | ... | @z@ 37 | uniSmall -> \tr{any Unicode lowercase letter} 38 | 39 | large -> ascLarge | uniLarge 40 | ascLarge -> @A@ | @B@ | ... | @Z@ 41 | uniLarge -> \tr{any uppercase or titlecase Unicode letter} 42 | symbol -> ascSymbol | uniSymbol_{\langle{}special | @_@ | @"@ | @'@\rangle{}} 43 | 44 | ascSymbol -> @!@ | @#@ | @$@ | @%@ | @&@ | @*@ | @+@ | @.@ | @/@ | @<@ | @=@ | @>@ | @?@ | @@ 45 | | @\@ | @^@ | @|@ | @-@ | @~@ \hprime{| @:@} 46 | uniSymbol -> \tr{any Unicode symbol or punctuation} 47 | digit -> ascDigit | uniDigit 48 | ascDigit -> @0@ | @1@ | ... | @9@ 49 | uniDigit -> \tr{any Unicode decimal digit} 50 | octit -> @0@ | @1@ | ... | @7@ 51 | hexit -> digit | @A@ | ... | @F@ | @a@ | ... | @f@ 52 | 53 | @@@ 54 | 55 | \indexsyn{program}% 56 | \indexsyn{lexeme}% 57 | \indexsyn{literal}% 58 | \indexsyn{special}% 59 | \indexsyn{whitespace}% 60 | \indexsyn{whitestuff}% 61 | \indexsyn{whitechar}% 62 | \indexsyn{uniWhite}% 63 | \indexsyn{newline}% 64 | \indexsyn{space}% 65 | \indexsyn{tab}% 66 | \indexsyn{vertab}% 67 | \indexsyn{formfeed}% 68 | \indexsyn{comment}% 69 | \indexsyn{dashes}% 70 | \indexsyn{ncomment}% 71 | \indexsyn{opencom}% 72 | \indexsyn{closecom}% 73 | \indexsyn{ANYseq}% 74 | \indexsyn{ANY}% 75 | \indexsyn{any}% 76 | \indexsyn{graphic}% 77 | \indexsyn{small}% 78 | \indexsyn{ascSmall}% 79 | \indexsyn{uniSmall}% 80 | \indexsyn{uniDigit}% 81 | \indexsyn{large}% 82 | \indexsyn{ascLarge}% 83 | \indexsyn{uniLarge}% 84 | \indexsyn{symbol}% 85 | \indexsyn{ascSymbol}% 86 | \indexsyn{uniSymbol}% 87 | \indexsyn{digit}% 88 | \indexsyn{ascDigit}% 89 | \indexsyn{uniDigit}% 90 | \indexsyn{octit}% 91 | \indexsyn{hexit}% 92 | -------------------------------------------------------------------------------- /report/styles/code.sty: -------------------------------------------------------------------------------- 1 | 2 | % I have enclosed code.sty, which achieves 99% of what you want without 3 | % the need for a separate preprocessor. At the start of your document 4 | % you write "\makeatactive". From then on, inline code is written as @\x 5 | % -> x_1 & y@. The only difference with what you are used to, is that 6 | % instead of 7 | % 8 | % @ 9 | % foo :: Int -> Int 10 | % foo = \n -> n+1 11 | % @ 12 | % 13 | % you have to write 14 | % 15 | % \begin{code} 16 | % foo :: Int -> Int 17 | % foo = \n -> n+1 18 | % \end{code} 19 | % 20 | % and that you cannot use @ in \section{} and \caption{}. For the paper that occured twice, in which case I had to replace @...@ b y \texttt{...}. 21 | % 22 | % 23 | % code.sty --- nice verbatim mode for code 24 | 25 | % To get '@' use \verb+@+ 26 | 27 | \def\icode{% 28 | \relax\ifmmode\hbox\else\leavevmode\null\fi 29 | \bgroup 30 | %\begingroup 31 | \@noligs 32 | \verbatim@font 33 | \verb@eol@error 34 | \let\do\@makeother \dospecials 35 | \@vobeyspaces 36 | \frenchspacing 37 | \@icode} 38 | \def\@icode#1{% 39 | \catcode`#1\active 40 | \lccode`\~`#1% 41 | \lowercase{\let~\icode@egroup}} 42 | \def\icode@egroup{% 43 | %\endgroup} 44 | \egroup} 45 | 46 | % The \makeatactive command: 47 | % makes @ active, in such a way that @...@ behaves as \icode@...@: 48 | { 49 | \catcode`@=\active 50 | \gdef\makeatactive{ 51 | \catcode`@=\active \def@{\icode@} 52 | % Since @ becomes active, it has to be taken care of in verbatim-modes: 53 | \let\olddospecials\dospecials \def\dospecials{\do\@\olddospecials}} 54 | } 55 | % \gdef\makeatother{\g@remfrom@specials{\@}\@makeother\@} 56 | \gdef\makeatother{\@makeother\@} 57 | 58 | \newcommand\codetabwidth{42pt} 59 | {\catcode`\^^I=\active% 60 | \gdef\@vobeytab{\catcode`\^^I\active\let^^I\@xobeytab}} 61 | \def\@xobeytab{\leavevmode\penalty10000\hskip\codetabwidth} 62 | 63 | \begingroup \catcode `|=0 \catcode `[= 1 64 | \catcode`]=2 \catcode `\{=12 \catcode `\}=12 65 | \catcode`\\=12 |gdef|@xcode#1\end{code}[#1|end[code]] 66 | |endgroup 67 | \def\@code{\trivlist \item\relax 68 | \if@minipage\else\vskip\parskip\fi 69 | \leftskip\@totalleftmargin\rightskip\z@skip 70 | \parindent\z@\parfillskip\@flushglue\parskip\z@skip 71 | \@@par 72 | \@tempswafalse 73 | \def\par{% 74 | \if@tempswa 75 | \leavevmode \null \@@par\penalty\interlinepenalty 76 | \else 77 | \@tempswatrue 78 | \ifhmode\@@par\penalty\interlinepenalty\fi 79 | \fi}% 80 | \obeylines \verbatim@font \@noligs 81 | \let\do\@makeother \dospecials 82 | \everypar \expandafter{\the\everypar \unpenalty}% 83 | } 84 | \def\code{\@code \frenchspacing\@vobeytab\@vobeyspaces \@xcode} 85 | \def\endcode{\if@newlist \leavevmode\fi\endtrivlist} 86 | -------------------------------------------------------------------------------- /report/styles/grammar.sty: -------------------------------------------------------------------------------- 1 | %%% LaTeX2e package file to set EBNF in the style of the Haskell report 2 | %%% 3 | %%% Manuel M. T. Chakravarty [1997..2001] 4 | %%% 5 | %%% $Id: grammar.sty,v 1.1 2003/01/14 06:58:33 chak Exp $ 6 | %%% 7 | %%% This file is free software; you can redistribute it and/or modify 8 | %%% it under the terms of the GNU General Public License as published by 9 | %%% the Free Software Foundation; either version 2 of the License, or 10 | %%% (at your option) any later version. 11 | %%% 12 | %%% This file is distributed in the hope that it will be useful, 13 | %%% but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | %%% GNU General Public License for more details. 16 | %%% 17 | %%% DOCU ====================================================================== 18 | %%% 19 | %%% As a cheap (and ineffective) substitute for proper documentation, here an 20 | %%% example using the macros: 21 | %%% 22 | %%% \begin{grammar} 23 | %%% \grule{ftype}{% 24 | %%% \gnterm{frtype}} 25 | %%% \gor{% 26 | %%% \gnterm{fatype} -> \gnterm{ftype}} 27 | %%% \grule{frtype}{% 28 | %%% \gnterm{fatype}} 29 | %%% \gor{% 30 | %%% ()} 31 | %%% \grule[$k\geq0$]{fatype}{% 32 | %%% \gnterm{qtycon} \gnterm[1]{atype} \gellipse\ \gnterm[k]{atype}} 33 | %%% \end{grammar} 34 | %%% 35 | %%% TODO ====================================================================== 36 | %%% 37 | %%% * flexible way of determining the column width is needed (should be the 38 | %%% same throughout a single grammar (or even the whole document) 39 | %%% 40 | 41 | \ProvidesPackage{grammar}[2001/04/17, v0.5a, ] 42 | 43 | \RequirePackage{ifthen} 44 | 45 | % font configuration 46 | % 47 | % * these two commands can be redefined to change the default fonts for 48 | % terminals and non-terminals, respectively 49 | % 50 | \newcommand{\gtermfont}{\ttfamily} 51 | \newcommand{\gntermfont}{\rmfamily\itshape} 52 | 53 | % remembers whether we are in the star form of the grammar environment 54 | % (internal) 55 | % 56 | \newif\if@quoted 57 | 58 | % grammar environment 59 | % 60 | % * typeset in paragraph mode within a tabular 61 | % * there are four columns, containing the nonterminal, rule symbol (-> or |), 62 | % the rules rhs, and a comment, respectively 63 | % * the star form of the command is not `quote'd 64 | % 65 | \newenvironment{grammar}{% 66 | \@quotedtrue 67 | \@grammar 68 | }{% 69 | \@endgrammar 70 | } 71 | \newenvironment{grammar*}{% 72 | \@quotedfalse 73 | \@grammar 74 | }{% 75 | \@endgrammar 76 | } 77 | 78 | % internal implementation of the grammar environment 79 | % 80 | \newcommand{\@grammar}{% 81 | \gtermfont % for terminals 82 | \if@quoted\quote\fi 83 | \tabular{@{}lcl@{\quad}l@{}} 84 | } 85 | \newcommand{\@endgrammar}{% 86 | \endtabular 87 | \if@quoted\endquote\fi 88 | \ignorespaces\global\@ignoretrue 89 | } 90 | 91 | % a rule: optional comment, lhs, and rhs 92 | % 93 | \newcommand{\grule}[3][!*NEVER USED ARGUMENT*!]{% 94 | \ifthenelse{\equal{#1}{!*NEVER USED ARGUMENT*!}}{% 95 | \gnterm{#2} &$\rightarrow$& #3 \\ 96 | }{% 97 | \gnterm{#2} &$\rightarrow$& #3 & \rmfamily(#1)\\ 98 | }% 99 | } 100 | 101 | % a rule alternative: optional comment and rhs 102 | % 103 | \newcommand{\gor}[2][!*NEVER USED ARGUMENT*!]{% 104 | \ifthenelse{\equal{#1}{!*NEVER USED ARGUMENT*!}}{% 105 | &$|$& #2\\ 106 | }{% 107 | &$|$& #2 & \rmfamily(#1)\\ 108 | }% 109 | } 110 | 111 | % set a non-terminal with an optimal subscript 112 | % 113 | \newcommand{\gnterm}[2][!*NEVER USED ARGUMENT*!]{% 114 | \bgroup 115 | \gntermfont#2% 116 | \ifthenelse{\equal{#1}{!*NEVER USED ARGUMENT*!}}\relax{% 117 | \(_{#1}\)% 118 | }% 119 | \egroup 120 | } 121 | 122 | \newcommand{\galt}{$|$} % inline alternatives 123 | \newcommand{\gellipse}{\textrm{\ldots}} % ellipses 124 | \newcommand{\ggroup}[1]{\textrm(#1\textrm)} % grouped expression 125 | \newcommand{\gopt}[1]{\textrm[#1\textrm]} % optinal term 126 | \newcommand{\grepeat}[1]{\textrm\{#1\textrm\}} % repeated term 127 | \newcommand{\gminus}[1]{% % set difference 128 | \(_{\langle\mbox{\scriptsize #1}\rangle}\)} 129 | \newcommand{\gverbal}[1]{{\rmfamily\textbf{#1}}}% informal description 130 | 131 | % the following command is for terminals, but it is not necessary with the 132 | % `grammar' environment, as terminals are the default; it is however useful in 133 | % the rest of the text 134 | % 135 | \newcommand{\gterm}[1]{{\normalfont\gtermfont#1}} 136 | 137 | % some characters that are difficult to denote 138 | % 139 | \newcommand{\gbackslash}{\char"5C} 140 | \newcommand{\gtilde}{\char"7E} 141 | \newcommand{\ghat}{\char"5E} 142 | -------------------------------------------------------------------------------- /report/tools/Makefile: -------------------------------------------------------------------------------- 1 | # Tools for building the Haskell Report 2 | 3 | # tex.hs -- Program to generate html from verb / hs 4 | # index.hs -- Program to hyperlink prelude index 5 | # splitAndIndexPgm -- perl script to convert .hs to .verb 6 | 7 | # What is GHC? 8 | GHC = ghc 9 | 10 | # What is Lex? 11 | LEX = flex 12 | LEX_OPTS = -t -8 13 | 14 | all : verbatim verb-tex4ht run_index 15 | 16 | %.c : %.lex 17 | $(LEX) $(LEX_OPTS) $< > $@ || ( rm -f verbatim.c && exit 1 ) 18 | 19 | %.o : %.c 20 | $(CC) -c $< -o $@ 21 | 22 | verbatim: verbatim.o 23 | $(CC) -o $@ $^ 24 | 25 | verb-tex4ht: verb-tex4ht.o 26 | $(CC) -o $@ $^ 27 | 28 | run_index: index.hs 29 | $(GHC) -o run_index index.hs -Wall 30 | 31 | clean: 32 | rm -f verbatim verb-tex4ht run_tex run_index *.o *.hi 33 | -------------------------------------------------------------------------------- /report/tools/index.hs: -------------------------------------------------------------------------------- 1 | 2 | -- This generates the prelude index to the report by hyper-linking all 3 | -- of the names in a hand-written document. This is probably too 4 | -- obscure to bother explaining. Hardwires for the Haskell report at the 5 | -- moment. 6 | 7 | module Main where 8 | 9 | import Data.Char 10 | import Data.List 11 | import System.IO.Error 12 | 13 | main :: IO () 14 | main = do refs <- readRefFile "reportrefs" 15 | doFiles refs ["prelude-index"] 16 | 17 | doFiles :: Refs -> [FilePath] -> IO () 18 | doFiles r files = do mapM_ (doFile r) files 19 | putStrLn "Done." 20 | 21 | doFile :: Refs -> FilePath -> IO () 22 | doFile r f = catchIOError 23 | (do putStrLn ("Reading " ++ f ++ ".idx") 24 | ls <- readFile (f ++ ".idx") 25 | let output = expandAllRefs r (lines ls) 26 | writeFile ("haskell-report-html/" ++ f ++ ".html") 27 | (unlines output)) 28 | (\err -> putStrLn ("Error: " ++ show err)) 29 | 30 | -- This sets up the parts of the state that need to be reset at the start of 31 | -- each file. 32 | 33 | type Refs = [(String,String)] 34 | 35 | expandAllRefs :: Refs -> [String] -> [String] 36 | expandAllRefs r ls = expandAll1 r False ls 37 | 38 | expandAll1 :: Refs -> Bool -> [String] -> [String] 39 | expandAll1 _ _ [] = [] 40 | expandAll1 r table (l:ls) | l == "#table" = expandAll1 r True ls 41 | | l == "#endtable" = expandAll1 r False ls 42 | | table = ("" ++ nbspaces (expandRefs r l) 43 | ++ "") : rest 44 | | otherwise = (expandRefs r l) : rest 45 | where rest = expandAll1 r table ls 46 | 47 | expandRefs :: Refs -> String -> String 48 | expandRefs _ "" = "" 49 | expandRefs r ('#':l) = expandRef r "" l 50 | expandRefs r (c:cs) = c : expandRefs r cs 51 | 52 | expandRef :: Refs -> String -> String -> String 53 | expandRef r txt ('V':l) = expandVar r txt (parseRef l) 54 | expandRef r txt ('I':l) = expandInstance r txt (parseRef l) 55 | expandRef r txt ('T':l) = expandTycon r txt (parseRef l) 56 | expandRef r txt ('L':l) = expandLink r txt (parseRef l) 57 | expandRef r txt ('S':l) = expandSect r txt (parseRef l) 58 | expandRef r _ ('&':l) = "" ++ expandRefs r l 59 | expandRef r _ ('#':l) = "#" ++ expandRefs r l 60 | expandRef r _ ('.':l) = expandRefs r l 61 | expandRef _ _ l = error ("Bad ref:" ++ l ++ "\n") 62 | 63 | parseRef :: String -> (String, String) 64 | parseRef = break (\c -> isSpace c || c == '#') 65 | 66 | expandVar :: Refs -> String -> (String, String) -> String 67 | expandVar r txt (v,rest) = let n = mangleVar v 68 | f = lookup n r in 69 | case f of 70 | Nothing -> trySig r txt v rest n 71 | _ -> anchor v f n txt ++ expandRefs r rest 72 | 73 | expandTycon :: Refs -> String -> (String, String) -> String 74 | expandTycon r txt (t,rest) = let n = mangleTycon t 75 | f = lookup n r in 76 | anchor t f n txt ++ expandRefs r rest 77 | 78 | expandInstance :: Refs -> String -> (String, String) -> String 79 | expandInstance r txt (c,'#':rest ) = let (t,rest') = parseRef rest 80 | n = mangleInstance c t 81 | f = lookup n r in 82 | anchor c f n txt ++ expandRefs r rest' 83 | expandInstance _ _ (_,l) = error ("bad instance " ++ l ++ "\n") 84 | 85 | expandSect :: Refs -> String -> (String, String) -> String 86 | expandSect r txt (s,rest) = let n = mangleSect s 87 | f = lookup n r in 88 | "(see " ++ anchor s f n txt ++ ")" ++ 89 | expandRefs r rest 90 | 91 | expandLink :: Refs -> String -> (String, String) -> String 92 | expandLink r _ (t,'#':l') = expandRef r t l' 93 | expandLink _ _ (l,l') = error ("Bad link: " ++ l ++ l' ++ "\n") 94 | 95 | trySig :: Refs -> String -> String -> String -> String -> String 96 | trySig r txt v rest n = 97 | let c = parseClass rest 98 | n = mangleTycon c 99 | f = lookup n r in 100 | anchor v f n txt ++ expandRefs r rest 101 | 102 | anchor :: String -> Maybe String -> String -> String -> String 103 | anchor str mfile tag txt = 104 | case mfile of 105 | Just f -> "" ++ t ++ "" 107 | Nothing -> "Bad tag:" ++ tag ++ " " ++ t 108 | where 109 | t = htmlS $ if txt == "" then str else txt 110 | 111 | mangleVar :: String -> String 112 | mangleVar n = "$v" ++ mangleName (filter (\c -> not (c `elem` "()")) n) 113 | 114 | mangleTycon :: String -> String 115 | mangleTycon n = "$t" ++ mangleName n 116 | 117 | mangleInstance :: String -> String -> String 118 | mangleInstance c t = "$i" ++ mangleName c ++ "$$" ++ mangleName t 119 | 120 | mangleSect :: String -> String 121 | mangleSect s = "sect" ++ s 122 | 123 | mangleName :: String -> String 124 | mangleName r = concatMap 125 | (\c -> case c of '(' -> "$P" 126 | ')' -> "$C" 127 | '-' -> "$D" 128 | '[' -> "$B" 129 | ']' -> "$c" 130 | ',' -> "$x" 131 | '#' -> "$p" 132 | '$' -> "$D" 133 | '|' -> "$b" 134 | '!' -> "$E" 135 | '&' -> "$A" 136 | '^' -> "$U" 137 | '>' -> "$G" 138 | '<' -> "$L" 139 | '=' -> "$Q" 140 | _ -> [c]) r 141 | 142 | mangleType :: String -> String 143 | mangleType t = mangleName (case t of 144 | "(IO" -> "IO" 145 | "(a->b)" -> "->" 146 | "[a]" -> "[]" 147 | x -> x) 148 | 149 | 150 | 151 | readRefFile :: String -> IO [(String, String)] 152 | readRefFile f = catchIOError 153 | (do l <- readFile f 154 | return (map parseKV (lines l))) 155 | (\e -> do putStrLn ("Can't read ref file: " ++ f) 156 | print e 157 | return []) 158 | 159 | parseKV :: String -> (String, String) 160 | parseKV l = let (k,l1) = span (/= '=') l 161 | val = case l1 of 162 | ('=':v) -> trim v 163 | _ -> "" 164 | in (trimr k,val) 165 | 166 | parseClass :: String -> String 167 | parseClass s = let s1 = (skip "(" . skip "::") s 168 | (c,_) = span isAlpha (trim s1) in 169 | c 170 | 171 | trim :: String -> String 172 | trim s = dropWhile isSpace s 173 | 174 | trimr :: String -> String 175 | trimr s = reverse (dropWhile isSpace (reverse s)) 176 | 177 | skip :: String -> String -> String 178 | skip val s = case stripPrefix val (trim s) of 179 | Just s' -> s' 180 | Nothing -> s 181 | 182 | htmlEncode :: Char -> String 183 | htmlEncode '>' = ">" 184 | htmlEncode '<' = "<" 185 | htmlEncode '&' = "&" 186 | htmlEncode c = [c] 187 | 188 | htmlS :: String -> String 189 | htmlS s = concatMap htmlEncode s 190 | 191 | nbspaces :: String -> String 192 | nbspaces "" = "" 193 | nbspaces (' ' : cs) = " " ++ nbspaces cs 194 | nbspaces ('<':cs) = ['<'] ++ c ++ nbspaces r where 195 | (c,r) = span (/= '>') cs 196 | nbspaces (c:cs) = c:nbspaces cs 197 | -------------------------------------------------------------------------------- /report/tools/splitAndIndexPgm: -------------------------------------------------------------------------------- 1 | eval "exec perl -S $0 $*" 2 | if $running_under_some_random_shell; 3 | # 4 | # $Header: /home/cvs/root/haskell-report/tools/splitAndIndexPgm,v 1.3 2002/12/03 10:27:22 ross Exp $ 5 | # 6 | # This script reads a Haskell program and inserts LaTeX/verbatim 7 | # magic to indicate where a page break may occur. 8 | # It must be after a blank line that is followed by code or a 9 | # comment that begins in column 1. 10 | # Also, if the number of lines spit out between allowed breaks 11 | # exceeds $maxLines, then the LaTeX magic is inserted anyway. 12 | # 13 | # Makes up \index (or \indextt) entries from type signatures. 14 | # 15 | # Will Partain, partain@cs.glasgow.ac.uk 16 | # 17 | $pgm = $0; 18 | $prevState = 'toplevCode'; 19 | $currState = ''; 20 | $savedBlanks = 0; 21 | $maxLines = 42; # before there must be a break 22 | $lineCnt = 0; 23 | @indexentries = (); 24 | @specialentries = (); # these don't get mangled by printIndex... 25 | $SaveForIndexing = ''; 26 | 27 | while ($ARGV[0] =~ /^-/) { 28 | $_ = $ARGV[0]; shift; 29 | if (/^-m(\d+)/) { 30 | $maxLines = $1; 31 | } 32 | } 33 | 34 | print "\\noindent\\bprogB\n\@\n"; 35 | while (<>) { 36 | $currState = &newState(); 37 | 38 | if ($prevState eq 'blankLine' && 39 | ($currState =~ /^toplev/)) { # a break OK here 40 | print "\@\n"; 41 | &printIndexEntries(); # for previous block 42 | $SaveForIndexing .= $_; 43 | print "\\eprogB\\vspace{-2ex}\\noindent\\bprogB\n\@\n$_"; 44 | $lineCnt = 0; 45 | $savedBlanks = 0; 46 | 47 | } elsif ($currState eq 'blankLine') { # save these up 48 | $savedBlanks++; 49 | 50 | } else { 51 | if ($lineCnt > $maxLines) { 52 | print stderr "$pgm: Forced split after $maxLines lines\n"; 53 | print "\@\n"; 54 | &printIndexEntries(); # for the blk we're forced to emit 55 | $SaveForIndexing .= $_; 56 | print "\\eprogB\\noindent\\bprogB\n\@\n"; 57 | $lineCnt = 0; 58 | } else { 59 | $SaveForIndexing .= $_; 60 | } 61 | print "\n" if ($savedBlanks > 0); 62 | $lineCnt++ if ($savedBlanks > 0); 63 | print $_; 64 | $lineCnt++; 65 | $savedBlanks = 0; 66 | } 67 | $prevState = $currState; 68 | } 69 | print "\@\n"; 70 | &printIndexEntries(); 71 | print "\\eprogB\n"; 72 | 73 | sub newState { 74 | if (/^--/) { # comment in column 1 75 | 'toplevComment'; 76 | } elsif (/^\s*$/ && $prevState eq 'toplevComment') { # the gimmick 77 | 'toplevComment'; 78 | } elsif (/^\s*$/) { 79 | 'blankLine'; 80 | } elsif (/^[^ \t]/) { # something in column 1 81 | 'toplevCode'; 82 | } else { 83 | 'localCode'; 84 | } 85 | } 86 | 87 | sub printIndexEntries { # also re-sets $indexentries, specialentries 88 | 89 | local($i,$raw,$processed); 90 | 91 | &grokForIndexEntries(); # in $SaveForIndexing; results in @indexentries, @specialentries 92 | 93 | foreach $i (@indexentries) { 94 | if ($i =~ /^[A-Za-z][A-Za-z0-9'_]*$/) { 95 | $i =~ s/\_/\{\\char'137\}/g; 96 | print "\\indextt\{$i\}%\n" if ($i !~ /^prim[A-Z]/); # no primitives, we're British 97 | } elsif ($i =~ /^\((.*)\)$/) { 98 | $raw = $1; 99 | $processed = "\001" .$raw . "\003"; 100 | 101 | # this is really really ugly... 102 | $processed =~ s/\\/\{\\char'134\}/g; 103 | 104 | $processed =~ s/\!/\{\\char'041\}/g; 105 | $processed =~ s/\$/\{\\char'044\}/g; 106 | $processed =~ s/\%/\{\\char'045\}/g; 107 | $processed =~ s/\&/\\\&/g; # 046 108 | $processed =~ s/\^/\{\\char'136\}/g; 109 | $processed =~ s/\_/\{\\char'137\}/g; 110 | $processed =~ s/\|/\{\\char'174\}/g; 111 | # 112 | $processed =~ s/\001/\{\\tt /; 113 | $processed =~ s/\003/\}/; 114 | # 115 | # there are a few "raw" chars that need fiddling, too... 116 | # 117 | $raw =~ s/!/""!/g; 118 | $raw =~ s/\@/""\@\@/g; 119 | $raw =~ s/\\/\\\\/g; 120 | $raw =~ s/\|/\\vert/g; 121 | 122 | print "\\index\{$raw\@\@$processed\}%\n"; 123 | } else { 124 | print stderr "index proto-entry in unexpected form: $i\n"; 125 | } 126 | } 127 | foreach $i (@specialentries) { # print as is 128 | print "\\index\{$i\}%\n"; 129 | } 130 | @indexentries = (); # re-set 131 | @specialentries = (); 132 | } 133 | 134 | sub grokForIndexEntries { # in $_ 135 | local($save_line); 136 | local($goodies,@goodie); 137 | 138 | $* = 1; 139 | $save_line = $_; # restore at the end 140 | $_ = $SaveForIndexing; 141 | 142 | # rm comments and blank lines 143 | s/--.*//g; 144 | s/^\s*\n//g; 145 | 146 | #print STDERR "to index: $SaveForIndexing\n"; 147 | 148 | # lines ending in commas are suspected of being continuation lines 149 | s/,\s*\n/,/g; 150 | 151 | # now, we are deeply interested in type signatures 152 | while (/^\s*([a-z\(].*)::/) { 153 | $goodies = $1; 154 | $goodies =~ s/[ \t]//g; 155 | # ADR Hack: 156 | # Part of the prelude contains the expression (maxBound::Char) 157 | # and we don't want to index that. 158 | # Ditto for type sig on local definition. 159 | if (!($goodies =~ /\(maxBound/ 160 | || $goodies eq "wherelastChar")) { 161 | push(@indexentries, split(/\s*,\s*/,$goodies)); 162 | #print STDERR "goodies: $goodies ;; @indexentries\n"; 163 | } 164 | s/^\s*[a-z\(].*:://; 165 | } 166 | 167 | # we are modestly interested in other things 168 | # record exact index entries in specialentries; otherwise indexentries 169 | 170 | while (/^\s*(module|interface|import)\s+([A-Z][A-Za-z0-9_']*)(\s*)/) { 171 | local($before) = $1; local($thing) = $2; local($after) = $3; 172 | 173 | push(@specialentries, "$thing\@\@{\\tt $thing} (module)"); 174 | s/^\s*$before\s+$thing$after//; 175 | } 176 | 177 | while (/^\s*infix.?\s+[0-9]\s+(.*)/) { 178 | $goodies = $1; 179 | $goodies =~ s/[ \t]//g; 180 | # convert to magic form required for printing 181 | local($g); 182 | foreach $g (split(/\s*,\s*/,$goodies)) { 183 | $g = "($g)"; # add parens 184 | $g =~ s/\(\`(.*)\`\)/\1/; # fix parend,backquoted ... 185 | push(@indexentries, $g); 186 | } 187 | #print STDERR "goodies: $goodies ;; @indexentries\n"; 188 | s/^\s*infix.*//; 189 | } 190 | 191 | while (/^\s*class\s+(.*)\s+([A-Z][A-Za-z0-9_']*)\s+[a-z]\s+where\s*$/) { 192 | local($context) = $1; local($class) = $2; 193 | 194 | push(@specialentries, "$class\@\@{\\tt $class} (class)"); 195 | 196 | if ($context =~ /\((.*)\)\s+=>/) { 197 | ($goodies = $1) =~ s/ [a-z]//g; # nuke the variable 198 | $goodies =~ s/[ \t]//g; 199 | local($g); 200 | foreach $g (split(/\s*,\s*/,$goodies)) { 201 | push(@specialentries, "$g\@\@{\\tt $g} (class)!superclass of {\\tt $class}"); 202 | } 203 | } 204 | s/^\s*class//; 205 | } 206 | 207 | while (/^\s*instance\s+(.*)\s+where\s*$/) { 208 | local($stuff) = $1; 209 | local($class); local($ty); 210 | 211 | # toss context 212 | $stuff =~ s/\(.*\)\s*=>//; 213 | 214 | if ($stuff =~ /([A-Z][A-Za-z0-9_']*)\s*\(([A-Z][A-Za-z0-9_',]*)\s+[ a-z]+\)/) { 215 | # instance Foo(Bar x y z) where 216 | $class = $1; $ty = $2; 217 | push(@specialentries, "$class\@\@{\\tt $class} (class)!instance for {\\tt $ty}"); 218 | } elsif ($stuff =~ /([A-Z][A-Za-z0-9_']*)\s+([A-Z\[][A-Za-z0-9_'\]]*)/) { 219 | # instance Foo Bar where 220 | $class = $1; $ty = $2; 221 | push(@specialentries, "$class\@\@{\\tt $class} (class)!instance for {\\tt $ty}"); 222 | } else { 223 | print STDERR "!!! didn't grok instance: $stuff\n"; 224 | } 225 | s/^\s*instance\s+//; 226 | } 227 | 228 | while (/^\s*data\s+([A-Z][A-Za-z0-9_']*)(\s*)/) { 229 | local($tycon) = $1; 230 | 231 | push(@specialentries, "$tycon\@\@{\\tt $tycon} (datatype)"); 232 | s/^\s*data\s+//; 233 | } 234 | 235 | while (/^\s*type\s+([A-Z][A-Za-z0-9_']*)(\s*)/) { 236 | local($tysyn) = $1; 237 | 238 | push(@specialentries, "$tysyn\@\@{\\tt $tysyn} (type synonym)"); 239 | s/^\s*type\s+//; 240 | } 241 | 242 | 243 | $SaveForIndexing = ''; # reset 244 | $_ = $save_line; 245 | } 246 | -------------------------------------------------------------------------------- /report/tools/subsection: -------------------------------------------------------------------------------- 1 | # Change section -> chapter etc, for formatting with book style 2 | 3 | sed -e 's/\\section{/\\chapter{/g' -e 's/subsection{/section{/g' -e 's/Appendix/Chapter/g' 4 | -------------------------------------------------------------------------------- /report/tools/verb-tex4ht.lex: -------------------------------------------------------------------------------- 1 | %START NORM VERB INVERB MATH SYNTAX 2 | sp [ \t]* 3 | verb \n{sp}@{sp}\n 4 | math \n{sp}\"{sp}\n 5 | synt \n{sp}@@@{sp}\n 6 | nl {sp}\n{sp} 7 | %{ 8 | #define PUSH states[top++] = 9 | #define POP BEGIN states[--top] 10 | int yywrap (void) { return 1; } 11 | %} 12 | %% 13 | int states[256]; 14 | int top; 15 | BEGIN NORM; 16 | top = 0; 17 | @@ { printf ("@"); } 18 | @ { printf ("\\mbox{\\tt "); 19 | PUSH NORM; BEGIN INVERB; } 20 | " " { printf ("\\ "); } 21 | @ { printf ("}"); POP; } 22 | \# { printf ("{\\char'43}"); } 23 | \$ { printf ("{\\char'44}"); } 24 | \% { printf ("{\\char'45}"); } 25 | \& { printf ("{\\char'46}"); } 26 | \~ { printf ("{\\char'176}"); } 27 | \_ { printf ("{\\char'137}"); } 28 | \^ { printf ("{\\char'136}"); } 29 | \\ { printf ("{\\char'134}"); } 30 | \{ { printf ("{\\char'173}"); } 31 | \} { printf ("{\\char'175}"); } 32 | {verb} { printf ("\\begin{verbatim}\n"); PUSH NORM; BEGIN VERB; } 33 | {verb} { printf ("\\end{verbatim}\n"); POP; } 34 | \"\" { printf ("\""); } 35 | \"{sp} { printf ("\\mbox{$\\it "); 36 | PUSH NORM; BEGIN MATH; } 37 | {sp}\" { printf ("$}"); POP; } 38 | {math}{sp} { printf ("\n\\[\n\\it "); 39 | PUSH NORM; BEGIN MATH; } 40 | {sp}{math} { printf ("\n\\]\n"); POP; } 41 | {nl} { printf ("\\\\\n\\it "); } 42 | {sp}&{sp} { printf ("&\\it "); } 43 | \\{nl} { } 44 | {sp} { printf ("\\ "); } 45 | "..." { printf ("\\ldots "); } 46 | ">=" { printf ("\\geq "); } 47 | "<=" { printf ("\\leq "); } 48 | "->" { printf ("\\rightarrow "); } 49 | "<-" { printf ("\\leftarrow "); } 50 | @@ { printf ("@"); } 51 | @ { printf ("\\makebox{\\tt "); 52 | PUSH MATH; BEGIN INVERB; } 53 | {synt}{sp} { printf ("\n\\begin{flushleft}"); 54 | printf ("\\it\\begin{tabular}{lcll}\n$\\it "); 55 | BEGIN SYNTAX; } 56 | {sp}{synt} { printf ("$\n\\end{tabular}\\end{flushleft}\n"); 57 | BEGIN NORM; } 58 | {nl} { printf ("$\\\\ \n$\\it "); } 59 | {sp}"->"{sp} { printf ("$ & \\makebox[3.5em]{$\\rightarrow$} &"); 60 | printf ("$\\it "); } 61 | {nl}"|"{sp} { printf ("$\\\\ \n$\\it "); 62 | printf ("$ & \\makebox[3.5em]{$|$} & $\\it "); } 63 | {sp}&{sp} { printf ("$ & ~~~~$\\it "); } 64 | {nl}$ { 65 | /* this is for the HTML output: to get a blank row in a table, it 66 | needs to contain something, so we add a non-breaking space */ 67 | printf ("$\\\\ \n~\\\\\n$\\it "); } 68 | \\{nl} { } 69 | {sp} { printf ("\\ "); } 70 | "..." { printf ("\\ldots "); } 71 | ">=" { printf ("\\geq "); } 72 | "<=" { printf ("\\leq "); } 73 | "->" { printf ("\\rightarrow "); } 74 | "<-" { printf ("\\leftarrow "); } 75 | @@ { printf ("@"); } 76 | @ { printf ("\\makebox{\\tt "); 77 | PUSH SYNTAX; BEGIN INVERB; } 78 | %% 79 | int 80 | main() 81 | { 82 | yylex(); 83 | return(0); 84 | } 85 | -------------------------------------------------------------------------------- /report/tools/verbatim.lex: -------------------------------------------------------------------------------- 1 | %START NORM VERB INVERB MATH SYNTAX 2 | sp [ \t]* 3 | verb ^{sp}@{sp}\n 4 | math \n{sp}\"{sp}\n 5 | synt \n{sp}@@@{sp}\n 6 | nl {sp}\n{sp} 7 | %{ 8 | #define PUSH states[top++] = 9 | #define POP BEGIN states[--top] 10 | int yywrap (void) { return 1; } 11 | %} 12 | %% 13 | int states[256]; 14 | int top; 15 | BEGIN NORM; 16 | top = 0; 17 | @@ { printf ("@"); } 18 | @ { printf ("\\mbox{\\tt "); 19 | PUSH NORM; BEGIN INVERB; } 20 | " " { printf ("\\ "); } 21 | @ { printf ("}"); POP; } 22 | \# { printf ("{\\char'43}"); } 23 | \$ { printf ("{\\char'44}"); } 24 | \% { printf ("{\\char'45}"); } 25 | \& { printf ("{\\char'46}"); } 26 | \~ { printf ("{\\char'176}"); } 27 | \_ { printf ("{\\char'137}"); } 28 | \^ { printf ("{\\char'136}"); } 29 | \\ { printf ("{\\char'134}"); } 30 | \{ { printf ("{\\char'173}"); } 31 | \} { printf ("{\\char'175}"); } 32 | {verb} { printf ("{\\small\\begin{verbatim}\n"); PUSH NORM; BEGIN VERB; } 33 | {verb} { printf ("\\end{verbatim}}\n"); POP; } 34 | \"\" { printf ("\""); } 35 | \"{sp} { printf ("\\mbox{$\\it "); 36 | PUSH NORM; BEGIN MATH; } 37 | {sp}\" { printf ("$}"); POP; } 38 | {math}{sp} { printf ("\n\\[\n\\it "); 39 | PUSH NORM; BEGIN MATH; } 40 | {sp}{math} { printf ("\n\\]\n"); POP; } 41 | {nl} { printf ("\\\\\n\\it "); } 42 | {sp}&{sp} { printf ("&\\it "); } 43 | \\{nl} { } 44 | {sp} { printf ("\\ "); } 45 | "..." { printf ("\\ldots "); } 46 | ">=" { printf ("\\geq "); } 47 | "<=" { printf ("\\leq "); } 48 | "->" { printf ("\\rightarrow "); } 49 | "<-" { printf ("\\leftarrow "); } 50 | @@ { printf ("@"); } 51 | @ { printf ("\\makebox{\\tt "); 52 | PUSH MATH; BEGIN INVERB; } 53 | {synt}{sp} { printf ("\n\\begin{flushleft}"); 54 | printf ("\\it\\begin{tabbing}\n"); 55 | printf ("\\hspace{0.6in}\\="); 56 | printf ("\\hspace{3.1in}\\=\\kill\n$\\it "); 57 | BEGIN SYNTAX; } 58 | {sp}{synt} { printf ("$\n\\end{tabbing}\\end{flushleft}\n"); 59 | BEGIN NORM; } 60 | {nl} { printf ("$\\\\ \n$\\it "); } 61 | {sp}"->"{sp} { printf ("$\\>\\makebox[3.5em]{$\\rightarrow$}"); 62 | printf ("$\\it "); } 63 | {nl}"|"{sp} { printf ("$\\\\ \n$\\it "); 64 | printf ("$\\>\\makebox[3.5em]{$|$}$\\it "); } 65 | {sp}&{sp} { printf ("$\\>\\makebox[3em]{}$\\it "); } 66 | \\{nl} { } 67 | {sp} { printf ("\\ "); } 68 | "..." { printf ("\\ldots "); } 69 | ">=" { printf ("\\geq "); } 70 | "<=" { printf ("\\leq "); } 71 | "->" { printf ("\\rightarrow "); } 72 | "<-" { printf ("\\leftarrow "); } 73 | @@ { printf ("@"); } 74 | @ { printf ("\\makebox{\\tt "); 75 | PUSH SYNTAX; BEGIN INVERB; } 76 | 77 | %% 78 | int 79 | main() 80 | { 81 | yylex(); 82 | return(0); 83 | } 84 | -------------------------------------------------------------------------------- /texts/.gitkeep: -------------------------------------------------------------------------------- 1 | (Dummy file because Git does not support committing empty folders. Safe to 2 | remove once anything else is in the same directory.) --------------------------------------------------------------------------------