This file is indexed.

/usr/share/doc/hugs/users_guide/implicit-parameters.html is in hugs 98.200609.21-5.4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Implicit parameters</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="The Hugs 98 User's Guide"
HREF="index.html"><LINK
REL="UP"
TITLE="Language extensions supported by Hugs and GHC"
HREF="hugs-ghc.html"><LINK
REL="PREVIOUS"
TITLE="Type annotations in patterns"
HREF="type-annotations.html"><LINK
REL="NEXT"
TITLE="Hugs-specific language extensions"
HREF="hugs-only.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="hugs-ug.css"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Hugs 98 User's Guide</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="type-annotations.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 6. Language extensions supported by Hugs and GHC</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="hugs-only.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="IMPLICIT-PARAMETERS"
>6.5. Implicit parameters</A
></H1
><P
> Implicit parameters are implemented as described in
<I
CLASS="CITETITLE"
>Implicit parameters: dynamic scoping with static types</I
>,
J Lewis, MB Shields, E Meijer, J Launchbury,
<I
CLASS="CITETITLE"
>27th ACM Symposium on Principles of Programming Languages (POPL'00)</I
>,
Boston, Jan 2000.
Note however that the binding syntax in that paper,
using keywords <TT
CLASS="LITERAL"
>dlet</TT
> and <TT
CLASS="LITERAL"
>with</TT
>,
has been replaced by the form presented below.</P
><P
>(Most of the following, still rather incomplete,
documentation is due to Jeff Lewis.)</P
><P
>A variable is called <I
CLASS="FIRSTTERM"
>dynamically bound</I
> when it is
bound by the calling context of a function and
<I
CLASS="FIRSTTERM"
>statically bound</I
> when bound by the callee's context.
In Haskell, all variables are statically bound.
Dynamic binding of variables is a notion that goes back to Lisp,
but was later discarded in more modern incarnations, such as Scheme,
as dynamic binding can be very confusing in an untyped language.
Unfortunately typed languages,
in particular Hindley-Milner typed languages like Haskell,
only support static scoping of variables.</P
><P
>However, by a simple extension to the type class system of Haskell,
we can support dynamic binding.
Basically, we express the use of a dynamically bound variable
as a constraint on the type.
These constraints lead to types of the form <TT
CLASS="LITERAL"
>(?x::t') =&#62; t</TT
>,
which says
<SPAN
CLASS="QUOTE"
>"this function uses a dynamically-bound variable <TT
CLASS="LITERAL"
>?x</TT
>
of type <TT
CLASS="LITERAL"
>t'</TT
>"</SPAN
>.
For example,
the following expresses the type of a <CODE
CLASS="FUNCTION"
>sort</CODE
> function,
implicitly parameterized by a comparison function named <TT
CLASS="LITERAL"
>cmp</TT
>.
<PRE
CLASS="PROGRAMLISTING"
>sort :: (?cmp :: a -&#62; a -&#62; Bool) =&#62; [a] -&#62; [a]</PRE
>
The dynamic binding constraints are just a new form of predicate
in the type class system.</P
><P
>An implicit parameter occurs in an expression using the special form
<TT
CLASS="LITERAL"
>?x</TT
>,
where <TT
CLASS="LITERAL"
>x</TT
> is any valid identifier
(e.g. <TT
CLASS="LITERAL"
>ord ?x</TT
> is a valid expression).
Use of this construct also introduces a new
dynamic-binding constraint in the type of the expression.
For example, the following definition
shows how we can define an implicitly parameterized sort function in
terms of an explicitly parameterized <CODE
CLASS="FUNCTION"
>sortBy</CODE
> function:
<PRE
CLASS="PROGRAMLISTING"
>sortBy :: (a -&#62; a -&#62; Bool) -&#62; [a] -&#62; [a]

sort   :: (?cmp :: a -&#62; a -&#62; Bool) =&#62; [a] -&#62; [a]
sort    = sortBy ?cmp</PRE
></P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1588"
>6.5.1. Implicit-parameter type constraints</A
></H2
><P
>Dynamic binding constraints behave just like other type class
constraints in that they are automatically propagated.
Thus, when a function is used,
its implicit parameters are inherited by the function that called it.
For example, our <CODE
CLASS="FUNCTION"
>sort</CODE
> function might be used
to pick out the least value in a list:
<PRE
CLASS="PROGRAMLISTING"
>least   :: (?cmp :: a -&#62; a -&#62; Bool) =&#62; [a] -&#62; a
least xs = fst (sort xs)</PRE
>
Without lifting a finger, the <TT
CLASS="LITERAL"
>?cmp</TT
> parameter is
propagated to become a parameter of <CODE
CLASS="FUNCTION"
>least</CODE
> as well.
With explicit parameters,
the default is that parameters must always be explicitly propagated.
With implicit parameters, the default is to always propagate them.</P
><P
>An implicit-parameter type constraint differs from other type class
constraints in the following way:
all uses of a particular implicit parameter must have the same type.
This means that the type of <TT
CLASS="LITERAL"
>(?x, ?x)</TT
>
is <TT
CLASS="LITERAL"
>(?x::a) =&#62; (a,a)</TT
>, and not
<TT
CLASS="LITERAL"
>(?x::a, ?x::b) =&#62; (a, b)</TT
>, as would be the case for type
class constraints.</P
><P
>You can't have an implicit parameter in the context of a class or instance
declaration.  For example, both these declarations are illegal:
<PRE
CLASS="PROGRAMLISTING"
>class (?x::Int) =&#62; C a where ...
instance (?x::a) =&#62; Foo [a] where ...</PRE
>
Reason: exactly which implicit parameter you pick up depends on exactly where
you invoke a function.
But the <SPAN
CLASS="QUOTE"
>"invocation"</SPAN
> of instance declarations is done behind
the scenes by the compiler,
so it's hard to figure out exactly where it is done.
The easiest thing is to outlaw the offending types.</P
><P
>Implicit-parameter constraints do not cause ambiguity.
For example, consider:
<PRE
CLASS="PROGRAMLISTING"
>f :: (?x :: [a]) =&#62; Int -&#62; Int
f n = n + length ?x

g :: (Read a, Show a) =&#62; String -&#62; String
g s = show (read s)</PRE
>
Here, <TT
CLASS="LITERAL"
>g</TT
> has an ambiguous type, and is rejected,
but <TT
CLASS="LITERAL"
>f</TT
> is fine.
The binding for <TT
CLASS="LITERAL"
>?x</TT
> at <TT
CLASS="LITERAL"
>f</TT
>'s call site is
quite unambiguous, and fixes the type <TT
CLASS="LITERAL"
>a</TT
>.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1609"
>6.5.2. Implicit-parameter bindings</A
></H2
><P
>An implicit parameter is <I
CLASS="FIRSTTERM"
>bound</I
> using the standard
<TT
CLASS="LITERAL"
>let</TT
> or <TT
CLASS="LITERAL"
>where</TT
> binding forms.
For example, we define the <CODE
CLASS="FUNCTION"
>min</CODE
> function by binding
<TT
CLASS="LITERAL"
>cmp</TT
>:
<PRE
CLASS="PROGRAMLISTING"
>min :: [a] -&#62; a
min  = let ?cmp = (&#60;=) in least</PRE
></P
><P
>A group of implicit-parameter bindings may occur anywhere a normal group
of Haskell bindings can occur, except at top level.
That is, they can occur in a <TT
CLASS="LITERAL"
>let</TT
>
(including in a list comprehension or do-notation),
or a <TT
CLASS="LITERAL"
>where</TT
> clause.
Note the following points:
<P
></P
><UL
><LI
><P
>An implicit-parameter binding group must be a
collection of simple bindings to implicit-style variables
(no function-style bindings, and no type signatures);
these bindings are neither polymorphic or recursive.</P
></LI
><LI
><P
>You may not mix implicit-parameter bindings with ordinary bindings in a
single <TT
CLASS="LITERAL"
>let</TT
> expression;
use two nested <TT
CLASS="LITERAL"
>let</TT
>s instead.
(In the case of <TT
CLASS="LITERAL"
>where</TT
> you are stuck,
since you can't nest <TT
CLASS="LITERAL"
>where</TT
> clauses.)</P
></LI
><LI
><P
>You may put multiple implicit-parameter bindings in a single binding group;
but they are <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>not</I
></SPAN
> treated as a mutually recursive group
(as ordinary <TT
CLASS="LITERAL"
>let</TT
> bindings are).
Instead they are treated as a non-recursive group,
simultaneously binding all the implicit parameters.
The bindings are not nested, and may be re-ordered without changing
the meaning of the program.
For example, consider:
<PRE
CLASS="PROGRAMLISTING"
>f t = let { ?x = t; ?y = ?x+(1::Int) } in ?x + ?y</PRE
>
The use of <TT
CLASS="LITERAL"
>?x</TT
> in the binding for <TT
CLASS="LITERAL"
>?y</TT
>
does not <SPAN
CLASS="QUOTE"
>"see"</SPAN
> the binding for <TT
CLASS="LITERAL"
>?x</TT
>,
so the type of <TT
CLASS="LITERAL"
>f</TT
> is
<PRE
CLASS="SCREEN"
>f :: (?x::Int) =&#62; Int -&#62; Int</PRE
></P
></LI
></UL
></P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="type-annotations.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="hugs-only.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Type annotations in patterns</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="hugs-ghc.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Hugs-specific language extensions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>