X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=8bca4857c5840fd55b658d0215077c8c94b2516d;hb=f7c548fd652b99e7e2e4069ecd7ce2a5821d33ae;hp=6dfda6b84fbeee125d1af01fff7ed64496cfb7b4;hpb=63006863be568d5cbb21d3198d43859c743152ce;p=ghc-hetmet.git
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 6dfda6b..8bca485 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -241,6 +241,14 @@ documentation describes all the libraries that come with GHC.
+
+
+ Enables overloaded string literals (see ).
+
+
+
+ Enables lexically-scoped type variables (see
+
+Overloaded string literals
+
+
+
+GHC supports overloaded string literals. Normally a
+string literal has type String, but with overloaded string
+literals enabled (with -foverloaded-strings)
+ a string literal has type (IsString a) => a.
+
+
+This means that the usual string syntax can be used, e.g., for packed strings
+and other variations of string like types. String literals behave very much
+like integer literals, i.e., they can be used in both expressions and patterns.
+If used in a pattern the literal with be replaced by an equality test, in the same
+way as an integer literal is.
+
+
+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:
+
+instance IsString [Char] where
+ fromString cs = cs
+
+
+
+A small example:
+
+newtype MyString = MyString String deriving (Eq, Show)
+instance IsString MyString where
+ fromString = MyString
+
+greet :: MyString -> MyString
+greet "hello" = "world"
+greet other = other
+
+main = do
+ print $ greet "hello"
+ print $ greet "fool"
+
+
+
+Note that deriving Eq is necessary for the pattern matching
+to work since it gets translated into an equality comparison.
+
+
+
@@ -4167,6 +4226,14 @@ Tim Sheard is going to expand it.)
(It would make sense to do so, but it's hard to implement.)
+
+ Furthermore, you can only run a function at compile time if it is imported
+ from another module that is not part of a mutually-recursive group of modules
+ that includes the module currently being compiled. For example, when compiling module A,
+ you can only run Template Haskell functions imported from B if B does not import A (directly or indirectly).
+ The reason should be clear: to run B we must compile and run A, but we are currently type-checking A.
+
+
The flag -ddump-splices shows the expansion of all top-level splices as they happen.
@@ -5899,12 +5966,6 @@ The following are good consumers:
- length
-
-
-
-
-++ (on its first argument)