@@ -1044,17 +1044,17 @@ If we have a function that gets us from an `m a` to an `n a`, for any `a`, what
1044do we have?
1044do we have?
1046``` haskell ignore
1046``` haskell ignore
1047−newtype m :~> n = Nat { unNat :: forall a. m a -> n a}
1047+newtype m :~> n = NT { ($$) :: forall a. m a -> n a}
1050For example:
1050For example:
1052``` haskell
1052``` haskell
1053−listToMaybeNat :: [] :~> Maybe
1053+listToMaybeNT :: [] :~> Maybe
1054−listToMaybeNat = Nat listToMaybe -- from Data.Maybe
1054+listToMaybeNT = NT listToMaybe -- from Data.Maybe
1057−(`Nat` comes from "natural transformation", in case you're wondering.)
1057+(`NT` comes from "natural transformation", in case you're wondering.)
1059So if you want to write handlers using another monad/type than `Handler`, say the `Reader String` monad, the first thing you have to
1059So if you want to write handlers using another monad/type than `Handler`, say the `Reader String` monad, the first thing you have to
1060prepare is a function:
1060prepare is a function:
@@ -1066,14 +1066,14 @@ readerToHandler :: Reader String :~> Handler
1066Let's start with `readerToHandler'`. We obviously have to run the `Reader`
1066Let's start with `readerToHandler'`. We obviously have to run the `Reader`
1067computation by supplying it with a `String`, like `"hi"`. We get an `a` out
1067computation by supplying it with a `String`, like `"hi"`. We get an `a` out
1068from that and can then just `return` it into `ExceptT`. We can then just wrap
1068from that and can then just `return` it into `ExceptT`. We can then just wrap
1069−that function with the `Nat` constructor to make it have the fancier type.
1069+that function with the `NT` constructor to make it have the fancier type.
1071``` haskell
1071``` haskell
1072readerToHandler' :: forall a. Reader String a -> Handler a
1072readerToHandler' :: forall a. Reader String a -> Handler a
1073readerToHandler' r = return (runReader r "hi")
1073readerToHandler' r = return (runReader r "hi")
1075readerToHandler :: Reader String :~> Handler
1075readerToHandler :: Reader String :~> Handler
1076−readerToHandler = Nat readerToHandler'
1076+readerToHandler = NT readerToHandler'
1079We can write some simple webservice with the handlers running in `Reader String`.
1079We can write some simple webservice with the handlers running in `Reader String`.