You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/monad-transformers.md
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -120,15 +120,17 @@ If we look at the type of `lift` when specialized to various transformers, we ca
120
120
121
121
In this example, we can use `lift` to go from `IO` into our transformer. But with a deeper stack, we run into problems:
122
122
123
-
```> type MyDeeperStack = ReaderT Int (WriterT String IO) Bool
123
+
```
124
+
> type MyDeeperStack = ReaderT Int (WriterT String IO) Bool
124
125
> :t \x -> (lift x :: MyDeeperStack)
125
126
\x -> (lift x :: MyDeeperStack)
126
127
:: WriterT String IO Bool -> MyDeeperStack
127
128
```
128
129
129
130
In other words, the `m` from `lift :: m a -> t m a` in our `MyDeeperStack` is `WriterT String IO`. So we would to need `lift`*again* in order to go from `IO Bool -> MyDeeperStack`, i.e.
130
131
131
-
```> :t \x -> ((lift . lift) x :: MyDeeperStack)
132
+
```
133
+
> :t \x -> ((lift . lift) x :: MyDeeperStack)
132
134
\x -> ((lift . lift) x :: MyDeeperStack)
133
135
:: IO Bool -> MyDeeperStack
134
136
```
@@ -143,14 +145,16 @@ type MyDeeperStack = ReaderT Int (WriterT String (MaybeT IO)) Bool
143
145
144
146
`lift . lift` will no longer allow us to lift an `IO` action into our stack because we now have a third layer.
0 commit comments