Ticket #1410: Control-Monad-Reader-Class.html

File Control-Monad-Reader-Class.html, 10.6 KB (added by guest, 7 years ago)

Control.Monad.Reader.Class haddock output.

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<!--Rendered using the Haskell Html Library v0.2-->
3<HTML
4><HEAD
5><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
6><TITLE
7>Control.Monad.Reader.Class</TITLE
8>
9
10<style type="text/css">
11/* -------- Global things --------- */
12
13BODY { 
14  background-color: #ffffff;
15  color: #000000;
16  font-family: sans-serif;
17  } 
18
19A:link    { color: #0000e0; text-decoration: none }
20A:visited { color: #0000a0; text-decoration: none }
21A:hover   { background-color: #e0e0ff; text-decoration: none }
22
23TABLE.vanilla {
24  width: 100%;
25  border-width: 0px;
26  /* I can't seem to specify cellspacing or cellpadding properly using CSS... */
27}
28
29TABLE.vanilla2 {
30  border-width: 0px;
31}
32
33/* <TT> font is a little too small in MSIE */
34TT  { font-size: 100%; }
35PRE { font-size: 100%; }
36
37LI P { margin: 0pt } 
38
39TD {
40  border-width: 0px;
41}
42
43TABLE.narrow {
44  border-width: 0px;
45}
46
47TD.s8  {  height: 8px;  }
48TD.s15 {  height: 15px; }
49
50SPAN.keyword { text-decoration: underline; }
51
52/* Resize the buttom image to match the text size */
53IMG.coll { width : 0.75em; height: 0.75em; margin-bottom: 0; margin-right: 0.5em }
54
55/* --------- Contents page ---------- */
56
57DIV.node {
58  padding-left: 3em;
59}
60
61DIV.cnode {
62  padding-left: 1.75em;
63}
64
65SPAN.pkg {
66  position: absolute;
67  left: 50em;
68}
69
70/* --------- Documentation elements ---------- */
71
72TD.children {
73  padding-left: 25px;
74  }
75
76TD.synopsis {
77  padding: 2px;
78  background-color: #f0f0f0;
79  font-family: monospace
80 }
81
82TD.decl { 
83  padding: 2px;
84  background-color: #f0f0f0; 
85  font-family: monospace;
86  vertical-align: top;
87  }
88
89/*
90  arg is just like decl, except that wrapping is not allowed.  It is
91  used for function and constructor arguments which have a text box
92  to the right, where if wrapping is allowed the text box squashes up
93  the declaration by wrapping it.
94*/
95TD.arg { 
96  padding: 2px;
97  background-color: #f0f0f0; 
98  font-family: monospace;
99  vertical-align: top;
100  white-space: nowrap;
101  }
102
103TD.recfield { padding-left: 20px }
104
105TD.doc  { 
106  padding-top: 2px;
107  padding-left: 10px;
108  }
109
110TD.ndoc  { 
111  padding: 2px;
112  }
113
114TD.rdoc  { 
115  padding: 2px;
116  padding-left: 10px;
117  width: 100%;
118  }
119
120TD.body  { 
121  padding-left: 10px
122  }
123
124TD.pkg {
125  width: 100%;
126  padding-left: 10px
127}
128
129TD.indexentry {
130  vertical-align: top;
131  padding-right: 10px
132  }
133
134TD.indexannot {
135  vertical-align: top;
136  padding-left: 20px;
137  white-space: nowrap
138  }
139
140TD.indexlinks {
141  width: 100%
142  }
143
144/* ------- Section Headings ------- */
145
146TD.section1 {
147  padding-top: 15px;
148  font-weight: bold;
149  font-size: 150%
150  }
151
152TD.section2 {
153  padding-top: 10px;
154  font-weight: bold;
155  font-size: 130%
156  }
157
158TD.section3 {
159  padding-top: 5px;
160  font-weight: bold;
161  font-size: 110%
162  }
163
164TD.section4 {
165  font-weight: bold;
166  font-size: 100%
167  }
168
169/* -------------- The title bar at the top of the page */
170
171TD.infohead {
172  color: #ffffff;
173  font-weight: bold;
174  padding-right: 10px;
175  text-align: left;
176}
177
178TD.infoval {
179  color: #ffffff;
180  padding-right: 10px;
181  text-align: left;
182}
183
184TD.topbar {
185  background-color: #000099;
186  padding: 5px;
187}
188
189TD.title {
190  color: #ffffff;
191  padding-left: 10px;
192  width: 100%
193  }
194
195TD.topbut {
196  padding-left: 5px;
197  padding-right: 5px;
198  border-left-width: 1px;
199  border-left-color: #ffffff;
200  border-left-style: solid;
201  white-space: nowrap;
202  }
203
204TD.topbut A:link {
205  color: #ffffff
206  }
207
208TD.topbut A:visited {
209  color: #ffff00
210  }
211
212TD.topbut A:hover {
213  background-color: #6060ff;
214  }
215
216TD.topbut:hover {
217  background-color: #6060ff
218  }
219
220TD.modulebar { 
221  background-color: #0077dd;
222  padding: 5px;
223  border-top-width: 1px;
224  border-top-color: #ffffff;
225  border-top-style: solid;
226  }
227
228/* --------- The page footer --------- */
229
230TD.botbar {
231  background-color: #000099;
232  color: #ffffff;
233  padding: 5px
234  }
235TD.botbar A:link {
236  color: #ffffff;
237  text-decoration: underline
238  }
239TD.botbar A:visited {
240  color: #ffff00
241  }
242TD.botbar A:hover {
243  background-color: #6060ff
244  }
245
246</style>
247
248
249<SCRIPT SRC="haddock.js" TYPE="text/javascript"
250></SCRIPT
251></HEAD
252><BODY
253><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
254><TR
255><TD CLASS="topbar"
256><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
257><TR
258><TD
259><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
260></TD
261><TD CLASS="title"
262></TD
263><TD CLASS="topbut"
264><A HREF="index.html"
265>Contents</A
266></TD
267><TD CLASS="topbut"
268><A HREF="doc-index.html"
269>Index</A
270></TD
271></TR
272></TABLE
273></TD
274></TR
275><TR
276><TD CLASS="modulebar"
277><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
278><TR
279><TD
280><FONT SIZE="6"
281>Control.Monad.Reader.Class</FONT
282></TD
283><TD ALIGN="right"
284><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
285><TR
286><TD CLASS="infohead"
287>Portability</TD
288><TD CLASS="infoval"
289>non-portable (multi-param classes, functional dependencies)</TD
290></TR
291><TR
292><TD CLASS="infohead"
293>Stability</TD
294><TD CLASS="infoval"
295>experimental</TD
296></TR
297><TR
298><TD CLASS="infohead"
299>Maintainer</TD
300><TD CLASS="infoval"
301>libraries@haskell.org</TD
302></TR
303></TABLE
304></TD
305></TR
306></TABLE
307></TD
308></TR
309><TR
310><TD CLASS="s15"
311></TD
312></TR
313><TR
314><TD
315><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
316></TABLE
317></TD
318></TR
319><TR
320><TD CLASS="s15"
321></TD
322></TR
323><TR
324><TD CLASS="section1"
325>Description</TD
326></TR
327><TR
328><TD CLASS="doc"
329><DL
330><DT
331>Computation type:</DT
332><DD
333> Computations which read values from a shared environment.
334</DD
335><DT
336>Binding strategy:</DT
337><DD
338> Monad values are functions from the environment to a value.
339The bound function is applied to the bound value, and both have access
340to the shared environment.
341</DD
342><DT
343>Useful for:</DT
344><DD
345> Maintaining variable bindings, or other shared environment.
346</DD
347><DT
348>Zero and plus:</DT
349><DD
350> None.
351</DD
352><DT
353>Example type:</DT
354><DD
355> <TT
356>Reader [(String,Value)] a</TT
357>
358</DD
359></DL
360><P
361>The Reader monad (also called the Environment monad).
362Represents a computation, which can read values from
363a shared environment, pass values from function to function,
364and execute sub-computations in a modified environment.
365Using Reader monad for such computations is often clearer and easier
366than using the <TT
367><A HREF="Control-Monad-State.html#t%3AState"
368>State</A
369></TT
370> monad.
371</P
372><P
373>Inspired by the paper
374  <EM
375>Functional Programming with Overloading and
376      Higher-Order Polymorphism</EM
377>,
378    Mark P Jones (<A HREF="http://www.cse.ogi.edu/~mpj/"
379>http://www.cse.ogi.edu/~mpj/</A
380>)
381    Advanced School of Functional Programming, 1995.
382</P
383></TD
384></TR
385><TR
386><TD CLASS="s15"
387></TD
388></TR
389><TR
390><TD CLASS="section1"
391>Synopsis</TD
392></TR
393><TR
394><TD CLASS="s15"
395></TD
396></TR
397><TR
398><TD CLASS="body"
399><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
400><TR
401><TD CLASS="decl"
402><SPAN CLASS="keyword"
403>class</SPAN
404> Monad m =&gt; <A HREF="#t%3AMonadReader"
405>MonadReader</A
406> r m | m -&gt; r <SPAN CLASS="keyword"
407>where</SPAN
408></TD
409></TR
410><TR
411><TD CLASS="body"
412><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
413><TR
414><TD CLASS="decl"
415><A HREF="#v%3Aask"
416>ask</A
417> :: m r</TD
418></TR
419><TR
420><TD CLASS="decl"
421><A HREF="#v%3Alocal"
422>local</A
423> :: (r -&gt; r) -&gt; m a -&gt; m a</TD
424></TR
425></TABLE
426></TD
427></TR
428><TR
429><TD CLASS="s8"
430></TD
431></TR
432><TR
433><TD CLASS="decl"
434><A HREF="#v%3Aasks"
435>asks</A
436> :: <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
437>MonadReader</A
438> r m =&gt; (r -&gt; a) -&gt; m a</TD
439></TR
440></TABLE
441></TD
442></TR
443><TR
444><TD CLASS="s15"
445></TD
446></TR
447><TR
448><TD CLASS="section1"
449>Documentation</TD
450></TR
451><TR
452><TD CLASS="s15"
453></TD
454></TR
455><TR
456><TD CLASS="decl"
457><SPAN CLASS="keyword"
458>class</SPAN
459> Monad m =&gt; <A NAME="t%3AMonadReader"
460></A
461><B
462>MonadReader</B
463> r m | m -&gt; r <SPAN CLASS="keyword"
464>where</SPAN
465></TD
466></TR
467><TR
468><TD CLASS="body"
469><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
470><TR
471><TD CLASS="ndoc"
472>Note, the partially applied function type <TT
473>(-&gt;) r</TT
474> is a simple reader monad.
475See the <TT
476>instance</TT
477> declaration below.
478See examples in <A HREF="Control-Monad-Reader.html"
479>Control.Monad.Reader</A
480>.
481</TD
482></TR
483><TR
484><TD CLASS="s8"
485></TD
486></TR
487><TR
488><TD CLASS="section4"
489>Methods</TD
490></TR
491><TR
492><TD CLASS="body"
493><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
494><TR
495><TD CLASS="decl"
496><A NAME="v%3Aask"
497></A
498><B
499>ask</B
500> :: m r</TD
501></TR
502><TR
503><TD CLASS="doc"
504>Retrieves the monad environment.
505</TD
506></TR
507><TR
508><TD CLASS="s8"
509></TD
510></TR
511><TR
512><TD CLASS="decl"
513><A NAME="v%3Alocal"
514></A
515><B
516>local</B
517> :: (r -&gt; r) -&gt; m a -&gt; m a</TD
518></TR
519><TR
520><TD CLASS="doc"
521><P
522>Executes a computation in a modified environment. Parameters:
523</P
524><UL
525><LI
526> The function to modify the environment.
527</LI
528><LI
529> <TT
530>Reader</TT
531> to run.
532</LI
533><LI
534> The resulting <TT
535>Reader</TT
536>.
537</LI
538></UL
539></TD
540></TR
541></TABLE
542></TD
543></TR
544><TR
545><TD CLASS="s8"
546></TD
547></TR
548><TR
549><TD CLASS="section4"
550><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:MonadReader')" ALT="show/hide"
551> Instances</TD
552></TR
553><TR
554><TD CLASS="body"
555><DIV ID="i:MonadReader" STYLE="display:block;"
556><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
557><TR
558><TD CLASS="decl"
559><A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
560>MonadReader</A
561> r (<A HREF="Control-Monad-Reader.html#t%3AReader"
562>Reader</A
563> r)</TD
564></TR
565><TR
566><TD CLASS="decl"
567><A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
568>MonadReader</A
569> r ((-&gt;) r)</TD
570></TR
571><TR
572><TD CLASS="decl"
573>(<A HREF="Control-Monad-Error-Class.html#t%3AError"
574>Error</A
575> e, <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
576>MonadReader</A
577> r m) =&gt; <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
578>MonadReader</A
579> r (<A HREF="Control-Monad-Error.html#t%3AErrorT"
580>ErrorT</A
581> e m)</TD
582></TR
583><TR
584><TD CLASS="decl"
585>Monad m =&gt; <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
586>MonadReader</A
587> r (<A HREF="Control-Monad-Reader.html#t%3AReaderT"
588>ReaderT</A
589> r m)</TD
590></TR
591><TR
592><TD CLASS="decl"
593><A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
594>MonadReader</A
595> r' m =&gt; <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
596>MonadReader</A
597> r' (<A HREF="Control-Monad-Cont.html#t%3AContT"
598>ContT</A
599> r m)</TD
600></TR
601></TABLE
602></DIV
603></TD
604></TR
605></TABLE
606></TD
607></TR
608><TR
609><TD CLASS="s15"
610></TD
611></TR
612><TR
613><TD CLASS="decl"
614><A NAME="v%3Aasks"
615></A
616><B
617>asks</B
618> :: <A HREF="Control-Monad-Reader-Class.html#t%3AMonadReader"
619>MonadReader</A
620> r m =&gt; (r -&gt; a) -&gt; m a</TD
621></TR
622><TR
623><TD CLASS="doc"
624><P
625>Retrieves a function of the current environment. Parameters:
626</P
627><UL
628><LI
629> The selector function to apply to the environment.
630</LI
631></UL
632><P
633>See an example in <A HREF="Control-Monad-Reader.html"
634>Control.Monad.Reader</A
635>.
636</P
637></TD
638></TR
639><TR
640><TD CLASS="s15"
641></TD
642></TR
643><TR
644><TD CLASS="botbar"
645>Produced by <A HREF="http://www.haskell.org/haddock/"
646>Haddock</A
647> version 0.7</TD
648></TR
649></TABLE
650></BODY
651></HTML
652>