2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[RnPat]{Renaming of patterns}
6 Basically dependency analysis.
8 Handles @Match@, @GRHSs@, @HsExpr@, and @Qualifier@ datatypes. In
9 general, all of these functions return a renamed thing, and a set of
14 -- The above warning supression flag is a temporary kludge.
15 -- While working on this module you are encouraged to remove it and fix
16 -- any warnings in the module. See
17 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
20 module RnPat (-- main entry points
21 rnPatsAndThen_LocalRightwards, rnBindPat,
23 NameMaker, applyNameMaker, -- a utility for making names:
24 localRecNameMaker, topRecNameMaker, -- sometimes we want to make local names,
25 -- sometimes we want to make top (qualified) names.
27 rnHsRecFields_Con, rnHsRecFields_Update, --rename record fields in a constructor
36 -- Pattern Error messages that are also used elsewhere
37 checkTupSize, patSigErr
40 -- ENH: thin imports to only what is necessary for patterns
42 import {-# SOURCE #-} RnExpr( rnLExpr, rnStmts)
44 import {-# SOURCE #-} TcSplice( runQuasiQuotePat )
47 #include "HsVersions.h"
52 import HscTypes ( availNames )
53 import RnNames ( getLocalDeclBinders, extendRdrEnvRn )
54 import RnTypes ( rnHsTypeFVs,
55 mkOpFormRn, mkOpAppRn, mkNegAppRn, checkSectionPrec, mkConOpPatRn
57 import DynFlags ( DynFlag(..) )
58 import BasicTypes ( FixityDirection(..) )
59 import SrcLoc ( SrcSpan )
60 import PrelNames ( thFAKE, hasKey, assertIdKey, assertErrorName,
61 loopAName, choiceAName, appAName, arrAName, composeAName, firstAName,
62 negateName, thenMName, bindMName, failMName,
63 eqClassName, integralClassName, geName, eqName,
64 negateName, minusName, lengthPName, indexPName,
65 plusIntegerName, fromIntegerName, timesIntegerName,
66 ratioDataConName, fromRationalName, fromStringName, mkUnboundName )
67 import Constants ( mAX_TUPLE_SIZE )
68 import Name ( Name, nameOccName, nameModule_maybe, getOccName, nameSrcSpan )
69 import OccName ( occEnvElts )
72 import RdrName ( RdrName, GlobalRdrElt(..), Provenance(..),
73 extendLocalRdrEnv, lookupLocalRdrEnv, hideSomeUnquals,
74 mkRdrUnqual, nameRdrName, gre_name, globalRdrEnvElts, isLocalGRE )
75 import LoadIface ( loadInterfaceForName )
76 import UniqSet ( emptyUniqSet )
78 import Util ( isSingleton )
79 import ListSetOps ( removeDups, minusList )
80 import Maybes ( expectJust )
82 import SrcLoc ( Located(..), unLoc, getLoc, cmpLocated, noLoc )
84 import Literal ( inIntRange, inCharRange )
85 import List ( unzip4 )
88 import ErrUtils (Message)
92 *********************************************************
96 *********************************************************
99 -- externally abstract type of name makers,
100 -- which is how you go from a RdrName to a Name
101 data NameMaker = NM (forall a. Located RdrName -> (Name -> RnM (a, FreeVars))
102 -> RnM (a, FreeVars))
104 matchNameMaker :: NameMaker
106 = NM (\ rdr_name thing_inside ->
107 do { names@[name] <- newLocalsRn [rdr_name]
108 ; bindLocalNamesFV names $
109 warnUnusedMatches names $
112 topRecNameMaker, localRecNameMaker
113 :: UniqFM (Located Fixity) -- mini fixity env for the names we're about to bind
114 -- these fixities need to be brought into scope with the names
117 -- topNameMaker and localBindMaker do not check for unused binding
118 localRecNameMaker fix_env
119 = NM (\ rdr_name thing_inside ->
120 do { [name] <- newLocalsRn [rdr_name]
121 ; bindLocalNamesFV_WithFixities [name] fix_env $
124 topRecNameMaker fix_env
125 = NM (\rdr_name thing_inside ->
126 do { mod <- getModule
127 ; name <- newTopSrcBinder mod rdr_name
128 ; bindLocalNamesFV_WithFixities [name] fix_env $
130 -- Note: the bindLocalNamesFV_WithFixities is somewhat suspicious
131 -- because it binds a top-level name as a local name.
132 -- however, this binding seems to work, and it only exists for
133 -- the duration of the patterns and the continuation;
134 -- then the top-level name is added to the global env
135 -- before going on to the RHSes (see RnSource.lhs).
137 applyNameMaker :: NameMaker -> Located RdrName
138 -> (Name -> RnM (a,FreeVars)) -> RnM (a, FreeVars)
139 applyNameMaker (NM f) = f
142 -- There are various entry points to renaming patterns, depending on
143 -- (1) whether the names created should be top-level names or local names
144 -- (2) whether the scope of the names is entirely given in a continuation
145 -- (e.g., in a case or lambda, but not in a let or at the top-level,
146 -- because of the way mutually recursive bindings are handled)
147 -- (3) whether the a type signature in the pattern can bind
148 -- lexically-scoped type variables (for unpacking existential
149 -- type vars in data constructors)
150 -- (4) whether we do duplicate and unused variable checking
151 -- (5) whether there are fixity declarations associated with the names
152 -- bound by the patterns that need to be brought into scope with them.
154 -- Rather than burdening the clients of this module with all of these choices,
155 -- we export the three points in this design space that we actually need:
158 -- binds local names; the scope of the bindings is entirely in the thing_inside
159 -- allows type sigs to bind type vars
161 -- unused and duplicate checking
163 rnPatsAndThen_LocalRightwards :: HsMatchContext Name -- for error messages
165 -- the continuation gets:
166 -- the list of renamed patterns
167 -- the (overall) free vars of all of them
168 -> ([LPat Name] -> RnM (a, FreeVars))
171 rnPatsAndThen_LocalRightwards ctxt pats thing_inside
172 = do { envs_before <- getRdrEnvs
174 -- (0) bring into scope all of the type variables bound by the patterns
175 -- (1) rename the patterns, bringing into scope all of the term variables
176 -- (2) then do the thing inside.
177 ; bindPatSigTyVarsFV (collectSigTysFromPats pats) $
178 rnLPatsAndThen matchNameMaker pats $ \ pats' ->
179 do { -- Check for duplicated and shadowed names
180 -- Because we don't bind the vars all at once, we can't
181 -- check incrementally for duplicates;
182 -- Nor can we check incrementally for shadowing, else we'll
183 -- complain *twice* about duplicates e.g. f (x,x) = ...
184 ; let names = collectPatsBinders pats'
185 ; checkDupNames doc_pat names
186 ; checkShadowedNames doc_pat envs_before
187 [(nameSrcSpan name, nameOccName name) | name <- names]
188 ; thing_inside pats' } }
190 doc_pat = ptext SLIT("In") <+> pprMatchContext ctxt
194 -- binds local names; in a recursive scope that involves other bound vars
195 -- e.g let { (x, Just y) = e1; ... } in ...
196 -- does NOT allows type sig to bind type vars
198 -- no unused and duplicate checking
199 -- fixities might be coming in
200 rnBindPat :: NameMaker
203 -- free variables of the pattern,
204 -- but not including variables bound by this pattern
207 rnBindPat name_maker pat
208 = rnLPatsAndThen name_maker [pat] $ \ [pat'] ->
209 return (pat', emptyFVs)
212 -- general version: parametrized by how you make new names
213 -- invariant: what-to-do continuation only gets called with a list whose length is the same as
214 -- the part of the pattern we're currently renaming
215 rnLPatsAndThen :: NameMaker -- how to make a new variable
216 -> [LPat RdrName] -- part of pattern we're currently renaming
217 -> ([LPat Name] -> RnM (a, FreeVars)) -- what to do afterwards
218 -> RnM (a, FreeVars) -- renaming of the whole thing
220 rnLPatsAndThen var = mapFvRnCPS (rnLPatAndThen var)
224 rnLPatAndThen :: NameMaker
225 -> LPat RdrName -- part of pattern we're currently renaming
226 -> (LPat Name -> RnM (a, FreeVars)) -- what to do afterwards
227 -> RnM (a, FreeVars) -- renaming of the whole thing
228 rnLPatAndThen var@(NM varf) (L loc p) cont =
231 lcont = \ unlocated -> cont (reloc unlocated)
234 WildPat _ -> lcont (WildPat placeHolderType)
236 ParPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (ParPat pat')
237 LazyPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (LazyPat pat')
238 BangPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (BangPat pat')
241 varf (reloc name) $ \ newBoundName ->
242 lcont (VarPat newBoundName)
243 -- we need to bind pattern variables for view pattern expressions
244 -- (e.g. in the pattern (x, x -> y) x needs to be bound in the rhs of the tuple)
246 SigPatIn pat ty -> do
247 patsigs <- doptM Opt_PatternSignatures
249 then rnLPatAndThen var pat
250 (\ pat' -> do { (ty', fvs1) <- rnHsTypeFVs tvdoc ty
251 ; (res, fvs2) <- lcont (SigPatIn pat' ty')
252 ; return (res, fvs1 `plusFV` fvs2) })
253 else do addErr (patSigErr ty)
254 rnLPatAndThen var pat cont
256 tvdoc = text "In a pattern type-signature"
258 LitPat lit@(HsString s) ->
259 do ovlStr <- doptM Opt_OverloadedStrings
261 then rnLPatAndThen var (reloc $ mkNPat (mkHsIsString s placeHolderType) Nothing) cont
262 else do { rnLit lit; lcont (LitPat lit) } -- Same as below
264 LitPat lit -> do { rnLit lit; lcont (LitPat lit) }
266 NPat lit mb_neg eq ->
267 do { (lit', fvs1) <- rnOverLit lit
268 ; (mb_neg', fvs2) <- case mb_neg of
269 Nothing -> return (Nothing, emptyFVs)
270 Just _ -> do { (neg, fvs) <- lookupSyntaxName negateName
271 ; return (Just neg, fvs) }
272 ; (eq', fvs3) <- lookupSyntaxName eqName
273 ; (res, fvs4) <- lcont (NPat lit' mb_neg' eq')
274 ; return (res, fvs1 `plusFV` fvs2 `plusFV` fvs3 `plusFV` fvs4) }
275 -- Needed to find equality on pattern
277 NPlusKPat name lit _ _ ->
278 varf name $ \ new_name ->
279 do { (lit', fvs1) <- rnOverLit lit
280 ; (minus, fvs2) <- lookupSyntaxName minusName
281 ; (ge, fvs3) <- lookupSyntaxName geName
282 ; (res, fvs4) <- lcont (NPlusKPat (L (nameSrcSpan new_name) new_name) lit' ge minus)
283 ; return (res, fvs1 `plusFV` fvs2 `plusFV` fvs3 `plusFV` fvs4) }
284 -- The Report says that n+k patterns must be in Integral
287 varf name $ \ new_name ->
288 rnLPatAndThen var pat $ \ pat' ->
289 lcont (AsPat (L (nameSrcSpan new_name) new_name) pat')
291 ViewPat expr pat ty ->
292 do { vp_flag <- doptM Opt_ViewPatterns
293 ; checkErr vp_flag (badViewPat p)
294 -- because of the way we're arranging the recursive calls,
295 -- this will be in the right context
296 ; (expr', fv_expr) <- rnLExpr expr
297 ; (res, fvs_res) <- rnLPatAndThen var pat $ \ pat' ->
298 lcont (ViewPat expr' pat' ty)
299 ; return (res, fvs_res `plusFV` fv_expr) }
302 pat@(QuasiQuotePat _) -> pprPanic "Can't do QuasiQuotePat without GHCi" (ppr p)
304 QuasiQuotePat qq -> do
305 (qq', _) <- rnQuasiQuote qq
306 pat' <- runQuasiQuotePat qq'
307 rnLPatAndThen var pat' $ \ (L _ pat'') ->
311 ConPatIn con stuff ->
312 -- rnConPatAndThen takes care of reconstructing the pattern
313 rnConPatAndThen var con stuff cont
316 rnLPatsAndThen var pats $ \ patslist ->
317 lcont (ListPat patslist placeHolderType)
320 do { (res, res_fvs) <- rnLPatsAndThen var pats $ \ patslist ->
321 lcont (PArrPat patslist placeHolderType)
322 ; return (res, res_fvs `plusFV` implicit_fvs) }
324 implicit_fvs = mkFVs [lengthPName, indexPName]
326 TuplePat pats boxed _ ->
327 do { checkTupSize (length pats)
328 ; rnLPatsAndThen var pats $ \ patslist ->
329 lcont (TuplePat patslist boxed placeHolderType) }
332 do { (name', fvs1) <- rnHsTypeFVs (text "In a type pattern") name
333 ; (res, fvs2) <- lcont (TypePat name')
334 ; return (res, fvs1 `plusFV` fvs2) }
337 -- helper for renaming constructor patterns
338 rnConPatAndThen :: NameMaker
339 -> Located RdrName -- the constructor
340 -> HsConPatDetails RdrName
341 -> (LPat Name -> RnM (a, FreeVars)) -- what to do afterwards
344 rnConPatAndThen var (con@(L loc _)) (PrefixCon pats) cont
345 = do { con' <- lookupLocatedOccRn con
346 ; (res, res_fvs) <- rnLPatsAndThen var pats $ \ pats' ->
347 cont (L loc $ ConPatIn con' (PrefixCon pats'))
348 ; return (res, res_fvs `addOneFV` unLoc con') }
350 rnConPatAndThen var (con@(L loc _)) (InfixCon pat1 pat2) cont
351 = do { con' <- lookupLocatedOccRn con
352 ; (res, res_fvs) <- rnLPatAndThen var pat1 $ \ pat1' ->
353 rnLPatAndThen var pat2 $ \ pat2' ->
354 do { fixity <- lookupFixityRn (unLoc con')
355 ; pat' <- mkConOpPatRn con' fixity pat1' pat2'
356 ; cont (L loc pat') }
357 ; return (res, res_fvs `addOneFV` unLoc con') }
359 rnConPatAndThen var (con@(L loc _)) (RecCon rpats) cont
360 = do { con' <- lookupLocatedOccRn con
361 ; (res, res_fvs) <- rnHsRecFieldsAndThen_Pattern con' var rpats $ \ rpats' ->
362 cont (L loc $ ConPatIn con' (RecCon rpats'))
363 ; return (res, res_fvs `addOneFV` unLoc con') }
365 -- what kind of record expression we're doing
366 -- the first two tell the name of the datatype constructor in question
367 -- and give a way of creating a variable to fill in a ..
368 data RnHsRecFieldsChoice a = Constructor (Located Name) (RdrName -> a)
369 | Pattern (Located Name) (RdrName -> a)
372 choiceToMessage (Constructor _ _) = "construction"
373 choiceToMessage (Pattern _ _) = "pattern"
374 choiceToMessage Update = "update"
376 doDotDot (Constructor a b) = Just (a,b)
377 doDotDot (Pattern a b) = Just (a,b)
378 doDotDot Update = Nothing
380 getChoiceName (Constructor n _) = Just n
381 getChoiceName (Pattern n _) = Just n
382 getChoiceName (Update) = Nothing
386 -- helper for renaming record patterns;
387 -- parameterized so that it can also be used for expressions
388 rnHsRecFieldsAndThen :: RnHsRecFieldsChoice field
389 -- how to rename the fields (CPSed)
390 -> (Located field -> (Located field' -> RnM (c, FreeVars))
391 -> RnM (c, FreeVars))
393 -> HsRecFields RdrName (Located field)
394 -- what to do in the scope of the field vars
395 -> (HsRecFields Name (Located field') -> RnM (c, FreeVars))
397 -- Haddock comments for record fields are renamed to Nothing here
398 rnHsRecFieldsAndThen choice rn_thing (HsRecFields fields dd) cont =
401 -- helper to collect and report duplicate record fields
402 reportDuplicateFields doingstr fields =
404 -- each list represents a RdrName that occurred more than once
405 -- (the list contains all occurrences)
406 -- invariant: each list in dup_fields is non-empty
407 dup_fields :: [[RdrName]]
408 (_, dup_fields) = removeDups compare
409 (map (unLoc . hsRecFieldId) fields)
411 -- duplicate field reporting function
412 field_dup_err dup_group = addErr (dupFieldErr doingstr (head dup_group))
414 mapM_ field_dup_err dup_fields
416 -- helper to rename each field
417 rn_field pun_ok (HsRecField field inside pun) cont = do
418 fieldname <- lookupRecordBndr (getChoiceName choice) field
419 checkErr (not pun || pun_ok) (badPun field)
420 (res, res_fvs) <- rn_thing inside $ \ inside' ->
421 cont (HsRecField fieldname inside' pun)
422 return (res, res_fvs `addOneFV` unLoc fieldname)
424 -- Compute the extra fields to be filled in by the dot-dot notation
425 dot_dot_fields fs con mk_field cont = do
426 con_fields <- lookupConstructorFields (unLoc con)
427 let missing_fields = con_fields `minusList` fs
428 loc <- getSrcSpanM -- Rather approximate
429 -- it's important that we make the RdrName fields that we morally wrote
430 -- and then rename them in the usual manner
431 -- (rather than trying to make the result of renaming directly)
432 -- because, for patterns, renaming can bind vars in the continuation
434 (map (L loc . mk_field . mkRdrUnqual . getOccName) missing_fields) $
436 let new_fs = [ HsRecField (L loc f) r False
437 | (f, r) <- missing_fields `zip` rhss ]
442 -- report duplicate fields
443 let doingstr = choiceToMessage choice
444 reportDuplicateFields doingstr fields
446 -- rename the records as written
447 -- check whether punning (implicit x=x) is allowed
448 pun_flag <- doptM Opt_RecordPuns
450 mapFvRnCPS (rn_field pun_flag) fields $ \ fields1 ->
454 Nothing -> cont (HsRecFields fields1 dd)
455 Just n -> ASSERT( n == length fields ) do
456 dd_flag <- doptM Opt_RecordWildCards
457 checkErr dd_flag (needFlagDotDot doingstr)
458 let fld_names1 = map (unLoc . hsRecFieldId) fields1
459 case doDotDot choice of
460 Nothing -> do addErr (badDotDot doingstr)
461 -- we return a junk value here so that error reporting goes on
462 cont (HsRecFields fields1 dd)
463 Just (con, mk_field) ->
464 dot_dot_fields fld_names1 con mk_field $
466 cont (HsRecFields (fields1 ++ fields2) dd)
468 needFlagDotDot str = vcat [ptext SLIT("Illegal `..' in record") <+> text str,
469 ptext SLIT("Use -XRecordWildCards to permit this")]
471 badDotDot str = ptext SLIT("You cannot use `..' in record") <+> text str
473 badPun fld = vcat [ptext SLIT("Illegal use of punning for field") <+> quotes (ppr fld),
474 ptext SLIT("Use -XRecordPuns to permit this")]
478 rnHsRecFieldsAndThen_Pattern :: Located Name
479 -> NameMaker -- new name maker
480 -> HsRecFields RdrName (LPat RdrName)
481 -> (HsRecFields Name (LPat Name) -> RnM (c, FreeVars))
483 rnHsRecFieldsAndThen_Pattern n var
484 = rnHsRecFieldsAndThen (Pattern n VarPat) (rnLPatAndThen var)
487 -- wrapper to use rnLExpr in CPS style;
488 -- because it does not bind any vars going forward, it does not need
489 -- to be written that way
490 rnLExprAndThen :: (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
492 -> (LHsExpr Name -> RnM (c, FreeVars))
494 rnLExprAndThen f e cont = do { (x, fvs1) <- f e
495 ; (res, fvs2) <- cont x
496 ; return (res, fvs1 `plusFV` fvs2) }
499 -- non-CPSed because exprs don't leave anything bound
500 rnHsRecFields_Con :: Located Name
501 -> (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
502 -> HsRecFields RdrName (LHsExpr RdrName)
503 -> RnM (HsRecFields Name (LHsExpr Name), FreeVars)
504 rnHsRecFields_Con n rnLExpr fields = rnHsRecFieldsAndThen (Constructor n HsVar)
505 (rnLExprAndThen rnLExpr) fields $ \ res ->
506 return (res, emptyFVs)
508 rnHsRecFields_Update :: (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
509 -> HsRecFields RdrName (LHsExpr RdrName)
510 -> RnM (HsRecFields Name (LHsExpr Name), FreeVars)
511 rnHsRecFields_Update rnLExpr fields = rnHsRecFieldsAndThen Update
512 (rnLExprAndThen rnLExpr) fields $ \ res ->
513 return (res, emptyFVs)
518 %************************************************************************
520 \subsubsection{Literals}
522 %************************************************************************
524 When literals occur we have to make sure
525 that the types and classes they involve
529 rnLit :: HsLit -> RnM ()
530 rnLit (HsChar c) = checkErr (inCharRange c) (bogusCharError c)
531 rnLit other = return ()
533 rnOverLit (HsIntegral i _ _) = do
534 (from_integer_name, fvs) <- lookupSyntaxName fromIntegerName
536 return (HsIntegral i from_integer_name placeHolderType, fvs)
538 extra_fvs = mkFVs [plusIntegerName, timesIntegerName]
539 -- Big integer literals are built, using + and *,
540 -- out of small integers (DsUtils.mkIntegerLit)
541 -- [NB: plusInteger, timesInteger aren't rebindable...
542 -- they are used to construct the argument to fromInteger,
543 -- which is the rebindable one.]
545 return (HsIntegral i from_integer_name placeHolderType, fvs `plusFV` extra_fvs)
547 rnOverLit (HsFractional i _ _) = do
548 (from_rat_name, fvs) <- lookupSyntaxName fromRationalName
550 extra_fvs = mkFVs [ratioDataConName, plusIntegerName, timesIntegerName]
551 -- We have to make sure that the Ratio type is imported with
552 -- its constructor, because literals of type Ratio t are
553 -- built with that constructor.
554 -- The Rational type is needed too, but that will come in
555 -- as part of the type for fromRational.
556 -- The plus/times integer operations may be needed to construct the numerator
557 -- and denominator (see DsUtils.mkIntegerLit)
558 return (HsFractional i from_rat_name placeHolderType, fvs `plusFV` extra_fvs)
560 rnOverLit (HsIsString s _ _) = do
561 (from_string_name, fvs) <- lookupSyntaxName fromStringName
562 return (HsIsString s from_string_name placeHolderType, fvs)
565 %************************************************************************
567 \subsubsection{Quasiquotation}
569 %************************************************************************
571 See Note [Quasi-quote overview] in TcSplice.
574 rnQuasiQuote :: HsQuasiQuote RdrName -> RnM (HsQuasiQuote Name, FreeVars)
575 rnQuasiQuote (HsQuasiQuote n quoter quoteSpan quote)
576 = do { loc <- getSrcSpanM
577 ; [n'] <- newLocalsRn [L loc n]
578 ; quoter' <- (lookupOccRn quoter)
579 -- If 'quoter' is not in scope, proceed no further
580 -- Otherwise lookupOcc adds an error messsage and returns
581 -- an "unubound name", which makes the subsequent attempt to
582 -- run the quote fail
583 ; return (HsQuasiQuote n' quoter' quoteSpan quote, unitFV quoter') }
586 %************************************************************************
588 \subsubsection{Errors}
590 %************************************************************************
593 checkTupSize :: Int -> RnM ()
594 checkTupSize tup_size
595 | tup_size <= mAX_TUPLE_SIZE
598 = addErr (sep [ptext SLIT("A") <+> int tup_size <> ptext SLIT("-tuple is too large for GHC"),
599 nest 2 (parens (ptext SLIT("max size is") <+> int mAX_TUPLE_SIZE)),
600 nest 2 (ptext SLIT("Workaround: use nested tuples or define a data type"))])
603 = (ptext SLIT("Illegal signature in pattern:") <+> ppr ty)
604 $$ nest 4 (ptext SLIT("Use -XPatternSignatures to permit it"))
607 = hsep [ptext SLIT("duplicate field name"),
609 ptext SLIT("in record"), text str]
612 = ptext SLIT("character literal out of range: '\\") <> char c <> char '\''
614 badViewPat pat = vcat [ptext SLIT("Illegal view pattern: ") <+> ppr pat,
615 ptext SLIT("Use -XViewPatterns to enalbe view patterns")]