Skip to content

Commit 175c151

Browse files
committed
fix ghci code block formatting
1 parent 291e498 commit 175c151

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

content/monad-transformers.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,17 @@ If we look at the type of `lift` when specialized to various transformers, we ca
120120

121121
In this example, we can use `lift` to go from `IO` into our transformer. But with a deeper stack, we run into problems:
122122

123-
```> type MyDeeperStack = ReaderT Int (WriterT String IO) Bool
123+
```
124+
> type MyDeeperStack = ReaderT Int (WriterT String IO) Bool
124125
> :t \x -> (lift x :: MyDeeperStack)
125126
\x -> (lift x :: MyDeeperStack)
126127
:: WriterT String IO Bool -> MyDeeperStack
127128
```
128129

129130
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.
130131

131-
```> :t \x -> ((lift . lift) x :: MyDeeperStack)
132+
```
133+
> :t \x -> ((lift . lift) x :: MyDeeperStack)
132134
\x -> ((lift . lift) x :: MyDeeperStack)
133135
:: IO Bool -> MyDeeperStack
134136
```
@@ -143,14 +145,16 @@ type MyDeeperStack = ReaderT Int (WriterT String (MaybeT IO)) Bool
143145

144146
`lift . lift` will no longer allow us to lift an `IO` action into our stack because we now have a third layer.
145147

146-
```> :t \x -> ((lift . lift) x :: MyDeeperStack)
148+
```
149+
> :t \x -> ((lift . lift) x :: MyDeeperStack)
147150
\x -> ((lift . lift) x :: MyDeeperStack)
148151
:: MaybeT IO Bool -> MyDeeperStack
149152
```
150153
151154
With `liftIO`, as is well:
152155
153-
```> :t \x -> (liftIO x :: MyDeeperStack)
156+
```
157+
> :t \x -> (liftIO x :: MyDeeperStack)
154158
\x -> (liftIO x :: MyDeeperStack) :: IO Bool -> MyDeeperStack
155159
```
156160
@@ -160,13 +164,15 @@ Want to add another layer? No problem:
160164
type MyDeeperStack = ReaderT Int (WriterT String (MaybeT (ExceptT String IO))) Bool
161165
```
162166

163-
```> :t \x -> (liftIO x :: MyDeeperStack)
167+
```
168+
> :t \x -> (liftIO x :: MyDeeperStack)
164169
\x -> (liftIO x :: MyDeeperStack) :: IO Bool -> MyDeeperStack
165170
```
166171

167172
Without `liftIO` we'd need to keep adjusting the number of lifts:
168173

169-
```> :t \x -> ((lift . lift . lift . lift) x :: MyDeeperStack)
174+
```
175+
> :t \x -> ((lift . lift . lift . lift) x :: MyDeeperStack)
170176
\x -> ((lift . lift . lift . lift) x :: MyDeeperStack)
171177
:: IO Bool -> MyDeeperStack
172178
```

0 commit comments

Comments
 (0)