@@ -68,39 +68,6 @@ instance Show a => Show (Maybe a) where
68 show Nothing = "Nothing"
68 show Nothing = "Nothing"
69 show (Just x) = "Just " ++ show x
69 show (Just x) = "Just " ++ show x
73−instance Monad IO where
74− return t = io_return t
75− b >>= k = io_bind b k
77−instance Monad Maybe where
80− Nothing >>= k = Nothing
83−instance MonadPlus Maybe where
86− mplus (Just x) _ = Just x
87− mplus Nothing (Just y) = Just y
88− mplus Nothing Nothing = Nothing
90−instance Monad (Either e) where
93− (Left n) >>= _ = Left n
94− (Right r) >>= f = f r
96−instance Monad List where
98− m >>= f = concatMap f m
100−instance MonadPlus List where
104---- Functor instances
71---- Functor instances
106instance Functor Maybe where
73instance Functor Maybe where
@@ -134,6 +101,39 @@ instance Applicative List where
135 fs <$> vs = concatMap (\f => map f vs) fs
102 fs <$> vs = concatMap (\f => map f vs) fs
106+instance Monad IO where
107+ return t = io_return t
108+ b >>= k = io_bind b k
110+instance Monad Maybe where
113+ Nothing >>= k = Nothing
114+ (Just x) >>= k = k x
116+instance MonadPlus Maybe where
119+ mplus (Just x) _ = Just x
120+ mplus Nothing (Just y) = Just y
121+ mplus Nothing Nothing = Nothing
123+instance Monad (Either e) where
126+ (Left n) >>= _ = Left n
127+ (Right r) >>= f = f r
129+instance Monad List where
131+ m >>= f = concatMap f m
133+instance MonadPlus List where
137---- some mathematical operations
137---- some mathematical operations
139%include "math.h"
139%include "math.h"