[Wiki backup, first version Neil Mitchell **20051213135248] { addfile ./wiki/Hoogle.html hunk ./wiki/Hoogle.html 1 + + + + + + +Hoogle - The Haskell Wiki + + + + + + + + + + + + + + + + + + +
UserPreferences
+

Hoogle

+ + + +
+ + + +
+

Hoogle

+

+A Haskell API search engine, written by NeilMitchell. It allows you to search by either name, or by approximate type signature. An article is being written for TheMonadReader, which will include some technical details. +

+

How to use Hoogle

+ + +

Examples

+

+If you wanted to search for the standard prelude function map, you could type into the search any one of: +

+
map 
+(a -> b) -> [a] -> [b]
+(a -> a) -> [a] -> [a]
+(Int -> Bool) -> [Int] -> [Bool]
+[a] -> (a -> b) -> [b]

Todo

+

Admin

+ + +

Short Term

+

+i.e. before Hoogle3 goes public +

+ + +

Medium Term

+ + +

Long Term

+ + +

Hoogle Suggest

+ + +

Bad Searches

+ + +

Higher Kinds

+

+The following searches are all wrong because Hoogle doesn't understand higher kinds, i.e. Monad's. +

+ + +
+ + + + + + + + addfile ./wiki/Keywords.html hunk ./wiki/Keywords.html 1 + + + + + + +Keywords - The Haskell Wiki + + + + + + + + + + + + + + + + + + +
UserPreferences
+

Keywords

+ + + +
+ + + +
+

Haskell Keywords

+

+This page lists all Haskell keywords, feel free to edit. Hoogle searches return results from this page. Please respect the Anchor macros. +

+

+Some of the material below is taken from [WWW]the Haskell 98 report. +

+

+

|

+ +

+ +
+safeTail x | null x = []
+           | otherwise = tail x
+
+squares = [a*a | a <- [1..]]
+
+ + +

+ +

+

+

->

+ +

+

+Please write this +

+

+

<-

+ +

+

+Please write this +

+

+

@

+ +

+

+Patterns of the form var@pat are called as-patterns, and allow one to use var as a name for the value being matched by pat. For example: +

+ +
+case e of { xs@(x:rest) -> if x==0 then rest else xs }
+
+ + +

+ +

+

+is equivalent to: +

+ +
+let { xs = e } in
+  case xs of { (x:rest) -> if x==0 then rest else xs }
+
+ + +

+ +

+

+

!

+ +

+

+Whenever a data constructor is applied, each argument to the constructor is evaluated if and only if the corresponding type in the algebraic datatype declaration has a strictness flag, denoted by an exclamation point. For example: +

+ +
+data STList a 
+        = STCons a !(STList a)  -- the second argument to STCons will be 
+                                -- evaluated before STCons is applied
+        | STNil
+
+ + +

+ +

+

+to illustrate the difference between strict versus lazy constructor application, consider the following: +

+ +
+stList = STCons 1 undefined
+lzList = (:)    1 undefined
+stHead (STCons h _) = h -- this evaluates to undefined when applied to stList
+lzHead (h : _)      = h -- this evaluates to 1 when applied to lzList
+
+ + +

+ +

+

+

::

+ +

+

+Please write this +

+

+

_

+ +

+

+Patterns of the form _ are wildcards and are useful when some part of a pattern is not referenced on the right-hand-side. It is as if an identifier not used elsewhere were put in its place. For example, +

+ +
+case e of { [x,_,_]  ->  if x==0 then True else False }
+
+ + +

+ +

+

+is equivalent to: +

+ +
+case e of { [x,y,z]  ->  if x==0 then True else False }
+
+ + +

+ +

+

+

~

+ +

+

+Please write this +

+

+

as

+ +

+

+Please write this +

+

+

case, of

+ +

+

+A case expression has the general form +

+ +
+case e of { p1 match1 ; ... ; pn matchn }
+
+ + +

+ +

+

+where each match is of the general form +

+ +
+  | g1  -> e1
+    ...
+  | gm -> em
+     where decls
+
+ + +

+ +

+

+Each alternative consists of a pattern pi and its matches, matchi. Each match in turn consists of a sequence of pairs of guards gj and bodies ej (expressions), followed by optional bindings (decls) that scope over all of the guards and expressions of the alternative. An alternative of the form +

+ +
+pat -> exp where decls
+
+ + +

+ +

+

+is treated as shorthand for: +

+ +
+  pat | True -> exp
+  where decls
+
+ + +

+ +

+

+A case expression must have at least one alternative and each alternative must have at least one body. Each body must have the same type, and the type of the whole expression is that type. +

+

+A case expression is evaluated by pattern matching the expression e against the individual alternatives. The alternatives are tried sequentially, from top to bottom. If e matches the pattern in the alternative, the guards for that alternative are tried sequentially from top to bottom, in the environment of the case expression extended first by the bindings created during the matching of the pattern, and then by the declsi in the where clause associated with that alternative. If one of the guards evaluates to True, the corresponding right-hand side is evaluated in the same environment as the guard. If all the guards evaluate to False, matching continues with the next alternative. If no match succeeds, the result is _|_. +

+

+

class

+ +

+

+Please write this +

+

+

data

+ +

+

+Please write this +

+

+

default

+ +

+

+Please write this +

+

+

deriving

+ +

+

+Please write this +

+

+

do

+ +

+

+Please write this +

+

+

forall

+ +

+

+This is a GHC/Hugs extension, and as such is not portable Haskell 98. +

+

+

hiding

+ +

+

+Please write this +

+

+

if, then, else

+ +

+

+A conditional expression has the form: +

+ +
+if e1 then e2 else e3
+
+ + +

+ +

+

+...and returns the value of e2 if the value of e1 is True, e3 if e1 is False, and _|_ otherwise. +

+ +
+max a b = if a > b then a else b
+
+ + +

+ +

+

+

import

+ +

+

+Please write this +

+

+

infix, infixl, infixr

+ +

+

+Please write this +

+

+

instance

+ +

+

+Please write this +

+

+

let, in

+ +

+

+Let expressions have the general form: +

+ +
+let { d1 ; ... ; dn } in e
+
+ + +

+ +

+

+They introduce a nested, lexically-scoped, mutually-recursive list of declarations (let is often called letrec in other languages). The scope of the declarations is the expression e and the right hand side of the declarations. +

+

+

module

+ +

+

+Please write this +

+

+

newtype

+ +

+

+Please write this +

+

+

qualified

+ +

+

+Please write this +

+

+

type

+ +

+

+Please write this +

+

+

where

+ +

+

+Please write this +

+
+ + + + + + + + addfile ./wiki/LibraryDocumentation.html hunk ./wiki/LibraryDocumentation.html 1 + + + + + + +LibraryDocumentation - The Haskell Wiki + + + + + + + + + + + + + + + + + + +
UserPreferences
+

LibraryDocumentation

+ + + +
+ + + +
+

Library Documentation

+

+This is a folder for documentation of every function in the Haskell world. It will be used by Hoogle when someone searches for a function. +

+

Naming

+

+In order to find things unambiguously, its necessary to put things in every specific places. To give an example: all the documentation for Data.Map should be placed at LibraryDocumentation/Data.Map. Every function should have an anchor defined, for example insert would be on that page with #v:insert as the anchor (this is to be compatible with Haddock). +

+

Pages

+

+

+ + +

+
+ + + + + + + + addfile ./wiki/LibraryDocumentation_2fCPUTime.html hunk ./wiki/LibraryDocumentation_2fCPUTime.html 1 + + + + + + +LibraryDocumentation/CPUTime - The Haskell Wiki + + + + + + + + + + + + + + + + + + + +
UserPreferences
+

LibraryDocumentation/CPUTime

+ + + +
+ + + +
+

CPUTime - Library Documentation

+

+Part of the LibraryDocumentation project. +

+

+A standard Haskell 98 library for measuring elapsed CPU/Processor Time. In the hierarchical libraries this has become System.CPUTime. (Haddock) +

+

+

cpuTimePrecision :: Integer

+ +

+

+This is the precision of the result given by getCPUTime. This is the smallest measurable difference in CPU time that the implementation can record, and is given as an integral number of picoseconds. +

+

+In the hierarchical libraries, this has been moved to the module System.CPUTime. (Haddock) +

+

+

getCPUTime :: IO Integer

+ +

+

+Computation getCPUTime returns the number of picoseconds of CPU time used by the current program. The precision of this result is given by cpuTimePrecision. +

+ +
+> getCPUTime >>= \x -> print x
+296875000000
+
+ + +

+ +

+

+In the hierarchical libraries, this has been moved to the module System.CPUTime. (Haddock) +

+
+ + + + + + + + addfile ./wiki/LibraryDocumentation_2fIx.html hunk ./wiki/LibraryDocumentation_2fIx.html 1 + + + + + + +LibraryDocumentation/Ix - The Haskell Wiki + + + + + + + + + + + + + + + + + + + +
UserPreferences
+

LibraryDocumentation/Ix

+ + + +
+ + + +
+

Ix - Library Documentation

+

+Part of the LibraryDocumentation project. +

+

+Controls indexing, typically used in conjunction with ?LibraryDocumentation/Array. +

+ +
+module Ix ( Ix(range, index, inRange), rangeSize ) where
+
+class  (Ord a) => Ix a  where
+   range               :: (a,a) -> [a]
+   index               :: (a,a) -> a -> Int
+   inRange             :: (a,a) -> a -> Bool
+
+rangeSize :: Ix a => (a,a) -> Int
+rangeSize b@(l,h) | null (range b) = 0
+                 | otherwise      = index b h + 1
+-- NB: replacing "null (range b)" by "l > h" fails if
+-- the bounds are tuples. For example,
+-- (2,1) > (1,2),
+-- but
+-- range ((2,1),(1,2)) = []
+
+
+instance  Ix Char  where
+   range (m,n) = [m..n]
+   index b@(c,c') ci
+       | inRange b ci  =  fromEnum ci - fromEnum c
+       | otherwise     =  error "Ix.index: Index out of range."
+   inRange (c,c') i    =  c <= i && i <= c'
+
+instance  Ix Int  where
+   range (m,n) = [m..n]
+   index b@(m,n) i
+       | inRange b i   =  i - m
+       | otherwise     =  error "Ix.index: Index out of range."
+   inRange (m,n) i     =  m <= i && i <= n
+
+instance  Ix Integer  where
+   range (m,n) = [m..n]
+   index b@(m,n) i
+       | inRange b i   =  fromInteger (i - m)
+       | otherwise     =  error "Ix.index: Index out of range."
+   inRange (m,n) i     =  m <= i && i <= n
+
+instance (Ix a,Ix b) => Ix (a, b) -- as derived, for all tuples
+instance Ix Bool                  -- as derived
+instance Ix Ordering              -- as derived
+instance Ix ()                    -- as derived
+
+ + +

+ +

+

+

index :: Ix a => (a,a) -> a -> Int

+ +

+

+maps a bounding pair, which defines the lower and upper bounds of the range, and a subscript, to an integer. +

+ +
+> index (10,15) 12
+2
+
+> index ('A','Z') 'Z'
+25
+
+> index ((1,5),(6,10)) (3,7)
+14
+
+ + +

+ +

+

+

inRange :: Ix a => (a,a) -> a -> Bool

+ +

+

+Returns True if a particular subscript lies in the range defined by a bounding pair. +

+ +
+> inRange (1,5) 3
+True
+
+> inRange (1,5) 12
+False
+
+> inRange ((1,5),(10,12)) (7,8)
+True
+
+ + +

+ +

+

+

range :: Ix a => (a,a) -> [a]

+ +

+

+The range operation enumerates all subscripts. +

+ +
+> range (3,6)
+[3,4,5,6]
+
+> range ((1,3),(2,4))
+[(1,3),(1,4),(2,3),(2,4)]
+
+> range ('e','i')
+"efghi"
+
+> range (('a','b'),('c','d'))
+[('a','b'),('a','c'),('a','d'),('b','b'),('b','c'),('b','d'),('c','b'),('c','c'),('c','d')]
+
+ + +

+ +

+

+

rangeSize :: Ix a => (a,a) -> Int

+ +

+

+TODO +

+
+ + + + + + + + addfile ./wiki/LibraryDocumentation_2fPrelude.html hunk ./wiki/LibraryDocumentation_2fPrelude.html 1 + + + + + + +LibraryDocumentation/Prelude - The Haskell Wiki + + + + + + + + + + + + + + + + + + + +
UserPreferences
+

LibraryDocumentation/Prelude

+ + + +
+ + + +
+

Prelude - Library Documentation

+

+Part of the LibraryDocumentation project. +

+

+Todo... +

+
+ + + + + + + + }