summaryrefslogtreecommitdiff
blob: 119f2260b83ed432756b0976b5ecc2d948820655 (plain)
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
diff --git a/Base.lhs b/Base.lhs
index c26e048..46c68de 100644
--- a/Base.lhs
+++ b/Base.lhs
@@ -38,3 +38,4 @@
 > import Prettier
-> import Control.Monad                  (  MonadPlus(..)  )
+> import Control.Applicative
+> import Control.Monad
 > import System.IO
@@ -117,2 +118,9 @@ A simple exception monad.
 
+> instance Functor Result where
+>     fmap  = liftM
+
+> instance Applicative Result where
+>     pure  = return
+>     (<*>) = ap  -- defined in Control.Monad
+
 > instance Monad Result where
@@ -123,2 +131,6 @@ A simple exception monad.
 
+> instance Alternative Result where
+>     (<|>) = mplus
+>     empty = mzero
+
 > instance MonadPlus Result where
diff --git a/Compact.lhs b/Compact.lhs
index 6886a6a..84f125c 100644
--- a/Compact.lhs
+++ b/Compact.lhs
@@ -54,3 +54,3 @@
 > import Data.Maybe
-> import Prelude                hiding (  lookup  )
+> import Prelude                hiding (  lookup, (<$>)  )
 
diff --git a/Convert.lhs b/Convert.lhs
index 01d2c32..d31f437 100644
--- a/Convert.lhs
+++ b/Convert.lhs
@@ -50,2 +50,3 @@
 > import Control.Monad
+> import Control.Applicative
 > import System.IO                     hiding (  isEOF  )
@@ -235,2 +235,9 @@ Writer monad for collecting multiple error messages.
 
+> instance Functor (Writer w) where
+>     fmap  = liftM
+
+> instance Applicative (Writer w) where
+>     pure  = return
+>     (<*>) = ap  -- defined in Control.Monad
+
 > instance Monad (Writer w) where
diff --git a/GParser2.hs b/GParser2.hs
index 0cb4c21..1597acc 100644
--- a/GParser2.hs
+++ b/GParser2.hs
@@ -41,2 +41,5 @@
   where
+  import Prelude hiding ((<$>))
+  import Control.Applicative hiding ((<$>))
+  import Control.Monad hiding ( guard )
   import Lexer2
@@ -2130,3 +2133,10 @@
                                                          -> m Answer) }
- 
+
+  instance (Monad m) => Functor (Lex m) where
+      fmap  = liftM
+
+  instance (Monad m) => Applicative (Lex m) where
+      pure  = return
+      (<*>) = ap  -- defined in Control.Monad
+
   instance (Monad m) => Monad (Lex m) where
diff --git a/GParser2.lg b/GParser2.lg
index e036f8f..800e245 100644
--- a/GParser2.lg
+++ b/GParser2.lg
@@ -41,2 +41,5 @@ Compile me with
 > where
+> import Prelude hiding ((<$>))
+> import Control.Applicative hiding ((<$>))
+> import Control.Monad hiding ( guard )
 > import Lexer2
@@ -354,2 +357,10 @@ A continuation-based state monad.
 >
+
+> instance (Monad m) => Functor (Lex m) where
+>     fmap  = liftM
+
+> instance (Monad m) => Applicative (Lex m) where
+>     pure  = return
+>     (<*>) = ap  -- defined in Control.Monad
+
 > instance (Monad m) => Monad (Lex m) where
diff --git a/GVStack.lhs b/GVStack.lhs
index acb5d96..3869493 100644
--- a/GVStack.lhs
+++ b/GVStack.lhs
@@ -51,3 +51,3 @@
 > import Data.List                   (  maximumBy  )
-> import Prelude                hiding (  lookup  )
+> import Prelude                hiding (  lookup, (<$>)  )
 
diff --git a/Lib/OrdUniqListSet.lhs b/Lib/OrdUniqListSet.lhs
index ddb8629..decf65d 100644
--- a/Lib/OrdUniqListSet.lhs
+++ b/Lib/OrdUniqListSet.lhs
@@ -63,2 +63,3 @@
 > import Control.Monad
+> import Control.Applicative (Applicative, pure, (<*>))
 
@@ -114,2 +114,6 @@ Yes, \tr{Set} is a functor and a monad.
 >
+> instance Applicative Set where
+>     pure  = return
+>     (<*>) = ap  -- defined in Control.Monad
+>
 > instance Monad Set where
diff --git a/Stackless.lhs b/Stackless.lhs
index 2fb1a97..dac8ef5 100644
--- a/Stackless.lhs
+++ b/Stackless.lhs
@@ -53,3 +53,3 @@
 > import Control.Monad
-> import Prelude                hiding (  lookup  )
+> import Prelude                hiding (  lookup, (<$>)  )
 
diff --git a/Standard.lhs b/Standard.lhs
index 9fb5305..c3fcbb0 100644
--- a/Standard.lhs
+++ b/Standard.lhs
@@ -52,3 +52,3 @@
 > import Data.Maybe
-> import Prelude                hiding (  lookup  )
+> import Prelude                hiding (  lookup, (<$>)  )