X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=4475af4bf523653d46d60994578da9bd5b66045c;hb=500fb9ad138112e8145d9f125f8c6d013f449205;hp=e680d6cc046ad6aa6371cdbf3c11cfdad14944d8;hpb=2f4e21c6f741995e20cc3b53b109ff9edf18eb3c;p=ghc-hetmet.git diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index e680d6c..4475af4 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -964,7 +964,7 @@ a data type with no constructors. For example: Syntactically, the declaration lacks the "= constrs" part. The type can be parameterised over types of any kind, but if the kind is not * then an explicit kind annotation must be used -(see ). +(see ). Such data types have only one value, namely bottom. Nevertheless, they can be useful when defining "phantom types". @@ -1330,7 +1330,7 @@ data Counter a = forall self. NewCounter Here tag is a public field, with a well-typed selector function tag :: Counter a -> a. The self type is hidden from the outside; any attempt to apply _this, -_inc or _output as functions will raise a +_inc or _display as functions will raise a compile-time error. In other words, GHC defines a record selector function only for fields whose type does not mention the existentially-quantified variables. (This example used an underscore in the fields for which record selectors @@ -3372,7 +3372,7 @@ and you'd be right. That is why they are an experimental feature. ================ END OF Linear Implicit Parameters commented out --> - + Explicitly-kinded quantification @@ -4086,15 +4086,39 @@ The class IsString is defined as: class IsString a where fromString :: String -> a -And the only predefined instance is the obvious one to make strings work as usual: +The only predefined instance is the obvious one to make strings work as usual: instance IsString [Char] where fromString cs = cs +The class IsString is not in scope by default. If you want to mention +it explicitly (for exmaple, to give an instance declaration for it), you can import it +from module GHC.Exts. + + +Haskell's defaulting mechanism is extended to cover string literals, when is specified. +Specifically: + + +Each type in a default declaration must be an +instance of Num or of IsString. + + + +The standard defaulting rule (Haskell Report, Section 4.3.4) +is extended thus: defaulting applies when all the unresolved constraints involve standard classes +or IsString; and at least one is a numeric class +or IsString. + + A small example: +module Main where + +import GHC.Exts( IsString(..) ) + newtype MyString = MyString String deriving (Eq, Show) instance IsString MyString where fromString = MyString @@ -4852,7 +4876,7 @@ Because the preprocessor targets Haskell (rather than Core), - + Bang patterns <indexterm><primary>Bang patterns</primary></indexterm> @@ -4867,7 +4891,7 @@ than the material below. Bang patterns are enabled by the flag . - + Informal description of bang patterns @@ -4922,7 +4946,7 @@ is part of the syntax of let bindings. - + Syntax and semantics @@ -4996,7 +5020,7 @@ a module. - + Assertions <indexterm><primary>Assertions</primary></indexterm>