1cyc(1)                    BSD General Commands Manual                   cyc(1)
2

NAME

4     cyc, cyc-0.9.11 — A native code compiler for Curry.
5

SYNOPSIS

7     cyc [option ...] file ...
8

DESCRIPTION

10     cyc is a native code compiler for the multi-paradigm declarative language
11     Curry. Normally, it performs compilation, assembly, and linking. The
12     ``overall options'' allow stopping this process at an intermediate stage.
13     For example, the -c option says not to run the linker. The output then
14     consists of object files output by the assembler.
15
16     Other options control one stage of processing; for instance, the --debug
17     option tells cyc to compile Curry modules such that they can be evaluated
18     by the declarative debugger.
19
20     The cyc program accepts options and file names as operands. Options and
21     file names can be mixed on the command line. In general, the order of
22     options is not relevant with the exception of additional libraries speci‐
23     fied with -l options. On many systems, these should be specified last on
24     the command line in order to ensure proper linking of programs.
25
26     The source language of a file and the associated processing is determined
27     by the file name extension. Argument names which end with .curry are
28     taken to be Curry source, names ending in .lcurry are taken to be liter‐
29     ate Curry source, names ending in .c are taken to be C code, names ending
30     in .s are taken to be assembler programs, and .o are object files.
31
32     By default, a program linked with cyc executes the main function in the
33     main module of the program. The compiler assumes that the last Curry
34     source file appearing on the command line defines the main module. A dif‐
35     ferent main module can be specified explicitly with the -M option. It is
36     possible to specify a different goal with the -e option. If the type of
37     the goal is IO t, for some arbitrary type t, the program executes the
38     corresponding I/O action. Otherwise, the goal is evaluated and its solu‐
39     tions are presented incrementally on the standard output.
40
41   Overall Options
42     The following options control the general processing of source files.
43
44     -n       Do not execute any command, but display each command that nor‐
45              mally would be executed.
46
47     -q       This option has no effect.
48
49     -v       Display each command before it is executed by cyc.
50
51     -C       Stop processing after generating C code from the Curry source
52              modules.
53
54     -S       Stop processing after generating assembler code from the Curry
55              and C source files.
56
57     -c       Compile and assemble the source file but do not link.
58
59     -o file  Place the output in a file named file.  Since only one output
60              file can be specified, it does not make sense to use -o when
61              compiling more than one input file unless you are producing an
62              executable file as output.
63
64              If -o is not specified, the default is to put an executable file
65              in a.out, the object file for source.suffix in source.o its
66              assembler file in source.s, and its C file in source.c.
67
68     -arch arch
69              Mac OS X: Compile for the specified target architecture arch.
70              Multiple options work, and direct the compiler to produce ``uni‐
71              versal'' binaries. Using this option on other systems is likely
72              to produce a C compiler error.
73
74   Compiling Curry Modules
75     The names of Curry source files must end with .curry or .lcurry.  The
76     latter are taken to contain literate Curry source and are deliterated
77     first. All Curry source files are compiled into C code. In addition, for
78     every source file file.curry and file.lcurry, respectively, the compiler
79     creates a file file.icurry containing the module's interface. The com‐
80     piler uses module interfaces when processing import declarations in a
81     source module. In order for the compiler to find the interfaces of
82     imported modules, the name of the source file should agree with its mod‐
83     ule name. Hierarchical module names of the form A.B.C are mapped onto the
84     filesystem as in Java, i.e., the compiler expects to find the interface
85     of this module in file C.icurry in directory A/B relative to the direc‐
86     tory where the compiler was invoked or to one of the directories specify‐
87     ing the import search path.
88
89     The following options control the compilation of Curry source into C
90     code.
91
92     -g       Deprecated synonym for --debug.
93
94     --debug  Prepare the compiled code for executing the program with the
95              declarative debugger.
96
97              Note that code compiled with this option is incompatible with
98              code compiled without this option. This option must therefore be
99              used consistently for compiling and linking all modules of a
100              program.
101
102     --trusted
103              This flag has an effect only in conjunction with one of previous
104              options. It tells that debugger that it can trust all functions
105              from a module compiled with this flag. The debugger will not ask
106              questions about such functions.
107
108     -i dir   Add directory dir to the list of paths used to locate interface
109              files. By default, the compiler searches for interface files in
110              the current directory and in its standard library directory
111              /usr/lib64/curry-0.9.11.
112
113              The directory dir is also added to the list of paths used to
114              locate header files, as if -I dir was present on the command
115              line.
116
117     -P dir   Add directory dir to the list of paths used to locate interface
118              files. By default, the compiler searches for interface files in
119              the current directory and in its standard library directory
120              /usr/lib64/curry-0.9.11.
121
122              The directory dir is also added to the lists of paths used to
123              locate header and library files, respectively, as if -I dir and
124              -L dir were present on the command line.
125
126     -Whaskell
127     -Wprolog
128     -Wgoedel
129              Warn whenever a definition does not obey the selected case mode
130              (cf. Sect. C.1 of the Curry report).
131
132     -Wall     Enable all warnings below.
133
134     -Wunused
135              Enable all unused warnings below.
136
137     -Wunused-data
138              Warn whenever a data constructor is not used.
139
140     -Wunused-decl
141              Warn whenever a function or pattern declaration is not used.
142
143     -Wunused-var
144              Warn whenever a function or pattern argument is not used.
145
146     -Wshadow
147              Warn whenever a local declaration shadows a declaration from an
148              outer scope.
149
150     -Woverlap
151              Warn whenever a function's equations have overlapping left hand
152              sides.
153
154     -H size  Change the heap size used by the compiler to size.  It is possi‐
155              ble to use the abbreviations sizek and sizeM to specify the heap
156              size in kBytes and MBytes, respectively.
157
158              Note that this option does not effect the heap size of the com‐
159              piled executable. Use -h size for this (see below).
160
161   Compiling C Files
162     The following list describes only the most common options understood by
163     cyc when compiling C source either directly or as a result of previously
164     compiling Curry source into C code. In fact, cyc passes on most of its
165     options to the C compiler. For a detailed description of these options
166     see the gcc(1) man page.
167
168     -D name  Predefine name as a macro, with definition 1.
169
170     -D name=defn
171              Predefine name as a macro with definition defn.
172
173     -U name  Cancel any previous definition of name, either built in or pro‐
174              vided with a -D definition.
175
176     -I dir   Add directory dir to the list of paths used to locate header
177              files. The standard library directory (/usr/lib64/curry-0.9.11)
178              is always included in this list.
179
180     -F dir   Mac OS X: Add the framework directory dir to the list of paths
181              used to locate header files. Using this option on other systems
182              is likely to produce a C compiler error.
183
184     -O       equivalent to -O1.
185
186     -Olevel  Controls optimization of the compiled code.  -O0 disables all
187              optimizations. Note that -O3 and higher levels will fail to pro‐
188              duce valid code for Curry modules on many architectures.
189
190     --ccopt opt
191              Passes the option opt to the C compiler without interpretation.
192              For instance, in order to include debugging symbols in the com‐
193              piled C code, invoke the compiler with --ccopt -g.
194
195     --ccopts opts
196              Passes each option from the comma separated list opts to the C
197              compiler without further interpretation.
198
199   Linking
200     The following options are relevant while linking a program. The compiler
201     creates a tiny C code file in this phase, which contains the startup code
202     initializing the Curry runtime system and starting the evaluation of the
203     goal. This file is compiled like other C code during the link phase.
204
205     -g       Deprecated synonym for --debug.
206
207     --debug  Compile a program that invokes the declarative debugger. All
208              Curry modules must have been compiled with the --debug option as
209              well.
210
211     -h size  Use size bytes for the heap of the Curry program. Note that
212              actually twice as much memory is allocated for the heap because
213              the runtime system uses a two-space copying collector. The
214              abbreviations sizek and sizeM can be used for specifying the
215              size in kBytes and MBytes, respectively. The default is to use a
216              4 MByte heap.
217
218     -k size  Use size bytes for the stack of the Curry program. The abbrevia‐
219              tions sizek and sizeM can be used for specifying the size in
220              kBytes and MBytes, respectively. The default is to use a 512
221              kByte stack.
222
223     -t size  Use size bytes for the trail stack of the Curry program. The
224              abbreviations sizek and sizeM can be used for specifying the
225              size in kBytes and MBytes, respectively. The default is to use a
226              512 kByte trail stack.
227
228     -f       Print all failures during execution of a non-deterministic goal.
229              If given multiple times, print also failures inside encapsulated
230              search.
231
232     -p       Print cumulated execution times and memory usage statistics at
233              the end of the run. If specified more than once, also print mem‐
234              ory statistics at each garbage collection.
235
236     -e goal  Evaluate goal instead of main.  The goal is evaluated with
237              respect to the modules specified with -M options and the Curry
238              source files appearing on the command line. All entities
239              exported from the Prelude and the Curry source file that appears
240              last on the command line or the last module specified with a -M
241              option, if there are no source file arguments, are in scope with
242              unqualified and qualified names. The exported entities of all
243              other modules are in scope with qualified names only.
244
245     -T goal  Compute the type of goal.  The goal's type is computed with
246              respect to the modules specified with -M options and the Curry
247              source files appearing on the command line. All entities
248              exported from the Prelude and the Curry source file that appears
249              last on the command line or the last module specified with a -M
250              option, if there are no source file arguments, are in scope with
251              unqualified and qualified names. The exported entities of all
252              other modules are in scope with qualified names only.
253
254     -M module
255              Brings all entities exported from module into scope with their
256              qualified names for a goal specified with the -e and -T options.
257              By default, only the entities exported from the Prelude and the
258              Curry source files occurring on the command line are in scope.
259              The entities exported from the Prelude and the last source file
260              appearing on the command line or specified with the last -M
261              option, if there are no source file arguments, are brought into
262              scope with their unqualified names, too.
263
264              Module is either the name of a source file (ending in .lcurry or
265              .curry), the name of an interface file (ending in .icurry), or
266              the name of a module whose interface can be located in the
267              interface search path.
268
269     -L dir   Add directory dir to the list of paths used to locate libraries
270              specified with -l options. The standard library directory
271              /usr/lib64/curry-0.9.11 is always included in this list.
272
273     -l lib   Search the library named lib when linking.
274
275     -framework name
276              Mac OS X: Link against framework name.  Using this option on
277              other systems is likely to produce a C compiler error.
278
279     --ldopt opt
280              Passes the option opt to the C compiler without interpretation.
281              In contrast to --ccopt (see above), opt is used only during the
282              link phase.
283
284     --ldopts opts
285              Passes each option from the comma separated list opts to the C
286              compiler without further interpretation. As with --ldopt, opts
287              are used only during the link phase.
288
289   Running Programs
290     The operation of a Curry program depends on the type of the goal being
291     evaluated. If it is of type IO t, the I/O action described by the goal is
292     executed. All command line arguments except for the runtime system
293     options (see below) are available to the program and can be accessed with
294     the function System.getArgs.
295
296     If the goal's type is not IO t, the program computes and prints the solu‐
297     tions of the goal with a depth first search strategy. A solution com‐
298     prises the normal form of the goal and the bindings and constraints for
299     its free variables. When run on an interactive terminal, solutions are
300     presented one by one giving the user a chance to stop the computation
301     after each solution. Otherwise, all solutions of the goal are computed.
302
303     This behavior can be changed by passing one of the options -i and -n to
304     the program. If invoked with -i, the program computes the solutions
305     incrementally as if it were run on an interactive terminal. If invoked
306     with -n, the goal's solutions are computed all at once.
307
308     All Curry programs run with fixed size heap, stack, and trail. Their
309     sizes can be specified at link time, but can be changed at run-time by
310     passing options to the Curry runtime system. Such options must be
311     enclosed with +RTS and -RTS arguments on the command line. The -RTS
312     switch may be omitted if it is the last argument on the command line.
313
314     The Curry runtime system understands the following options:
315
316     -bmode   Use buffer mode mode for the standard input and output of the
317              program where the following modes are recognized
318              n        Unbuffered
319              l        Line buffered
320              f n      Fully buffered
321              The optional number n allows specifying the buffer size when
322              using fully buffered mode.
323
324     -h n     Use n bytes for the heap in this run of the program. Note that
325              actually twice as much memory is allocated for the heap because
326              the runtime system uses a two-space copying collector. The
327              abbreviations nk and nM can be used for specifying the size in
328              kBytes and MBytes, respectively.
329
330     -k n     Use n bytes for the stack in this run of the program. The abbre‐
331              viations nk and nM can be used for specifying the size in kBytes
332              and MBytes, respectively.
333
334     -t n     Use n bytes for the trail stack in this run of the program. The
335              abbreviations nk and nM can be used for specifying the size in
336              kBytes and MBytes, respectively.
337
338     -f       Print all failures during execution of a non-deterministic goal.
339              If given multiple times, print also failures inside encapsulated
340              search.
341
342     -p       Print cumulated execution times and memory usage statistics at
343              the end of the run. If specified more than once, also print mem‐
344              ory statistics at each garbage collection.
345
346     -d       Turn on the low-level tracer of the abstract machine. In general
347              you do not want to see its output, but it may give hints to why
348              a program does not compute an expected solution or runs into a
349              deadlock. Beware that tracing can slow down program execution
350              considerably and the output may be excessively large.
351

