X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fglasgow_exts.sgml;h=012f922c89126073290450e30620dc5a3aba60b3;hb=7bcdfdba58be3bd3159a87ca8413c28e3c64d147;hp=49d378b2591fb1d9cfc742a5be395499141eebd9;hpb=f482977cba3daaaf2347f5a11d55cdbeae6ac13c;p=ghc-hetmet.git diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 49d378b..012f922 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -19,8 +19,9 @@ performance because of the implementation costs of Haskell's Before you get too carried away working at the lowest level (e.g., sloshing MutableByteArray#s around your program), you may wish to check if there are libraries that provide a -“Haskellised veneer” over the features you want. See -. +“Haskellised veneer” over the features you want. The +separate libraries documentation describes all the libraries that come +with GHC. @@ -163,14 +164,16 @@ program), you may wish to check if there are libraries that provide a With the flag, GHC lets you declare a data type with no constructors. For example: + data S -- S :: * data T a -- T :: * -> * + Syntactically, the declaration lacks the "= constrs" part. The -type can be parameterised, but only over ordinary types, of kind *; since -Haskell does not have kind signatures, you cannot parameterise over higher-kinded -types. +type can be parameterised over types of any kind, but if the kind is +not * then an explicit kind annotation must be used +(see ). Such data types have only one value, namely bottom. Nevertheless, they can be useful when defining "phantom types". @@ -894,21 +897,19 @@ is (?x::a) => (a,a), and not class constraints. -An implicit parameter is bound using an expression of the form -expr with binds, -where with is a new keyword. This form binds the implicit -parameters arising in the body, not the free variables as a let or -where would do. For example, we define the min function by binding -cmp. +An implicit parameter is bound using the standard +let binding form, where the bindings must be a +collection of simple bindings to implicit-style variables (no +function-style bindings, and no type signatures); these bindings are +neither polymorphic or recursive. This form binds the implicit +parameters arising in the body, not the free variables as a +let or where would do. For +example, we define the min function by binding +cmp. min :: [a] -> a - min = least with ?cmp = (<=) + min = let ?cmp = (<=) in least -Syntactically, the binds part of a with construct must be a -collection of simple bindings to variables (no function-style -bindings, and no type signatures); these bindings are neither -polymorphic or recursive. - Note the following additional constraints: @@ -1379,7 +1380,7 @@ for rank-2 types. - + Liberalised type synonyms @@ -2346,21 +2347,24 @@ assert pred val ==> assertError "Main.hs|15" pred val The rewrite is only performed by the compiler when it spots -applications of Exception.assert, so you can still define and -use your own versions of assert, should you so wish. If not, -import Exception to make use assert in your code. +applications of Control.Exception.assert, so you +can still define and use your own versions of +assert, should you so wish. If not, import +Control.Exception to make use +assert in your code. To have the compiler ignore uses of assert, use the compiler option -. -fignore-asserts option That is, -expressions of the form assert pred e will be rewritten to e. +. -fignore-asserts +option That is, expressions of the form +assert pred e will be rewritten to +e. Assertion failures can be caught, see the documentation for the -Exception library () -for the details. +Control.Exception library for the details. @@ -2369,6 +2373,53 @@ for the details. Syntactic extensions + + + + Hierarchical Modules + + GHC supports a small extension to the syntax of module + names: a module name is allowed to contain a dot + ‘.’. This is also known as the + “hierarchical module namespace” extension, because + it extends the normally flat Haskell module namespace into a + more flexible hierarchy of modules. + + A module name in the extended syntax consists of a + sequence of components, each separated by a dot. When searching + for an interface file (or a source file, in the case of GHCi or + when using ) for an imported module, GHC + interprets the dot as a path separator. So for example, if a + module A.B.C is imported, then for each + directory D on the search path (see the + option, ), GHC will look in the + directory D/A/BOn Windows, + this would be D\A\B. for an + interface file called C.hi or a source file + C.hs or C.lhs. + + Note that as far as the compiler is concerned, module + names are always fully qualified; the hierarchy only has a + special meaning when searching for interface files and source + files in the filesystem. In particular, this means that the + full module name must be given after the + module keyword at the beginning of the + module; for example, the module A.B.C must + begin + +module A.B.C + + GHC comes with a large collection of libraries arranged + hierarchically; see the accompanying library documentation. + There is an ongoing project to create and maintain a stable set + of core libraries used by several Haskell + compilers, and the libraries that GHC comes with represent the + current status of that project. For more details, see . + + + @@ -2554,14 +2605,18 @@ qualifier list has just one element, a boolean expression. Rebindable syntax - Your may want to - define your own numeric class hierarchy. It completely - defeats that purpose if the literal "1" means - "Prelude.fromInteger 1", which is what - the Haskell Report specifies. So the - flag causes the - following pieces of built-in syntax to refer to whatever - is in scope, not the Prelude versions: + GHC allows most kinds of built-in syntax to be rebound by + the user, to facilitate replacing the Prelude + with a home-grown version, for example. + + You may want to define your own numeric class + hierarchy. It completely defeats that purpose if the + literal "1" means "Prelude.fromInteger + 1", which is what the Haskell Report specifies. + So the flag causes + the following pieces of built-in syntax to refer to + whatever is in scope, not the Prelude + versions: @@ -2587,11 +2642,12 @@ qualifier list has just one element, a boolean expression. - "Do" notation is translated using whatever functions - (>>=), (>>), fail, - and return, are in scope (not the Prelude versions). - List comprehensions, and parallel array comprehensions, are unaffected. - + "Do" notation is translated using whatever + functions (>>=), + (>>), fail, and + return, are in scope (not the Prelude + versions). List comprehensions, and parallel array + comprehensions, are unaffected. Be warned: this is an experimental facility, with fewer checks than