... |
... |
@@ -251,8 +251,8 @@ We can compile ``D``, then load the whole program, like this: |
251
|
251
|
|
252
|
252
|
.. code-block:: none
|
253
|
253
|
|
254
|
|
- ghci> :! ghc -c -dynamic D.hs
|
255
|
|
- ghci> :load A
|
|
254
|
+ ghci> :! ghc -c -this-unit-id interactive-session -dynamic D.hs
|
|
255
|
+ ghci> :load A B C D
|
256
|
256
|
Compiling B ( B.hs, interpreted )
|
257
|
257
|
Compiling C ( C.hs, interpreted )
|
258
|
258
|
Compiling A ( A.hs, interpreted )
|
... |
... |
@@ -268,6 +268,10 @@ Note the :ghc-flag:`-dynamic` flag to GHC: GHCi uses dynamically-linked object |
268
|
268
|
code (if you are on a platform that supports it), and so in order to use
|
269
|
269
|
compiled code with GHCi it must be compiled for dynamic linking.
|
270
|
270
|
|
|
271
|
+Also, note the :ghc-flag:`-this-unit-id ⟨unit-id⟩` `interactive-session` to GHC: GHCi
|
|
272
|
+can only use the object code of a module loaded via :ghci-cmd:`:load`,
|
|
273
|
+if the object code has been compiled for the `interactive-session`.
|
|
274
|
+
|
271
|
275
|
At any time you can use the command :ghci-cmd:`:show modules` to get a list of
|
272
|
276
|
the modules currently loaded into GHCi:
|
273
|
277
|
|
... |
... |
@@ -301,8 +305,8 @@ So let's try compiling one of the other modules: |
301
|
305
|
|
302
|
306
|
.. code-block:: none
|
303
|
307
|
|
304
|
|
- *ghci> :! ghc -c C.hs
|
305
|
|
- *ghci> :load A
|
|
308
|
+ *ghci> :! ghc -c -this-unit-id interactive-session -dynamic C.hs
|
|
309
|
+ *ghci> :load A B C D
|
306
|
310
|
Compiling D ( D.hs, interpreted )
|
307
|
311
|
Compiling B ( B.hs, interpreted )
|
308
|
312
|
Compiling C ( C.hs, interpreted )
|
... |
... |
@@ -316,7 +320,7 @@ rejected ``C``\'s object file. Ok, so let's also compile ``D``: |
316
|
320
|
|
317
|
321
|
.. code-block:: none
|
318
|
322
|
|
319
|
|
- *ghci> :! ghc -c D.hs
|
|
323
|
+ *ghci> :! ghc -c -this-unit-id interactive-session -dynamic D.hs
|
320
|
324
|
*ghci> :reload
|
321
|
325
|
Ok, modules loaded: A, B, C, D.
|
322
|
326
|
|
... |
... |
@@ -325,7 +329,7 @@ picked up by :ghci-cmd:`:reload`, only :ghci-cmd:`:load`: |
325
|
329
|
|
326
|
330
|
.. code-block:: none
|
327
|
331
|
|
328
|
|
- *ghci> :load A
|
|
332
|
+ *ghci> :load A B C D
|
329
|
333
|
Compiling B ( B.hs, interpreted )
|
330
|
334
|
Compiling A ( A.hs, interpreted )
|
331
|
335
|
Ok, modules loaded: A, B, C (C.o), D (D.o).
|