19
19
-- @
20
20
21
21
module Language.C.Inline
22
- ( -- * Build process
22
+ ( -- * GHCi
23
23
-- $building
24
24
25
25
-- * Contexts
@@ -81,41 +81,18 @@ import Language.C.Inline.FunPtr
81
81
82
82
-- $building
83
83
--
84
- -- Each module that uses at least one of the TH functions in this module gets
85
- -- a C file associated to it, where the filename of said file will be the same
86
- -- as the module but with a `.c` extension. This C file must be built after the
87
- -- Haskell code and linked appropriately. If you use cabal, all you have to do
88
- -- is declare each associated C file in the @.cabal@ file.
89
- --
90
- -- For example:
84
+ -- Currently @inline-c@ does not work in interpreted mode. However, GHCi
85
+ -- can still be used using the @-fobject-code@ flag. For speed, we
86
+ -- reccomend passing @-fobject-code -O0@, for example
91
87
--
92
88
-- @
93
- -- executable foo
94
- -- main-is: Main.hs, Foo.hs, Bar.hs
95
- -- hs-source-dirs: src
96
- -- -- Here the corresponding C sources must be listed for every module
97
- -- -- that uses C code. In this example, Main.hs and Bar.hs do, but
98
- -- -- Foo.hs does not.
99
- -- c-sources: src\/Main.c, src\/Bar.c
100
- -- -- These flags will be passed to the C compiler
101
- -- cc-options: -Wall -O2
102
- -- -- Libraries to link the code with.
103
- -- extra-libraries: -lm
104
- -- ...
89
+ -- stack ghci --ghci-options='-fobject-code -O0'
105
90
-- @
106
91
--
107
- -- Note that currently @cabal repl@ is not supported, because the C code is not
108
- -- compiled and linked appropriately.
109
- --
110
- -- If we were to compile the above manually, we could:
92
+ -- or
111
93
--
112
94
-- @
113
- -- $ ghc -c Main.hs
114
- -- $ cc -c Main.c -o Main_c.o
115
- -- $ ghc Foo.hs
116
- -- $ ghc Bar.hs
117
- -- $ cc -c Bar.c -o Bar_c.o
118
- -- $ ghc Main.o Foo.o Bar.o Main_c.o Bar_c.o -lm -o Main
95
+ -- cabal repl --ghc-options='-fobject-code -O0'
119
96
-- @
120
97
121
98
------------------------------------------------------------------------
@@ -237,7 +214,7 @@ import Language.C.Inline.FunPtr
237
214
-- corresponding to the current Haskell file. Every inline C expression will result
238
215
-- in a corresponding C function.
239
216
-- For example, if we define @c_cos@
240
- -- as in the example above in @CCos.hs@, we will get a file @CCos.c@ containing
217
+ -- as in the example above in @CCos.hs@, we will get a file containing
241
218
--
242
219
-- @
243
220
-- #include <math.h>
@@ -250,12 +227,7 @@ import Language.C.Inline.FunPtr
250
227
-- Every anti-quotation will correspond to an argument in the C function. If the same
251
228
-- Haskell variable is anti-quoted twice, this will result in two arguments.
252
229
--
253
- -- The C function is then invoked from Haskell with the correct arguments passed in.
254
- --
255
- -- == Known issues
256
- --
257
- -- * https://github.com/fpco/inline-c/issues/21
258
- -- * https://github.com/fpco/inline-c/issues/11
230
+ -- The C function is then automatically compiled and invoked from Haskell with the correct arguments passed in.
259
231
260
232
-- | C expressions.
261
233
exp :: TH. QuasiQuoter
0 commit comments