Skip to content

Commit 29f94a6

Browse files
authored
Briefly correct ExceptT mentions into Handler (#693)
1 parent 2fd9757 commit 29f94a6

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

doc/tutorial/Server.lhs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ $ curl -H 'Accept: text/html' http://localhost:8081/persons
603603
604604
## The `Handler` monad
605605
606-
At the heart of the handlers is the monad they run in, namely `ExceptT ServantErr IO`
607-
([haddock documentation for `ExceptT`](http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)), which is aliased as `Handler`.
606+
At the heart of the handlers is the monad they run in, namely a newtype `Handler` around `ExceptT ServantErr IO`
607+
([haddock documentation for `ExceptT`](http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)).
608608
One might wonder: why this monad? The answer is that it is the
609609
simplest monad with the following properties:
610610
@@ -626,7 +626,7 @@ action that either returns an error or a result.
626626
627627
The module [`Control.Monad.Except`](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html#t:ExceptT)
628628
from which `ExceptT` comes is worth looking at.
629-
Perhaps most importantly, `ExceptT` is an instance of `MonadError`, so
629+
Perhaps most importantly, `ExceptT` and `Handler` are an instances of `MonadError`, so
630630
`throwError` can be used to return an error from your handler (whereas `return`
631631
is enough to return a success).
632632
@@ -636,8 +636,8 @@ kind and abort early. The next two sections cover how to do just that.
636636
637637
### Performing IO
638638
639-
Another important instance from the list above is `MonadIO m => MonadIO
640-
(ExceptT e m)`.
639+
Another important instances from the list above are `MonadIO m => MonadIO
640+
(ExceptT e m)`, and therefore also `MonadIO Handler` as there is `MonadIO IO` instance..
641641
[`MonadIO`](http://hackage.haskell.org/package/transformers-0.4.3.0/docs/Control-Monad-IO-Class.html)
642642
is a class from the **transformers** package defined as:
643643
@@ -646,8 +646,7 @@ class Monad m => MonadIO m where
646646
liftIO :: IO a -> m a
647647
```
648648
649-
The `IO` monad provides a `MonadIO` instance. Hence for any type
650-
`e`, `ExceptT e IO` has a `MonadIO` instance. So if you want to run any kind of
649+
So if you want to run any kind of
651650
IO computation in your handlers, just use `liftIO`:
652651
653652
``` haskell
@@ -861,7 +860,7 @@ Server UserAPI4 = Int -> ( Handler User
861860
862861
In the first case, each handler receives the *userid* argument. In the latter,
863862
the whole `Server` takes the *userid* and has handlers that are just
864-
computations in `ExceptT`, with no arguments. In other words:
863+
computations in `Handler`, with no arguments. In other words:
865864
866865
``` haskell
867866
server8 :: Server UserAPI3
@@ -1069,7 +1068,7 @@ readerToHandler :: Reader String :~> Handler
10691068
10701069
Let's start with `readerToHandler'`. We obviously have to run the `Reader`
10711070
computation by supplying it with a `String`, like `"hi"`. We get an `a` out
1072-
from that and can then just `return` it into `ExceptT`. We can then just wrap
1071+
from that and can then just `return` it into `Handler`. We can then just wrap
10731072
that function with the `NT` constructor to make it have the fancier type.
10741073
10751074
``` haskell

0 commit comments

Comments
 (0)