X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=fd6e32286d894c3b685ee68215ceedeb8c4cd2ec;hb=5e418599f051ecb88d9d2dbeea96563cf438b065;hp=6b41b39057bbdd4cc4f3b81ebfbc72af919610d6;hpb=3eeeb57d95c6a218ce457f85e1f5b3511057101f;p=ghc-hetmet.git diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 6b41b39..fd6e322 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -128,6 +128,45 @@ documentation describes all the libraries that come with GHC. + : + + + + + As an experimental change, we are exploring the possibility of + making pattern bindings monomorphic; that is, not generalised at all. + A pattern binding is a binding whose LHS has no function arguments, + and is not a simple variable. For example: + + f x = x -- Not a pattern binding + f = \x -> x -- Not a pattern binding + f :: Int -> Int = \x -> x -- Not a pattern binding + + (g,h) = e -- A pattern binding + (f) = e -- A pattern binding + [x] = e -- A pattern binding + +Experimentally, GHC now makes pattern bindings monomorphic by +default. Use to recover the +standard behaviour. + + + + + + + : + + + + Use GHCi's extended default rules in a regular module (). + Independent of the + flag. + + + + + @@ -140,7 +179,7 @@ documentation describes all the libraries that come with GHC. - + @@ -617,7 +656,7 @@ clunky env var1 var1 = case lookup env var1 of Nothing -> fail Just val2 -> val1 + val2 where - fail = val1 + val2 + fail = var1 + var2 @@ -2022,6 +2061,11 @@ something more specific does not: op = ... -- Default +You can find lots of background material about the reason for these +restrictions in the paper +Understanding functional dependencies via Constraint Handling Rules. + @@ -2090,7 +2134,7 @@ option, you can use arbitrary types in both an instance context and instance head. Termination is ensured by having a fixed-depth recursion stack. If you exceed the stack depth you get a sort of backtrace, and the opportunity to increase the stack depth -with N. +with N. @@ -2466,7 +2510,7 @@ function that called it. For example, our sort function might to pick out the least value in a list: least :: (?cmp :: a -> a -> Bool) => [a] -> a - least xs = fst (sort xs) + least xs = head (sort xs) Without lifting a finger, the ?cmp parameter is propagated to become a parameter of least as well. With explicit @@ -6072,7 +6116,7 @@ shortcoming is something that could be fixed, with some kind of pragma.) - The <literal>inline</literal> function + The <literal>lazy</literal> function The lazy function restrains strictness analysis a little: @@ -6097,6 +6141,21 @@ look strict in y which would defeat the whole purpose of par. + + The <literal>unsafeCoerce#</literal> function + +The function unsafeCoerce# allows you to side-step the +typechecker entirely. It has type + + unsafeCoerce# :: a -> b + +That is, it allows you to coerce any type into any other type. If you use this +function, you had better get it right, otherwise segmentation faults await. +It is generally used when you want to write a program that you know is +well-typed, but where Haskell's type system is not expressive enough to prove +that it is well typed. + +