@@ -152,11 +152,7 @@ Here is an example, using the maybe monad::
153 data Maybe a = Nothing | Just a
153 data Maybe a = Nothing | Just a
155− instance Monad Maybe where
155+ isEven :: Number -> Maybe {}
157− (>>=) Nothing _ = Nothing
158− (>>=) (Just a) f = f a
160 isEven n | n % 2 == 0 = Just {}
156 isEven n | n % 2 == 0 = Just {}
161 isEven _ = Nothing
157 isEven _ = Nothing
@@ -165,17 +161,17 @@ Here is an example, using the maybe monad::
166 let sum = n + m
162 let sum = n + m
167 isEven sum
163 isEven sum
168− ret sum
164+ return sum
170``isEven`` adds two values of type ``Maybe Number`` and returns their sum, if the sum is even. If the sum is odd, ``evenSum`` returns ``Nothing``.
166``isEven`` adds two values of type ``Maybe Number`` and returns their sum, if the sum is even. If the sum is odd, ``evenSum`` returns ``Nothing``.
172−When using ``do`` notation, the corresponding type constructor must be an instance of the ``Prelude.Monad`` type class, which defines the ``ret`` and ``>>=`` functions.
168+When using ``do`` notation, the corresponding type constructor must be an instance of the ``Prelude.Monad`` type class.
174Statements can have the following form:
170Statements can have the following form:
176−- ``a <- x`` which desugars to ``m.bind x (\a -> ...)` `
172+- ``a <- x`` which desugars to ``x >>= \a -> ...` `
177−- ``let a = x`` which desugars to ``(\a -> ...)(x)``
178−- ``x`` which desugars to ``m.bind x (\_ -> ...)`` or just ``x`` if this is the last statement.
173+- ``x`` which desugars to ``x >>= \_ -> ...`` or just ``x`` if this is the last statement.
174+- A let binding ``let a = x`` where ``a`` can be either a name or a binder. Note the lack of the ``in`` keyword.
180Binders can be used on the left hand side of ``<-`` or ``=``. For example::
176Binders can be used on the left hand side of ``<-`` or ``=``. For example::