X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fglasgow_exts.xml;h=a25d42e89712e066a786d6f5cda416e9ea96dd2b;hb=8e14697c6e2cccc0a632233ffe95505765db2eef;hp=5a22e7c6addcaf5a011a18f8a8e3f8b68ae5b738;hpb=338dbad4975a5575e7a1b2c8300744637d484700;p=ghc-hetmet.git diff --git a/ghc/docs/users_guide/glasgow_exts.xml b/ghc/docs/users_guide/glasgow_exts.xml index 5a22e7c..a25d42e 100644 --- a/ghc/docs/users_guide/glasgow_exts.xml +++ b/ghc/docs/users_guide/glasgow_exts.xml @@ -219,6 +219,28 @@ documentation describes all the libraries that come with GHC. + + + Enables implicit parameters (see ). Currently also implied by + . + + Syntax stolen: + ?varid, + %varid. + + + + + + + Enables lexically-scoped type variables (see ). Implied by + . + + + + Enables Template Haskell (see describes all the libraries that come with GHC. - - - - Enables implicit parameters (see ). Currently also implied by - . - - Syntax stolen: - ?varid, - %varid. - - - @@ -270,7 +279,7 @@ became out of date, and wrong information is worse than none. The Real Truth about what primitive types there are, and what operations work over those types, is held in the file -fptools/ghc/compiler/prelude/primops.txt. +fptools/ghc/compiler/prelude/primops.txt.pp. This file is used directly to generate GHC's primitive-operation definitions, so it is always correct! It is also intended for processing into text. @@ -334,11 +343,16 @@ it is accidental that it is represented by a pointer. If a pointer represents a primitive value, then it really does point to that value: no unevaluated thunks, no indirections…nothing can be at the other end of the pointer than the primitive value. +A numerically-intensive program using unboxed types can +go a lot faster than its “standard” +counterpart—we saw a threefold speedup on one example. -There are some restrictions on the use of primitive types, the main -one being that you can't pass a primitive value to a polymorphic +There are some restrictions on the use of primitive types: + +The main restriction +is that you can't pass a primitive value to a polymorphic function or store one in a polymorphic data type. This rules out things like [Int#] (i.e. lists of primitive integers). The reason for this restriction is that polymorphic @@ -350,11 +364,33 @@ attempt to dereference the pointer, with disastrous results. Even worse, the unboxed value might be larger than a pointer (Double# for instance). + + You cannot bind a variable with an unboxed type +in a top-level binding. + + You cannot bind a variable with an unboxed type +in a recursive binding. + + You may bind unboxed variables in a (non-recursive, +non-top-level) pattern binding, but any such variable causes the entire +pattern-match +to become strict. For example: + + data Foo = Foo Int Int# - -Nevertheless, A numerically-intensive program using unboxed types can -go a lot faster than its “standard” -counterpart—we saw a threefold speedup on one example. + f x = let (Foo a b, w) = ..rhs.. in ..body.. + +Since b has type Int#, the entire pattern +match +is strict, and the program behaves as if you had written + + data Foo = Foo Int Int# + + f x = case ..rhs.. of { (Foo a b, w) -> ..body.. } + + + + @@ -389,21 +425,19 @@ values, but they avoid the heap allocation normally associated with using fully-fledged tuples. When an unboxed tuple is returned, the components are put directly into registers or on the stack; the unboxed tuple itself does not have a composite representation. Many -of the primitive operations listed in this section return unboxed +of the primitive operations listed in primops.txt.pp return unboxed tuples. +In particular, the IO and ST monads use unboxed +tuples to avoid unnecessary allocation during sequences of operations. There are some pretty stringent restrictions on the use of unboxed tuples: - - - - - Unboxed tuple types are subject to the same restrictions as +Values of unboxed tuple types are subject to the same restrictions as other unboxed types; i.e. they may not be stored in polymorphic data structures or passed to polymorphic functions. @@ -412,56 +446,46 @@ structures or passed to polymorphic functions. - Unboxed tuples may only be constructed as the direct result of -a function, and may only be deconstructed with a case expression. -eg. the following are valid: +No variable can have an unboxed tuple type, nor may a constructor or function +argument have an unboxed tuple type. The following are all illegal: -f x y = (# x+1, y-1 #) -g x = case f x x of { (# a, b #) -> a + b } - - + data Foo = Foo (# Int, Int #) -but the following are invalid: + f :: (# Int, Int #) -> (# Int, Int #) + f x = x + g :: (# Int, Int #) -> Int + g (# a,b #) = a - -f x y = g (# x, y #) -g (# x, y #) = x + y + h x = let y = (# x,x #) in ... - - - - - - No variable can have an unboxed tuple type. This is illegal: - - - -f :: (# Int, Int #) -> (# Int, Int #) -f x = x - - - -because x has an unboxed tuple type. - - - - - - -Note: we may relax some of these restrictions in the future. - - - -The IO and ST monads use unboxed -tuples to avoid unnecessary allocation during sequences of operations. +The typical use of unboxed tuples is simply to return multiple values, +binding those multiple results with a case expression, thus: + + f x y = (# x+1, y-1 #) + g x = case f x x of { (# a, b #) -> a + b } + +You can have an unboxed tuple in a pattern binding, thus + + f x = let (# p,q #) = h x in ..body.. + +If the types of p and q are not unboxed, +the resulting binding is lazy like any other Haskell pattern binding. The +above example desugars like this: + + f x = let t = case h x o f{ (# p,q #) -> (p,q) + p = fst t + q = snd t + in ..body.. + +Indeed, the bindings can even be recursive. @@ -619,7 +643,7 @@ clunky env var1 var1 -The semantics should be clear enough. The qualifers are matched in order. +The semantics should be clear enough. The qualifiers are matched in order. For a <- qualifier, which I call a pattern guard, the right hand side is evaluated and matched against the pattern on the left. If the match fails then the whole guard fails and the next equation is @@ -835,26 +859,38 @@ This name is not supported by GHC. return, are in scope (not the Prelude versions). List comprehensions, and parallel array comprehensions, are unaffected. + + + Similarly recursive do notation (see + ) uses whatever + mfix function is in scope, and arrow + notation (see ) + uses whatever arr, + (>>>), first, + app, (|||) and + loop functions are in scope. + - Be warned: this is an experimental facility, with fewer checks than - usual. In particular, it is essential that the functions GHC finds in scope - must have the appropriate types, namely: + The functions with these names that GHC finds in scope + must have types matching those of the originals, namely: - fromInteger :: forall a. (...) => Integer -> a - fromRational :: forall a. (...) => Rational -> a - negate :: forall a. (...) => a -> a - (-) :: forall a. (...) => a -> a -> a - (>>=) :: forall m a. (...) => m a -> (a -> m b) -> m b - (>>) :: forall m a. (...) => m a -> m b -> m b - return :: forall m a. (...) => a -> m a - fail :: forall m a. (...) => String -> m a + fromInteger :: Integer -> N + fromRational :: Rational -> N + negate :: N -> N + (-) :: N -> N -> N + (>>=) :: forall a b. M a -> (a -> M b) -> M b + (>>) :: forall a b. M a -> M b -> M b + return :: forall a. a -> M a + fail :: forall a. String -> M a - (The (...) part can be any context including the empty context; that part - is up to you.) - If the functions don't have the right type, very peculiar things may - happen. Use -dcore-lint to - typecheck the desugared program. If Core Lint is happy you should be all right. + (Here N may be any type, + and M any type constructor.) + + Be warned: this is an experimental facility, with + fewer checks than usual. Use -dcore-lint + to typecheck the desugared program. If Core Lint is happy + you should be all right. @@ -889,18 +925,34 @@ Nevertheless, they can be useful when defining "phantom types". -Infix type constructors +Infix type constructors and classes -GHC allows type constructors to be operators, and to be written infix, very much +GHC allows type constructors and classes to be operators, and to be written infix, very much like expressions. More specifically: - A type constructor can be an operator, beginning with a colon; e.g. :*:. + A type constructor or class can be an operator, beginning with a colon; e.g. :*:. The lexical syntax is the same as that for data constructors. - Types can be written infix. For example Int :*: Bool. + Data type and type-synonym declarations can be written infix, parenthesised + if you want further arguments. E.g. + + data a :*: b = Foo a b + type a :+: b = Either a b + class a :=: b where ... + + data (a :**: b) x = Baz a b x + type (a :++: b) y = Either (a,b) y + + + + Types, and class constraints, can be written infix. For example + + x :: Int :*: Bool + f :: (a :=: b) => a -> b + Back-quotes work @@ -908,7 +960,7 @@ like expressions. More specifically: Int `a` Bool. Similarly, parentheses work the same; e.g. (:*:) Int Bool. - Fixities may be declared for type constructors just as for data constructors. However, + Fixities may be declared for type constructors, or classes, just as for data constructors. However, one cannot distinguish between the two in a fixity declaration; a fixity declaration sets the fixity for a data constructor and the corresponding type constructor. For example: @@ -922,13 +974,6 @@ like expressions. More specifically: Function arrow is infixr with fixity 0. (This might change; I'm not sure what it should be.) - Data type and type-synonym declarations can be written infix. E.g. - - data a :*: b = Foo a b - type a :+: b = Either a b - - - The only thing that differs between operators in types and operators in expressions is that ordinary non-constructor operators, such as + and * are not allowed in types. Reason: the uniform thing to do would be to make them type @@ -945,7 +990,7 @@ like expressions. More specifically: Liberalised type synonyms -Type synonmys are like macros at the type level, and +Type synonyms are like macros at the type level, and GHC does validity checking on types only after expanding type synonyms. That means that GHC can be very much more liberal about type synonyms than Haskell 98: @@ -994,7 +1039,7 @@ You can apply a type synonym to a partially applied type synonym: foo :: Generic Id [] -After epxanding the synonym, foo has the legal (in GHC) type: +After expanding the synonym, foo has the legal (in GHC) type: foo :: forall x. x -> [x] @@ -1446,7 +1491,7 @@ be acyclic. So these class declarations are OK: All of the class type variables must be reachable (in the sense mentioned in ) -from the free varibles of each method type +from the free variables of each method type . For example: @@ -1577,7 +1622,7 @@ get any more information about tv. Note that the reachability condition is weaker than saying that a is -functionally dependendent on a type variable free in +functionally dependent on a type variable free in type (see ). The reason for this is there might be a "hidden" dependency, in a superclass perhaps. So @@ -1686,99 +1731,67 @@ means Instance declarations - + Overlapping instances -In general, instance declarations may not overlap. The two instance -declarations - - - - instance context1 => C type1 where ... - instance context2 => C type2 where ... - - -"overlap" if type1 and type2 unify. - - -However, if you give the command line option --fallow-overlapping-instances -option then overlapping instance declarations are permitted. -However, GHC arranges never to commit to using an instance declaration -if another instance declaration also applies, either now or later. - - - - - - EITHER type1 and type2 do not unify - - - - - - OR type2 is a substitution instance of type1 -(but not identical to type1), or vice versa. - - - -Notice that these rules - - - - - make it clear which instance decl to use -(pick the most specific one that matches) - - - - - - - do not mention the contexts context1, context2 -Reason: you can pick which instance decl -"matches" based on the type. - - - - -However the rules are over-conservative. Two instance declarations can overlap, -but it can still be clear in particular situations which to use. For example: - - instance C (Int,a) where ... - instance C (a,Bool) where ... - -These are rejected by GHC's rules, but it is clear what to do when trying -to solve the constraint C (Int,Int) because the second instance -cannot apply. Yell if this restriction bites you. - - -GHC is also conservative about committing to an overlapping instance. For example: - - class C a where { op :: a -> a } - instance C [Int] where ... - instance C a => C [a] where ... - - f :: C b => [b] -> [b] - f x = op x - -From the RHS of f we get the constraint C [b]. But -GHC does not commit to the second instance declaration, because in a paricular -call of f, b might be instantiate to Int, so the first instance declaration -would be appropriate. So GHC rejects the program. If you add -GHC will instead silently pick the second instance, without complaining about +In general, GHC requires that that it be unambiguous which instance +declaration +should be used to resolve a type-class constraint. This behaviour +can be modified by two flags: +-fallow-overlapping-instances + +and +-fallow-incoherent-instances +, as this section discusses. + +When GHC tries to resolve, say, the constraint C Int Bool, +it tries to match every instance declaration against the +constraint, +by instantiating the head of the instance declaration. For example, consider +these declarations: + + instance context1 => C Int a where ... -- (A) + instance context2 => C a Bool where ... -- (B) + instance context3 => C Int [a] where ... -- (C) + instance context4 => C Int [Int] where ... -- (D) + +The instances (A) and (B) match the constraint C Int Bool, but (C) and (D) do not. When matching, GHC takes +no account of the context of the instance declaration +(context1 etc). +GHC's default behaviour is that exactly one instance must match the +constraint it is trying to resolve. +It is fine for there to be a potential of overlap (by +including both declarations (A) and (B), say); an error is only reported if a +particular constraint matches more than one. + + + +The flag instructs GHC to allow +more than one instance to match, provided there is a most specific one. For +example, the constraint C Int [Int] matches instances (A), +(C) and (D), but the last is more specific, and hence is chosen. If there is no +most-specific match, the program is rejected. + + +However, GHC is conservative about committing to an overlapping instance. For example: + + f :: [b] -> [b] + f x = ... + +Suppose that from the RHS of f we get the constraint +C Int [b]. But +GHC does not commit to instance (C), because in a particular +call of f, b might be instantiate +to Int, in which case instance (D) would be more specific still. +So GHC rejects the program. If you add the flag , +GHC will instead pick (C), without complaining about the problem of subsequent instantiations. -Regrettably, GHC doesn't guarantee to detect overlapping instance -declarations if they appear in different modules. GHC can "see" the -instance declarations in the transitive closure of all the modules -imported by the one being compiled, so it can "see" all instance decls -when it is compiling Main. However, it currently chooses not -to look at ones that can't possibly be of use in the module currently -being compiled, in the interests of efficiency. (Perhaps we should -change that decision, at least for Main.) - +Because overlaps are checked and reported lazily, as described above, you need +the in the module that calls +the overloaded function, rather than in the module that defines it. + @@ -1935,7 +1948,7 @@ allowing these idioms interesting idioms. Implicit parameters - Implicit paramters are implemented as described in + Implicit parameters are implemented as described in "Implicit parameters: dynamic scoping with static types", J Lewis, MB Shields, E Meijer, J Launchbury, 27th ACM Symposium on Principles of Programming Languages (POPL'00), @@ -2106,7 +2119,7 @@ problem that monads seem over-kill for certain sorts of problem, notably: distributing a supply of unique names - distributing a suppply of random numbers + distributing a supply of random numbers distributing an oracle (as in QuickCheck) @@ -2393,7 +2406,7 @@ is implicitly added by Haskell. The functions f2 and g2 have rank-2 types; -the forall is on the left of a function arrrow. As g2 +the forall is on the left of a function arrow. As g2 shows, the polymorphic type on the left of the function arrow can be overloaded. @@ -2566,7 +2579,7 @@ matching. Type inference -In general, type inference for arbitrary-rank types is undecideable. +In general, type inference for arbitrary-rank types is undecidable. GHC uses an algorithm proposed by Odersky and Laufer ("Putting type annotations to work", POPL'96) to get a decidable algorithm by requiring some help from the programmer. We do not yet have a formal specification of "some help" but the rule is this: @@ -2665,22 +2678,19 @@ for rank-2 types. -A pattern type signature can introduce a scoped type -variable. For example - - - - +A lexically scoped type variable can be bound by: + +A declaration type signature () +A pattern type signature () +A result type signature () + +For example: f (xs::[a]) = ys ++ ys where ys :: [a] ys = reverse xs - - - - The pattern (xs::[a]) includes a type signature for xs. This brings the type variable a into scope; it scopes over all the patterns and right hand sides for this equation for f. @@ -2688,8 +2698,6 @@ In particular, it is in scope at the type signature for y. - Pattern type signatures are completely orthogonal to ordinary, separate -type signatures. The two can be used independently or together. At ordinary type signatures, such as that for ys, any type variables mentioned in the type signature that are not in scope are implicitly universally quantified. (If there are no type variables in @@ -2712,10 +2720,10 @@ So much for the basic idea. Here are the details. -What a pattern type signature means +What a scoped type variable means -A type variable brought into scope by a pattern type signature is simply -the name for a type. The restriction they express is that all occurrences +A lexically-scoped type variable is simply +the name for a type. The restriction it expresses is that all occurrences of the same name mean the same type. For example: f :: [Int] -> Int -> Int @@ -2885,7 +2893,33 @@ scope over the methods defined in the where part. For exampl - + +Declaration type signatures +A declaration type signature that has explicit +quantification (using forall) brings into scope the +explicitly-quantified +type variables, in the definition of the named function(s). For example: + + f :: forall a. [a] -> [a] + f (x:xs) = xs ++ [ x :: a ] + +The "forall a" brings "a" into scope in +the definition of "f". + +This only happens if the quantification in f's type +signature is explicit. For example: + + g :: [a] -> [a] + g (x:xs) = xs ++ [ x :: a ] + +This program will be rejected, because "a" does not scope +over the definition of "f", so "x::a" +means "x::forall a. a" by Haskell's usual implicit +quantification rules. + + + + Where a pattern type signature can occur @@ -2895,7 +2929,7 @@ A pattern type signature can occur in any pattern. For example: A pattern type signature can be on an arbitrary sub-pattern, not -ust on a variable: +just on a variable: @@ -3002,10 +3036,12 @@ in f4's scope. +Pattern type signatures are completely orthogonal to ordinary, separate +type signatures. The two can be used independently or together. - + Result type signatures @@ -3279,6 +3315,109 @@ instances is most interesting. + + + +Generalised Algebraic Data Types + +Generalised Algebraic Data Types (GADTs) generalise ordinary algebraic data types by allowing you +to give the type signatures of constructors explicitly. For example: + + data Term a where + Lit :: Int -> Term Int + Succ :: Term Int -> Term Int + IsZero :: Term Int -> Term Bool + If :: Term Bool -> Term a -> Term a -> Term a + Pair :: Term a -> Term b -> Term (a,b) + +Notice that the return type of the constructors is not always Term a, as is the +case with ordinary vanilla data types. Now we can write a well-typed eval function +for these Terms: + + eval :: Term a -> a + eval (Lit i) = i + eval (Succ t) = 1 + eval t + eval (IsZero i) = eval i == 0 + eval (If b e1 e2) = if eval b then eval e1 else eval e2 + eval (Pair e1 e2) = (eval e2, eval e2) + +These and many other examples are given in papers by Hongwei Xi, and Tim Sheard. + + The extensions to GHC are these: + + + Data type declarations have a 'where' form, as exemplified above. The type signature of +each constructor is independent, and is implicitly universally quantified as usual. Unlike a normal +Haskell data type declaration, the type variable(s) in the "data Term a where" header +have no scope. Indeed, one can write a kind signature instead: + + data Term :: * -> * where ... + +or even a mixture of the two: + + data Foo a :: (* -> *) -> * where ... + +The type variables (if given) may be explicitly kinded, so we could also write the header for Foo +like this: + + data Foo a (b :: * -> *) where ... + + + + +There are no restrictions on the type of the data constructor, except that the result +type must begin with the type constructor being defined. For example, in the Term data +type above, the type of each constructor must end with ... -> Term .... + + + +You cannot use a deriving clause on a GADT-style data type declaration, +nor can you use record syntax. (It's not clear what these constructs would mean. For example, +the record selectors might ill-typed.) However, you can use strictness annotations, in the obvious places +in the constructor type: + + data Term a where + Lit :: !Int -> Term Int + If :: Term Bool -> !(Term a) -> !(Term a) -> Term a + Pair :: Term a -> Term b -> Term (a,b) + + + + +Pattern matching causes type refinement. For example, in the right hand side of the equation + + eval :: Term a -> a + eval (Lit i) = ... + +the type a is refined to Int. (That's the whole point!) +A precise specification of the type rules is beyond what this user manual aspires to, but there is a paper +about the ideas: "Wobbly types: practical type inference for generalised algebraic data types", on Simon PJ's home page. + + The general principle is this: type refinement is only carried out based on user-supplied type annotations. +So if no type signature is supplied for eval, no type refinement happens, and lots of obscure error messages will +occur. However, the refinement is quite general. For example, if we had: + + eval :: Term a -> a -> a + eval (Lit i) j = i+j + +the pattern match causes the type a to be refined to Int (because of the type +of the constructor Lit, and that refinement also applies to the type of j, and +the result type of the case expression. Hence the addition i+j is legal. + + + + + +Notice that GADTs generalise existential types. For example, these two declarations are equivalent: + + data T a = forall b. MkT b (b->a) + data T' a where { MKT :: b -> (b->a) -> T a } + + + + + + @@ -3423,7 +3562,7 @@ module Printf where -- you intend to use it. -- Import some Template Haskell syntax -import Language.Haskell.TH.Syntax +import Language.Haskell.TH -- Describe a format string data Format = D | S | L String @@ -4096,7 +4235,7 @@ Assertion failures can be caught, see the documentation for the {-# DEPRECATED f, C, T "Don't use these" #-} When you compile any module that imports and uses any - of the specifed entities, GHC will print the specified + of the specified entities, GHC will print the specified message. @@ -4113,6 +4252,31 @@ Assertion failures can be caught, see the documentation for the . + + INCLUDE pragma + + The INCLUDE pragma is for specifying the names + of C header files that should be #include'd into + the C source code generated by the compiler for the current module (if + compiling via C). For example: + + +{-# INCLUDE "foo.h" #-} +{-# INCLUDE <stdio.h> #-} + + The INCLUDE pragma(s) must appear at the top of + your source file with any OPTIONS_GHC + pragma(s). + + An INCLUDE pragma is the preferred alternative + to the option (), because the + INCLUDE pragma is understood by other + compilers. Yet another alternative is to add the include file to each + foreign import declaration in your code, but we + don't recommend using this approach with GHC. + + INLINE and NOINLINE pragmas @@ -4152,7 +4316,7 @@ key_function :: Int -> String -> (Bool, Double) The normal unfolding machinery will then be very keen to inline it. - Syntactially, an INLINE pragma for a + Syntactically, an INLINE pragma for a function can be put anywhere its type signature could be put. @@ -4186,7 +4350,7 @@ key_function :: Int -> String -> (Bool, Double) you're very cautious about code size. NOTINLINE is a synonym for - NOINLINE (NOTINLINE is + NOINLINE (NOINLINE is specified by Haskell 98 as the standard way to disable inlining, so it should be used if you want your code to be portable). @@ -4202,7 +4366,7 @@ key_function :: Int -> String -> (Bool, Double) number; the phase number decreases towards zero. If you use you'll see the sequence of phase numbers for successive runs of the - simpifier. In an INLINE pragma you can optionally specify a + simplifier. In an INLINE pragma you can optionally specify a phase number, thus: @@ -4286,16 +4450,19 @@ key_function :: Int -> String -> (Bool, Double) - OPTIONS pragma - OPTIONS + OPTIONS_GHC pragma + OPTIONS_GHC - pragmaOPTIONS + pragmaOPTIONS_GHC - The OPTIONS pragma is used to specify + The OPTIONS_GHC pragma is used to specify additional options that are given to the compiler when compiling this source file. See for details. + + Previous versions of GHC accepted OPTIONS rather + than OPTIONS_GHC, but that is now deprecated. @@ -4447,7 +4614,7 @@ data S = S {-# UNPACK #-} !Int {-# UNPACK #-} !Int Rewrite rules -<indexterm><primary>RULES pagma</primary></indexterm> +<indexterm><primary>RULES pragma</primary></indexterm> <indexterm><primary>pragma, RULES</primary></indexterm> <indexterm><primary>rewrite rules</primary></indexterm> @@ -4613,7 +4780,7 @@ same type. GHC makes absolutely no attempt to verify that the LHS and RHS -of a rule have the same meaning. That is undecideable in general, and +of a rule have the same meaning. That is undecidable in general, and infeasible in most interesting cases. The responsibility is entirely the programmer's! @@ -4645,7 +4812,7 @@ This rule will cause the compiler to go into an infinite loop. for matching a rule LHS with an expression. It seeks a substitution which makes the LHS and expression syntactically equal modulo alpha conversion. The pattern (rule), but not the expression, is eta-expanded if -necessary. (Eta-expanding the epression can lead to laziness bugs.) +necessary. (Eta-expanding the expression can lead to laziness bugs.) But not beta conversion (that's called higher-order matching). @@ -5011,7 +5178,7 @@ If you add you get a more detailed listing. - The defintion of (say) build in GHC/Base.lhs looks llike this: + The definition of (say) build in GHC/Base.lhs looks llike this: build :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] @@ -5060,7 +5227,7 @@ program even if fusion doesn't happen. More rules in GHC/List.lhs - Sematically, this is equivalent to: + Semantically, this is equivalent to: g x = show x