1************************
3************************
5``Idris`` has been designed such that the compiler can generate code for
6different backends upon request. By default ``Idris`` generates a ``C``
7backend when generating an executable. Included within the standard Idris installation are backends for Javascript and Node.js.
9However, there are third-party code generators out there. Below we
10describe some of these backends and how you can use them when
11compiling your ``Idris`` code. If you want to write your own codegen for your language there is a `stub project on GitHub <https://github.com/idris-lang/idris-emptycg>`__ that can help point you in the right direction.
19The default target of Idris is C. In order to view the generated C code, compile via:
23 $ idris hello.idr -S -o hello.c
29To generate code that is tailored for running in the browser
30issue the following command:
34 $ idris --codegen javascript hello.idr -o hello.js
37Idris can produce very big chunks of JavaScript code (hello world
38weighs in at 1500 lines). However, the generated code can be minified
39using the `closure-compiler
40<https://developers.google.com/closure/compiler/>`__ from Google.
44 java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js hello.js
50Generating code for NodeJS is slightly different. Idris outputs a
51JavaScript file that can be directly executed via node.
55 $ idris --codegen node hello.idr -o hello
66 These are third-party code generations and may have bit-rotted or
67 do not work with current versions of Idris. Please speak to the
68 project's maintainors if there are any problems.
71CIL (.NET, Mono, Unity)
72-----------------------
76 idris --codegen cil Main.idr -o HelloWorld.exe \
77 && mono HelloWorld.exe
79The resulting assemblies can also be used with .NET or Unity.
81Requires `idris-cil <https://github.com/bamboo/idris-cil>`__.
86`Available online <https://github.com/lenary/idris-erlang>`__
91`Available online <https://github.com/idris-hackers/idris-java>`__
96 idris hello.idr --codegen java -o hello.jar
99Note: The resulting .jar is automatically prefixed by a header including
100an .sh script to allow executing it directly.
105`Available online <https://github.com/mmhelloworld/idris-jvm>`__
110`Available online <https://github.com/idris-hackers/idris-llvm>`__
115`Available online <https://github.com/stedolan/idris-malfunction>`__
120`Available online <https://github.com/ziman/idris-ocaml>`__
125`Available online <https://github.com/edwinb/idris-php>`__
130`Available online <https://github.com/ziman/idris-py>`__
135`Available online <https://github.com/mrb/idris-ruby>`__
140`Available online <https://github.com/edwinb/WS-idr>`__
145`Available online <https://github.com/SPY/idris-codegen-wasm>`__
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list