[project @ 2000-07-11 16:24:57 by simonmar]
[ghc-hetmet.git] / ghc / compiler / rename / RnBinds.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[RnBinds]{Renaming and dependency analysis of bindings}
5
6 This module does renaming and dependency analysis on value bindings in
7 the abstract syntax.  It does {\em not} do cycle-checks on class or
8 type-synonym declarations; those cannot be done at this stage because
9 they may be affected by renaming (which isn't fully worked out yet).
10
11 \begin{code}
12 module RnBinds (
13         rnTopBinds, rnTopMonoBinds,
14         rnMethodBinds, renameSigs,
15         rnBinds,
16         unknownSigErr
17    ) where
18
19 #include "HsVersions.h"
20
21 import {-# SOURCE #-} RnSource ( rnHsSigType )
22
23 import HsSyn
24 import HsBinds          ( eqHsSig, sigName, hsSigDoc )
25 import RdrHsSyn
26 import RnHsSyn
27 import RnMonad
28 import RnExpr           ( rnMatch, rnGRHSs, rnPat, checkPrecMatch )
29 import RnEnv            ( bindLocatedLocalsRn, lookupBndrRn, 
30                           lookupGlobalOccRn, lookupOccRn, lookupSigOccRn,
31                           warnUnusedLocalBinds, mapFvRn, 
32                           FreeVars, emptyFVs, plusFV, plusFVs, unitFV, addOneFV,
33                           unknownNameErr
34                         )
35 import CmdLineOpts      ( opt_WarnMissingSigs )
36 import Digraph          ( stronglyConnComp, SCC(..) )
37 import Name             ( OccName, Name, nameOccName, mkUnboundName, isUnboundName )
38 import NameSet
39 import RdrName          ( RdrName, rdrNameOcc  )
40 import BasicTypes       ( RecFlag(..), TopLevelFlag(..) )
41 import List             ( partition )
42 import Bag              ( bagToList )
43 import Outputable
44 \end{code}
45
46 -- ToDo: Put the annotations into the monad, so that they arrive in the proper
47 -- place and can be used when complaining.
48
49 The code tree received by the function @rnBinds@ contains definitions
50 in where-clauses which are all apparently mutually recursive, but which may
51 not really depend upon each other. For example, in the top level program
52 \begin{verbatim}
53 f x = y where a = x
54               y = x
55 \end{verbatim}
56 the definitions of @a@ and @y@ do not depend on each other at all.
57 Unfortunately, the typechecker cannot always check such definitions.
58 \footnote{Mycroft, A. 1984. Polymorphic type schemes and recursive
59 definitions. In Proceedings of the International Symposium on Programming,
60 Toulouse, pp. 217-39. LNCS 167. Springer Verlag.}
61 However, the typechecker usually can check definitions in which only the
62 strongly connected components have been collected into recursive bindings.
63 This is precisely what the function @rnBinds@ does.
64
65 ToDo: deal with case where a single monobinds binds the same variable
66 twice.
67
68 The vertag tag is a unique @Int@; the tags only need to be unique
69 within one @MonoBinds@, so that unique-Int plumbing is done explicitly
70 (heavy monad machinery not needed).
71
72 \begin{code}
73 type VertexTag  = Int
74 type Cycle      = [VertexTag]
75 type Edge       = (VertexTag, VertexTag)
76 \end{code}
77
78 %************************************************************************
79 %*                                                                      *
80 %* naming conventions                                                   *
81 %*                                                                      *
82 %************************************************************************
83
84 \subsection[name-conventions]{Name conventions}
85
86 The basic algorithm involves walking over the tree and returning a tuple
87 containing the new tree plus its free variables. Some functions, such
88 as those walking polymorphic bindings (HsBinds) and qualifier lists in
89 list comprehensions (@Quals@), return the variables bound in local
90 environments. These are then used to calculate the free variables of the
91 expression evaluated in these environments.
92
93 Conventions for variable names are as follows:
94 \begin{itemize}
95 \item
96 new code is given a prime to distinguish it from the old.
97
98 \item
99 a set of variables defined in @Exp@ is written @dvExp@
100
101 \item
102 a set of variables free in @Exp@ is written @fvExp@
103 \end{itemize}
104
105 %************************************************************************
106 %*                                                                      *
107 %* analysing polymorphic bindings (HsBinds, Bind, MonoBinds)            *
108 %*                                                                      *
109 %************************************************************************
110
111 \subsubsection[dep-HsBinds]{Polymorphic bindings}
112
113 Non-recursive expressions are reconstructed without any changes at top
114 level, although their component expressions may have to be altered.
115 However, non-recursive expressions are currently not expected as
116 \Haskell{} programs, and this code should not be executed.
117
118 Monomorphic bindings contain information that is returned in a tuple
119 (a @FlatMonoBindsInfo@) containing:
120
121 \begin{enumerate}
122 \item
123 a unique @Int@ that serves as the ``vertex tag'' for this binding.
124
125 \item
126 the name of a function or the names in a pattern. These are a set
127 referred to as @dvLhs@, the defined variables of the left hand side.
128
129 \item
130 the free variables of the body. These are referred to as @fvBody@.
131
132 \item
133 the definition's actual code. This is referred to as just @code@.
134 \end{enumerate}
135
136 The function @nonRecDvFv@ returns two sets of variables. The first is
137 the set of variables defined in the set of monomorphic bindings, while the
138 second is the set of free variables in those bindings.
139
140 The set of variables defined in a non-recursive binding is just the
141 union of all of them, as @union@ removes duplicates. However, the
142 free variables in each successive set of cumulative bindings is the
143 union of those in the previous set plus those of the newest binding after
144 the defined variables of the previous set have been removed.
145
146 @rnMethodBinds@ deals only with the declarations in class and
147 instance declarations.  It expects only to see @FunMonoBind@s, and
148 it expects the global environment to contain bindings for the binders
149 (which are all class operations).
150
151 %************************************************************************
152 %*                                                                      *
153 \subsubsection{ Top-level bindings}
154 %*                                                                      *
155 %************************************************************************
156
157 @rnTopBinds@ assumes that the environment already
158 contains bindings for the binders of this particular binding.
159
160 \begin{code}
161 rnTopBinds    :: RdrNameHsBinds -> RnMS (RenamedHsBinds, FreeVars)
162
163 rnTopBinds EmptyBinds                     = returnRn (EmptyBinds, emptyFVs)
164 rnTopBinds (MonoBind bind sigs _)         = rnTopMonoBinds bind sigs
165   -- The parser doesn't produce other forms
166
167
168 rnTopMonoBinds EmptyMonoBinds sigs 
169   = returnRn (EmptyBinds, emptyFVs)
170
171 rnTopMonoBinds mbinds sigs
172  =  mapRn lookupBndrRn binder_rdr_names         `thenRn` \ binder_names ->
173     let
174         bndr_name_set = mkNameSet binder_names
175     in
176     renameSigs (okBindSig bndr_name_set) sigs `thenRn` \ (siglist, sig_fvs) ->
177     let
178         type_sig_vars   = [n | Sig n _ _ <- siglist]
179         un_sigd_binders | opt_WarnMissingSigs = nameSetToList (delListFromNameSet bndr_name_set type_sig_vars)
180                         | otherwise           = []
181     in
182     mapRn_ (addWarnRn.missingSigWarn) un_sigd_binders   `thenRn_`
183
184     rn_mono_binds siglist mbinds                   `thenRn` \ (final_binds, bind_fvs) ->
185     returnRn (final_binds, bind_fvs `plusFV` sig_fvs)
186   where
187     binder_rdr_names = map fst (bagToList (collectMonoBinders mbinds))
188 \end{code}
189
190 %************************************************************************
191 %*                                                                      *
192 %*              Nested binds
193 %*                                                                      *
194 %************************************************************************
195
196 \subsubsection{Nested binds}
197
198 @rnMonoBinds@
199 \begin{itemize}
200 \item collects up the binders for this declaration group,
201 \item checks that they form a set
202 \item extends the environment to bind them to new local names
203 \item calls @rnMonoBinds@ to do the real work
204 \end{itemize}
205 %
206 \begin{code}
207 rnBinds       :: RdrNameHsBinds 
208               -> (RenamedHsBinds -> RnMS (result, FreeVars))
209               -> RnMS (result, FreeVars)
210
211 rnBinds EmptyBinds             thing_inside = thing_inside EmptyBinds
212 rnBinds (MonoBind bind sigs _) thing_inside = rnMonoBinds bind sigs thing_inside
213   -- the parser doesn't produce other forms
214
215
216 rnMonoBinds :: RdrNameMonoBinds 
217             -> [RdrNameSig]
218             -> (RenamedHsBinds -> RnMS (result, FreeVars))
219             -> RnMS (result, FreeVars)
220
221 rnMonoBinds EmptyMonoBinds sigs thing_inside = thing_inside EmptyBinds
222
223 rnMonoBinds mbinds sigs thing_inside -- Non-empty monobinds
224   =     -- Extract all the binders in this group,
225         -- and extend current scope, inventing new names for the new binders
226         -- This also checks that the names form a set
227     bindLocatedLocalsRn (text "a binding group") mbinders_w_srclocs
228     $ \ new_mbinders ->
229     let
230         binder_set = mkNameSet new_mbinders
231     in
232         -- Rename the signatures
233     renameSigs (okBindSig binder_set) sigs      `thenRn` \ (siglist, sig_fvs) ->
234
235         -- Report the fixity declarations in this group that 
236         -- don't refer to any of the group's binders.
237         -- Then install the fixity declarations that do apply here
238         -- Notice that they scope over thing_inside too
239     let
240         fixity_sigs = [(name,sig) | FixSig sig@(FixitySig name _ _) <- siglist ]
241     in
242     extendFixityEnv fixity_sigs $
243
244     rn_mono_binds siglist mbinds           `thenRn` \ (binds, bind_fvs) ->
245
246     -- Now do the "thing inside", and deal with the free-variable calculations
247     thing_inside binds                     `thenRn` \ (result,result_fvs) ->
248     let
249         all_fvs        = result_fvs `plusFV` bind_fvs `plusFV` sig_fvs
250         unused_binders = nameSetToList (binder_set `minusNameSet` all_fvs)
251     in
252     warnUnusedLocalBinds unused_binders `thenRn_`
253     returnRn (result, delListFromNameSet all_fvs new_mbinders)
254   where
255     mbinders_w_srclocs = bagToList (collectMonoBinders mbinds)
256 \end{code}
257
258
259 %************************************************************************
260 %*                                                                      *
261 \subsubsection{         MonoBinds -- the main work is done here}
262 %*                                                                      *
263 %************************************************************************
264
265 @rn_mono_binds@ is used by {\em both} top-level and nested bindings.
266 It assumes that all variables bound in this group are already in scope.
267 This is done {\em either} by pass 3 (for the top-level bindings),
268 {\em or} by @rnMonoBinds@ (for the nested ones).
269
270 \begin{code}
271 rn_mono_binds :: [RenamedSig]           -- Signatures attached to this group
272               -> RdrNameMonoBinds       
273               -> RnMS (RenamedHsBinds,  -- 
274                          FreeVars)      -- Free variables
275
276 rn_mono_binds siglist mbinds
277   =
278          -- Rename the bindings, returning a MonoBindsInfo
279          -- which is a list of indivisible vertices so far as
280          -- the strongly-connected-components (SCC) analysis is concerned
281     flattenMonoBinds siglist mbinds             `thenRn` \ mbinds_info ->
282
283          -- Do the SCC analysis
284     let 
285         edges       = mkEdges (mbinds_info `zip` [(0::Int)..])
286         scc_result  = stronglyConnComp edges
287         final_binds = foldr1 ThenBinds (map reconstructCycle scc_result)
288
289          -- Deal with bound and free-var calculation
290         rhs_fvs = plusFVs [fvs | (_,fvs,_,_) <- mbinds_info]
291     in
292     returnRn (final_binds, rhs_fvs)
293 \end{code}
294
295 @flattenMonoBinds@ is ever-so-slightly magical in that it sticks
296 unique ``vertex tags'' on its output; minor plumbing required.
297
298 Sigh --- need to pass along the signatures for the group of bindings,
299 in case any of them \fbox{\ ???\ } 
300
301 \begin{code}
302 flattenMonoBinds :: [RenamedSig]                -- Signatures
303                  -> RdrNameMonoBinds
304                  -> RnMS [FlatMonoBindsInfo]
305
306 flattenMonoBinds sigs EmptyMonoBinds = returnRn []
307
308 flattenMonoBinds sigs (AndMonoBinds bs1 bs2)
309   = flattenMonoBinds sigs bs1   `thenRn` \ flat1 ->
310     flattenMonoBinds sigs bs2   `thenRn` \ flat2 ->
311     returnRn (flat1 ++ flat2)
312
313 flattenMonoBinds sigs (PatMonoBind pat grhss locn)
314   = pushSrcLocRn locn                   $
315     rnPat pat                           `thenRn` \ (pat', pat_fvs) ->
316
317          -- Find which things are bound in this group
318     let
319         names_bound_here = mkNameSet (collectPatBinders pat')
320     in
321     sigsForMe names_bound_here sigs     `thenRn` \ sigs_for_me ->
322     rnGRHSs grhss                       `thenRn` \ (grhss', fvs) ->
323     returnRn 
324         [(names_bound_here,
325           fvs `plusFV` pat_fvs,
326           PatMonoBind pat' grhss' locn,
327           sigs_for_me
328          )]
329
330 flattenMonoBinds sigs (FunMonoBind name inf matches locn)
331   = pushSrcLocRn locn                                   $
332     lookupBndrRn name                                   `thenRn` \ new_name ->
333     let
334         names_bound_here = unitNameSet new_name
335     in
336     sigsForMe names_bound_here sigs                     `thenRn` \ sigs_for_me ->
337     mapFvRn rnMatch matches                             `thenRn` \ (new_matches, fvs) ->
338     mapRn_ (checkPrecMatch inf new_name) new_matches    `thenRn_`
339     returnRn
340       [(unitNameSet new_name,
341         fvs,
342         FunMonoBind new_name inf new_matches locn,
343         sigs_for_me
344         )]
345
346
347 sigsForMe names_bound_here sigs
348   = foldlRn check [] (filter (sigForThisGroup names_bound_here) sigs)
349   where
350     check sigs sig = case filter (eqHsSig sig) sigs of
351                         []    -> returnRn (sig:sigs)
352                         other -> dupSigDeclErr sig      `thenRn_`
353                                  returnRn sigs
354 \end{code}
355
356
357 @rnMethodBinds@ is used for the method bindings of a class and an instance
358 declaration.   Like @rnMonoBinds@ but without dependency analysis.
359
360 NOTA BENE: we record each {\em binder} of a method-bind group as a free variable.
361 That's crucial when dealing with an instance decl:
362 \begin{verbatim}
363         instance Foo (T a) where
364            op x = ...
365 \end{verbatim}
366 This might be the {\em sole} occurrence of @op@ for an imported class @Foo@,
367 and unless @op@ occurs we won't treat the type signature of @op@ in the class
368 decl for @Foo@ as a source of instance-decl gates.  But we should!  Indeed,
369 in many ways the @op@ in an instance decl is just like an occurrence, not
370 a binder.
371
372 \begin{code}
373 rnMethodBinds :: RdrNameMonoBinds -> RnMS (RenamedMonoBinds, FreeVars)
374
375 rnMethodBinds EmptyMonoBinds = returnRn (EmptyMonoBinds, emptyFVs)
376
377 rnMethodBinds (AndMonoBinds mb1 mb2)
378   = rnMethodBinds mb1   `thenRn` \ (mb1', fvs1) ->
379     rnMethodBinds mb2   `thenRn` \ (mb2', fvs2) ->
380     returnRn (mb1' `AndMonoBinds` mb2', fvs1 `plusFV` fvs2)
381
382 rnMethodBinds (FunMonoBind name inf matches locn)
383   = pushSrcLocRn locn                                   $
384
385     lookupGlobalOccRn name                              `thenRn` \ sel_name -> 
386         -- We use the selector name as the binder
387
388     mapFvRn rnMatch matches                             `thenRn` \ (new_matches, fvs) ->
389     mapRn_ (checkPrecMatch inf sel_name) new_matches    `thenRn_`
390     returnRn (FunMonoBind sel_name inf new_matches locn, fvs `addOneFV` sel_name)
391
392 -- Can't handle method pattern-bindings which bind multiple methods.
393 rnMethodBinds mbind@(PatMonoBind other_pat _ locn)
394   = pushSrcLocRn locn   $
395     failWithRn (EmptyMonoBinds, emptyFVs) (methodBindErr mbind)
396 \end{code}
397
398
399 %************************************************************************
400 %*                                                                      *
401 \subsection[reconstruct-deps]{Reconstructing dependencies}
402 %*                                                                      *
403 %************************************************************************
404
405 This @MonoBinds@- and @ClassDecls@-specific code is segregated here,
406 as the two cases are similar.
407
408 \begin{code}
409 reconstructCycle :: SCC FlatMonoBindsInfo
410                  -> RenamedHsBinds
411
412 reconstructCycle (AcyclicSCC (_, _, binds, sigs))
413   = MonoBind binds sigs NonRecursive
414
415 reconstructCycle (CyclicSCC cycle)
416   = MonoBind this_gp_binds this_gp_sigs Recursive
417   where
418     this_gp_binds      = foldr1 AndMonoBinds [binds | (_, _, binds, _) <- cycle]
419     this_gp_sigs       = foldr1 (++)         [sigs  | (_, _, _, sigs) <- cycle]
420 \end{code}
421
422 %************************************************************************
423 %*                                                                      *
424 \subsubsection{ Manipulating FlatMonoBindInfo}
425 %*                                                                      *
426 %************************************************************************
427
428 During analysis a @MonoBinds@ is flattened to a @FlatMonoBindsInfo@.
429 The @RenamedMonoBinds@ is always an empty bind, a pattern binding or
430 a function binding, and has itself been dependency-analysed and
431 renamed.
432
433 \begin{code}
434 type FlatMonoBindsInfo
435   = (NameSet,                   -- Set of names defined in this vertex
436      NameSet,                   -- Set of names used in this vertex
437      RenamedMonoBinds,
438      [RenamedSig])              -- Signatures, if any, for this vertex
439
440 mkEdges :: [(FlatMonoBindsInfo, VertexTag)] -> [(FlatMonoBindsInfo, VertexTag, [VertexTag])]
441
442 mkEdges flat_info
443   = [ (info, tag, dest_vertices (nameSetToList names_used))
444     | (info@(names_defined, names_used, mbind, sigs), tag) <- flat_info
445     ]
446   where
447          -- An edge (v,v') indicates that v depends on v'
448     dest_vertices src_mentions = [ target_vertex
449                                  | ((names_defined, _, _, _), target_vertex) <- flat_info,
450                                    mentioned_name <- src_mentions,
451                                    mentioned_name `elemNameSet` names_defined
452                                  ]
453 \end{code}
454
455
456 %************************************************************************
457 %*                                                                      *
458 \subsubsection[dep-Sigs]{Signatures (and user-pragmas for values)}
459 %*                                                                      *
460 %************************************************************************
461
462 @renameSigs@ checks for:
463 \begin{enumerate}
464 \item more than one sig for one thing;
465 \item signatures given for things not bound here;
466 \item with suitably flaggery, that all top-level things have type signatures.
467 \end{enumerate}
468 %
469 At the moment we don't gather free-var info from the types in
470 signatures.  We'd only need this if we wanted to report unused tyvars.
471
472 \begin{code}
473 renameSigs ::  (RenamedSig -> Bool)             -- OK-sig predicate
474             -> [RdrNameSig]
475             -> RnMS ([RenamedSig], FreeVars)
476
477 renameSigs ok_sig [] = returnRn ([], emptyFVs)  -- Common shortcut
478
479 renameSigs ok_sig sigs
480   =      -- Rename the signatures
481     mapFvRn renameSig sigs      `thenRn` \ (sigs', fvs) ->
482
483         -- Check for (a) duplicate signatures
484         --           (b) signatures for things not in this group
485     let
486         in_scope         = filter is_in_scope sigs'
487         is_in_scope sig  = case sigName sig of
488                                 Just n  -> not (isUnboundName n)
489                                 Nothing -> True
490         (goods, bads)    = partition ok_sig in_scope
491     in
492     mapRn_ unknownSigErr bads                   `thenRn_`
493     returnRn (goods, fvs)
494
495 -- We use lookupSigOccRn in the signatures, which is a little bit unsatisfactory
496 -- because this won't work for:
497 --      instance Foo T where
498 --        {-# INLINE op #-}
499 --        Baz.op = ...
500 -- We'll just rename the INLINE prag to refer to whatever other 'op'
501 -- is in scope.  (I'm assuming that Baz.op isn't in scope unqualified.)
502 -- Doesn't seem worth much trouble to sort this.
503
504 renameSig :: Sig RdrName -> RnMS (Sig Name, FreeVars)
505
506 renameSig (Sig v ty src_loc)
507   = pushSrcLocRn src_loc $
508     lookupSigOccRn v                            `thenRn` \ new_v ->
509     rnHsSigType (quotes (ppr v)) ty             `thenRn` \ (new_ty,fvs) ->
510     returnRn (Sig new_v new_ty src_loc, fvs `addOneFV` new_v)
511
512 renameSig (SpecInstSig ty src_loc)
513   = pushSrcLocRn src_loc $
514     rnHsSigType (text "A SPECIALISE instance pragma") ty `thenRn` \ (new_ty, fvs) ->
515     returnRn (SpecInstSig new_ty src_loc, fvs)
516
517 renameSig (SpecSig v ty src_loc)
518   = pushSrcLocRn src_loc $
519     lookupSigOccRn v                    `thenRn` \ new_v ->
520     rnHsSigType (quotes (ppr v)) ty     `thenRn` \ (new_ty,fvs) ->
521     returnRn (SpecSig new_v new_ty src_loc, fvs `addOneFV` new_v)
522
523 renameSig (FixSig (FixitySig v fix src_loc))
524   = pushSrcLocRn src_loc $
525     lookupSigOccRn v            `thenRn` \ new_v ->
526     returnRn (FixSig (FixitySig new_v fix src_loc), unitFV new_v)
527
528 renameSig (InlineSig v p src_loc)
529   = pushSrcLocRn src_loc $
530     lookupSigOccRn v            `thenRn` \ new_v ->
531     returnRn (InlineSig new_v p src_loc, unitFV new_v)
532
533 renameSig (NoInlineSig v p src_loc)
534   = pushSrcLocRn src_loc $
535     lookupSigOccRn v            `thenRn` \ new_v ->
536     returnRn (NoInlineSig new_v p src_loc, unitFV new_v)
537 \end{code}
538
539 \begin{code}
540 renameIE :: (RdrName -> RnMS Name) -> IE RdrName -> RnMS (IE Name, FreeVars)
541 renameIE lookup_occ_nm (IEVar v)
542   = lookup_occ_nm v             `thenRn` \ new_v ->
543     returnRn (IEVar new_v, unitFV new_v)
544
545 renameIE lookup_occ_nm (IEThingAbs v)
546   = lookup_occ_nm v             `thenRn` \ new_v ->
547     returnRn (IEThingAbs new_v, unitFV new_v)
548
549 renameIE lookup_occ_nm (IEThingAll v)
550   = lookup_occ_nm v             `thenRn` \ new_v ->
551     returnRn (IEThingAll new_v, unitFV new_v)
552
553 renameIE lookup_occ_nm (IEThingWith v vs)
554   = lookup_occ_nm v             `thenRn` \ new_v ->
555     mapRn lookup_occ_nm vs      `thenRn` \ new_vs ->
556     returnRn (IEThingWith new_v new_vs, plusFVs [ unitFV x | x <- new_v:new_vs ])
557
558 renameIE lookup_occ_nm (IEModuleContents m)
559   = returnRn (IEModuleContents m, emptyFVs)
560 \end{code}
561
562
563 %************************************************************************
564 %*                                                                      *
565 \subsection{Error messages}
566 %*                                                                      *
567 %************************************************************************
568
569 \begin{code}
570 dupSigDeclErr sig
571   = pushSrcLocRn loc $
572     addErrRn (sep [ptext SLIT("Duplicate") <+> ptext what_it_is <> colon,
573                    ppr sig])
574   where
575     (what_it_is, loc) = hsSigDoc sig
576
577 unknownSigErr sig
578   = pushSrcLocRn loc $
579     addErrRn (sep [ptext SLIT("Misplaced") <+> ptext what_it_is <> colon,
580                    ppr sig])
581   where
582     (what_it_is, loc) = hsSigDoc sig
583
584 missingSigWarn var
585   = sep [ptext SLIT("definition but no type signature for"), quotes (ppr var)]
586
587 methodBindErr mbind
588  =  hang (ptext SLIT("Can't handle multiple methods defined by one pattern binding"))
589        4 (ppr mbind)
590 \end{code}