ENVIRONMENT

353     CURRY_PATH
354              The environment variable CURRY_PATH is used to locate the com‐
355              piler executables. The default value is /usr/lib64/curry-0.9.11.
356
357     CURRY_IMPORT_PATH
358     CURRY_INCLUDE_PATH
359     CURRY_LIBRARY_PATH
360              The environment variables CURRY_IMPORT_PATH, CURRY_INCLUDE_PATH,
361              and CURRY_LIBRARY_PATH contain colon-separated lists of directo‐
362              ries that are searched for imported interfaces, included header
363              files, and library files, respectively. Their default value is
364              $CURRY_PATH.
365

FILES

367     /usr/lib64/curry-0.9.11/cycc
368              The Curry to C compiler.
369
370     /usr/lib64/curry-0.9.11/*.icurry, /usr/lib64/curry-0.9.11/*.h
371              Interface and header files for the standard library and runtime
372              system of the Curry compiler.
373
374     /usr/lib64/curry-0.9.11/libcurry.a
375              The runtime system and standard library.
376
377     /usr/lib64/curry-0.9.11/libcurry_g.a
378              Standard library prepared for debugging. All library modules
379              have been compiled with --trusted.
380

EXAMPLES

382     cyc test.curry
383              This command compiles and links the Curry module in test.curry.
384              The executable is put in a.out and evaluates the main function
385              in test.curry.
386
387     cyc -h12M -O2 A.lcurry B.lcurry -o B
388              This command compiles and links the Curry modules in A.lcurry
389              and B.lcurry in that order. Both files are assumed to contain
390              literate Curry source. The code is optimized by the C compiler
391              using optimization level 2. The executable is put in file B.  It
392              evaluates the main function in B.lcurry and uses a larger
393              default heap (12 MBytes).
394
395     cyc -c nat.curry
396     cyc -e add n Z =:= S Z where n free nat.o -Mnat -o one
397              The first of these commands compiles the Curry module in
398              nat.curry and places the object file in nat.o.  The second com‐
399              mand then links the object file into a program which evaluates
400              the goal add n Z =:= S Z where n free in the context of this
401              module. Note that this context must be specified explicitly with
402              a -M option because no Curry module was named on the second com‐
403              mand line. The executable is placed in one.
404
405     cyc -e length Xs where Xs free
406              This command compiles and links a program that evaluates the
407              goal length Xs where Xs free .  The executable is placed in
408              a.out.
409
410     a.out -x +RTS -k512k -h8M -t0 -RTS foo
411              executes a.out with an 8 MByte heap, a 512 kByte stack, and no
412              trail stack. The arguments -x and foo are passed to the Curry
413              program and are available from Curry code via System.getArgs.
414              Note that running a program without a trail stack, as in this
415              example, requires that the code is completely deterministic and
416              does not use encapsulated search.
417

SEE ALSO

419     cyi(1), cymake(1), gcc(1)
420
421BSD                              June 22, 2019                             BSD
Impressum